Skip to content

test(cron): pin cronLgtm's merge count and its no-read short circuits - #573

Open
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-cron-lgtm-short-circuits
Open

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-cron-lgtm-short-circuits

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds __tests__/cronJobTest/lgtmShortCircuits.test.ts (new file; nothing else changes), calling cronLgtm in src/cronJobs/lgtm.ts directly to pin two contracts its docstring states but no test observed:

  • the resolved count — cronLgtm returns the number of PRs merged or enqueued across every page. handleCronJob.ts:33 discards it, so jobsDone++ → -- and return false → true in tryMergePr passed every existing test.
  • "costs no further call" — a PR that fails meetsMergeGate or is locked is skipped before evaluateMerge. Because tide's own blockedReason also refuses such a PR, the existing merge observers could not distinguish the guard from its absence; the new cases watch GET /pulls/:number and assert it is never made.
  • plus state: 'open' on the listing and { required: true } on the github-token input.

Evidence

Stryker (harness from #572, --mutate src/cronJobs/lgtm.ts, main @ e3119ad, local): 13 survivors → 4, score 80.60% → 94.03%. The four left are log-text literals (lines 57, 87, 125, 133). Unit/e2e line and branch coverage of the file were already 100% (npm run test:coverage, npm run test:coverage:e2e, same revision), so this is a mutation finding, not a coverage gap.

Occupied-ground check

Disjoint from every open hold-gated PR: #571 touches __tests__/cronJobTest/lgtm.test.ts (harness-wide edit) — this PR adds a separate file and does not edit it; #572's default mutate set is mergeGate/labelMatch/hold/duration, not cronJobs/lgtm.ts.

Checks run

  • npx vitest run __tests__/cronJobTest — 98 passed
  • npx eslint __tests__/cronJobTest/lgtmShortCircuits.test.ts, npx tsc --noEmit

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

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

cronLgtm resolves to the number of pull requests it merged or enqueued,
and a pull request it skips before the shared merge path - gate failure
or locked - costs no further request. Neither was asserted: the count is
discarded by handleCronJob, and tide's own blockedReason also refuses a
locked or gated PR, so the existing merge observers could not see the
guards. A mutation run over src/cronJobs/lgtm.ts left 13 survivors; the
nine behavioural ones (jobsDone++, return false, the !gate.ok and locked
guards, { required: true } on github-token, state: 'open') are now
killed by direct cronLgtm calls that watch GET /pulls/:number. The four
left are log text.

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 23, 2026 21:10
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 23, 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 test file against the tree at the reviewed head, not just the diff. This looks correct to me.

Verified against src/cronJobs/lgtm.ts:

  • Count contract — cronLgtm accumulates progress.jobsDone++ per merged/enqueued PR (lgtm.ts:98-100) and returns it from the empty-page arm (lgtm.ts:84). The three count tests (2 across two pages, 0 all-skipped, carry-in {jobsDone: 3} → 4) pin exactly that, and the carry-in test correctly starts at page 2 so the empty pages[0] never terminates it early.
  • No-read short circuits — a gate failure returns from tryMergePr at lgtm.ts:162-165 before evaluateMerge, and pr.locked returns at lgtm.ts:93-95 before tryMergePr; neither path can issue GET /pulls/:number. The ObserveRequest.notCalled() assertions (testUtils.ts:200) observe that directly, and failOnUnhandledRequest keeps the fixtures honest.
  • state: 'open' is passed in getOpenPrs (lgtm.ts:129) and the listing test reads it off the captured request rather than trusting the stub.
  • Token guard — core.getInput('github-token', { required: true }) at lgtm.ts:60 runs before any listing; the test deletes the env var and asserts listing.ref stays null, matching the order.
  • The custom do-not-merge/* gate case matches meetsMergeGate's missing_labels arm (src/utils/mergeGate.ts:26-28).

One note, not a defect: the PR body says handleCronJob.ts:33 discards the count, but that line is return await cronLgtm(1, context)... — the value is propagated, presumably dropped further up. Doesn't change the finding that no prior test observed it.

Additive only (one new test file, no source or existing-test edits), disjoint from #571/#572 as the body claims, CI 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