Repository navigation
test(auth): pin the repository- and issue-scoped cache keys of the root OWNERS and commenter reads, and the null and non-string arms of getErrorDetails - #698
Conversation
…ot OWNERS and commenter reads, and the null and non-string arms of getErrorDetails A mutation run over src/utils/auth.ts left five behavioural survivors: the memoized() keys of checkIssueComments and retrieveOwnersFile could be emptied without a test noticing, so one repository's OWNERS or one issue's commenters would answer for every other; and getErrorDetails' null guard and message-is-string guard could be flipped. Each test here fails against its mutant and passes on main. Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
|
Please add a kind label with |
There was a problem hiding this comment.
Verified correct — test-only, and the pins do what the table claims.
What I checked (repo at pr head f202abc):
- The four guarded sites exist as described: the per-issue commenter key at
src/utils/auth.ts:146(${owner}/${repo}#${issueNum}), the per-repository root-OWNERS key atsrc/utils/auth.ts:457(${owner}/${repo}), and theerror !== null/typeof error.message === 'string'arms ofgetErrorDetailsatsrc/utils/auth.ts:13and:21. - Ran the file on the PR head:
12 passed. - Reproduced two of the claimed mutant kills by hand: replacing the issue key at line 146 with
fails exactly `memoizes per issue` (1 failed | 11 passed); replacing the repository key at line 457 withfails exactlymemoizes per repository(1 failed | 11 passed). Both match the evidence table in the body. - The error-arm expectations are consistent with the source: a
nullrejection takes the non-object branch and rendersmessage=null;{status: 500, message: 42}fails the string check and rendersString(error)→[object Object]— both warnings asserted verbatim.
The per-repository memoization test is the valuable one: it is the only pin keeping one repository's root OWNERS from authorizing trusted-policy commands on another within a shared App-server state, and nothing else in the suite distinguishes that key from ``.
Scope matches the body: one test file, no src/, config, or workflow change; deferring the stryker.nightly.config.mjs wiring until #691 lands avoids a conflicting edit to the same lines. Looks correct to me — a maintainer can take it from here.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
Test Improvement
Adds five tests to
__tests__/utils/authGuards.test.ts— the file that already holds the auth.ts survivor pins — each of which fails against the mutation it names and passes onmain:src/utils/auth.tssitecheckIssueComments› memoizes per issuememoized(... issueCommenters,${owner}/${repo}#${issueNum})the root OWNERS read› memoizes per repositorymemoized(... rootOwners,${owner}/${repo})trustedon Other)checkOrgMember› rejects with nullerror !== nulltrue(TypeError escapes the catch instead of a warning)checkOrgMember› message is not a stringtypeof error.message === 'string'true, and&&→||Why.
policyAllowsandassertAuthorizedByOwnersOrMembershipare the authorization decisions behind/lgtm,/approve,/holdand the label commands. Their per-repository memoization is what keeps one repository's OWNERS from leaking into another within the App server's or a cron run's state;ownersGuards.test.tspins that key forrepoHasOwners, but the two keys inauth.tshad no pin at all.Evidence (local, main@9aa12b8,
npx stryker run stryker.config.mjs --mutate src/utils/auth.ts): 284 mutants, 268 killed, 16 survived (94.37 %). The five above are behavioural; the other eleven are log text or equivalent (issue?.pull_requeston callers that are allissue_commenthandlers;contents === ''ahead of aparseOwnersthat already treats''as{}), and are left alone. Each new test was checked by applying its mutant to the source by hand:1 failed | 11 passedfor each of the five; the file is12 passedon unmodifiedmain.Related Issue
Refs #679 — the hive consolidated this finding's issue into that docs tracker by component. The remaining deliverable, adding
src/utils/auth.tstostryker.nightly.config.mjswith its reviewed-survivor table indocs/contributing.mdand an extension of__tests__/mutationConfig.test.ts, is deliberately left out: #691 (held) edits those same lines forapprove.ts, and a second PR over them would only force a rebase. It should follow once #691 lands.Files:
__tests__/utils/authGuards.test.tsonly. Nosrc/, docs, config or workflow change. Disjoint from held #680–#697 (none touch this file).Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88