Skip to content

admin-bypass-sweep (2) the merged tally comes from the trunk check - #497

Open
EdbertChan wants to merge 4 commits into
mainfrom
plan/admin-bypass-sweep-2-the-merged-tally-comes-from-the-trunk-check
Open

admin-bypass-sweep (2) the merged tally comes from the trunk check#497
EdbertChan wants to merge 4 commits into
mainfrom
plan/admin-bypass-sweep-2-the-merged-tally-comes-from-the-trunk-check

Conversation

@EdbertChan

@EdbertChan EdbertChan commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Summary

An administrative sweep checks whether pull requests truly reached the main branch before counting them as merged.

Previously, GitHub's merged label could count work that landed only on a stack branch.

Now each result comes from a trunk ancestry check, with separate outcomes for merged, misplaced, and unchecked work.

Review Claim

The sweep counts a pull request as merged only when its commit is present on the trunk.

Review Lane

behavior

Review Unit

product-skill

Safety Invariant

The merged tally cannot be computed from GitHub pull-request state alone; a pull request whose ancestry check is not successful is reported as unchecked, not merged.

Slice Rationale

This slice changes one reporting step and adds its focused contract test; merge commands, blocked-pull-request policy, and the verifier remain separate concerns.

Non-goals

  • Does not change the merge commands in Step 4.
  • Does not change Step 5's blocked-pull-request policy.
  • Does not modify the ancestry verifier itself.
  • Does not touch any other skill.

Architecture

Before

graph TD
    A["GitHub pull-request state"] --> B["Step 6 merged tally"]
Loading

After

graph TD
    A["Each pull request"] --> B["Trunk ancestry verifier"]
    B --> C["merged / merged-but-not-on-trunk / unchecked"]
    C --> D["Step 6 tally"]
Loading

Test Plan

Test Plan
  • python3 engine/skills/make-pr/scripts/preflight.py --base origin/main
    • Result: ok preflight passed
  • python3 -m unittest discover -s product/skills/admin-bypass-sweep/tests -v
    • Result: Ran 5 tests and OK
  • python3 scripts/check_skill_test_coverage.py --base origin/main --head HEAD
    • Result: ok skill test coverage
  • python3 scripts/check_skills_three_harnesses.py
    • Result: ok skills three-harness check
  • python3 scripts/check_ecosystem_boundaries.py
    • Result: ok ecosystem boundaries
  • bash scripts/scrub-handoff-artifacts.sh
    • Result: scrub-handoff-artifacts-ok

Revert Plan

Revert Plan
  • Safe to revert? Yes.
  • Revert command: git revert <merge-commit-sha>
  • Post-revert steps: Re-run the focused skill tests.
  • Data migration? No.

Note

Low Risk
Documentation and contract tests for post-sweep reporting only; merge steps and the verifier script are unchanged.

Overview
Step 6 no longer treats GitHub MERGED / gh pr view state as proof a sweep PR reached trunk. It now runs verify_pr_landed_on_trunk.sh for each touched PR and classifies results by exit code: merged (0), merged-but-not-on-trunk (1), and unchecked (3); only exit 0 counts toward the merged tally.

Final reporting adds merged-but-not-on-trunk and unchecked buckets (with PR numbers/titles), alongside merged and blocked.

A stack-branch landing fixture (PR #1789: GitHub merged but commit not on origin/master) documents the regression this fixes, and unit tests assert Step 6 names the verifier, maps all exit codes, and forbids driving the merged count from PR state alone.

Reviewed by Cursor Bugbot for commit 95362db. Bugbot is set up for automated code reviews on this repo. Configure here.

Invoker Bot and others added 4 commits September 12, 2026 18:15
…p 6 compute its merged tally from the trunk ancestry check.

Review claim: A sweep cannot report a PR as merged unless its merge commit is an ancestor of the trunk.
Review lane: behavior
Safety invariant: The merged tally cannot be computed from `gh pr view` state alone; a PR whose ancestry check does not return OK is reported unchecked, not merged.
Effectiveness measurement: A fixture PR that closed against a stack branch rather than the trunk must be reported unchecked by the new Step 6 and merged by the old one, asserted in the skill's test directory.
Slice rationale: One step of the sweep skill's reporting procedure; stacked behind the probe step because both edit the same SKILL.md.
Architectural effect: Step 6 gains a dependency on the already-shipped verify_pr_landed_on_trunk.sh instead of relying on gh pr view alone.
Goal: Rewrite Step 6 of product/skills/admin-bypass-sweep/SKILL.md so each PR's status line comes from engine/hooks/gh-write-verification/verify_pr_landed_on_trunk.sh and a non-OK result is reported as unchecked.
Motivation: A 19-PR sweep reported 13 merged from gh pr view output alone. A Stop hook had to force the real ancestry check afterwards. All 13 did pass, but the claim went out before the check that proves it, and the same skill had already caused a manual replay of four PRs three days earlier.
Alternative considerations: Adding a sentence telling the operator to also run the verifier was rejected: Step 6 already says to re-query every PR and not trust running tallies, and that prose did not produce an ancestry check. Leaving the hook as the only catch was rejected because it fires after the reply is drafted.
Implementation details: Replace the `gh pr view --json number,state,mergedAt,title` loop in Step 6 with a loop calling verify_pr_landed_on_trunk.sh per PR, branching on its documented exit codes: engine/hooks/gh-write-verification/verify_pr_landed_on_trunk.sh lines 4-6 (EXIT_OK=0, EXIT_FAIL=1, EXIT_UNCHECKED=3). Report exit 0 as merged, exit 1 as merged-but-not-on-trunk, and exit 3 as unchecked. State in the prose that a merged count may not be reported from gh pr view alone. Add a fixture under the skill's tests directory asserting the new Step 6 text names the verifier and the three outcomes.
Non-goals: Does not change the merge commands in Step 4, does not change Step 5's blocked-PR policy, does not modify the verifier script itself, and does not touch any other skill.
Layer: domain
Feature state: active
Files: product/skills/admin-bypass-sweep/SKILL.md, product/skills/admin-bypass-sweep/tests/
Change types:
- product/skills/admin-bypass-sweep/SKILL.md: docs-only
- product/skills/admin-bypass-sweep/tests/fires_step6_names_verifier.md: create
Acceptance criteria:
- `python3 -m unittest discover -s product/skills/admin-bypass-sweep/tests -v` exits 0.
- Step 6 names verify_pr_landed_on_trunk.sh and all three exit codes.
- Step 6 no longer derives a merged count from `gh pr view` state alone.

Solution:
  Make Step 6 compute its merged tally from the trunk ancestry check.
Review claim: A sweep cannot report a PR as merged unless its merge commit is an ancestor of the trunk.
Review lane: behavior
Safety invariant: The merged tally cannot be computed from `gh pr view` state alone; a PR whose ancestry check does not return OK is reported unchecked, not merged.
Effectiveness measurement: A fixture PR that closed against a stack branch rather than the trunk must be reported unchecked by the new Step 6 and merged by the old one, asserted in the skill's test directory.
Slice rationale: One step of the sweep skill's reporting procedure; stacked behind the probe step because both edit the same SKILL.md.
Architectural effect: Step 6 gains a dependency on the already-shipped verify_pr_landed_on_trunk.sh instead of relying on gh pr view alone.
Goal: Rewrite Step 6 of product/skills/admin-bypass-sweep/SKILL.md so each PR's status line comes from engine/hooks/gh-write-verification/verify_pr_landed_on_trunk.sh and a non-OK result is reported as unchecked.
Motivation: A 19-PR sweep reported 13 merged from gh pr view output alone. A Stop hook had to force the real ancestry check afterwards. All 13 did pass, but the claim went out before the check that proves it, and the same skill had already caused a manual replay of four PRs three days earlier.
Alternative considerations: Adding a sentence telling the operator to also run the verifier was rejected: Step 6 already says to re-query every PR and not trust running tallies, and that prose did not produce an ancestry check. Leaving the hook as the only catch was rejected because it fires after the reply is drafted.
Implementation details: Replace the `gh pr view --json number,state,mergedAt,title` loop in Step 6 with a loop calling verify_pr_landed_on_trunk.sh per PR, branching on its documented exit codes: engine/hooks/gh-write-verification/verify_pr_landed_on_trunk.sh lines 4-6 (EXIT_OK=0, EXIT_FAIL=1, EXIT_UNCHECKED=3). Report exit 0 as merged, exit 1 as merged-but-not-on-trunk, and exit 3 as unchecked. State in the prose that a merged count may not be reported from gh pr view alone. Add a fixture under the skill's tests directory asserting the new Step 6 text names the verifier and the three outcomes.
Non-goals: Does not change the merge commands in Step 4, does not change Step 5's blocked-PR policy, does not modify the verifier script itself, and does not touch any other skill.
Layer: domain
Feature state: active
Files: product/skills/admin-bypass-sweep/SKILL.md, product/skills/admin-bypass-sweep/tests/
Change types:
- product/skills/admin-bypass-sweep/SKILL.md: docs-only
- product/skills/admin-bypass-sweep/tests/fires_step6_names_verifier.md: create
Acceptance criteria:
- `python3 -m unittest discover -s product/skills/admin-bypass-sweep/tests -v` exits 0.
- Step 6 names verify_pr_landed_on_trunk.sh and all three exit codes.
- Step 6 no longer derives a merged count from `gh pr view` state alone.

Invoker-Finalize-Id: 616fd5ec-4b0c-4737-9ac1-85da4a7c9f4a
…erministic proof for the trunk-derived merged tally.

Review claim: The sweep skill's fixtures assert Step 6 reports from the ancestry check.
Review lane: proof
Safety invariant: Proof-only; adds no product behavior.
Effectiveness measurement: The suite fails if Step 6 stops naming the verifier or drops the unchecked outcome.
Slice rationale: One proof slice for this step.
Architectural effect: None; verification only.
Goal: Prove the trunk-derived merged tally deterministically.
Motivation: The defect is a reporting path, so the proof asserts the reporting text names its source.
Alternative considerations: Manual verification was rejected as non-deterministic.
Implementation details: Execute the command below as the terminal proof.
Non-goals: No product edits here; proof only.
Layer: app_regression
Feature state: active

Exit code: 0
Invoker-Finalize-Id: 931b523d-2572-41c1-8c3e-4f3e187d758f
… that no ephemeral inter-task handoff files remain.

Review claim: The workflow leaves no scratch handoff artifacts behind.
Review lane: cleanup
Safety invariant: Read-only; never deletes files, alters the index, or commits caller work.
Effectiveness measurement: The gate fails when a plans/invoker-handoff.* or lens-*.json file is still present after the leaf tasks complete.
Slice rationale: One terminal hygiene gate for the workflow.
Architectural effect: None; check only.
Goal: Confirm no ephemeral handoff files survive the run.
Motivation: Inter-task scratch files leak into diffs and read as part of the work.
Alternative considerations: Deleting them automatically was rejected; the gate reports, it does not mutate.
Implementation details: Run scripts/scrub-handoff-artifacts.sh without --apply.
Non-goals: No deletion, no index changes, no commits.
Layer: app_regression
Feature state: active

Exit code: 0
Invoker-Finalize-Id: 9d4fd2eb-452d-4846-91e9-4fe370c27a64
…a80cd87b9-03a12c6d — Terminal check that no ephemeral inter-task handoff files remain.

Review claim: The workflow leaves no scratch handoff artifacts behind.
Review lane: cleanup
Safety invariant: Read-only; never deletes files, alters the index, or commits caller work.
Effectiveness measurement: The gate fails when a plans/invoker-handoff.* or lens-*.json file is still present after the leaf tasks complete.
Slice rationale: One terminal hygiene gate for the workflow.
Architectural effect: None; check only.
Goal: Confirm no ephemeral handoff files survive the run.
Motivation: Inter-task scratch files leak into diffs and read as part of the work.
Alternative considerations: Deleting them automatically was rejected; the gate reports, it does not mutate.
Implementation details: Run scripts/scrub-handoff-artifacts.sh without --apply.
Non-goals: No deletion, no index changes, no commits.
Layer: app_regression
Feature state: active
@cursor

cursor Bot commented Sep 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_a5c20b67-3a80-477c-80a0-6aab4b5a84c4)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant