Repository navigation
feat(bin): continue published PR branches through a guarded resync owner - #50
Merged
Merged
Conversation
bin/fm-pr-resync.sh verifies a branch's published head on origin, archives stale non-contained local history under archive/<task>-pre-rebase-<sha8>, advances with reset --keep on a clean tree, and settles no-mistakes branch custody only through native-offered actions with refusals and no force. tests/fm-pr-resync.test.sh reproduces a pipeline-rebased published head against a stale local branch with a real bare remote.
…--check ref-free The resync owner now refuses a native no-mistakes verdict outside its handled set at the preflight and pre-move reads, before any archive or advance, and --check fetches objects only so no remote-tracking ref or FETCH_HEAD changes.
--check now reads origin's advertised head before and after its ref-free fetch and refuses when they differ, so a move to an already-present commit cannot pass the fetched/advertised check; the redundant unreadable-custody branch is folded into the handled-verdict refusal.
fm-brief and fm-spawn gain --pr-branch for continuing an existing published branch: the brief ships that exact branch, and the spawn runs bin/fm-pr-resync.sh on the pooled copy instead of the hard-reset base refresh, refusing unless it settles. --from-branch starts a ship or scout from origin's source branch while the pull request keeps its default target. A ship relaunch whose recorded branch is on origin runs the owner in the recorded worktree first and embeds its monitoring-only contract when a run is active; fm-promote --pr-branch runs the owner before the task record changes.
…nuation's ship line A successor launched with --from-branch keeps its brief's Source branch line, so checking it on relaunch refused every relaunch of that task. The agreement now binds only the launch that selects the start. A --pr-branch launch also no longer inherits the legacy default-branch warning: its brief must carry the matching Ship branch line.
The no-mistakes driving block now names bin/fm-pr-resync.sh with the task and branch for a branch diverged from or rewritten against the pipeline's published head, and validation-supervision names it for supervisors, so neither teaches a hand-run archive/reset/sync sequence.
… test The validation-supervision check grepped skill source, which the coding guidelines forbid; the rendered DoD assertions stay.
The no-mistakes driving block now names each brief's task and branch in the resync owner command, so the gerrit/default forge comparison maps that line the same way it already maps the arm command.
The advance is now conditional on the branch tip captured at classification, so a concurrent local commit makes the owner refuse instead of resetting it away, and a detached HEAD holding commits absent from the branch and the published head refuses before any switch. Every Git network call, including the relaunch pre-probe, runs under the existing bounded runner and refuses on timeout while reporting earlier changes. A PR continuation brief keeps its Base branch line so spawn accepts --pr-branch with --base-branch, and a fresh Orca copy is detached before the continuation resync while its initial branch stays. Tests cover mismatched keep-local identities, the monitoring-only contract's permissions and release condition, and active-custody refusal at fresh continuation and promotion.
…t detached switches
…ch custody - Relaunch resyncs the recorded branch only for no-mistakes work or a copy with a no-mistakes remote, and passes --refuse-diverged so diverged history is refused without an archive or ref move; direct-PR and local-only branches stay worker-owned. - A refused --pr-branch spawn returns a pool copy it found detached to detached at its current HEAD, without discarding files or branches. - When the index/worktree update fails after the conditional advance, fm-pr-resync.sh moves the branch back only while it still holds the published head, keeps the archive and reports the actual position.
Pibomeister
added a commit
that referenced
this pull request
Oct 30, 2026
… local checks pass on the final code. The five changed files are uncommitted in the worktree; I did not commit or push them. This replaces my earlier result, which reported the final lint run as unknown. Changes: - `bin/fm-lint.sh`: `--partition` accepts KofN for N >= 1 and 1 <= K <= N. It refuses 0ofN, K>N, N<1, leading zeros, malformed values and integers past the shell range, with exit 2. Packing uses N bins with the same greedy least-loaded rule, and ties go to the lowest bin. Error and help text are updated. - `tests/fm-lint.test.sh`: the 1of3 refusal is replaced with runs of 1of3, 2of3 and 3of3. It also checks that the N parts cover every canonical root exactly once for N=2 and N=3, and adds more refusal cases. - `.github/workflows/ci.yml`: lint matrix is `[1, 2, 3]`; timeout-minutes stays 30. - `CONTRIBUTING.md`: adds the `Lint 3` context. - `docs/fm-test-portable-shards.md`: now says three lint partitions and twenty-one jobs. One addition goes beyond the literal scope. A partition with no roots (K above the root count, such as 9999of10000) crashed on an unbound `ROOTS`. Accepting any N makes that input reachable, so I fixed it: it now prints a note, runs the non-ShellCheck checks and exits by their result. The test file covers this case. Evidence on the final code: - `/bin/bash tests/fm-lint.test.sh`: rc 0, 50 ok, no `not ok`. - `/bin/bash tests/fm-ci-workflow.test.sh`: rc 0. - `bin/fm-lint.sh`: rc 0, in changed-file mode, so this is not a full canonical lint. - Assignment for 1of2 and 2of2: identical to the old two-bin formula, compared over the same current weights. This was a local check and is not a committed test. The edit changed byte weights, so the lists can differ from those taken before the edit. - Split at 3 bins: 195, 195 and 196 roots. Not verified: - CI on the new head, so whether three partitions finish under 30m is unproven. - The `Full suite` log. Its failure is attributed to the cancelled `Lint 2` from timing only. Decisions for you: - If a branch ruleset on the fork lists `Lint 1` and `Lint 2`, add `Lint 3`, or the new job is not enforced. I did not inspect the ruleset. - PR #50 has the same Lint 2 timeout and gets this fix only after it picks up this change
Keep main's fm_nm_driving_block signature (<forge|no-ci> <task-id>) and freshen_spawn_worktree_base plus the t3code skip. Fold #50's --pr-branch/--from-branch resync around them so freshening the base does not clobber a published PR head, and keep main's disk-alarm, pr=manual, Rex, and primary-checkout base behavior. Co-authored-by: Eduardo Picazo <[email protected]>
Bring in #122, #124, #123, and #121. No textual conflicts; keep the published-head resync owner on main's driving-block signature, freshen_spawn_worktree_base, and t3code skip. Co-authored-by: Eduardo Picazo <[email protected]>
Owner
Author
AgentKit super-review
Seats
Verdict: APPROVE (no blocking findings)Findings
Correctness and adversarial checks (no findings)
Protocol steps that couldn't run here
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Finish the three required independent Fable review fixes for the preserved pipeline-resync work from PR49 at published d926f79. Gate relaunch_pr_resync on no-mistakes delivery (or a verified no-mistakes remote); relaunch must refuse diverged history rather than archive-advance it, with a direct-PR relaunch negative control. Restore a --pr-branch pool copy to detached on spawn refusal and assert the actual POOL_DIR HEAD. If read-tree fails after conditional update-ref, conditionally restore the branch ref to local_head while retaining the archive, with behavioral tests. Minors4/5 are optional. Use a fresh40M Opus closeout task from the current pushed source; preserve all previous work and costs. Deliver a green Pibomeister/firstmate PR targeting main. Main firstmate merges when green.
Substance of the referenced review of PR49 (pipeline-resync work): (1) blocker - bin/fm-spawn.sh runs the published-head resync for every ship relaunch whose branch exists on origin regardless of delivery mode, so in direct-PR and local-only modes, where the worker owns the branch, a locally amended or rebased but unpushed branch is moved back to origin's older head and its work archived, reversing the relaunch's promise to continue from the branch's current state; there was no direct-PR relaunch negative control. (2) major - a fresh --pr-branch spawn whose resync refuses (exit 1 or 3) after the owner switched the detached pool copy onto the branch leaves that pool copy on a named branch, and the existing test asserted only project refs, never the pool copy's HEAD. (3) major - in bin/fm-pr-resync.sh, if read-tree -m -u fails after the old-OID-conditional update-ref succeeded, HEAD sits at the published head while the index and worktree hold the stale tree, so a later commit would recreate stale content; the fix is a conditional update-ref back to the old local head (old value = the published head) with the archive kept. Optional minor 4: the relaunch origin probe reads exit 2 as branch-absent and hardcodes 120 seconds instead of honoring FM_PR_RESYNC_TIMEOUT. Optional minor 5: --from-branch spawn tests append a synthetic Setup heading instead of scaffolding with fm-brief.sh --from-branch.
What Changed
bin/fm-pr-resync.sh, the single owner for continuing work on a branch whose pull-request head the pipeline may have rebased and republished. It verifies origin's published head and reads no-mistakes custody withaxi sync --check. It then classifies the local branch as equal, ahead, advanced, or archived-advanced. A diverged history is first kept atarchive/<task>-pre-rebase-<sha8>. All ref moves are old-OID-conditional.--refuse-divergedleaves a diverged branch untouched. If the index or worktree update fails after the ref moved, the script conditionally moves the branch back to the old local head and keeps the archive. It exits 3 when a pipeline run is active, and--checkpreviews the action without moving any refs.fm-spawn.sh,fm-promote.shandfm-brief.shgain--pr-branch, to continue an existing published branch through the resync owner, and--from-branch, to start from origin's source branch while the PR targets the default branch. A refused--pr-branchspawn puts the pool copy back on a detached HEAD. Ship relaunches run the resync only for no-mistakes delivery or when a no-mistakes remote exists. Explicit direct-PR and local-only modes skip it, and a relaunch refuses diverged history instead of archiving it.fm-dod-lib.shnow sends workers to the resync owner instead of hand-run archive, reset or sync steps whenbranch_syncreports divergence.docs/agent-control.md,docs/architecture.mdand the validation-supervision skill to name the resync owner. Addedtests/fm-pr-resync.test.shand extended the brief, relaunch, spawn, DoD and delivery tests. New cases cover a direct-PR relaunch negative control, the pool copy's HEAD after a refused spawn, and rollback after a failed index update.Risk Assessment
Testing
I ran the three focused suites. They drive the real bin/fm-spawn.sh (--relaunch and fresh --pr-branch) and bin/fm-pr-resync.sh against disposable git origins, worktrees and pool copies; all three exited 0. The scenarios cover: - the explicit direct-PR and local-only relaunch skip, with a no-mistakes remote and amended local history - the no-mistakes and legacy diverged refusal, with no move and no archive - the behind advance - the pool copy restored to detached after an owner refusal - the read-tree failure rollback and the concurrent-writer preservation Red counterfactuals showed the explicit-mode precedence guard, the --refuse-diverged wiring and the read-tree move-back are each needed. The pool-detach counterfactual did not apply, so that guard has a passing test but no red proof. The agent launch inside fm-spawn is a test launcher, not a real Claude primary in an fm-lab home. The changed behavior is all git branch custody, which ran for real. There is no UI surface, so no screenshots. The worktree is clean and every file was restored. Overall: go.Evidence: fm-pr-resync suite transcript
Source: fm-pr-resync suite transcript
Evidence: fm-control-relaunch suite transcript
Source: fm-control-relaunch suite transcript
Evidence: fm-spawn-pool-base-freshen suite transcript
Source: fm-spawn-pool-base-freshen suite transcript
Evidence: Red counterfactual transcript (CF1, CF2, CF4 red; CF3 edit did not apply)
Source: Red counterfactual transcript (CF1, CF2, CF4 red; CF3 edit did not apply)
Evidence: Key scenario results
Pipeline
Updates from git push no-mistakes
Evidence for this closeout
agent-kit verify gate not recorded: no runner-attested verifier on this host (known boundary); host-unattested verifier receipt attached.
This PR supersedes the predecessor branch for the same work (published at
d926f79b) and adds the three required fixes from its independent review, plus the explicit-mode precedence fix this pipeline's review requested.What changed in this closeout
no-mistakesdelivery, or for legacy task records with no recorded mode in a repository with ano-mistakesremote. An explicitdirect-PRorlocal-onlyrelaunch never resyncs, so unpushed local work stays in place.--refuse-diverged: a diverged branch is refused and left as-is, with no archive and no ref move. A behind branch still advances, and an active run still relaunches monitoring-only.--pr-branchspawn returns a pool copy it found detached to detached at its current HEAD, without removing files or branches.bin/fm-pr-resync.shmoves the branch back only while it still holds the published head, keeps the archive, and reports the actual position.Real-tool suite runs
Run with the real
/bin/psand a PATH without mise activation, atd926f79bplus the candidate diff (sha25675301ea6…, committed unchanged asb9228328):bash tests/fm-pr-resync.test.shbash tests/fm-spawn-pool-base-freshen.test.shbash tests/fm-spawn-orca-worktree.test.shbash tests/fm-control-relaunch.test.shbin/fm-lint.shbin/fm-doc-audience-check.shThe pipeline's own test step then ran at the final head
af81c3d9.Red counterfactuals
Each guard was removed alone in a clone with full history, and the suite failed on that guard's own regression after earlier tests passed:
af81c3d9)direct-PR worker-owned branch did not relaunch(45 earlier passes)b9228328)direct-PR worker-owned branch did not relaunch(45 earlier passes)diverged with refusal flag: exit: expected exit 1, got 0active continuation left the pool copy on a named branch(33 earlier passes)index update refused: branch moved backOne earlier attempt at two of these controls used copies without Git history, and failed on unrelated fixtures; it is not relied on.
Host-unattested independent verifier receipt
A separate read-only model context reviewed only these three fixes, the suite receipts and the red controls at
d926f79bplus diff sha25675301ea6…, ran no suites, and returned PASS. It recordsisolation: host-unattested. It is not an agent-kit verify gate. Coverage limit it named: aread-treethat fails after a partial index or worktree update is not separately exercised; the branch and archive are protected, and the files would still need inspection.agent-kit lifecycle record
A task-bound agent-kit 0.1.73 run was opened from an approved ticket for these three fixes. Its
check --evidencestill refuses: the build-checks, verify, review-full and review-readiness gates have no recorded evidence, and acceptance criteria AC-1 to AC-3 are uncovered. No gate was recorded, because none has a genuine agent-kit judgment at this head yet. The verify gap is the known runner-attestation boundary; the build-checks and two review gaps are separate missing judgments, not part of that boundary. This pipeline's review is a no-mistakes review and is not relabelled as an agent-kit review.Verification scope at the final head
The verifier receipt and suite table above cover
b9228328. The final headaf81c3d9adds the pipeline's explicit-mode precedence and documentation fix; its evidence is the pipeline's own test step and the precedence red control above, not the earlier verifier receipt.Predecessor history (unchanged, not re-verified here)
Lint 2job timed out once and passed on a single targeted retry.✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-spawn.sh:3903- An explicit direct-PR or local-only relaunch still runs the resync whenever the repo has ano-mistakesremote. relaunch_pr_resync only skips the resync for a non-no-mistakes MODE whengit remote get-url no-mistakesfails. The worktree shares remotes with the project, so a task recorded asmode=direct-PRin a repo that has ano-mistakesremote still runs the resync. One example is a direct-PR task in ano-mistakes-prod-onlyproject; fm-spawn.sh:4150 allows that mode. In that repo the worker owns the branch. Concrete sequence: the worker amends or rebases the branch locally without pushing, then gets relaunched.axi sync --checkreports no push binding (blocked_wrong_branch, no run), which settled() counts as settled. The branch classifies as diverged, and--refuse-divergedrefuses at bin/fm-pr-resync.sh:287. The worker's work is no longer archived, which was the old blocker. But the relaunch is now refused outright for a branch the worker legitimately owns. PR49's promise was to continue from the branch's current state, and that still fails for these tasks. The direct-PR/local-only negative control (tests/fm-control-relaunch.test.sh, the rl96 loop) never adds ano-mistakesremote, so this path is untested. The intent says "(or a verified no-mistakes remote)", but the code only checks that a remote with that name exists. Decision needed: should the remote fallback apply only when no mode is recorded (MODE empty, legacy metadata), so that an explicit direct-PR/local-only always skips? Or is a bare remote name meant to count as "verified"? If the narrower rule is chosen, the fix iscase "$MODE" in direct-PR|local-only) return 0 ;; esacbefore the remote probe, plus a negative-control case that has ano-mistakesremote.docs/agent-control.md:92- The relaunch documentation still says every ship relaunch with an origin branch resyncs to the published head: "A ship relaunch whose recorded branch exists on origin first resyncs that worktree to the published head throughbin/fm-pr-resync.sh." After this change, the resync only runs for no-mistakes delivery or when ano-mistakesremote exists. A diverged branch is now refused and left as-is rather than resynced (bin/fm-spawn.sh:69-72 and 3903-3913). An operator reading this doc would expect a direct-PR relaunch to be moved to origin's head, and a diverged no-mistakes relaunch to be archive-advanced; neither happens now. The same staleness is at docs/architecture.md:405, which describes the owner as "archiving stale local history" for the callers it lists, including ship relaunch. Relaunch no longer archives. Fix: reword both to match the fm-spawn.sh header (no-mistakes-gated; divergence refused and left as-is).bin/fm-spawn.sh:3919- The diverged-relaunch refusal does not name the recovery step. Now that a no-mistakes relaunch refuses a branch the pipeline rebased (rel=diverged), the operator only sees "branch ... diverged from the published head; the branch was left as-is". The message does not say that runningbin/fm-pr-resync.sh <id> <wt> <branch>without--refuse-divergedis the supported way to archive-advance before relaunching. The refusal itself is what the intent requires; this only notes that the message gives no next step.🔧 Fix applied.
1 info still open:
bin/fm-spawn.sh:3919- The diverged-relaunch refusal does not name the recovery step. Now that a no-mistakes relaunch refuses a branch the pipeline rebased (rel=diverged), the operator only sees "branch ... diverged from the published head; the branch was left as-is". The message does not say that runningbin/fm-pr-resync.sh <id> <wt> <branch>without--refuse-divergedis the supported way to archive-advance before relaunching. The refusal itself is what the intent requires; this only notes that the message gives no next step.✅ **Test** - passed
✅ No issues found.
bash tests/fm-pr-resync.test.sh(exit 0): --refuse-diverged on behind and diverged branches, read-tree failure with move-back (index.lock held), concurrent writer surviving a failed index updatebash tests/fm-control-relaunch.test.sh(exit 0): realbin/fm-spawn.sh --relaunchon cases rl90 (diverged no-mistakes), rl95 (behind), rl96-direct-PR and rl96-local-only (no-mistakes remote plus an amended unpushed commit), rl97 (legacy, no mode)bash tests/fm-spawn-pool-base-freshen.test.sh(exit 0): fresh --pr-branch spawn where the resync owner exits 1 or 3; asserts POOL_DIR is detached at STALE_SHA with its files intactCounterfactual CF1: replaced the explicit-mode precedence guard with the remote-probe fallback; red withnot ok - direct-PR worker-owned branch did not relaunch; file restoredCounterfactual CF2: dropped--refuse-divergedfrom relaunch_pr_resync; red withnot ok - a diverged relaunch was not refused; file restoredCounterfactual CF4: removed the read-tree move-back in fm-pr-resync.sh; red withnot ok - index update refused: branch moved back; file restoredCounterfactual CF3 (pool detach restore removed) did not apply: the perl edit matched nothing, so the suite ran against unchanged source and proved nothing✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.