Skip to content

feat(bin): seed local-only projects into secondmates with guarded primary landing - #26

Merged
twilwa merged 24 commits into
mainfrom
fm/fm-local-only-seed-handoff
Sep 26, 2026
Merged

twilwa merged 24 commits into
mainfrom
fm/fm-local-only-seed-handoff

Conversation

@twilwa

@twilwa twilwa commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Intent

Implement local-only secondmate seed and handoff with guarded primary landing on the isolated Firstmate branch. Correct all four Codex review findings: refuse child cleanup when the offered task branch advanced even if its worktree is gone; bind delegated landing to the exact held and released captain-call lifecycle; offer from the task recorded branch rather than assuming fm/; and refuse reseeding a bound local-only child clone with any configured remote, not just origin. Preserve child custody, parent-only landing, exact-head receipts, and safe refusal of unlanded work. Add behavioral regressions for each finding. Do not provision production homes, use the shared daemon, or run full local test suites. Validate with the isolated Opus no-mistakes gate, route ask-user findings to firstmate, and report the PR URL, validated head, and finding dispositions without merging or adopting.

What Changed

  • bin/fm-home-seed.sh can now seed local-only projects into local secondmate homes. Each seeded project is an independent clone, pinned to the current commit on the primary's default branch, with no remotes and no no-mistakes init. The seed records a parent binding under data/local-only-bindings/. A reseed refuses a clone that has any remote configured or that is not bound to this parent. bin/fm-remote-home-seed.sh still refuses local-only projects.
  • New bin/fm-local-handoff.sh and bin/fm-local-handoff-lib.sh add the handoff flow. offer runs in the child and publishes an immutable offer pinned to one head, plus a git bundle, taken from the task's recorded branch (falling back to fm/<task-id>). request runs in the primary and pins a held landing row's approval to that offer's exact commit and to the lifecycle of the held captain call. receipt runs in the primary and recovers a landing idempotently without merging again. bin/fm-merge-local.sh gains an --offer <file> --expect-head <sha> landing path that only the parent can use. It refuses a missing, mismatched or already-landed landing record, a captain-call lifecycle or release that is missing or different, and a project that is no longer local-only. Only after publishing the receipt does it close the row. bin/fm-captain-hold.sh now writes a Captain hold answered: stamp and makes sure a re-hold gets a strictly later hold-set stamp. It also adds open --identity-if-released, which reports a released call's lifecycle identity.
  • bin/fm-teardown.sh now refuses to clean up a bound local-only child task unless a landing offer and a receipt exist. It also refuses if the task branch has moved off the offered commit, even when the worktree is gone, and it re-proves that the commit is contained in the primary's default branch. Other changes: a new tests/fm-local-handoff.test.sh suite with test-family routing in bin/fm-test-run.sh; library links added to tests/fm-gotmp.test.sh; updates to tests/fm-secondmate-safety.test.sh; and updated routing and custody docs (the secondmate-provisioning and task-intake skills, docs/architecture.md, docs/configuration.md, docs/captain-hold-lifecycle.md).

Risk Assessment

⚠️ Medium: This is a large change to how local-only landings are held, approved and recorded, but the latest fix round is narrowly scoped and checks out: legacy date-only stamps now parse the same way as active ones, re-holds still get a new stamp, and the regression test goes through the real landing script and would fail without the fix.

Testing

  • ⏭️ Test - skipped

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped
  • ⚠️ AGENTS.md - merge conflict rebasing onto origin/main
  • ⚠️ bin/fm-dispatch-resolve.sh - merge conflict rebasing onto origin/main
  • ⚠️ docs/configuration.md - merge conflict rebasing onto origin/main
  • ⚠️ docs/verification/dispatch-resolve.md - merge conflict rebasing onto origin/main
  • ⚠️ tests/fm-dispatch-resolve.test.sh - merge conflict rebasing onto origin/main
🔧 **Review** - 4 issues found → auto-fixed (2) ✅
  • ⚠️ bin/fm-local-handoff-lib.sh:892 - The released-identity check requires the current identity to be exactly &lt;pinned-stamp&gt;#(pinned-count+1). It assumes exactly one resolution record follows the pin. A deferral breaks that assumption, even though it is a first-class captain answer that fm-captain-hold.sh:1019-1027 documents as continuing the same call. Concrete sequence: (1) The row is held with stamp S and N records, and request pins hold_identity=S#N. (2) The captain runs answer --defer-until &lt;date&gt;. write_resolution_record (fm-captain-hold.sh:957) prepends a deferred record that carries Captain hold answered: S. The row stays captain-held with stamp S, so the count is now N+1. (3) The captain later runs answer --release. That prepends a released record (count N+2) and unholds. (4) fm-merge-local.sh land-app --offer … --expect-head … calls this function. open --identity --identity-if-released prints S#(N+2), the comparison fails, and the landing is refused with "captain-call lifecycle or recorded answer differs from the pinned approval". Receipt recovery (bin/fm-local-handoff.sh:427) refuses the same way. The pin is immutable (request_report_existing), so this landing id can never land. The only way out is a new landing row plus a new pin, and the error message does not say so. This is the same captain call, held and then released, so it falls inside what the intent means by "bind delegated landing to the exact held and released captain-call lifecycle". Fix: require the answered stamp to equal the pinned stamp, the newest mode to be released (fm-captain-hold.sh already guarantees this for --identity-if-released output), and the count to be greater than or equal to pinned+1 instead of equal to it. Within one stamp, the only records possible are deferrals and then a single terminal answer, and the new re-hold stamp bump (fm-captain-hold.sh:895-899) keeps later lifecycles distinct. Add a test that pins, defers, releases, and expects the landing to succeed. The same comparison is used at bin/fm-merge-local.sh:272 (landing) and bin/fm-local-handoff.sh:427 (pinned receipt recovery).
  • ⚠️ bin/fm-teardown.sh:1828 - The new branch check treats a missing task branch the same as an advanced one ([ -z &#34;$branch_head&#34; ] || … then REFUSED). But teardown deletes that branch itself before it returns the worktree. At fm-teardown.sh:3590-3594 it detaches WT and runs git -C &#34;$WT&#34; branch -D &#34;$branch&#34;. Because WT is a worktree of the bound clone, that removes refs/heads/<branch> in child_project. Only after that does it call teardown_treehouse_return (3605) with post_lock_cleanup_check=validate_worktree_teardown_safety. Concrete sequences: (a) Stale lock. treehouse return hits the stale index.lock case the script header describes, so it removes the lock and reruns validate_worktree_teardown_safety (fm-teardown.sh:1774). The branch is gone, so the new check refuses and the return aborts, every time, for a bound local-only task whose work is already landed and receipted. (b) Rerun. Any failure after 3593 (a non-lock treehouse return error, or a later pane or record step after the worktree was returned) leaves the branch deleted. Every plain rerun then refuses at 3440 with "offered branch … is now at no verifiable commit", even though WT's detached HEAD equals the offered head and the parent receipt proves the landing. Before this commit both sequences passed. The intent asks to refuse when the offered branch has advanced, and a deleted branch has not advanced. Narrower fix: refuse only when the branch exists and resolves to a commit other than the offered head. When the branch is absent, fall through to the existing worktree-head and receipt checks. Add a regression that deletes the task branch after a receipted landing and expects teardown to pass. The stale-lock path through post_lock_cleanup_check (fm-teardown.sh:1774 via 3605) goes through the same check.
  • ℹ️ bin/fm-captain-hold.sh:898 - The new re-hold stamp bump uses date -u -d &#34;$previous_hold_set + 1 second&#34;, which only GNU date understands. The repo supports stock macOS (the macos-stock-bash CI job), and the neighbouring helpers try the BSD form first (fm-classify-lib.sh:123 and fm-public-followup-lib.sh:474 use date -j … || date -u -d …). On macOS, re-holding a released captain row within the same second as its previous answered stamp (or at an earlier FM_CAPTAIN_HOLD_NOW) fails with "cannot mint a distinct hold-set stamp". This is rare and fails closed. Fix: add the BSD fallback (date -u -j -v+1S -f %Y-%m-%dT%H:%M:%SZ &#34;$previous_hold_set&#34; +%Y-%m-%dT%H:%M:%SZ), or do the arithmetic on epoch seconds using the existing portable helpers.
  • ℹ️ bin/fm-local-handoff-lib.sh:868 - fm_local_handoff_landing_released_identity was inserted between fm_local_handoff_landing_row_ready's doc comment (lines 868-874, including its # shellcheck disable=SC2034 directive) and that function's body. The row_ready description ("Establish that the parent-owned landing row can still authorize…") and the shellcheck directive now sit on the new function, and row_ready at line 898 has no header. Fix: move the new function and its own comment above line 868, or below row_ready.

🔧 Fix applied.
2 infos still open:

  • ℹ️ bin/fm-captain-hold.sh:898 - The new re-hold stamp bump uses date -u -d &#34;$previous_hold_set + 1 second&#34;, which only GNU date understands. The repo supports stock macOS (the macos-stock-bash CI job), and the neighbouring helpers try the BSD form first (fm-classify-lib.sh:123 and fm-public-followup-lib.sh:474 use date -j … || date -u -d …). On macOS, re-holding a released captain row within the same second as its previous answered stamp (or at an earlier FM_CAPTAIN_HOLD_NOW) fails with "cannot mint a distinct hold-set stamp". This is rare and fails closed. Fix: add the BSD fallback (date -u -j -v+1S -f %Y-%m-%dT%H:%M:%SZ &#34;$previous_hold_set&#34; +%Y-%m-%dT%H:%M:%SZ), or do the arithmetic on epoch seconds using the existing portable helpers.
  • ℹ️ bin/fm-captain-hold.sh:800 - Introduced in d6d952c. fm_local_handoff_valid_hold_identity (bin/fm-local-handoff-lib.sh:122) accepts a date-only hold stamp (the T part is optional), and body_hold_set_timestamp accepts the legacy Captain hold set: YYYY-MM-DD form. So request will pin 2026-01-05#N for a row still held under a legacy date-only stamp, and resolution_block will then write Captain hold answered: 2026-01-05. But body_answered_hold_set_timestamp only matches full …THH:MM:SSZ stamps. After the release, open --identity --identity-if-released prints #N+1, which fails the validity check in fm_local_handoff_landing_released_identity. The landing (fm-merge-local.sh:272) and pinned receipt recovery (fm-local-handoff.sh:427) then refuse forever with a misleading 'differs from the pinned approval' message. Other places that use the same parser: the re-hold stamp bump (fm-captain-hold.sh:896) and the answer-replay check (fm-captain-hold.sh:1182). This only affects legacy date-only rows reused as landing rows, and it fails closed. Fix: add the date-only alternative to body_answered_hold_set_timestamp, the same way body_hold_set_timestamp does.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⏭️ **Test** - skipped

Step was skipped.

✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

twilwa and others added 19 commits September 20, 2026 01:19
)

* Fix dispatch resolver model and receipts

* no-mistakes(review): Drop model-drift branch, harden receipt lock and brief join

* no-mistakes(review): Scope receipt recording to clear, report failed joins, measure latency

* no-mistakes(review): Narrow dispatch clause and concurrency test, shrink lock budget

* no-mistakes(review): Accept --project on the join, assert drop-or-append concurrency

* no-mistakes(review): Split lock budgets by path, drop receipt size bound

* no-mistakes(review): Record brief_path as spelled, drop abs_path normalization

* no-mistakes(review): Pin model in contract, bound receipt latency, record reason

* no-mistakes(review): Report dropped resolution receipts, project profile agreement, drop dispatch_id

* no-mistakes(review): Enforce append-only cmp, complete join example, govern latency bound

* no-mistakes(review): Keep no-rules exit 0 without jq, dedupe error default

* no-mistakes(review): Refuse symlinked receipts path, drop dead no_rules jq argument

* no-mistakes(document): Document receipt identity, symlink refusal, jq exit narrowing
* fix(bin): refuse an unrecognised fm-send flag instead of sending it as text

fm-send's option loop ended in an unconditional `*) break ;;`, so any token
it did not recognise - including one obviously shaped as a flag - fell out of
the loop and became the positional message body. A steer invoked with a flag
that does not exist was durably written into a live worker's steering inbox as
the literal flag string while fm-send exited 0, so the worker was mis-steered
and the caller got a success code and no diagnostic.

The accepted set is now an allowlist rather than a pattern. --key is a real,
supported flag parsed after this loop and must keep falling through it
untouched, so a blanket "starts with -- and matched no case arm, therefore
refuse" rule would have broken it.

A bare -- ends flag parsing, which is how a message whose text starts with --
is sent. That separator is threaded to the two --key dispatch points so text
after it is text everywhere rather than being re-parsed as a flag. A
single-dash word was never a flag here and still needs no separator.

The refusal exits before anything is marked, recorded, rung, or typed, the
same discipline the header already applies to an empty message.

* no-mistakes(review): drop -- end-of-flags separator, keep pure flag allowlist

* no-mistakes(document): document fm-send's flag allowlist and leading-`--` message limit

* docs(bin): drop the flag-allowlist commentary from fm-send's source

The header block in bin/fm-send.sh is that script's documented contract.
Recording the no-end-of-flags-separator limitation there amends that
contract and turns a deliberate, narrow behaviour change into a
documented guarantee the project would then owe. The rationale comment
above the option loop goes for the same reason: the limitation describes
a decision, which belongs in the pull request, not in the source, where
it reads as a promise.

Removes only those thirteen comment lines. The refusal itself is
unchanged: the option loop remains a pure allowlist, --key still falls
through to its own plane untouched, there is no end-of-flags handling,
the usage line is unmodified, and the tests are untouched.

* fix(bin): refuse trailing arguments after fm-send's --key

The option loop breaks at --key without consuming what follows it, and
the key path reads only the key itself, so every remaining argument was
discarded in silence while the key was still delivered and the command
still exited 0. `fm-send.sh lane --key Enter --not-a-real-flag` sent
Enter and reported success. That is the same silent-delivery shape the
unknown-flag refusal in this change exists to remove, so the key path
contradicted the contract on that one path.

The same ordering bypassed the --fire-and-forget incompatibility:
FIRE_AND_FORGET_ID is only set when the flag precedes --key, so
`--key Enter --fire-and-forget x` passed both existing guards.

The key path now refuses any trailing argument before delivering the
key, naming the offending token in the wording already used for an
unknown flag in flag position, and names --fire-and-forget specifically
so that incompatibility holds on either ordering. Adds regression
coverage for both orderings and for a trailing plain word; both new
tests fail before this commit and pass after it.
* Add head-keyed PR review policy ledger

* Add post-merge browser QA gate

* Fix PR review and post-merge gates

* Close remaining PR review gate gaps

* Harden migration risk and QA evidence parsing

* Close PR review guard bypasses

* Tighten review evidence boundaries

* Bind final review authorization

* Invalidate stale review dispositions

* Harden review evidence validation
* Add keyed decision defer mode

* no-mistakes(review): Fix defer date identity, hold age, parent channel, reporting

* no-mistakes(review): Derive board defer from the option's until alone

* no-mistakes(review): Show the defer date on the board card

* Fix deferred decision lifecycle edges

* no-mistakes(review): Drop fabricated defer hold reason fallback

* no-mistakes(document): Correct stale captain-defer docs for the recorded answer path

* Fix defer intake failure edges

* Require future dates for decision defers

* no-mistakes(review): Narrow UTC day parsing; fix elapsed-defer recovery guidance

* no-mistakes(review): Refuse duplicate board option values; fix defer recovery wording

* Stabilize chat defer hold assertion

* Keep chat defer date stable across midnight

* Refactor defer validation for bounded lint
* fix(brief): forbid validation auto-accept

* no-mistakes(review): restore fleet-wide --yes ban, add ask-user routing sentence

* no-mistakes(ci): Fixed a flaky test that failed the "Behavior portable serial 4" shard. Failure: tests/fm-pi-branch-extension.test.sh -> test_captain_outcome_processing_turn_is_sequence_keyed_and_re_presented, with "Error: supervision branch prompt settled but produced no durable outcome for its claimed wake rows" (thrown at .pi/extensions/fm-branch-supervision.ts:1548). Nothing in this PR's diff (the --yes DoD line, the harness-adapters sentence, three brief assertions) touches that extension or test; the other two check runs on the same head commit (99a0187) passed. It is a pre-existing race that surfaces on a slow/loaded runner. Root cause: in fm-branch-supervision.ts a wake builds the branch session (ensureBranch), then runs several awaited subprocesses (flushMirror, actingAsOwner, scopeForUnreadWake, writeEligibleRowsSnapshot, away-posture read-back) and only then snapshots reportRevisionBeforePrompt immediately before session.prompt(...); after the prompt settles it requires that revision to have advanced. The test synchronized on the wrong point: `settle(() => __fmSessions.length === 2, "replacement branch session")`. Session creation precedes that snapshot, so when the extension's pre-prompt work is slower than the test's report append, report2's durable append lands before the snapshot and the wake rejects its own settled prompt as outcome-less. The routine wake earlier in the same test already waits on __fmPrompts.length === 1 and is unaffected. Fix (tests/fm-pi-branch-extension.test.sh:1377, 9 insertions / 1 deletion): wait for the wake prompt as well as the replacement session, matching the routine wake's own idiom, with a comment naming why the built session is not the synchronization point. No production code changed; no new machinery. Verification: reproduced the exact CI error deterministically by temporarily injecting a delay ahead of reportRevisionBeforePrompt (delays 100/200/300/400/500/700 ms all failed with the identical message); that injection was reverted (git status shows only the test file modified). With the fix the test passes under injected delays of 100, 400 and 1500 ms. Full file run: exit 0, 45 tests passing. 24 parallel runs of the target test: 24/24 pass. shellcheck -x on the changed file is clean, and this PR's own tests (tests/fm-brief.test.sh, tests/fm-ask-user-authority.test.sh) still pass. The change is left uncommitted in the worktree, since prior rounds' commits on this branch were made by the executor rather than this phase
… v2.3.0 with official platform checksums. The Herdr failures were caused by v2.0.1 lacking the required `--root` capability. Verified installer download/checksum/version, `--root` support, lint, clone-custody regression, and dispatch-resolve regression. The portable failure was an unrelated transient broken-pipe race in unchanged code and passed locally
…axi-lib.sh by replacing the private process-substitution lookup with a direct case mapping. This preserves all provider mappings while preventing an early consumer exit from closing the producer pipe and leaking `printf: write error: Broken pipe` to stderr. Verified with tests/fm-dispatch-resolve.test.sh, bin/fm-lint.sh, and git diff --check; all passed
… primary-owned landing

A local-only project has no forge, so a secondmate home could not hold one at
all: bin/fm-home-seed.sh refused it and the routing prose sent that work back to
the primary. Seed it instead as an independent local clone of the primary's own
clone, pinned to its current default-branch commit, with no origin, no
publication remote, no borrowed object storage and no no-mistakes
initialization, recorded by a durable versioned binding inside the existing seed
transaction. Fleet sync keeps skipping it and the whole-home remote route still
refuses it.

Custody splits along the same line the design drew. The child keeps its task,
branch, worktree and endpoint; the landing stays with the primary that seeded
the copy. bin/fm-local-handoff.sh offer publishes an immutable head-pinned offer
carrying the commit as a git bundle, and the existing guarded entrypoint
bin/fm-merge-local.sh consumes it as a pinned delegated input under its own
per-task control lock, incarnation recheck and captain-hold check, rather than
gaining a second acceptance system. No worker record is read, written or
invented for the child. The primary alone fast-forwards its local default
branch, then publishes a landing receipt into the child home.

Only that receipt opens ordinary teardown, and bin/fm-teardown.sh re-proves the
receipt's commit is still contained in the primary's default branch before
accepting it; a child-local merge or a branch pushed anywhere is not that proof.
Receipt recovery after a landing whose acknowledgement failed is idempotent and
never merges. Missing or stale identities, dirty or diverged work, a changed
head, a changed route, a damaged record and an interrupted transaction all
refuse and preserve the work.

tests/fm-local-handoff.test.sh drives the real scripts against isolated
temporary homes over ten cases covering the bound seed, the two seed refusals
that remain, the child's inability to land its own clone, offer pinning and
republication, the guarded delegated landing and its receipt, the unpinned and
stale approval refusals, idempotent receipt recovery, the teardown gate and the
fail-closed record parsing, plus a held landing row blocking the landing. The
obsolete refusal case in tests/fm-secondmate-safety.test.sh is removed with the
behavior it asserted; the unchanged whole-home remote refusal stays covered by
tests/fm-remote-secondmate-lifecycle-e2e.test.sh. Test inventory entries are
additive only.
…ecord

The review found that an approval released by the captain could be inherited
by any later child head, that a receipt could be satisfied by a substituted
clone, that a refused landing left an imported ref behind, and that an absent
worktree skipped the receipt gate entirely.

Add one durable record, fm-local-landing.v1, written only by the new
bin/fm-local-handoff.sh request subcommand while the captain's row is still
held, and require the delegated landing to match that record's pinned offer,
head, and identity. The landing guard now also refuses an unreadable hold
status, a record already marked landed, and a project that has left local-only
custody, and deletes its private import ref on every refusal path.

The receipt proof derives the containment repository from the child's own
parent route and project binding and additionally requires the parent's own
landed record, so a receipt naming another clone proves nothing. Cleanup of a
bound local-only task now faces that gate even when its worktree is already
gone.
A request could publish its landing record after the captain's row had
already been released, so an answer given for one head was inherited by
another. The pin is now published create-only, and the whole check,
publication, and re-read of the row runs under the landing's existing
per-landing control lock, which bin/fm-merge-local.sh and
bin/fm-captain-hold.sh already take. A record that exists is reported
rather than replaced: the identical identity repeats it, a different head
refuses, and a landed record refuses outright. A row released outside
that lock withdraws this call's own record byte for byte.

Each approval therefore owns its own landing row; a moved head needs a
new row rather than a re-pin.
The case that covered a captain's answer overlapping a landing pin in
flight asserted only that the answer had not completed after a fixed
three-second window. That assertion passes whenever the answer has
simply not finished yet, so on a host where an uncontended release
already costs more than three seconds it would have passed with the
serialization removed entirely.

Replace it with positive evidence. The fixture wrapper that freezes a
publication now records the publishing process's pid, and the case
asserts that the landing's own control lock is held by that process, or
an ancestor of it, while the answer is running. The absence window
stays as independent corroboration but is now scaled to a baseline the
case measures on this host with the same command on its own row, and
the boundary at the release instant plus the row's state after the
answer completes are checked too. The frozen wrapper also ends with the
case that installed it, so a case that fails inside its own window no
longer leaves a publication spinning behind it.

With the request's lock acquisition removed from bin/fm-local-handoff.sh
the case now fails at that assertion rather than at a timer.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @twilwa, your pull request is larger than the review limit of 150,000 diff characters

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-26T07:23:12.218712Z b0c23e0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0c23e074e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/fm-merge-local.sh Outdated
exit 1
;;
1|3) ;;
1) ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind approval to the captain-call lifecycle

When a pinned, still-held landing row is removed without being answered and an ordinary unheld row is recreated under the same ID, this status is 1, so the surviving pin passes the merge guard even though the captain never approved it. Persist the lifecycle identity returned by fm-captain-hold.sh open --identity when pinning and require the same identity here before landing.

AGENTS.md reference: AGENTS.md:L125-L129

Useful? React with 👍 / 👎.

Comment thread bin/fm-local-handoff.sh Outdated
Comment on lines +169 to +171
branch="fm/$id"
git -C "$child_project" rev-parse --verify --quiet "refs/heads/$branch" >/dev/null \
|| die "branch $branch does not exist in $child_project"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the task's recorded branch in landing offers

When a local-only project configures a nondefault ship prefix such as branch=fix/ (or an empty prefix), spawning creates and records fix/<id> rather than fm/<id>. This hard-coded branch therefore does not exist, and the new secondmate handoff cannot publish an offer for any such supported project; read the branch from the task metadata as the existing local merge path does.

Useful? React with 👍 / 👎.

Comment thread bin/fm-teardown.sh
Comment on lines +1826 to +1828
if [ -d "$WT" ]; then
worktree_head=$(git -C "$WT" rev-parse --verify --quiet HEAD 2>/dev/null || true)
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check the child branch when its worktree is missing

If head A is offered and receipted, the child branch advances to an unlanded B, and the worktree directory then disappears, this conditional skips the current-head comparison and the proof below validates only A. Teardown can consequently remove the task's durable records despite B never reaching the parent; inspect the offer's branch ref in the child clone even when $WT is absent.

AGENTS.md reference: AGENTS.md:L34-L36

Useful? React with 👍 / 👎.

Comment thread bin/fm-home-seed.sh Outdated
Comment on lines +484 to +488
existing_origin=$(git -C "$dst" remote get-url origin 2>/dev/null || true)
[ -z "$existing_origin" ] || {
echo "error: seeded local-only project $project at $dst has origin $existing_origin; a local-only clone carries no publication remote" >&2
return 1
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject every remote on an existing bound clone

When reseeding a preexisting bound clone, this checks only the remote named origin, so a publication remote named fork, backup, or anything else is accepted. That contradicts the no-remote custody invariant enforced for freshly created copies and permits the child copy to publish outward; require git remote to be empty here as well.

Useful? React with 👍 / 👎.

…otmp.test.sh failed with "teardown exited non-zero with a valid tasktmp". Invariant: a test that runs the real bin/fm-teardown.sh from a fake bin folder must provide every library teardown loads. This PR made teardown load bin/fm-local-handoff-lib.sh, but the test's two fake bin folders (make_fake_root and the inline copy near line 170; the third case reuses make_fake_root) never got it, so teardown exited at startup. I reproduced this locally. No other test in tests/ links teardown into a fake folder, and the library's own dependencies (fm-secondmate-parent-lib.sh, fm-secondmate-registry-lib.sh) were already linked. Fix: link fm-local-handoff-lib.sh in both folders, with a comment matching the file's style. No production code changed. Verified: bash tests/fm-gotmp.test.sh passes all 3 cases and shellcheck is clean. ci-1 (Behavior portable serial 2), not caused by this PR. tests/fm-remote-secondmate-lifecycle-e2e.test.sh printed ALL TESTS PASSED, then exited 1 only because its cleanup rm -rf hit "Directory not empty" while a leftover background process was still writing. This PR doesn't touch that test or the watcher/remote code it runs. The same cleanup failure hit unrelated branch fm/fm-opencode-2-adapter (run 36213627355), so the test was already flaky. A local run on this loaded host (load average about 8.5) also failed: it hit the watcher's 30-second relaunch time limit, then the same cleanup failure. Making it reliable means finding which leftover process keeps writing, which is separate work outside this change. ci-3 (PR must be raised via no-mistakes), not caused by the code. The attestation check failed because the pipeline's test step had status=skipped, which depends on the pipeline run's state
@twilwa twilwa changed the title feat(bin): seed local-only projects into secondmate homes with parent-guarded landing feat(bin): seed local-only projects into secondmates with guarded primary landing Sep 26, 2026
@twilwa

twilwa commented Sep 26, 2026

Copy link
Copy Markdown
Owner Author

Final review disposition for head d6ea4a7e4080406fd0105d57d1c3200ad889004d (AI-generated summary).

  • Four Codex findings (missing-worktree branch check, pinned call identity, task-branch landing offers, every-remote rejection on reseed) were fixed in d6d952c with follow-ups 68602d2 and f2358ae. Each has a regression test in tests/fm-local-handoff.test.sh.
  • The Sourcery review was skipped because of the diff-size limit. The Codex summary and review wrapper carry no separate findings.
  • High-stakes gate: isolated no-mistakes run 01M3EH21C50D47NFJ6EW6EM5G3 on claude-opus-5-5 completed review on this head.
  • CI is green on this head except the fork-local 'PR must be raised via no-mistakes' check, which is waived under the fork-local test policy.

@twilwa
twilwa merged commit 8fbea6a into main Sep 26, 2026
21 of 23 checks passed
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