Skip to content

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

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-sweep-delay-boundaries
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-sweep-delay-boundaries

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds four cases to the sweep with blunderbuss.delay block of __tests__/cronJobTest/sweep.test.ts, for the Delayed-review boundaries item of #554 ("cover both exact shifted-window boundaries and timestamps immediately outside them") and the one unit-uncovered branch left in src/cronJobs/sweep.ts.

Files/functions claimed: __tests__/cronJobTest/sweep.test.ts only (serve gains an optional config argument; four new it cases). Source under test: requestReviewersIfDue and lastReadyForReview in src/cronJobs/sweep.ts. Disjoint from #553 (auth.ts), #555 (__tests__/bundle/*), #556 (e2e floor) and #557 (tide.test.ts).

case pull requests asserts
opened exactly at due.to, and 1 ms later created = now-60m / now-60m+1ms #1 requested, #2 not; #2 decided from created_at alone (no timeline read)
opened exactly at due.from, and 1 ms earlier created = now-90m / now-90m-1ms (listed because updated inside the window) #1 requested, #2 not; #2's timeline is read
last ready_for_review at due.to, due.to+1ms, due.from, due.from-1ms four former drafts exactly #1 and #3 requested
timeline read returns 500 #1 (needs the timeline), #2 (due) run fails with #1 (blunderbuss: could not read the timeline: HttpError: Server Error); #2 still gets reviewers

The boundary cases use sweep.lookback: 30m with delay: 1h, so the due window [now-90m, now-60m] ends before the candidate window starts and every pull request takes the delayed-reviewers path only.

Why these, per #554's "justify by mutation, not percentage"

Each one-character mutant below was applied to src/cronJobs/sweep.ts and run against the whole sweep.test.ts; the listed new case is the only one that fails, so the prior 42 cases accepted it:

mutant killed by
start > due.to → >= (early return, line 214) "opened exactly at the end of the due window"
start < due.from → <= (line 224) "opened exactly at the start…", "times the last ready_for_review…"
start > due.to → >= (line 224) "opened exactly at the end…", "times the last ready_for_review…"
catch in lastReadyForReview → events = [] (line 244) "reports a failed timeline read…"

Coverage evidence

  • Unit, npm run test:coverage on main@e3119ad (2330 tests, 99.92 % lines / 99.35 % branches): sweep.ts 98.33 / 92.3, uncovered 85,244. With this PR line 244 (the timeline catch) is covered; 85 (non-Error throw in the delayed loop) is untouched here.
  • End-to-end, npm run test:coverage:e2e on main@e3119ad (528 tests, 100 % / 99.46 %): sweep.ts 100 / 94.87, uncovered 80-85,208 — line 244 is already exercised by the bundle suite, so this was a unit-only gap, and the boundary instants add no new lines or branches in either run by design.

Verification

  • npx vitest run __tests__/cronJobTest/sweep.test.ts — 46 passed
  • npx eslint __tests__/cronJobTest/sweep.test.ts — clean

Related Issue

Refs #554 — ticks only the "Delayed-review boundaries" box of the P2 cross-request section. The remaining boxes (OWNERS pagination failure, successive sweeps, scheduling outage recovery, and the P1 CI/release/harness sections) are tracked there and in #555/#556/#557; the tracker itself must not be closed by a single test PR.


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

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

…d 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>
@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner October 21, 2026 21:16
@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

Copy link
Copy Markdown
Contributor Author

Another agent tried to open a PR from quality/test-unhandled-request-assertion, but this PR edits an overlapping set of files. No second PR was opened; please continue here, or rebase the new work onto this branch.

@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 diff against src/cronJobs/sweep.ts at merge-base, not just the test file. The four new cases match the real boundary semantics:

  • sweep.ts:214 (if (start > due.to)) and sweep.ts:224 (if (start < due.from || start > due.to)) are inclusive on both ends, exactly as the "opened exactly at the end/start of the due window" cases assert. The timelineReads expectations are also right: a PR failing the line-214 check returns before lastReadyForReview, while one failing only line 224 is read first — the tests distinguish the two correctly.
  • The ready_for_review case exercises the start = ready promotion at sweep.ts:219-222 against the same bounds.
  • The 500-timeline case matches the throw at sweep.ts:244 wrapped into the failure aggregate at sweep.ts:102-104, including the exact sweep: 1 pull request(s) failed: #1 (blunderbuss: could not read the timeline: HttpError: Server Error) message, and requested = [2] confirms the per-PR catch at sweep.ts:83-86 isolates the failure.

The lookback: 30m / delay: 1h shifted window keeps all fixtures on the delayed-only path (updated_at < since at sweep.ts:69), so no candidate-path crosstalk. Test-only change, no behavior touched, CI green. Looks correct to me — leaving the hold/merge call to a maintainer per the repo's hold-gated flow.

— 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

Copy link
Copy Markdown
Member

Consolidated into #589 (commit cherry-picked unchanged, author and DCO sign-off preserved).

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>
@mrbobbytables
mrbobbytables deleted the quality/test-sweep-delay-boundaries branch October 26, 2026 20:19
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. 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.

1 participant