Skip to content

test(mergeQueue): pin errorMessage's null-rejection guards, the once-per-run warning's initial state and the [bot] suffix anchor - #581

Open
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-merge-queue-guards
Open

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-merge-queue-guards

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds __tests__/utils/mergeQueueGuards.test.ts: seven cases pinning guards of src/utils/mergeQueue.ts that line coverage already reaches but no existing test would notice changing. No production code changes.

Evidence: npx stryker run --mutate src/utils/mergeQueue.ts on the harness of #572 (main@e3119ad) left 5 of 111 mutants alive (score 95.50%). Each survivor was re-applied by hand at its reported span: the existing mergeQueue.test.ts passes under all five; with this file every one fails 1–3 cases (111/111 killed).

Guards pinned (file / function):

  • errorMessage (mergeQueue.ts:184): a null or undefined rejection of octokit.graphql is reported as "null" / "undefined" instead of throwing a TypeError out of the guard — so queueState still warns and falls back to the REST merge, and enqueue still returns { ok: false, kind: 'other' }; an errors property that is not an array is not read as GraphQL errors (mutants: e !== null → true, the object/null/in conjunction → true, the last && → ||)
  • queueState (mergeQueue.ts:64): the once-per-run warning fires on the first failure of a fresh module instance that nothing has reset — every existing test resets it via resetMergeQueueWarnings() / setupActionsEnv(), which masked warnedUnavailable = true
  • enqueuedByBot (mergeQueue.ts:153): [bot] counts only as a suffix — dependabot[bot]-fan and [bot]renovate are humans (mutant: dropped $ anchor)

Disjoint from the open hold-gated PRs: new file only. #571's harness change edits __tests__/utils/mergeQueue.test.ts, not this file; #557/#578 cover tide.ts; #575/#579/#580/#573 cover owners/auth/approve/cron-lgtm.

Validation: npx eslint __tests__/utils/mergeQueueGuards.test.ts, npx vitest run (168 files, 2337 passed, 75 skipped).

Related Issue

No tracking issue; this continues the per-module mutation triage of #575, #578, #579 and #580 (harness: #572).


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

…per-run warning's initial state and the [bot] suffix anchor

Adds __tests__/utils/mergeQueueGuards.test.ts. Every line and branch of
src/utils/mergeQueue.ts is already covered, but five of its mutants survive
the Stryker harness: `npx stryker run --mutate src/utils/mergeQueue.ts`
(main@e3119ad) kills 106 of 111 (score 95.50%). The survivors, each
re-applied by hand at its reported span and confirmed to pass the existing
mergeQueue.test.ts:

- mergeQueue.ts:184 `e !== null` -> `true`, the whole
  `typeof e === 'object' && e !== null && 'errors' in e` conjunction -> `true`,
  and the final `&&` -> `||`: a null or undefined rejection of octokit.graphql
  would throw a TypeError out of errorMessage, so queueState would reject
  instead of warning and falling back to the REST merge, and enqueue would
  throw instead of returning `{ ok: false }`.
- mergeQueue.ts:64 `let warnedUnavailable = false` -> `true`: every existing
  test calls resetMergeQueueWarnings() (directly or via setupActionsEnv), so
  the first real run of a job never warning went unnoticed. Pinned on a fresh
  module instance (vi.resetModules) that nothing has reset.
- mergeQueue.ts:153 `/^github-actions$|\[bot\]$/i` -> `/^github-actions$|\[bot\]/i`:
  a login merely containing `[bot]` would count as an automation whose queue
  entry the gate may undo.

With this file all five are killed (manual re-application of each mutant
fails 1-3 of the new cases; 111/111 killed).

No production code changes.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner October 25, 2026 15:02
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 25, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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 outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@github-actions

Copy link
Copy Markdown
Contributor

Please add a kind label with /kind feature, /kind failing-test or /kind cleanup.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the new file against src/utils/mergeQueue.ts at the PR head; all three guard pins match the code and the mutant-kill claims hold. Looks correct to me.

Verified:

  • errorMessage null/undefined/non-array-errors arms (src/utils/mergeQueue.ts:184-191): typeof null === 'object' makes the e !== null check load-bearing — mutating it to true makes 'errors' in null throw out of queueState's catch, which the first test's resolves.toBeUndefined() catches. The { errors: 'not an array' } case likewise kills the && → || mutant, since 'not an array'.map would throw out of enqueue. Messages "null", "undefined", "[object Object]" are exactly what String(e) produces.
  • Once-per-run warning initial state (src/utils/mergeQueue.ts:63, :89-93): the test's vi.resetModules() + fresh dynamic import of both @actions/core and the module in one Promise.all gives a module instance with warnedUnavailable = false that nothing reset — the gap the PR body describes (every case in mergeQueue.test.ts goes through resetMergeQueueWarnings()). The global vi.mock('@actions/core', { spy: true }) in __tests__/setup.ts:4 re-applies on the fresh registry, so the spy assertions are sound.
  • [bot] suffix anchor (src/utils/mergeQueue.ts:153): /^github-actions$|\[bot\]$/i rejects dependabot[bot]-fan and [bot]renovate and accepts github-actions[bot]; dropping the $ anchor flips the first two, so the mutant is killed.

Disjointness also checks out: new file only; #571's harness edit touches __tests__/utils/mergeQueue.test.ts, not this file. All checks green. No findings.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Indicates that a PR should not merge because someone has issued a /hold command. needs-kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants