Skip to content

test(tide): pin the lgtm gate re-check after an unknown-mergeability retry (evaluateMerge, tide.ts:198-206) - #557

Merged
mrbobbytables merged 1 commit into
mainfrom
quality/test-tide-gate-change-mid-retry
Oct 26, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
quality/test-tide-gate-change-mid-retry

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Test Improvement

Adds two tryMergePullRequest cases to __tests__/plugins/tide.test.ts for the mid-retry gate change that #554 ("Judge tests by behavior") asks for: mergeability is unknown on the first read and the lgtm label is gone on the re-read.

  • stops retrying an unknown state once the lgtm label disappears on the re-read — asserts exactly 2 pull reads, one sleep(1000), skipping pr #1: missing lgtm, no merge, and no "still unknown after 3 retries" log.
  • does not merge when the re-read turns clean but has lost the lgtm label — asserts the merge is not called and the skip reason is missing lgtm.

Why these two, and not more coverage

Neither adds line/branch coverage; both are justified by mutants, as #554 requires:

  • Removing the blockedReason(pr, tide) ?? re-check after fetchMergeability in evaluateMerge (src/plugins/tide.ts:203) survived all 982 existing unit tests and, after npm run build && npm run pack, all 528 bundle tests. With that mutant a pull request whose lgtm is removed while GitHub computes mergeability would merge. The second case fails on it.
  • Removing || !retryIf(pr) in fetchMergeability was already caught by the direct fetchMergeability unit case (tide.test.ts:134-140), but not through the caller; the first case pins it at the tryMergePullRequest level with read and sleep counts.

Files/functions claimed: __tests__/plugins/tide.test.ts (tryMergePullRequest describe block) only. Disjoint from #555 (fakeGithub/ownersGroups/blunderbussDelay), #553 (auth arms), #556 (coverage config).

Related Issue

Fixes #554 — this ships the "focused integration scenario where mergeability is initially unknown and LGTM disappears on the next read" checkbox under P2: Judge tests by behavior. The tracker stays open: its other sections (CI enforcement, release delivery, harness/mutation runner, remaining cross-request contracts) are not touched here and the issue states a single test PR must not close it.

Verification

  • npx vitest run __tests__/plugins/tide.test.ts — 107 passed
  • npx eslint __tests__/plugins/tide.test.ts — clean

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

— hive: agent=quality backend=copilot model=claude-fable-5.1 requested_by=@mrbobbytables

tryMergePullRequest re-reads a pull request whose mergeability is still
unknown. Two cases were missing at the caller level: the lgtm label
disappearing on the re-read must end the wait at that read (no 2 s and 4 s
retries), and a re-read that turns clean while losing lgtm must not merge.

Dropping the blockedReason(pr, tide) re-check after fetchMergeability in
evaluateMerge survived every existing unit test (982) and the rebuilt
bundle suite (528); the second case fails on that mutant.

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 21, 2026 19:09
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 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.

@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 against main@e3119ad. This looks correct to me, and the second case pins a gate that genuinely has no other caller-level guard.

  • The re-check exists only at src/plugins/tide.ts:203 (reason = blockedReason(pr, tide) ?? … after fetchMergeability); nothing downstream re-reads labels before mergeOnce, so deleting that re-check would indeed merge a PR whose lgtm vanished during the unknown-mergeability wait. The "survived 982 unit + 528 bundle tests" claim is consistent with what the existing suite asserts — the nearest case (tide.test.ts:257 area) only covers unknown-with-lgtm-retained.
  • First case: servePull(pull(['lgtm'], unknown), pull([], unknown)) — fetchMergeability's retryIf: candidate => blockedReason(candidate, tide) === undefined (tide.ts:199) goes false on the re-read, so exactly 2 GETs and one sleep(1000) is what the source produces; the absence-of-give-up-line assertion is a nice touch.
  • Second case: re-read is clean but label-less, so it exercises the ?? left side specifically — the merge-blocking mutant the body names.
  • Helpers used (servePull, observeMerge, mocked sleep) behave as the test assumes (tide.test.ts:46-62,72).

Fixes/Refs semantics: the body says "Fixes #554" but then states #554 must stay open — note GitHub will close #554 on merge with that keyword. If the tracker is meant to survive, the line should read Refs #554. Worth a one-word edit before merge.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

/kind cleanup


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: e3119ad

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

@github-actions github-actions Bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind labels Oct 23, 2026
@mrbobbytables mrbobbytables removed the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 26, 2026
@mrbobbytables
mrbobbytables merged commit afd4147 into main Oct 26, 2026
12 checks passed
@mrbobbytables
mrbobbytables deleted the quality/test-tide-gate-change-mid-retry branch October 26, 2026 19:21
mrbobbytables added a commit that referenced this pull request Oct 26, 2026
…solidates #555, #558, #559, #561, #562, #564-#567) (#589)

* test: cover paginated OWNERS and review timelines

Exercise approval authorization, automatic reviewer selection, and delayed reviewer timing across page boundaries.

Hive-Run: #554

Hive-Plan: P2 cross-request contracts

Hive-Spec: issue-554#P2-cross-request-contracts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>

* test(sweep): pin the inclusive due-window bounds and the timeline-read failure of delayed reviewers

Add four cases to the 'sweep with blunderbuss.delay' block of
__tests__/cronJobTest/sweep.test.ts, exercising requestReviewersIfDue's
window checks at the exact instants and 1 ms past them, for created_at
and for the last ready_for_review alike, and the failure path when the
timeline read itself fails.

Each boundary case fails on a one-character mutant of sweep.ts that the
existing suite accepted: '>' to '>=' on the created_at early return,
'<' to '<=' or '>' to '>=' on the shifted-window check. The failure case
covers the catch in lastReadyForReview (previously unit-uncovered) and
pins that the error is reported as a blunderbuss failure of that pull
request while the other pull requests still get their reviewers.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(sweep): pin that a second delayed sweep leaves the first run's requested reviewers alone

The delayed-blunderbuss bundle suite modelled a pull that already had
reviewers only as a static fixture. This drives dist/index.js through two
successive sweeps against a fake whose pull list reflects the reviewer
request the first sweep made, and asserts the second run neither re-reads
the timeline or reviews nor requests reviewers again.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(sweep): pin the delayed-reviewers OWNERS guard on a base branch without OWNERS files

Both suites left the false arm of the branchHasOwners guard ahead of
requestReviewersIfDue in src/cronJobs/sweep.ts with zero hits: every
delayed-blunderbuss case served an OWNERS file on master. Add one unit case
and one dist/index.js scenario, each in its own file, that configure
blunderbuss.delay, serve an empty master tree and a due pull request, and
assert the tree is probed once while the timeline, reviews and
requested_reviewers endpoints are never touched. Both fail when the guard is
replaced by `|| true`.

Fixes #560

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(sweep): pin the reviewer-key fallbacks of delayed blunderbuss on a bare pull listing (sweep.ts:208)

requestReviewersIfDue reads requested_reviewers ?? [] and
requested_teams ?? [] off the pull list entry, but no unit or bundle test
listed a delayed-only pull request without those keys, leaving both
fallback arms unreached in coverage/ and coverage-e2e/. Serve a due pull
with the keys removed on both harnesses and assert reviewers are still
requested.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(owners): pin the fail-closed OWNERS group read when a later members page cannot be fetched (owners.ts:153-162)

Let the real octokit paginator walk a team's Link headers instead of the
stubbed paginate the existing group tests use. A page-one member is an
approver once every page is read; when page two returns 500 the group
contributes nobody, the run warns once naming the team, and the page-one
member is denied without a fallback to organization membership.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(sweep): pin the delayed-reviewers catch of sweep in its Error and String(e) arms (sweep.ts:85)

Adds __tests__/cronJobTest/sweepDelayFailures.test.ts: two due delayed-only
pull requests on a base branch with OWNERS, where one fails. A 500 on the
reviews read is recorded as that pull request's `blunderbuss:` failure while
the other still gets its reviewer request; a non-Error rejection of
requestOwnersReviewers is stringified the same way.

Before: coverage/lcov.info BRDA:85,5,0,0 / BRDA:85,5,1,0 (neither arm hit by
the unit suite). After: both 1; sweep.ts branches 92.3 -> 94.87 %.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(sweep): pin the ignore_drafts=false arm of delayed reviewers (sweep.ts:218)

With blunderbuss.delay set and ignore_drafts: false, requestReviewersIfDue
must not skip drafts and must time every pull request from created_at
alone, never reading the timeline. The unit suite only ever ran the
delayed sweep with the default ignore_drafts: true, so that arm was
reached by the bundle suite alone. Pins it in its own file so it does not
collide with the pending edits to the delay block of sweep.test.ts.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(sweep): pin the no-catch-up recovery of delayed reviewers after missed schedule runs

After the schedule misses runs for longer than sweep.lookback, a pull
request whose review clock expired before now - delay - lookback is
neither listed, read nor requested by the delayed-reviewers step, and a
longer sweep.lookback is what recovers it. Pinned in a unit suite
(__tests__/cronJobTest/sweepDelayOutage.test.ts) and against
dist/index.js (__tests__/bundle/blunderbussDelayOutage.test.ts); the
blunderbuss.delay paragraph of docs/configuration.md now records the
expectation.

Refs #554

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

* test(harness): fail tide and sweep unit tests on unserved requests

Completes the #571 wiring that was deferred while #557 and #558 occupied
these files: both servers now answer the merge-queue read with
noMergeQueue and assert at the end of each test that no request went
unserved; sweep's OWNERS scenarios serve the base-branch tip instead of
running through the 'could not read the tip' fallback.

Refs #570

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>

---------

Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
Co-authored-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-up: strengthen test contracts, CI enforcement, release delivery, and quality triage

1 participant