Skip to content

admin-bypass-sweep (1) a rebase probe with a third exit code - #492

Open
EdbertChan wants to merge 4 commits into
mainfrom
plan/admin-bypass-sweep-1-a-rebase-probe-with-a-third-exit-code
Open

admin-bypass-sweep (1) a rebase probe with a third exit code#492
EdbertChan wants to merge 4 commits into
mainfrom
plan/admin-bypass-sweep-1-a-rebase-probe-with-a-third-exit-code

Conversation

@EdbertChan

@EdbertChan EdbertChan commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Summary

This change adds a small check for testing whether a branch can be rebased before a pull request is swept.

Previously, a setup problem could look like a real merge conflict and trigger the wrong follow-up action.

The check now reports clean, conflicting, and unable-to-run outcomes separately.

The sweep procedure will call this check in a later step.

Review Claim

A rebase that could not run is reported as unchecked, never as a conflict.

Review Lane

behavior

Review Unit

engine-runtime

Safety Invariant

A setup failure can never produce the conflict exit code; the check reuses the established 0, 1, and 3 outcome contract.

Slice Rationale

This slice isolates the executable check and its tests so the outcome contract can be reviewed before any caller wiring.

Non-goals

  • Does not change the sweep procedure.
  • Does not resolve conflicts or alter merge commands.
  • Does not edit any skill.

Architecture

Before

graph TD
    A["scratch setup failure"] --> B["conflict outcome"]
Loading

After

graph TD
    A["scratch setup failure"] --> B["unchecked outcome: 3"]
    C["clean rebase"] --> D["success outcome: 0"]
    E["content conflict after rebase"] --> F["conflict outcome: 1"]
Loading

Test Plan

Test Plan
  • python3 engine/skills/make-pr/scripts/preflight.py --base origin/main — preflight passed; one engine-runtime file and one neutral test file.
  • python3 -m unittest discover -s tests -p 'test_probe_branch_rebase*.py' -v — asserts clean, conflict, and unchecked outcomes.
  • bash scripts/scrub-handoff-artifacts.sh — terminal hygiene check passed.

Revert Plan

Revert Plan
  • Safe to revert? Yes.
  • Revert command: git revert <sha>.
  • Post-revert steps: None.
  • Data migration? No.

Note

Low Risk
New standalone script and tests only; no changes to merge/sweep behavior until a later caller wires it in.

Overview
Adds scripts/probe_branch_rebase.sh, a dry-run check that rebases a source ref onto a base ref inside a temporary detached worktree and reports the outcome without touching the main checkout.

Exit contract: 0 when the rebase succeeds; 1 only when the rebase runs and leaves real content conflicts (ls-files -u); 3 (UNCHECKED) for any setup or inspection failure (invalid refs, worktree creation, ambiguous rebase failure). Setup problems cannot masquerade as conflicts.

Scratch worktrees live under rebase-probe-worktrees with hashed names and are removed on exit. tests/test_probe_branch_rebase.py covers clean rebase, conflicting rebase, and a stale registered-but-missing worktree path that must exit 3. No sweep or skill wiring in this slice.

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

Invoker Bot and others added 4 commits September 12, 2026 18:02
…ebase probe script whose setup failure is its own exit code.

Review claim: A rebase probe that could not run exits unchecked, never conflicted.
Review lane: behavior
Safety invariant: A setup failure can never produce the conflict exit code; the script reuses the contract already shipped at engine/hooks/gh-write-verification/verify_pr_landed_on_trunk.sh lines 4-6 (EXIT_OK=0, EXIT_FAIL=1, EXIT_UNCHECKED=3) rather than defining a new one.
Effectiveness measurement: A fixture that removes the scratch directory without deregistering it makes the probe exit 3. The same fixture under a two-branch loop yields the conflict code, so the test fails before the change and passes after.
Slice rationale: One executable and its tests, with no caller changes, so the exit contract can be reviewed on its own.
Architectural effect: Adds one shell script under scripts/ and its test module.
Goal: Add scripts/probe_branch_rebase.sh exiting 0 on a clean rebase, 1 on a real content conflict, and 3 when the probe could not run.
Motivation: During a sweep of nineteen pull requests an inline loop reported three conflicts when no rebase had executed, because a stale worktree registration made setup fail into the same branch as a genuine conflict. The same two-branch shape gated a force-push and an override merge on a clean result.
Alternative considerations: Folding this into the caller was rejected because the exit contract is the reviewable unit. Making the unchecked case exit 1 was rejected because it is the exact conflation being removed.
Implementation details: Create scripts/probe_branch_rebase.sh taking a source ref and a base ref. Declare the three exit codes to match engine/hooks/gh-write-verification/verify_pr_landed_on_trunk.sh lines 4-6 (EXIT_OK=0, EXIT_FAIL=1, EXIT_UNCHECKED=3). Any failure while creating the scratch worktree exits 3 with the underlying error on stderr and must not attempt the rebase. Only a rebase that actually ran may yield 0 or 1. Tear down with git worktree remove --force. Add tests/test_probe_branch_rebase.py with one case per exit code.
Non-goals: Does not change any caller, does not resolve conflicts, does not alter merge commands, and does not edit any skill.
Layer: domain
Feature state: active
Files: scripts/probe_branch_rebase.sh, tests/test_probe_branch_rebase.py
Change types:
- scripts/probe_branch_rebase.sh: create
- tests/test_probe_branch_rebase.py: create
Acceptance criteria:
- `python3 -m unittest discover -s tests -p 'test_probe_branch_rebase*.py' -v` exits 0.
- The probe exits 3, not 1, when its scratch worktree cannot be created.
- scripts/probe_branch_rebase.sh contains no `rm -rf`.

Solution:
  Ship a rebase probe script whose setup failure is its own exit code.
Review claim: A rebase probe that could not run exits unchecked, never conflicted.
Review lane: behavior
Safety invariant: A setup failure can never produce the conflict exit code; the script reuses the contract already shipped at engine/hooks/gh-write-verification/verify_pr_landed_on_trunk.sh lines 4-6 (EXIT_OK=0, EXIT_FAIL=1, EXIT_UNCHECKED=3) rather than defining a new one.
Effectiveness measurement: A fixture that removes the scratch directory without deregistering it makes the probe exit 3. The same fixture under a two-branch loop yields the conflict code, so the test fails before the change and passes after.
Slice rationale: One executable and its tests, with no caller changes, so the exit contract can be reviewed on its own.
Architectural effect: Adds one shell script under scripts/ and its test module.
Goal: Add scripts/probe_branch_rebase.sh exiting 0 on a clean rebase, 1 on a real content conflict, and 3 when the probe could not run.
Motivation: During a sweep of nineteen pull requests an inline loop reported three conflicts when no rebase had executed, because a stale worktree registration made setup fail into the same branch as a genuine conflict. The same two-branch shape gated a force-push and an override merge on a clean result.
Alternative considerations: Folding this into the caller was rejected because the exit contract is the reviewable unit. Making the unchecked case exit 1 was rejected because it is the exact conflation being removed.
Implementation details: Create scripts/probe_branch_rebase.sh taking a source ref and a base ref. Declare the three exit codes to match engine/hooks/gh-write-verification/verify_pr_landed_on_trunk.sh lines 4-6 (EXIT_OK=0, EXIT_FAIL=1, EXIT_UNCHECKED=3). Any failure while creating the scratch worktree exits 3 with the underlying error on stderr and must not attempt the rebase. Only a rebase that actually ran may yield 0 or 1. Tear down with git worktree remove --force. Add tests/test_probe_branch_rebase.py with one case per exit code.
Non-goals: Does not change any caller, does not resolve conflicts, does not alter merge commands, and does not edit any skill.
Layer: domain
Feature state: active
Files: scripts/probe_branch_rebase.sh, tests/test_probe_branch_rebase.py
Change types:
- scripts/probe_branch_rebase.sh: create
- tests/test_probe_branch_rebase.py: create
Acceptance criteria:
- `python3 -m unittest discover -s tests -p 'test_probe_branch_rebase*.py' -v` exits 0.
- The probe exits 3, not 1, when its scratch worktree cannot be created.
- scripts/probe_branch_rebase.sh contains no `rm -rf`.

Invoker-Finalize-Id: 259aacb5-064f-4dbf-a36f-f3fd4445463d
…erministic proof for the three-outcome rebase probe.

Review claim: The probe's three exit codes are asserted by tests.
Review lane: proof
Safety invariant: Proof-only; adds no product behavior.
Effectiveness measurement: The suite fails if the unchecked case returns 1 instead of 3.
Slice rationale: One proof slice for this step.
Architectural effect: None; verification only.
Goal: Prove the three-outcome rebase probe deterministically.
Motivation: The defect is a wrong exit path, so the proof exercises every exit path.
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: a4316ef4-e3eb-4b23-bf12-3d12f74bcbb7
… 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: a726a99a-fef6-4971-8bb1-446252907754
…a363dbbc6-5be0c2cc — 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_3a942efe-d38a-4d27-b106-e787f69c7a39)

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