Skip to content

fix(bin): ignore the no-mistakes mirror when teardown checks for landed work - #7820

Merged
kunchenguid merged 3 commits into
kunchenguid:mainfrom
trillium:fix/teardown-open-pr-and-mirror
Nov 3, 2026
Merged

kunchenguid merged 3 commits into
kunchenguid:mainfrom
trillium:fix/teardown-open-pr-and-mirror

Conversation

@trillium

@trillium trillium commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Intent

"main firstmate is down, please handle comments on kun chen firstmate PRs" (captain, 2026-10-29). This run is the existing kunchenguid/firstmate PR #7820 (teardown ignores the no-mistakes mirror): address the review comment on it. In tests/fm-teardown.test.sh, test_no_mistakes_mirror_only_branch_refuses must capture the task worktree HEAD before run_teardown and call assert_refusal_retained_task_state after the refusal, so the test proves the refusal kept the isolated copy, task branch, and task record. Nothing wider than that one comment.

What Changed

  • bin/fm-teardown.sh leaves out no-mistakes/* remote-tracking refs (via --exclude='no-mistakes/*' --remotes) when it looks for unpushed commits, both in validate_worktree_teardown_safety and unpushed_patches_are_in_pr_head. A branch pushed only to the local no-mistakes mirror now counts as unlanded, so teardown refuses it. The header comment now says the mirror is not a forge.
  • Adds test_no_mistakes_mirror_only_branch_refuses to tests/fm-teardown.test.sh. The test pushes a task branch only to a local no-mistakes bare mirror and captures the worktree HEAD before running teardown. It then checks that teardown exits 1 with a REFUSED line, and calls assert_refusal_retained_task_state to confirm the refusal kept the isolated copy, task branch and task record.

Risk Assessment

✅ Low: The change does what the review comment asked: the mirror-only refusal test now records the worktree HEAD before teardown and calls the existing assert_refusal_retained_task_state helper (signature: case_dir, label, head). The --exclude='no-mistakes/*' --remotes change is applied at both sites in bin/fm-teardown.sh that compute unpushed commits (lines 1691 and 2129), and the teardown script has no other remote-reachability check.

Testing

Ran the mirror-only teardown test and its two no-mistakes neighbours against the real fm-teardown CLI on throwaway git fixtures, and all passed. As adversarial checks, the new assertion failed with the right message for each of three teardowns that refuse but then delete the task record, remove the worktree, or move the branch. Against the pre-fix teardown script the test also fails (exit 0 instead of the expected refusal). This is a CLI-only change with no UI, so there are no screenshots; CLI transcripts are the evidence. No Herdr or tmux lab was needed because the refusal happens before any pane or session work. All temporary files were removed and the worktree is clean.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Teardown of a ship task whose branch is pushed only to the no-mistakes mirror is refused, and the worktree, task branch, HEAD and task record survive ✅ pass live 01-target-mirror-only-refusal.log: 'ok - branch pushed only to the no-mistakes mirror is refused as unlanded'
Adversarial: a teardown that refuses but then deletes the task record, removes the worktree, or resets the branch makes the test fail ✅ pass live 02-adversarial-destructive-refusal.log: each of the three variants failed with the matching 'refusal erased/removed/moved' message
Regression: the test fails against the pre-fix teardown (b83dc59) that treated the mirror as landed ✅ pass live 03-prefix-base-teardown.log: 'expected exit 1, got 0'
Neighbouring no-mistakes cases still pass: genuinely unpushed work is refused and a HEAD already on origin is torn down ✅ pass live 01-target-mirror-only-refusal.log: both neighbouring tests print 'ok'
Evidence: Target test passes against the real teardown

Source: Target test passes against the real teardown

ok - teardown leaves opencode's busy plugin in the returned pool worktree as on main
TEARDOWN under test: ~/.no-mistakes/worktrees/1467055f0b60/01M65TGVKNGS32R9645E1PZF5J/bin/fm-teardown.sh
ok - no-mistakes worktree with genuinely unlanded work is refused (safety preserved)
ok - branch pushed only to the no-mistakes mirror is refused as unlanded
ok - no-mistakes worktree with HEAD on origin is torn down (no regression)
FOCUSED RUN COMPLETE
Evidence: New assertion catches teardowns that refuse but destroy task state

Source: New assertion catches teardowns that refuse but destroy task state

meta destroyed -> not ok - nm-mirror-only: refusal erased the durable task record wt removed -> not ok - nm-mirror-only: refusal removed the isolated copy branch reset -> not ok - nm-mirror-only: refusal moved the task branch off the unlanded commit

=== sabotage: refusal then destroys meta ===
TEARDOWN under test: /var/folders/d9/2d5w27z5775c_r1qcw57vzzr0000gn/T//fm-sabotage.oOCALL/teardown-meta.sh
ok - no-mistakes worktree with genuinely unlanded work is refused (safety preserved)
not ok - nm-mirror-only: refusal erased the durable task record
exit=0
=== sabotage: refusal then destroys wt ===
TEARDOWN under test: /var/folders/d9/2d5w27z5775c_r1qcw57vzzr0000gn/T//fm-sabotage.oOCALL/teardown-wt.sh
ok - no-mistakes worktree with genuinely unlanded work is refused (safety preserved)
not ok - nm-mirror-only: refusal removed the isolated copy
exit=0
=== sabotage: refusal then destroys branch ===
TEARDOWN under test: /var/folders/d9/2d5w27z5775c_r1qcw57vzzr0000gn/T//fm-sabotage.oOCALL/teardown-branch.sh
ok - no-mistakes worktree with genuinely unlanded work is refused (safety preserved)
not ok - nm-mirror-only: refusal moved the task branch off the unlanded commit
exit=0
Evidence: Test fails against the pre-fix teardown

Source: Test fails against the pre-fix teardown

not ok - nm-mirror-only: teardown should refuse mirror-only work: expected exit 1, got 0

=== pre-fix base teardown (b83dc59e) ===
TEARDOWN under test: ~/.no-mistakes/worktrees/1467055f0b60/01M65TGVKNGS32R9645E1PZF5J/bin/.fm-teardown-base.sh
ok - no-mistakes worktree with genuinely unlanded work is refused (safety preserved)
not ok - nm-mirror-only: teardown should refuse mirror-only work: expected exit 1, got 0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Teardown of a ship task whose branch is pushed only to the no-mistakes mirror is refused, and the worktree, task branch, HEAD and task record survive ✅ pass live 01-target-mirror-only-refusal.log: 'ok - branch pushed only to the no-mistakes mirror is refused as unlanded'
Adversarial: a teardown that refuses but then deletes the task record, removes the worktree, or resets the branch makes the test fail ✅ pass live 02-adversarial-destructive-refusal.log: each of the three variants failed with the matching 'refusal erased/removed/moved' message
Regression: the test fails against the pre-fix teardown (b83dc59) that treated the mirror as landed ✅ pass live 03-prefix-base-teardown.log: 'expected exit 1, got 0'
Neighbouring no-mistakes cases still pass: genuinely unpushed work is refused and a HEAD already on origin is torn down ✅ pass live 01-target-mirror-only-refusal.log: both neighbouring tests print 'ok'
  • bash tests/.focused-mirror.sh (temporary copy of the test file's helpers that calls only test_no_mistakes_truly_unpushed_refuses, test_no_mistakes_mirror_only_branch_refuses, and test_no_mistakes_origin_remote_allows) against the real bin/fm-teardown.sh
  • Three throwaway wrapper scripts set as TEARDOWN; each calls the real bin/fm-teardown.sh and, after it refuses, deletes the task meta, removes the worktree, or resets the branch to HEAD~1
  • The pre-fix bin/fm-teardown.sh from b83dc59e set as TEARDOWN, to confirm the test catches the original bug
  • Deleted the temporary runner, the base-script copy and the wrapper directory; git status --short is clean
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@trillium

Copy link
Copy Markdown
Contributor Author

The only non-green check, Behavior portable serial 1, was cancelled by the runner (30m limit) in the shard that holds the known flaky tests/fm-supervision-host.test.sh; unrelated to this change.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @trillium, nice and narrow.

What I checked (head d419084c): both unpushed-work checks in bin/fm-teardown.sh (validate_worktree_teardown_safety and unpushed_patches_are_in_pr_head) now use git log ... --not --exclude='no-mistakes/*' --remotes, so a commit that only exists on the local no-mistakes mirror no longer counts as landed and teardown refuses. The --exclude pattern form is right for --remotes (no refs/remotes/ prefix), and the new test_no_mistakes_mirror_only_branch_refuses covers it. I found no workflow, network or credential changes. The no-mistakes attestation binds this head, and live validation is 2 of 3 with before/after transcripts.

How I'm classing it: a restore. Teardown already promises to refuse work that hasn't landed, and the mirror isn't a forge, so this puts the existing default refusal back in force. This addresses the teardown half of #7776; that issue also points at fm_dod_ref_contains in bin/fm-dod-lib.sh, which this PR leaves alone, so I'm not treating it as closing #7776 outright.

CI: 18/19 green. Behavior portable serial 1 was cancelled at the 30-minute cap in the shard holding tests/fm-supervision-host.test.sh, on a run cut while main itself was red with that same problem. That's on our side, not yours. I've re-run that shard; if it comes back green this can land on a later pass. Nothing is needed from you.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Reviews (3) · Last reviewed commit: "test: assert the mirror-only teardown re..." · Reviewed by Greptile

Comment thread tests/fm-teardown.test.sh Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @trillium. The head is still d419084c, so my earlier review holds: restore (teardown's refuse-unlanded promise; the local no-mistakes mirror isn't a forge), and the attestation binds this head. Closing and reopening the PR started a fresh CI run, which also takes care of the serial-1 rerun I owed you.

The reopen also brought a first Greptile review at 4/5. This repo's Greptile check only passes at 5/5, and its one point is fair: test_no_mistakes_mirror_only_branch_refuses checks the exit code and REFUSED, but not that the work was kept. It would still pass if teardown deleted the worktree or task record before refusing. Capture HEAD before run_teardown, then call the existing assert_refusal_retained_task_state helper after it.

Waiting on you: please add that assertion and re-raise through git push no-mistakes. When CI and Greptile are green on the new head, I'll merge it. No conflicts with main 6613c3e1 or with #7813. If anything nearby lands first and causes a conflict, we'll fix it on our side, so you won't need to rebase.

@trillium
trillium force-pushed the fix/teardown-open-pr-and-mirror branch from d419084 to 895abcb Compare October 30, 2026 05:16
@trillium trillium changed the title fix(teardown): stop counting the no-mistakes mirror as landed work fix(bin): stop counting the no-mistakes mirror as landed in teardown Oct 30, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @trillium, that's exactly the fix I asked for.

What I checked (head 895abcbc vs main c0aa730d): I read the diff myself. The net change is still narrow: both unpushed-work checks in bin/fm-teardown.sh use --not --exclude='no-mistakes/*' --remotes, and test_no_mistakes_mirror_only_branch_refuses now captures HEAD and calls assert_refusal_retained_task_state, so it would catch teardown deleting the work before refusing. The open-PR refusal from your first commit isn't in the net diff, and the title and body don't claim it, so that's fine. No workflow, network or credential changes. Greptile is 5/5 and its thread is resolved, the coverage guard and repo invariants pass, live validation is 6/6 with base-vs-target transcripts, and it merges cleanly with main. Contract-class: restore, unchanged.

One small thing from you (this is waiting on you): please re-raise once more through git push no-mistakes. The attestation binds this head, but its intent step was skipped, and we need a run with no skipped steps before this can merge. Adding a short ## Intent to the run should be enough.

On the Full suite check: it isn't red for you. Once the re-raise lands with the quick checks green, running the full suite is on us. After it passes, this can merge without a captain decision. If anything that lands first causes a conflict, we'll fix it on our side, so you won't need to rebase.

trillium and others added 3 commits October 30, 2026 00:13
… in the landed test

Teardown deletes the record that merge recording depends on, so an ordinary ship whose recorded pr= is still open is refused (--force bypasses). The unpushed-commit checks also exclude the local no-mistakes mirror remote, which is not a forge, so work that only reached the mirror is no longer counted as landed.
@trillium
trillium force-pushed the fix/teardown-open-pr-and-mirror branch from 895abcb to 0058aea Compare October 30, 2026 07:16
@trillium trillium changed the title fix(bin): stop counting the no-mistakes mirror as landed in teardown fix(bin): ignore the no-mistakes mirror when teardown checks for landed work Oct 30, 2026
@trillium

trillium commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

I did not re-raise this branch. The dedicated robot n0pif proof clone is already dirty (825 staged deletions) and its only origin fetches and pushes to kunchenguid/firstmate; no-mistakes axi status also reports it is not initialized. Initializing or driving it in that state could target the upstream repository rather than this PR's authorized trillium branch.

I confirmed the PR is still at 0058aea56ceb679f071a6a2c7f5b4cfb1ba9095a with 3 commits and 2 changed files. No re-raise or push was attempted; the branch is untouched.

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 3, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @trillium, and thanks for being careful with that proof clone. No further re-raise is needed: head 0058aea5 already carries the run I asked for, with every no-mistakes step completed (intent included) and the assert_refusal_retained_task_state check in the mirror-only test. I re-read the diff against main 69023626: both unpushed-work checks in bin/fm-teardown.sh skip only no-mistakes/* remote-tracking refs, live validation is 4/4, Greptile is 5/5 with its thread resolved, the quick checks pass, and it merges cleanly. Contract-class: restore, unchanged.

I've added the full-ci label so the Full suite runs now. If it comes back green, this merges without needing a captain decision. Nothing else is needed from you.

@kunchenguid
kunchenguid merged commit ed1eb1d into kunchenguid:main Nov 3, 2026
34 of 35 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @trillium. Teardown's landed-work check now ignores the no-mistakes mirror refs, so a worker isn't held back by its own pipeline mirror. Really appreciate you taking the time on this.

kayis-rahman pushed a commit to kayis-rahman/firstmate that referenced this pull request Nov 8, 2026
…ed work (kunchenguid#7820)

* fix(teardown): refuse open-PR ships and ignore the no-mistakes mirror in the landed test

Teardown deletes the record that merge recording depends on, so an ordinary ship whose recorded pr= is still open is refused (--force bypasses). The unpushed-commit checks also exclude the local no-mistakes mirror remote, which is not a forge, so work that only reached the mirror is no longer counted as landed.

* no-mistakes(review): Exclude no-mistakes mirror from teardown unpushed checks

* test: assert the mirror-only teardown refusal retains the task state
vinicius928e8r84 pushed a commit to vinicius928e8r84/firstmate that referenced this pull request Nov 11, 2026
…ed work (kunchenguid#7820)

* fix(teardown): refuse open-PR ships and ignore the no-mistakes mirror in the landed test

Teardown deletes the record that merge recording depends on, so an ordinary ship whose recorded pr= is still open is refused (--force bypasses). The unpushed-commit checks also exclude the local no-mistakes mirror remote, which is not a forge, so work that only reached the mirror is no longer counted as landed.

* no-mistakes(review): Exclude no-mistakes mirror from teardown unpushed checks

* test: assert the mirror-only teardown refusal retains the task state

(cherry picked from commit ed1eb1d)
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Nov 12, 2026
…ed work (kunchenguid#7820)

* fix(teardown): refuse open-PR ships and ignore the no-mistakes mirror in the landed test

Teardown deletes the record that merge recording depends on, so an ordinary ship whose recorded pr= is still open is refused (--force bypasses). The unpushed-commit checks also exclude the local no-mistakes mirror remote, which is not a forge, so work that only reached the mirror is no longer counted as landed.

* no-mistakes(review): Exclude no-mistakes mirror from teardown unpushed checks

* test: assert the mirror-only teardown refusal retains the task state
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Nov 13, 2026
…ed work (kunchenguid#7820)

* fix(teardown): refuse open-PR ships and ignore the no-mistakes mirror in the landed test

Teardown deletes the record that merge recording depends on, so an ordinary ship whose recorded pr= is still open is refused (--force bypasses). The unpushed-commit checks also exclude the local no-mistakes mirror remote, which is not a forge, so work that only reached the mirror is no longer counted as landed.

* no-mistakes(review): Exclude no-mistakes mirror from teardown unpushed checks

* test: assert the mirror-only teardown refusal retains the task state
joergoss pushed a commit to joergoss/firstmate that referenced this pull request Nov 23, 2026
…ed work (kunchenguid#7820)

* fix(teardown): refuse open-PR ships and ignore the no-mistakes mirror in the landed test

Teardown deletes the record that merge recording depends on, so an ordinary ship whose recorded pr= is still open is refused (--force bypasses). The unpushed-commit checks also exclude the local no-mistakes mirror remote, which is not a forge, so work that only reached the mirror is no longer counted as landed.

* no-mistakes(review): Exclude no-mistakes mirror from teardown unpushed checks

* test: assert the mirror-only teardown refusal retains the task state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants