Skip to content

feat(bin): merge upstream firstmate into the fork while keeping fork behaviours - #58

Merged
max-metaplanet merged 189 commits into
mainfrom
fm/firstmate-upstream-sync
Oct 14, 2026
Merged

max-metaplanet merged 189 commits into
mainfrom
fm/firstmate-upstream-sync

Conversation

@max-metaplanet

@max-metaplanet max-metaplanet commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Intent

Merge upstream/main from kunchenguid/firstmate into the max-metaplanet/firstmate fork main, preserving the fork behaviours including ClickUp ticket dispatch, Codex seats and renewal, seat-aware pipeline and quota cache.
Resolve conflicts by retaining both behaviours and drop a fork change only where upstream already implements the same thing, identifying each such equivalence in the PR.
Run the full no-mistakes pipeline and open the fork PR.
Report in the PR whether upstream needs newer no-mistakes than installed 1.72.0 (reported upstream floor 1.46.0), herdr than 0.9.1, or treehouse than the installed September 14 build, including treehouse v3 breaking changes and the reported v3.1.3 release.
Targeted validation for this run: the changed Herdr presentation e2e suite plus the CI change-scope and workflow suites, on top of the 22 fork-behaviour suites already run directly against the merged tree (Codex seats and renewal, the quota read path, the nine spawn suites, PR merge, lead restart, and the CI scope and workflow suites), which all passed. Do not run the full suite families; CI runs every suite on the pushed head.

What Changed

  • Merges kunchenguid/firstmate upstream/main (up to 7df545bf) into the fork. The new upstream features are: a Forgejo/Gitea forge through the tea CLI, the self-repo worker role (fm-role.sh, fm-role-lib.sh), opt-in per-project spawn capacity (fm-project-capacity-lib.sh), per-home worker tool exclusions, the armable daily startup growth check, --herdr-resume-lock-wait, starting a task from a named base branch, and per-task pipeline spend recording at teardown. The merge also brings many upstream fixes to fm-pr-merge, teardown, the watchers, pending-reply, remote-reply, busy-contract and Herdr/Pi handling, plus their tests and docs. Fork main's CI change-scope gating, with its 16 serial shards, is merged in too.

  • All fork behaviours are kept: ClickUp ticket dispatch (--ticket/--commit-type through spawn, brief, promote and the DoD, including the shared-ticket batch guard), Codex seats and guarded renewal, the seat-aware pipeline and quota cache, Jev dispatch provenance, and the GitHub PR freshness poll in fm-pr-merge.sh. Where both sides changed the same construct, the result combines them (the task-meta key set, the fm_dod_block parameters, the worker launch templates).

  • A fork change was dropped only where upstream already does the same thing:

    • The Pi extension string assertions: upstream's tests now run the handlers.
    • The FM_SIGNAL_GRACE timeout grace: upstream takes the grace as an explicit argument.
    • The single task-set lock refusal: upstream reports it through three more specific messages.
    • The none or gerrit forge refusals: upstream added forgejo to the same set.
    • The GitLab --allow-missing refusal in fm-pr-merge.sh: upstream's provider case gives the same message and exit status.
    • The 30s Herdr recovery-lock wait: replaced by upstream's refuse-by-default budget plus the opt-in --herdr-resume-lock-wait.

    A follow-up commit also fixes four defects the merge resolution introduced in fm_backend_send_literal and in duplicated fm-spawn.sh blocks. The diff does not raise the minimum version of no-mistakes, herdr or treehouse.

This branch must land as a merge commit, not a squash, so later upstream syncs keep the shared history.

🤖 Generated with Claude Code

Risk Assessment

⚠️ Medium: The round-1 fixes are applied correctly, and the conflict hunks I sampled keep both behaviours. The newest commit silently drops a fork default (the 30s herdr recovery wait) that upstream does not implement equivalently, and that needs the user's explicit sign-off and disclosure in the PR.

Testing

I ran the changed real-Herdr presentation e2e suite to completion in an isolated fm-lab-* session on herdr 0.9.1, and all 25 live cases passed. They include the cases a4a122a touches: a default resume refuses under lock contention, --herdr-resume-lock-wait waits it out instead, and concurrent cross-home recoveries stay serialized. The CI change-scope and workflow suites exited 0, but they are test-suite runs rather than live product runs, so those two scenarios are marked untested. The default Herdr session tripwire stayed intact, and the run left no files behind in the worktree. I did not re-run the 22 fork-behaviour suites the intent describes as already passing.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Adversarial: while another spawn holds the session lock, a default resume refuses rather than taking the lock ✅ pass live herdr-presentation-e2e.log: 'ok - real Herdr lab: default resumed identity refuses session lock contention'
Under the same contention, a resume with --herdr-resume-lock-wait waits the lock out and proceeds ✅ pass live herdr-presentation-e2e.log: 'ok - real Herdr lab: --herdr-resume-lock-wait waits out session lock contention instead of refusing'
Concurrent recoveries from different homes replace exact husks under one session lock without focus drift ✅ pass live herdr-presentation-e2e.log: 'ok - real Herdr lab: concurrent cross-home recoveries replace exact husks under one session lock with no focus drift'
Presentation projection, ordering, cleanup, and secondmate-home behaviour all work after the merge on herdr 0.9.1, and the default-session tripwire stays intact ✅ pass live herdr-presentation-e2e.log: 25 ok / 0 not ok, rc=0
CI change-scope classifier turns gates on or off correctly for changed paths, and fails safe (both gates on) for unknown paths and events ⏸️ untested no The prior payload did not establish a live result. Only a test-suite run was recorded (bash tests/fm-ci-change-scope.test.sh rc=0). A live check needs a real GitHub Actions CI run on a pushed branch…
CI workflow keeps job-level change-scope gates and the always-run CI gate after the merge ⏸️ untested no The prior payload did not establish a live result. Only a test-suite run was recorded (bash tests/fm-ci-workflow.test.sh rc=0). A live check needs a real GitHub Actions workflow run, and that belong…
Evidence: Herdr presentation e2e log (25/25 ok, rc=0)

Source: Herdr presentation e2e log (25/25 ok, rc=0)

ok - real Herdr lab: an opted-out spawn retains the Stage 1 Herdr command sequence with zero ordering calls
ok - real Herdr lab: a home that configured nothing is projected by default on herdr 0.9.1
ok - real Herdr lab: every projected create, task-tab create, seeded prune, and move preserves active workspace and tab
ok - real Herdr lab: persisted-focused seeded prune proceeds when no live client is attached
ok - real Herdr lab: bounded lock contention warns and falls back flat without projection or focus drift
ok - real Herdr lab: concurrent primary workers form one stable contiguous block without active workspace/tab drift
ok - real Herdr lab: forced workspace.move failure leaves a successful worker in default order with a warning and no cleanup
ok - real Herdr lab: concurrent post-create abort cleanup stays serialized with exact focus restoration
ok - real Herdr lab: Treehouse commands and metadata shape are byte-identical except for endpoint IDs and spawn incarnation
ok - real Herdr lab: exact task-pane close removes the projected workspace with no unrestored wrong-focus interval
ok - real Herdr lab: concurrent projected cleanup is serialized and leaves active workspace/tab unchanged
ok - real Herdr lab: three repeated concurrent create/order/cleanup waves have zero active workspace or tab drift
ok - real Herdr lab: the primary presentation setting inherits into real secondmate homes
ok - real Herdr lab: primary and two secondmate homes each own a top-level contiguous child block
ok - real Herdr lab: concurrent primary/A/B spawns preserve parent order and exact focus
ok - real Herdr lab: session lock contention from a secondmate home falls back flat with no journal
ok - real Herdr lab: Hi Bit and Wheelhouse-style same-identity restarts reclaim one nested space with exact focus and idempotence
ok - real Herdr lab: secondmate restart binding and reclaim stay isolated to the exact child home and parent
ok - real Herdr lab: concurrent cross-home recoveries replace exact husks under one session lock with no focus drift
ok - real Herdr lab: default resumed identity refuses session lock contention
ok - real Herdr lab: --herdr-resume-lock-wait waits out session lock contention instead of refusing
ok - real Herdr lab: legacy projection labels and flat secondmate tabs are left unmigrated
ok - real Herdr lab: multi-home exact-pane teardowns restore captain focus without workspace close authority
warning: no exact herdr presentation token match for missing1; leaving any stale space untouched and spawning flat
warning: no exact herdr presentation token match for renamed1; leaving any stale space untouched and spawning flat
warning: 2 exact herdr presentation token matches for duplicate1 are quarantined; inspecting only for duplicate-agent risk
warning: quarantined herdr presentation for duplicate1 is dead or agent-free; exact bound reclaim may proceed, otherwise spawning flat
warning: 2 exact herdr presentation token matches for duplicate1 are quarantined; inspecting only for duplicate-agent risk
error: quarantined herdr presentation for duplicate1 has a stale-agent pane; refusing duplicate launch
ok - real Herdr lab: missing, renamed, and duplicate tokens trigger zero destructive or adoptive calls, and live duplicate risk refuses launch
ok - real Herdr lab validation completed on Herdr 0.9.1 with the default-session tripwire intact
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/pre-rebase: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/pre-applypatch: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/pre-auto-gc: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/pre-merge-commit: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/post-commit: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/sendemail-validate: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/applypatch-msg: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/prepare-commit-msg: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/post-checkout: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/post-applypatch: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/post-rewrite: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/commit-msg: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/pre-push: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/post-merge: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks/pre-commit: Permission denied
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state/anchor.git-hooks: Directory not empty
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home/state: Directory not empty
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2/home: Directory not empty
rm: /private/var/folders/1l/gg6b5zsx0qn753wwhcmmq8cr0000gn/T/fm-herdr-presentation.4EcNW2: Directory not empty
bash tests/fm-backend-herdr-presentation-e2e.test.sh  160.64s user 240.81s system 37% cpu 17:46.45 total
rc=0
Evidence: Resume-lock cases from the live Herdr lab
ok - real Herdr lab: concurrent cross-home recoveries replace exact husks under one session lock with no focus drift
ok - real Herdr lab: default resumed identity refuses session lock contention
ok - real Herdr lab: --herdr-resume-lock-wait waits out session lock contention instead of refusing
ok - real Herdr lab validation completed on Herdr 0.9.1 with the default-session tripwire intact
rc=0
Evidence: CI change-scope suite log

Source: CI change-scope suite log

ok - prose no test reads turns both the behavior and macOS gates off
ok - a shell or CI workflow change keeps both gates on
ok - test-affecting non-shell changes run the behavior suites but skip macOS
ok - prose and data a test reads keeps the behavior gate on
ok - a single relevant path turns its gate back on for the whole change set
ok - a rename out of a test-read path keeps the behavior gate on
ok - an unrecognized path keeps both gates on
ok - push events, unknown events and unusable change sets keep both gates on
ok - an unknown argument is refused rather than silently classified
Evidence: CI workflow suite log

Source: CI workflow suite log

ok - CI matrices cover every executable serial lane and canonical lint root exactly once
ok - a newer push to one PR supersedes that PR's in-flight CI
ok - distinct PRs get distinct concurrency groups
ok - every main push keeps its own group and is never cancelled
ok - every ci.yml job carries a finite timeout
ok - every ci.yml job belongs to one of the four timeout tiers
ok - fast tier jobs share one 5 minute tripwire
ok - normal tier jobs share one 30 minute budget
ok - serial tier jobs share one 45 minute bound with a 40 minute step tripwire
ok - Herdr keeps a 20 minute step tripwire under a 75 minute job backstop
ok - the change-scope gates stay job-level and agree on their verdicts
ok - the CI gate always runs and covers every other job

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

⚠️ **Review** - 2 warnings
  • ⚠️ bin/fm-spawn.sh:4232 - Commit a4a122a drops the fork's 30s recovery wait (HERDR_PRESENTATION_RECOVERY_LOCK_ATTEMPTS=300). The default resume path now uses the adapter's opportunistic 5s budget and refuses when that runs out. Upstream does not implement the same behaviour: it refuses by default and only waits if the caller opts in. No caller in bin/ passes --herdr-resume-lock-wait, including fm-control.sh --relaunch, so nothing reaches that opt-in except a manual fm-spawn invocation. Concrete path: two ship or scout tasks are relaunched under herdr presentation at the same moment. The first holds the session lock through reclaim, treehouse get and the worktree settle. The fork's own removed comment said this hold takes seconds even on an idle host. The second relaunch refuses after 5s with exit 1 and has to be retried. The commit message itself acknowledges this on slow hosts. The intent says to drop a fork change "only where upstream already implements the same thing, identifying each such equivalence in the PR". This is a conflict between mutually exclusive defaults: upstream's e2e test asserts a refusal under a 15s hold, which a 30s wait cannot satisfy. It is not an equivalence. The user needs to accept losing the fork behaviour, or choose another option, for example having fm-control --relaunch pass --herdr-resume-lock-wait. Either way the PR should list it as a dropped fork behaviour, not as an equivalence.
  • ⚠️ bin/fm-spawn.sh:1619 - After a4a122a, no caller passes spawn_herdr_presentation_order_lock_acquire a <mode> other than empty or wait. Callers are at lines 1476, 4230, 4232 and 4282. The fork-only numeric pass-through (if [ -n &#34;$mode&#34; ]; then fm_backend_herdr_presentation_lock_acquire &#34;$session&#34; &#34;$mode&#34;) is therefore unreachable. The header comment at 1599-1601 still describes <mode> as "an attempt budget passed through". No intent requirement needs this component now that the 300-attempt caller is gone. Recommended remedy: remove the numeric branch and its comment, leaving the empty and wait modes, and keep the adapter's tested [attempts] parameter in bin/backends/herdr.sh.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Adversarial: while another spawn holds the session lock, a default resume refuses rather than taking the lock ✅ pass live herdr-presentation-e2e.log: 'ok - real Herdr lab: default resumed identity refuses session lock contention'
Under the same contention, a resume with --herdr-resume-lock-wait waits the lock out and proceeds ✅ pass live herdr-presentation-e2e.log: 'ok - real Herdr lab: --herdr-resume-lock-wait waits out session lock contention instead of refusing'
Concurrent recoveries from different homes replace exact husks under one session lock without focus drift ✅ pass live herdr-presentation-e2e.log: 'ok - real Herdr lab: concurrent cross-home recoveries replace exact husks under one session lock with no focus drift'
Presentation projection, ordering, cleanup, and secondmate-home behaviour all work after the merge on herdr 0.9.1, and the default-session tripwire stays intact ✅ pass live herdr-presentation-e2e.log: 25 ok / 0 not ok, rc=0
CI change-scope classifier turns gates on or off correctly for changed paths, and fails safe (both gates on) for unknown paths and events ⏸️ untested no The prior payload did not establish a live result. Only a test-suite run was recorded (bash tests/fm-ci-change-scope.test.sh rc=0). A live check needs a real GitHub Actions CI run on a pushed branch…
CI workflow keeps job-level change-scope gates and the always-run CI gate after the merge ⏸️ untested no The prior payload did not establish a live result. Only a test-suite run was recorded (bash tests/fm-ci-workflow.test.sh rc=0). A live check needs a real GitHub Actions workflow run, and that belong…
  • bash tests/fm-backend-herdr-presentation-e2e.test.sh against real herdr 0.9.1 and treehouse, through the guarded fm-herdr-lab.sh named lab session: 25 ok, 0 not ok, rc=0
  • bash tests/fm-ci-change-scope.test.sh (rc=0)
  • bash tests/fm-ci-workflow.test.sh (rc=0)
  • After the run, checked that the lab sessions were stopped and the worktree was clean
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.


Supervisor-recorded notes

These were added after the pipeline wrote the section above. The attestation block above is the pipeline's own and is unmodified.

Accepted loss of the fork's 30s Herdr recovery wait

The review finding above asks for an explicit decision on dropping HERDR_PRESENTATION_RECOVERY_LOCK_ATTEMPTS=300. It was accepted deliberately, and it is recorded here as a dropped fork behaviour, not an equivalence.

Why the two defaults cannot both hold: tests/fm-backend-herdr-presentation-e2e.test.sh asserts a refusal under a 15s hold, and a 30s budget cannot satisfy it. A bounded middle value was measured and rejected: at 100 attempts (10s) the concurrent-recovery case passes but the refusal case fails, because the spawn spends several seconds reaching the lock, so what matters is startup + budget against the hold rather than the budget alone. The window is empty on a slow host and non-empty on CI.

Known limitation on a slow host: one of two simultaneous resumes can refuse instead of waiting. That is a safe refusal rather than damage, and --herdr-resume-lock-wait is the opt-in for an unbounded wait, which is bounded in practice because fm_lock_try_acquire reclaims a dead owner rather than waiting it out.

Caller audit, which is why nothing regresses in-tree. The recovery block is guarded by [ "$KIND" != secondmate ], and --relaunch reads kind from the task's recorded meta, so every fork-only caller of that path skips the block entirely: fm-secondmate-park.sh unpark (fork-only, also fm-send's automatic wake path), the secondmate liveness auto-relaunch, and the remote secondmate control. The only caller that reaches the budget is fm-control.sh --relaunch for ship and scout tasks, which is shared with upstream and which upstream deliberately leaves on refuse-by-default.

Accepted follow-up: dead numeric budget pass-through

The second review finding is accepted as a follow-up rather than fixed here. After the budget change, no caller passes spawn_herdr_presentation_order_lock_acquire a <mode> other than empty or wait, so its numeric branch is unreachable and the header at 1599-1601 still advertises an attempt budget. Removing it moves toward upstream, which has no numeric pass-through at all - only wait plus a hardcoded inline loop. The adapter's tested [attempts] parameter in bin/backends/herdr.sh stays, and so does the library delegation that gives this path its distinct unresolvable-socket exit.

Tool version report

No floor in this merge exceeds what is installed, and nothing was upgraded.

  • no-mistakes: required floor is 1.46.0 (bin/fm-bootstrap.sh), installed 1.72.0. Satisfied. 1.84.0 exists and was deliberately not taken.
  • herdr: highest referenced floor is 0.8.0 with protocol 19, installed 0.9.1. Satisfied. CI pins 0.7.4 and passes.
  • treehouse: no version floor at all. It is gated by capability detection - treehouse_supports_lease() greps treehouse get --help for --lease. The installed build satisfies every capability this tree uses: get --lease, --lease-holder, return --if-lease-holder and return --force.

On the treehouse v3 breaking change: the installed build is not pre-v3, despite its September 14 pseudo-version. Its commit 6d33753e94ac is itself listed in the v3.0.0 changelog, and the compare API reports the breaking commit e57daab as an ancestor of it, so this host already runs the v3 behaviour where treehouse return exits 3 rather than 0 when it leaves a dirty worktree. Firstmate is unaffected because bin/fm-teardown.sh passes --force at every return site and branches on exit status rather than reading 0 as "released", which is the documented safe pattern.

For a future upgrade: go to v3.0.1 or later rather than v3.0.0, because v3.0.1 (#156) fixed pre-3.0 pool state being quarantined as recovered; v3.0.0 is the only release in the v3 line with breaking changes; and a go install upgrade needs the /v3 module path from v3.1.2 (#167), while CI's pinned release-tarball install is unaffected.

Fork-behaviour suites run directly against the merged tree

All 22 passed, zero failures, none gate-skipped.

  • Codex seats and renewal: fm-seat (413s), fm-seat-board, fm-seat-lock, fm-seat-renew, fm-seat-vendor-renew
  • Quota read path: fm-quota-choose, fm-procevent-quota, fm-quota-claude-mod, fm-quota-claude-mod-plugin
  • Spawn: all nine, including fm-spawn-batch and fm-spawn-dispatch-profile (708s)
  • PR merge: fm-pr-merge (2636s)
  • Lead restart: fm-lead-restart
  • CI gating from ci: gate CI jobs by changed path and split serial shards to 16 #57: fm-ci-workflow, fm-ci-change-scope

fm-spawn-batch covers the shared-ticket batch guard, which an earlier resolution pass had dropped and which was restored before this PR.

Environment-only test failure, for the record

tests/fm-supervision-host-attended-live-e2e.test.sh fails at step 3 on the development host. Plain upstream 7df545bf fails it identically there, so it is environmental and not from this merge. The suite is fm_live_gate opt-in, so it gate-skips in CI and does not gate this PR.

wesleymatosdev and others added 30 commits September 23, 2026 19:48
…henguid#2648)

* feat(bin): make the ship-branch prefix configurable per project

fm-brief.sh hardcoded every generated ship branch to fm/<task-id>, which
leaks that firstmate produced the branch/PR - unwanted for a third-party
public repo that does not use this tooling.

Add an optional --branch-prefix flag to fm-brief.sh (default "fm/", so
existing installs are unaffected) and teach fm-project-mode.sh - the
registry's single-owner parser - to resolve a project's optional
"branch=<prefix>" data/projects.md annotation via a new --branch-prefix
query, order-independent with the existing mode/+yolo tokens. Firstmate
resolves the override at task intake and passes it explicitly, mirroring
how --mode already works; fm-brief.sh itself never reads the registry.

An empty override resolves to a bare "<task-id>" branch rather than a
leading slash. All five previously hardcoded fm/$ID sites (branch
creation, never-push rule text, definition-of-done text, and the status
message) now render the resolved prefix consistently.

* no-mistakes(review): Wire branch-prefix intake in AGENTS.md; fix fm-merge-local.sh hardcoded fm/ prefix

* no-mistakes(document): docs: document configurable ship-branch prefix in architecture.md

* no-mistakes(review): Persist immutable branch contracts

* no-mistakes(document): Document configurable ship branch prefixes

* no-mistakes(lint): Captain: fix ShellCheck test warnings

* fix(bin): map bearings PR rows to their recorded ship branch (kunchenguid#1887)

fm-bearings-snapshot.sh keyed a PR back to its task by string-matching
the headRefName against the fm/ prefix, so any project whose branch
prefix was overridden (e.g. via kunchenguid#2648's branch=<prefix> registry
annotation) had its PRs silently drop to task "-" in the bearings
view, exactly the third fm/-assumption issue kunchenguid#1887 named alongside
fm-merge-local.sh and fm-bearings-snapshot.sh itself.

fm-fleet-snapshot.sh now surfaces each task's recorded branch=
metadata field in its JSON task rows, and fm-bearings-snapshot.sh
cross-references a PR's headRefName against those recorded branches
before falling back to the legacy fm/ prefix heuristic, so a custom
branch prefix maps a PR back to its real task.

Adds a regression test proving a PR opened against a fix/<task-id>
branch resolves to that task instead of "-"; confirmed it fails on
the prior startswith("fm/") logic and passes with this change.
ShellCheck clean; full fm-bearings-snapshot.test.sh and
fm-fleet-snapshot-view.test.sh suites pass.

* fix(ci): align lint arithmetic-looking assignment and stale Bearings snapshot count

- Quote the --branch-prefix want_value assignment in fm-brief.sh, fm-promote.sh,
  and fm-spawn.sh so ShellCheck SC2100 no longer misreads the plain string
  'branch-prefix' as arithmetic shorthand.
- Bump the Stock macOS Bash snapshot job's hardcoded Bearings test-count
  assertion from 59 to 60: this PR added a Bearings test, so the count was
  stale, not the feature.

* no-mistakes(review): fix(bin): honor recorded ship branch in relaunch and review-diff

* no-mistakes(document): docs: complete branch-prefix flag in brief and promote headers

* fix(lint): quote branch-prefix parser token; drop unused BRANCH_Q after rebase

* no-mistakes(review): Restore %q branch escaping in promotion instructions with regression test

* no-mistakes(document): document recorded ship branch and prefix flag

fm-review-diff.sh's header is the owner of its branch-resolution
contract; it still described only the legacy local-branch behavior
after the change made review-diff honor state/<id>.meta's recorded
ship branch. README's feature bullet enumerates the registry's
optional flags and was missing the new branch=<prefix> override.

* no-mistakes(lint): Silence SC2016 on intentional single-quoted sed expression

* no-mistakes(review): address branch-prefix review findings in DoD and project-mode

* no-mistakes(test): branch-prefix suites pass under tasks-axi 0.2.6; environment-only failure

* no-mistakes(document): purge stale fm/ branch naming from docs and headers

* fix(test): assert the merged epoch status wording in the branch-prefix override test

The rebase resolution of tests/fm-brief.test.sh kept the branch's
pre-merge \`done: ready in branch ...\` assertion while the merged
fm-dod-lib.sh (carrying main's epoch-stamped status line) renders
\`done [at=<epoch>]: ready in branch ...\`. Align the assertion so the
override-consistency test matches the behavior it verifies.

* no-mistakes(review): Address remaining branch-prefix findings in four bin scripts

* no-mistakes(test): skip real-tasks-axi tests below the repo's 0.2.6 floor

* no-mistakes(document): document spawn's branch-prefix registry deviation notice
…d per-rule confidence floors (kunchenguid#5478)

* feat(bin): send dispatch resolver only the brief's task sections

* Sent Jev only the scaffolded Captain's intent and Firstmate spec
  sections, falling back to the whole brief when neither heading is
  present, so the identical setup, rules, and definition-of-done
  boilerplate no longer reads as a signal about the task
* Added an optional per-rule min_confidence that replaces the global 0.6
  floor for that rule; a picked rule below its own floor falls to the most
  probable other option that clears its floor, or returns ambiguous
* Kept files with no declared floor on the exact previous behavior and
  kept the model blind to the new field
* Recorded the live old-versus-new comparison over scaffolded fixtures

* no-mistakes(review): share brief heading parser, add kind line, fix floors

* no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag

* no-mistakes(document): docs: list shared brief heading lib in scripts inventory
* feat(bin): supervision host core behind config/supervision-host

Add the supervision host (bin/fm-supervision-host.sh): beside a Claude
primary it owns the watcher cycle for the Stop auto-arm and, while the
away-posture record exists, hands each wake to a bounded headless Claude
engine session that runs the supervision branch's contract - the same
generated prompt, row eligibility, wake grant, per-actor drain, outcome
store, leases, and away relocation the Pi branch uses. Attended wakes pass
straight to main. Every path that cannot finish a wake hands it to main
with a supervision-host line; the park ends itself before the Stop hook
timeout with a cycle-boundary wake.

- bin/fm-supervision-engine-lib.sh: opt-in parse, verified engines
  (claude, default sonnet), one bounded engine turn, and a reap of engine
  tool processes that sit in their own process groups.
- bin/fm-branch-report.sh: the command twin of fm_branch_report, scoped
  to the tasks the current host turn claimed.
- bin/fm-branch-dispatch.mjs: command entry to the Pi dispatch module, so
  eligibility and the wake prompt have one owner.
- bin/fm-claude-stop-autoarm.sh runs the host in the arm's place when
  config/supervision-host exists; nothing changes without the file.
- bin/fm-watch-arm.sh --stop: home-scoped stop without a re-arm.
- bin/fm-lease-lib.sh: an opted-in home takes the lease-command lock for
  unmarked main too, closing the first-claim race; the refusal tells the
  caller to leave the lease alone and retry.
- /afk launches no away daemon on an opted-in Claude home; /quiet still
  does. Session start renders the host's main-side protocol there.

* fix(bin): relay a host turn's outcomes when the captain returns mid-turn, and log per-turn engine cost

Live validation found two supervision host gaps. A captain who returns while
an engine turn is running gets a return brief rendered before that turn's
outcomes exist, so the host now hands the close to main with those outcomes.
Claude reports a resumed conversation's running cost, so the engine lib now
derives each turn's cost from the total the host records, and the host log
records every close's destination.

* docs(verification): record the supervision host's live evidence

The dated live results behind docs/supervision-host.md: the Claude engine's
live guard, the away-wake cases against real workers, the engine's cost
reporting, and the flag-off before-and-after regression.

* docs: describe the supervision host ledger as covering every close

* no-mistakes(review): Harden supervision host ownership, boundary, ack, and late outcomes

* no-mistakes(review): Recheck park boundary just before starting an engine turn

* no-mistakes(review): Cap park boundary, deliver all host lines, reject incomplete results

* no-mistakes(document): Correct supervision host documentation and stale pointers
…t-in, and delivery (kunchenguid#5506)

Attestation MATCH; contract-class restore; CI/NM green. Squash-merged by Kun's firstmate.
…kunchenguid#5528)

* fix(bin): bound the startup-network worker's lock waits by its budget

Fixes kunchenguid#5377

The deferred startup network worker bounded its sweeps with a stage budget but
took the publish lock and the fleet-lock lease with an unbounded wait, so a live
holder of that lock kept the detached worker alive for hours past its timeout
with its output discarded at the end. Every wait now goes through the bounded
acquire and shares the remaining stage or delivery budget; a lock a live process
still holds at the deadline ends the worker with a failed record naming the
holder and the rerun command, and a wake so the result surfaces.

* no-mistakes(review): propagate publish exit code from cmd_run terminal paths
…dth (kunchenguid#5517)

* fix(bin): keep the ps fallback identity independent of terminal width

fm_pid_identity's portable fallback read the command column at the
ambient COLUMNS width, so an identity recorded from a wide shell never
matched the one recomputed inside a narrow hook and the continuity guard
denied every fleet command. Pass -ww so the column is never cut.

Fixes kunchenguid#799

* no-mistakes(ci): Fixed CI failure in Behavior portable serial 4. Root cause: the -ww flag added in commit ac7ab5d to fm_pid_identity (bin/fm-wake-lib.sh) shifted the ps argv so $1 became -ww instead of -p, breaking the positional fake-ps fixtures in tests/fm-procevent.test.sh (lines 2736, 3571) which then fell through to real ps and failed the fm-procevent test. Fix (already applied in the worktree, matching the authoritative user instruction exactly): replaced -ww with a COLUMNS=10000 environment pin so the call is COLUMNS=10000 LC_ALL=C ps -p "$pid" -o lstart= -o command=, mirroring fm_pending_reply_pid_identity in bin/fm-pending-reply-lib.sh:982. argv is back to -p PID -o lstart= -o command=, so the fixtures match again with no fixture edits. Comments above the call in bin/fm-wake-lib.sh and in test_pid_identity_is_terminal_width_invariant (tests/fm-watcher-lock.test.sh) now describe the COLUMNS pin instead of -ww; the regression test still asserts narrow-vs-wide byte equality and the full command. Verified: the terminal-width-invariant regression test passes. The only local not-ok results were flaky, run-varying timing tests (procevent launch/claim confirmation, listener reparenting) that differ each run and are unrelated to the ps argv change
…thorized intent (kunchenguid#5526)

Fixes kunchenguid#3608

When a scout is promoted to a ship, the captain's authorized intent is
extracted from a legacy `# Task` body by matching `Captain:` and `[captain]`
lines anywhere in the body, including inside fenced code blocks and indented
examples, while the heading reader already tracks fences. A fenced `Captain:`
example therefore passed the provenance gate and became the ship contract's
intent while the real ask was dropped.

Make the captain-words extractor fence-aware like the heading reader: a line
inside a ``` or ~~~ fenced block, or indented four spaces or a tab, is never a
marked line. The promotion and spawn callers need no change. The regression
test covers both the extractor and the promotion provenance gate refusing a
brief whose only Captain lines are fenced or indented examples.
…riefs (kunchenguid#2868)

* fix(bin): forbid administering the shared worktree pool in crewmate briefs

A crewmate ran a `git worktree remove` loop over the treehouse pool its own
worktree came from, destroying five worktrees - four belonging to tasks that
were running mid-pipeline. The generated brief's rule 2, "stay inside this
worktree; modify nothing outside it", is a rule about files: removing a
worktree is administration of shared state, not an edit outside a directory,
so the sentence never reached the act. The worker satisfied its brief
completely.

Rule 7 already named one piece of shared infrastructure - the no-mistakes
daemon, one instance serving every lane - with the reason stated plainly. The
worktree pool is the same class of thing and was unnamed.

Fold the pool into that existing rule rather than adding a second warning:
state the constraint around the act (create, remove, return, prune, move,
reassign a worktree or pool slot; write into a sibling slot), keep concrete
commands as examples rather than as the definition so no single provider is
pinned, and give the prohibition a real exit through `blocked:`.

The rule is emitted from one shared string interpolated into both crewmate
scaffolds, so the ship and scout copies cannot drift apart. The secondmate
charter deliberately omits it: that home runs its own fleet and legitimately
allocates and returns slots for its own crewmates.

Contract text only; no runtime enforcement layer.

* no-mistakes(document): Distill pool-safety comment rationale

* no-mistakes(review): align pool-rule test grep patterns with emitted [at=<epoch>] text
… a dispatch record (kunchenguid#5524)

* fix(bin): refuse tasks-axi add --start so In flight always has a dispatch record

Fixes kunchenguid#4753

Dispatch (bin/fm-spawn.sh) is the only path that moves a backlog row to
In flight, because it creates the task record, status file, and inbox
that go with the row. A row hand-placed there through the wrapper's
`add --start` had none of those, and nothing later noticed, so the
live-task count included work nobody was doing. The wrapper now refuses
`add --start` (exit 2) and names the dispatch path; plain `add` and
`start <id>` pass through unchanged, and the lifecycle transitions
address tasks-axi directly so dispatch is unaffected.

The issue's other half, a reconcile sweep in bin/fm-inactive-reconcile.sh
that notices an In flight row with no task record, is left as is; this
change closes the only path that creates such a row.

* no-mistakes(review): refuse create --start alias, not just add --start

* no-mistakes(review): reword add --start guard docs to drop only-path overclaim

* no-mistakes(review): scope add/create --start guard docs, drop universal claim
…#5503)

* feat(bin): run the supervision host beside the other non-Pi primaries while away

Cursor's stop-hook park, the OpenCode plugin, the omp watch extension, Grok's
model-owned background arm, and Codex's foreground checkpoint now run
bin/fm-supervision-host.sh in the watcher arm's place when the home opted in
with config/supervision-host, so the host's Claude engine takes away-posture
wakes beside those primaries exactly as it does beside Claude. Without the
file nothing changes.

- The host streams its first cycle's status line, accepts --restart and the
  owner's predecessor arm for its first cycle, and prints each exit in one
  write, so owners that wait for arm readiness and restart their own
  successor (OpenCode, omp) keep their handling handoff.
- Codex's checkpoint passes its bound to the host as the park boundary,
  raises it to FM_CODEX_WATCH_CHECKPOINT_AWAY (3600 s) while the away record
  exists, and lets an engine turn that starts before the bound finish after
  it (FM_SUPERVISION_HOST_PARK_LIMIT).
- /afk launches no away daemon on an opted-in home of those harnesses and
  says so at entry when the file selects no engine for that primary.
- Session start renders the host protocol for each arm owner, and Grok's
  arm command becomes the host.

* fix(bin): keep the watcher-down banner away from the supervision branch actor

A supervision host's engine turn runs guarded commands after its successor
watcher cycle may already have closed on a newer wake, so the guard showed it
the watcher-down banner with the primary's repair line. Under a Codex primary
pin that line is the checkpoint, and a live Codex lab run showed the away
session running it mid-turn (the nested host stood down on its ownership
check). The branch actor never owns watcher continuity, so the banner, its
reminder, and the episode state now leave that actor out, as the queued-wake
warning already does.

The lint telemetry fixture counts bin/fm-afk-launch.sh's source directives,
which the host engine note raised from four to five.

* fix(bin): queue away-session outcomes recorded after the return for main

A Cursor park superseded by the captain's return stops its host as the
engine turn ends, so the host's own handoff of that turn's outcomes was
never printed and the outcomes never reached main. The report surface now
queues every outcome it records after the away record is gone as a durable
check wake; the return owner archives the record before it reads the store,
so each outcome is in the return brief, queued, or both. A host stopped
mid-turn also removes its turn's result and error files.

The stream test now acknowledges its first close and accepts a restarted
cycle that closes on its resurface before the arm confirms it.

* fix(bin): clear a hard-killed host's turn at the next activation

A Cursor park superseded mid-turn can kill its host outright, which runs no
cleanup, so the turn's result, error, and descendant files stayed behind and
any tool process the engine started was left running. The next host's
activation now reaps the descendants that turn recorded and removes its
files. The host suite also registers its homes in a file, because
make_home runs in a command substitution, so its cleanup now stops every
host a case leaves running.

* fix(bin): leave rows that arrive after main's drain unclaimed at its acknowledgement

Main's acknowledgement re-claimed every unreserved queued row, including one
that arrived after the drain above the acknowledged cutoff. That row stayed
main's without ever being shown to it, so while away the supervision host
refused every later wake that included it and handed each back to main until
main drained again. The acknowledgement now claims only unreserved rows at or
below its cutoff.

* docs: name the killed turn's engine and files in the host's failure direction

* docs: record live supervision host runs on the non-Pi primaries

* no-mistakes(review): Replay host-only supervision boundaries across omp session replacement

* no-mistakes(review): Deliver omp supervision-host wakes only at the host's close

* no-mistakes(document): Correct supervision host documentation for non-Pi primaries

* no-mistakes(ci): Fixed the CI failure by naming FM_CODEX_WATCH_CHECKPOINT_AWAY in the rendered Codex host instructions. The focused instruction and checkpoint suites pass
)

* feat(bin): auto-relaunch dead persistent secondmates during ordinary supervision

A persistent secondmate whose primary agent exits mid-session previously
stayed down until the next session-start liveness sweep. Extract the
sweep's probe/classify/relaunch mechanics into a shared library and drive
the same contract from a cadence-gated watcher tick, so a positively dead
or missing endpoint is relaunched through the guarded spawn path within a
poll cycle instead of an hour later.

Only the recovery-grade `dead` and `missing` verdicts authorize relaunch;
ambiguous, unreadable, unverified, and unreachable-remote reads stay
fail-closed and a remote route is never replaced by a local endpoint.
Each relaunch emits exactly one `check` wake and appends to a durable
per-mate ledger; a mate exceeding the bounded attempt budget is parked
behind a marker until a live probe rearms it. A per-mate liveness lock
serializes the tick against a concurrent session-start sweep.

* no-mistakes(review): Fail closed on relaunch ledger errors; clear state on remote teardown

* no-mistakes(review): Share ledger read guard; retire relaunch state under liveness lock

* no-mistakes(review): Lazy-load wake lib; live rearm restores full relaunch budget

* no-mistakes(review): Finish liveness tick for every mate before waking once

* no-mistakes(review): Keep liveness tick scanning past per-mate errors, then wake

* no-mistakes(review): Wake only on queued rows; teardown holds liveness lock

* no-mistakes(review): Queue liveness outcome wake before releasing mate lock

* no-mistakes(document): Update secondmate liveness documentation for mid-session recovery

* no-mistakes(lint): Fix empty assignments flagged by ShellCheck

* no-mistakes(ci): Added ShellCheck analysis boundaries for the shared liveness library in both callers and marked its result globals as intentional library outputs. Changed-file lint passed; full CI partitions were not run locally

* no-mistakes(ci): Fixed Lint 2 by removing an unused test variable in tests/fm-wake-queue.test.sh. ShellCheck, bash syntax, and the full wake-queue test script pass

* no-mistakes(ci): Fixed the CI wake-queue fixture: stall-only watcher legs now seed the liveness cadence marker, preventing the new endpoint probe from interfering with their assertions. The full wake-queue test, ShellCheck, and diff checks pass locally
…cycle ends (kunchenguid#5550)

* fix(bin): start a successor when the Claude Stop-hook arm's attached cycle ends

Fixes kunchenguid#2381

When the Claude Stop hook's foreground arm attached to a peer watcher cycle
and that cycle ended, the arm reported the delivered wake and the hook exited
2 without starting a successor, so the handling turn ran with no watcher.
Pi, omp, and OpenCode start the next arm before delivering the wake and pass
the closed arm's pid as FM_WATCH_PREDECESSOR_ARM_PID; the Claude hook never
passed that predecessor identity.

The hook now runs its arm as a tracked child it waits on, so it holds that
arm's pid, and after any actionable close starts one handling-successor
bin/fm-watch-arm.sh with the closed arm's pid as FM_WATCH_PREDECESSOR_ARM_PID.
The successor is launched the one way a process outlives a Claude hook's
exit-2 rewake (nohup, detached stdio, own process group, the shape
bin/fm-startup-network.sh already uses); the hook waits for its status line
and adds one banner line when no live watcher was confirmed, never withholding
the wake. The supervision-host path is unchanged, as is the arm wrapper.

The regression test drives the real hook against an arm fixture whose attached
peer cycle ends: it fails on the previous tip because no successor starts, and
now asserts the successor names the closed arm as its predecessor and outlives
the rewake. A second case pins the unconfirmed-successor banner line.
docs/watcher-continuity.md no longer records the Claude asymmetry.

* no-mistakes(ci): Serial-4 failure was a real regression: tests/fm-session-lock-ancestry.test.sh asserts exact cumulative arm-invocation counts while driving the real fm-claude-stop-autoarm.sh hook against a stubbed fm-watch-arm.sh. This PR makes the hook start a handling successor after an actionable close, so every owned actionable phase now records TWO arm invocations (foreground arm + successor) instead of one, breaking "healthy chain: expected 1 arm(s), got 2". Fixed by updating the cumulative expectations to match the new behavior: owned phases 1/2/6 -> 2/4/6, foreign carry phases 3/4/5 -> 4, plus a comment explaining the +2-per-owned-phase model. Verified: phase-1 (the CI failure point) now passes on every run, syntax checks clean, and sibling arm-count tests (fm-claude-stop-autoarm.test.sh, fm-cursor-primary, fm-turnend-guard) pass unchanged. The only remaining local not-ok is a WSL-only environmental artifact (orphan reparents to a subreaper, not PID 1) that passes on the CI runner. Parallel-1 failure is an unrelated flake: its 11 tests (fm-lint, fm-pr-merge, fm-test-run, fm-cd-pretool-check, fm-pi-primary-types, fm-grok-harness, fm-composer-lib, fm-review-diff, fm-tmux-submit-busy, fm-composer-ghost, fm-brief) do not include fm-session-lock-ancestry and none reads any file this PR touches; all pass locally. It should clear on CI re-run. Made the smallest root-cause fix (one test file, 6 count updates + a clarifying comment). Validation of the branch continues through the no-mistakes pipeline, which owns re-running CI
…ning (kunchenguid#5566)

* fix(bin): report a Lavish source armed only after its listener is running

Registration alone was treated as ready, so arm could succeed before anything was collecting from the board.

* no-mistakes(review): Guard Lavish arm launches, keep retire refusals, report live prior listener

* no-mistakes(review): Keep polling through window before reporting a still-live prior listener

* test: wait for a capture's claim to drop before the next arm

The result is stored before the runner exits, so a re-arm in that gap was meeting a live claim.

* no-mistakes(document): Record Lavish arm readiness evidence in verification doc

* no-mistakes(ci): Both failures were caused by this PR, and both are fixed with test-only edits. Lint 2 (ShellCheck SC2034): this branch removed the only use of `reply_id` (a `start "$reply_id"` call) from tests/fm-procevent.test.sh, which left the assignment at line 1450 unused. I deleted that assignment. It was the only `reply_id` in the file. ShellCheck is now clean on both test files. Behavior portable serial 4: the failing test was tests/fm-bearings-board.test.sh, in the check "registration consumed its answer before the any-origin binding existed". I reproduced it locally: the hold was still `state: queued` when the test checked it. - What must hold: the test's check that the hold is closed must run after the listener has captured the answer. - Why it broke: the test used a stand-in adapter that ran `fm-procevent.sh start` in the foreground after `arm`, so capture finished before build returned. On this branch, `arm` starts the listener itself in the background, so the real listener captures the answer and closes the hold a moment after build returns. - Fix: removed the now-redundant stand-in adapter, the copied runtime directory, and its extra environment variables. The test now runs the real build through the existing `run_board` helper and waits up to about 10s for the hold to reach `state: done`. The checks that follow are unchanged: `Resolution mode: answered` and the any-origin binding. - Other tests: this was the only test in the file that stood in for the adapter this way. The shard's other pure-contract-unit test (tests/fm-trace-context-lib.test.sh) passed unchanged. Verification: - tests/fm-bearings-board.test.sh passed 3 times in a row via bin/fm-test-run.sh, all 18 checks, about 53s per run. - tests/fm-procevent.test.sh was not rerun, because the lint fix only removed an unused assignment
…elivered (kunchenguid#5599)

* fix(bin): acknowledge a delivered unknown-wake escalation

The same unrecognized wake was escalated again after it had already been handled, because delivery never recorded that identity.

* no-mistakes(review): Scope unknown-wake acknowledgements to one away session

* no-mistakes(review): Clear delivered digest when unknown-wake ack write fails

* no-mistakes(review): Limit unknown-wake suppression to acknowledged lines

* no-mistakes(document): List unknown-wake ack file among away-session artifacts
…ess wait (kunchenguid#5587)

* fix(bin): keep a stated default retraction from cancelling a keyless wait

A resolved line that names the shared default decision bucket was closing the keyless live wait that only prints as that same key. Keyless self-retraction still closes the keyless wait.

* no-mistakes(review): Keep declared waits standing past foreign-key resolved lines

* no-mistakes(review): Bound declared-wait read and share one decision-key parser

* no-mistakes(document): Document supervisors' key-aware declared-wait read
…unchenguid#5544)

* fix(bin): terminate a remote job worker that lost ownership when it receives TERM

A serving worker whose lock directory is gone can no longer quarantine shutdown, and resuming service publishes a false ready heartbeat. Exit after stopping only that worker's own command tree, without removing a replacement owner's lock.

* no-mistakes(review): Check worker lock ownership before publishing shutdown quarantine

* no-mistakes(document): Correct worker shutdown comment on replacement-owned lock

* fix(bin): keep an ousted remote job worker off the replacement quarantine

Shutdown can lose the lock after the first ownership check and before it
writes or clears quarantine. Bind both operations to the directory object
this process still owns so a replacement's quarantine stays untouched.

* no-mistakes(review): Make ousted-worker shutdown test reliably reach quarantine clear

* no-mistakes(document): Reattach worker_shutdown doc comment to its function

* no-mistakes(ci): Fixed the failing check (Behavior portable serial 7) with a test-only change to the stall test in tests/fm-remote-job.test.sh. Product code is unchanged; no other test changed. Cause: after the decoy dies, both workers run the same check-exists, read, delete sequence on the job records. On the CI runner the replacement deleted a record between the ousted worker's check and its read. The ousted worker exited 125, and because the file runs under set -e the unguarded `wait` ended the test with 125. The exit trap then killed the replacement, which produced the "Killed" line. Reproduction: a temporary 0.3 s delay between the check and the read, applied to the ousted worker only, made the committed test fail exactly as in CI (exit 125 and the "Killed" line). The new test passed with the same delay. The delay is reverted, along with a similar debug hook that the timed-out attempt had left in bin/fm-remote-job-worker.sh. Test changes: - The replacement is frozen (and confirmed stopped) before the decoy is killed and resumed only after the ousted worker exits, so only one worker touches the job records at a time. - The ousted worker is stopped only once its quarantine exists and its lane is reaped, which places it inside its stop loop. - Every fixed poll loop is now a wait on a named condition with a 30 s deadline and an explicit failure message. Exit detection also handles zombies. - The exit trap kills and waits for the decoy and both workers on every path. - A non-zero exit from the ousted worker now fails with its exit code and stderr instead of silently ending the file. The test still proves that the resumed ousted worker exits 0 and leaves the replacement's lock, quarantine contents and quarantine inode unchanged. Verification: the full test file passed four times on its own and three times under nice -n 10 with four busy-loop CPU hogs; bin/fm-lint.sh passes. Changes are not committed

* no-mistakes(ci): I fixed the failing check (Behavior portable serial 7) by changing only the stall test in tests/fm-remote-job.test.sh. Product code is unchanged. **What failed:** "an ousted worker in shutdown leaves the replacement quarantine untouched" failed on CI with the ousted worker exiting 125 ("could not stop the active command tree"). **Why:** during shutdown, the worker retries the still-running decoy command group a fixed 100 times, 0.01 s apart, then gives up and exits 125. The test tried to freeze the worker partway through those retries by sending SIGSTOP from outside. On a slow runner the retries ran out before the stop arrived, so the worker had already given up. The invariant is that the test must hold the ousted worker inside that retry loop until the replacement owns the lock. That was the only place the test depended on timing. The other waits already watch for a named state change with a 30 s deadline. **Fix:** - The ousted worker now starts with a small `sleep` wrapper at the front of its PATH, and the SIGSTOP race is gone. - The wrapper only holds a `sleep` called directly by that worker's own process (it checks its parent pid against a hold file) while its quarantine file exists. - The only such `sleep` is the first retry in the shutdown stop loop, so the worker waits there as long as needed. - The wrapper writes a marker when it starts holding. The test waits for that marker, then hands the lock to the replacement, freezes the replacement, and kills the decoy. - The test releases the worker by deleting the hold file. Deleting the whole temp directory also releases it, so a failed run cannot leave the wrapper looping. - A process leak: the test overwrites the job's command-group record with the decoy, so no worker ever stopped the job's real command. `fm-hold-job.sh` and its `sleep 30` stayed running for up to 30 s after the test. The test now records that group before overwriting it and kills it at the end of the test and in the exit cleanup. - The test still asserts the same things: the ousted worker exits 0, and the replacement's lock, quarantine contents and quarantine inode are unchanged. **Verification:** - The full file passed twice on its own, twice under `nice -n 10` with six busy-loop CPU hogs, and twice more after the leak fix. - `pgrep` found no leftover processes afterwards. - With the worker from just before the fix commit (cf45cb6^), the test still fails with "the ousted worker wrote or cleared the replacement quarantine during shutdown", so it still proves the fix. - `bin/fm-lint.sh` passes. - I did not reproduce the CI failure locally. The cause comes from the fixed retry limit and the CI error message. The changes are not committed

* no-mistakes(ci): I changed only the stall test ("an ousted worker in shutdown leaves the replacement quarantine untouched") in tests/fm-remote-job.test.sh. Product code is unchanged, and so is every other test. **Invariant:** the pid written to the job's group record must be a process-group leader whose group dies when that one process is killed. Otherwise the worker's bounded stop loop never sees the group die, gives up, and exits 125 ("could not stop the active command tree") before it reaches the lost-ownership exit. The decoy is the only place in this test that depends on this. **Fix:** - The decoy used to be `set -m; sleep 30 &`. It now starts as `perl -MPOSIX=setsid -e 'setsid() >= 0 or exit 1; exec @argv' sleep 30 &`, which gets its own session and group without shell job control. tests/fm-procevent.test.sh already uses the same idiom. - The test now waits, with the file's usual 30 s deadline and a named failure, until `ps -o pgid=` of the decoy equals its pid before writing it into the group record. This way the worker can never read the record before `setsid` has run. - The existing steps are unchanged: the test kills the decoy, reaps it with `wait` before releasing the hold file, and the exit trap still kills and reaps the decoy and both workers. - The assertions are unchanged: the ousted worker exits 0, and the replacement's lock pid, quarantine text and quarantine inode stay the same. **Cleanup:** I reverted a debug `printf` hook that the timed-out previous attempt had left in bin/fm-remote-job-worker.sh, and deleted its untracked `.tmp-repro/` directory. Neither was committed. **Verification:** - The full tests/fm-remote-job.test.sh passed twice normally and once under `setsid -w` with stdin from /dev/null (no controlling terminal). - `bin/fm-lint.sh` passes. - No leftover `sleep 30` processes afterwards. **Not reproduced:** I could not reproduce the CI failure locally. On this host `set -m` made the decoy its own group leader even without a controlling terminal, so the cause on the runner is not confirmed. The change removes the test's reliance on shell job control, as the user asked. Changes are not committed

* no-mistakes(ci): I changed only the stall test ("an ousted worker in shutdown leaves the replacement quarantine untouched") in tests/fm-remote-job.test.sh. Product code is unchanged, and so is every other test. **Invariant:** the group record the ousted worker checks in its stop loop must stay the job's own command group, and the test must stop that group before it releases the hold. Otherwise the bounded retry keeps seeing a live group, gives up, and exits 125 ("could not stop the active command tree") before it reaches the lost-ownership exit. The test overwrote this record in one place (the decoy) and stopped the group in one place (killing the decoy); both are changed. **Fix:** - I removed the setsid decoy and the overwrite of `.claim/group`. The record keeps the job's real command group, which the test still saves as `STALL_JOB_GROUP`. - The two-line `group_start` stays. It is still needed: without it the worker kills the real group on its first pass, before the replacement takes over, so the hold would never matter. - The `sleep` wrapper that holds the worker at its first stop-loop retry is unchanged. - After the replacement owns the lock, its quarantine is planted and it is frozen, the test runs `kill -KILL -- -$STALL_JOB_GROUP`. It then waits, with the file's usual 30 s deadline and a named failure, until `kill -0` on the group fails. Only then does it remove the hold file. The worker therefore always sees its own command already stopped and never races its retry budget. - The exit trap still kills the saved command group if the test fails. It can't `wait` on that group because the group is not a child of the test shell. The decoy variable and its cleanup entry are gone. - The assertions are unchanged: the ousted worker exits 0, and the replacement's lock pid, quarantine text and quarantine inode stay the same. **Verification:** - The full tests/fm-remote-job.test.sh passed twice normally. - It passed once under `setsid -w` with stdin from /dev/null (no controlling terminal). - It passed once under `nice -n 10` with six busy-loop CPU hogs. - With the worker from before the fix (cf45cb6^), the test still fails with "the ousted worker wrote or cleared the replacement quarantine during shutdown", so it still proves the fix. - No `fm-hold-job` or `sleep 30` processes were left afterwards. - `bin/fm-lint.sh` passes. **Not reproduced:** I couldn't reproduce the CI failure locally; the decoy version also passed on this host. So I can't confirm why the decoy group stayed alive on the runner. The new wait turns any leftover live group into a clear named failure instead of an exit 125. The changes are not committed

* fix(bin): keep a dead command group dead on bash 5.2

A bare return inside the liveness check drops the failing kill status when the check runs in a conditional, so shutdown keeps treating a stopped group as alive and exits 125.

* no-mistakes(review): Use bash 3.2 fd syntax and fix trap return comments
…henguid#5589)

* docs: make configuration settings easier to find and understand

* no-mistakes(review): Restore dropped qualifiers and fix misplaced config doc labels

* no-mistakes(review): Restore three dropped qualifiers in configuration reference
)

* fix: bound worker edits of project AGENTS.md/CLAUDE.md to factual corrections

These files are loaded into every agent session of a project, so additions
should be a deliberate human choice rather than automated task output. The
ship brief's project-memory section and AGENTS.md section 6 previously invited
workers to record durable knowledge, which let project AGENTS.md files accrete
detail the codebase or README already carries. Workers now edit only to fix
factually wrong content - including content their own change made wrong - and
fm-ensure-agents-md.sh runs only alongside such a correction. Stow no longer
routes project-memory additions through ship tasks, and the generated skeleton
no longer invites discovery-driven additions.

* no-mistakes(review): Stop running fm-ensure-agents-md.sh on memory-file corrections

* no-mistakes(document): Clarify manual project-memory initialization and remove duplicate guidance
…enguid#5635)

* fix(bin): let gate agents drive lifecycle against marked lab homes

Part 2 of the kunchenguid#5615 split. A no-mistakes gate agent runs inside a
checkout carrying the fleet-captain identity, so fm-gate-refuse-lib
refuses fleet mutation on the gate signal. That refusal was absolute,
which kept gate validation from ever exercising the real lifecycle.

Stamp a disposable lab FM_HOME with a .fm-lab-home marker file that
only bin/fm-lab-home.sh writes, and only onto a fresh empty dir, so
no call path can mark a populated real home. fm_refuse_if_gate_agent
then permits lifecycle only when FM_HOME carries the marker and is
driven through its stock layout - any FM_*_OVERRIDE relocation stays
refused so part of the "lab" cannot be split back onto the real fleet.
The threat model is a confused agent touching the real fleet, not
deliberate forgery, so the marker is a plain token file rather than a
bound record. FM_GATE_REFUSE_BYPASS is unchanged: it still serves the
test harness, which cannot mark hundreds of temp homes.

Teardown's slot-ownership scan compared state-dir paths textually
while fm_firstmate_root_home canonicalizes, so a lab home under a
symlinked TMPDIR scanned its own record twice and self-collided;
compare file identity (-ef) instead.

* no-mistakes(review): Refuse unlistable lab homes and hardlinked slot records

* no-mistakes(review): Mint lab markers only on verified-empty fresh dirs

* no-mistakes(document): Clarify lab-home gate documentation and comment contracts

* no-mistakes(document): Clarify lab-home gate documentation and remove stale claims

* no-mistakes(document): Clarify gate lab-home documentation and boundary wording
…ad of refusing every re-arm (kunchenguid#5594)

* fix(bin): replace a watcher whose beacon stalls past a hard bound instead of refusing every re-arm

A fleet watcher that is alive but whose liveness beacon has gone stale could
never be replaced: every re-arm was refused because the lock holder was a live
pid, and the holder was never evicted because it was not dead. Add
FM_WATCHER_STALL_BOUND (default 3x the stale grace): below it the refusal is
unchanged; at or past it the arm re-verifies the holder against the lock's
recorded identity, sends TERM, waits boundedly, and takes the lock the normal
way, ledgering a stalled-holder-replaced row. A holder that survives TERM keeps
the old refusal.

Fixes kunchenguid#4400

* no-mistakes(test): poll for replacement message to fix watcher-lock test flake

* no-mistakes(document): document FM_WATCHER_STALL_BOUND in config inventory
…n can keep them (kunchenguid#5563)

* fix(pi): hide queued Firstmate notifications under Calm only when the session can keep them

Calm now keeps authenticated Firstmate operational inputs out of Pi's queued-message
listing, but only after proving the live session exposes every member needed to keep
them across Escape. A session missing any of them keeps stock rows and Escape and shows
one generic warning. Escape and the dequeue key return only captain-authored messages to
the editor and re-queue hidden notifications in order; after an abort that kept any in
Pi's agent queue, the adapter starts the delivery turn itself because Pi 0.87.1 does not
continue an aborted run. Compaction-held notifications stay with Pi's compaction flush and
never start or announce a turn.

Fixes kunchenguid#1588

* docs(calm): record Pi 0.87.1 queued-row retention verification

* no-mistakes(review): Deliver kept Calm notifications after tree-navigation aborts too

* no-mistakes(review): Defer Calm notification turn until tree navigation finishes

* no-mistakes(lint): Silence SC2016 for literal JavaScript in queue-retention e2e test
…uid#5548)

* fix(bin): refuse teardown when a required source disappears

A missing sibling was sourced after cleanup had started, so Bash 3.2
exited 0 from the EXIT trap and Bash 5 continued and reported success.

* no-mistakes(review): Remove unused FM_TEST_ONLY hook from teardown tests

* no-mistakes(review): Check task backend sources before any teardown cleanup

* test(gotmp): give teardown fixtures every tmux adapter sibling

Teardown now refuses when a sibling the recorded backend's adapter sources
is missing, so the fake bin must carry fm-session-lock-lib.sh,
fm-agent-process-lib.sh and fm-gemini-lib.sh.
Restructure the supervision host doc's prose into shorter sections, lists,
and tables without changing documented behavior. Every original heading,
anchor, identifier, number, quoted string, and link target is preserved.
* docs: make herdr-backend easier to read

Restructure the Herdr backend doc's prose into shorter sections, lists, numbered procedures, and tables without changing documented behavior. Every original heading, anchor, fenced code block, link target, and documented fact is kept.

* no-mistakes(document): Restore composer-proof reason and complete Herdr topic table
Restructure the prose into sections, lists, and tables without changing
documented behavior. Every original heading and anchor, inline-code span,
link target, number, and quoted string is kept, and each sentence sits on
its own line. Adds a topic navigation table and short subsections under
the existing headings.
* docs: make watcher-continuity easier to read

Restructure the prose into sections, lists, and tables without changing documented behavior. Every original heading, anchor, identifier, link target, and number is kept.

* no-mistakes(review): Fix actor and supervision-host scope in watcher-continuity doc

* no-mistakes(review): Make readiness TERM and retry conditional on unready successor
* docs: make sessionstart-nudge easier to read

Restructure the prose into sections, lists, and tables without changing documented behavior. Every original heading, inline-code span, link target, number, and fact is preserved, and a harness-to-tier table now sits near the top.

* no-mistakes(review): Drop helm glossary line and dedupe exit-code lead-in
* docs: make captain-hold-lifecycle easier to read

Restructure the captain-hold lifecycle prose into sections, lists, and tables without changing documented behavior. Every original heading, anchor, identifier, number, quoted string, and link target is kept.

* no-mistakes(review): Fix verification record subjects and grouping headings

* no-mistakes(review): Clarify task-body read-back cases belong to the suite
* docs: make remote-secondmates easier to read

Restructure the remote second mates prose into sections, lists, numbered procedures, and tables without changing documented behavior. Every original heading, anchor, fenced code block, identifier, link target, and qualifier is preserved.

* no-mistakes(review): Merge remote-home table cell into one sentence

* no-mistakes(review): Tighten readiness lead-in, restore causal link, fix dangling reference
…nguid#5554)

* fix(bin): bound the away digest and log why a delivery failed

The away daemon joined every buffered escalation into one unbounded
digest. A start-up catch-all span can exceed what one transport argument
carries (tmux rejects the send-keys command; Linux refuses to exec any
argument above 131,071 bytes, which is how herdr receives it), so the
initial send failed on every housekeeping pass and was logged as an
unconfirmed Enter with text possibly in the composer.

escalate_flush now builds the injected digest under a fixed byte budget:
each event is cut at a UTF-8 boundary with an omitted-bytes marker, the
joined events stop with a "+K more event(s)" tail, and a bounded digest
names a state/.subsuper-digests/ file that keeps every buffered event
verbatim. The buffer itself is untouched, so the return catch-up stays
complete.

The tmux submit core and the herdr literal send now replay the
transport's stderr on failure, and inject_msg logs the failing stage
(initial send versus Enter confirmation) with the byte count and that
stderr. The wedge alarm line and marker carry the last failure reason.

Fixes kunchenguid#4382

* no-mistakes(review): Drop digest pruning; label send-failed as send-or-Enter stage

* no-mistakes(review): Keep digest full text once submit ran; reuse on retry

* no-mistakes(lint): Count digest files with find instead of ls

---------

Co-authored-by: firstmate-oss <firstmate@kunchenguid.local>
falkoro and others added 28 commits October 7, 2026 15:22
… section (kunchenguid#6785)

fm-procevent-lavish.sh read labels tag=message rows SESSION-ENDING MESSAGE
only when session_ended is true and CAPTAIN MESSAGE otherwise, but the
count line always said session_ending_message_count. Several composer
messages on a still-open board were therefore counted as session-ending.

The count line now follows the same session_ended switch:
session_ending_message_count once the session ended, captain_message_count
otherwise. Message rows stay out of the annotation count, per triage.

Fixes kunchenguid#6743
…henguid#6780)

The Herdr presentation lock namespace was the fixed machine-global
/tmp/firstmate-herdr-presentation, so on a host where two OS users run
Firstmate on Herdr the first account to create it owned it and every
teardown from the other account was refused with no way to clear it.

Suffix the namespace with the account uid. The owner-uid and mode-700
checks are unchanged, so a foreign-owned or wrong-mode name at this
account's path is still refused and never adopted, chowned, or removed.

Fixes kunchenguid#4716.
…te (kunchenguid#6809)

The OpenCode session plugin's shouldArm kept its own copy of the need
test that only looked for in-flight task records, while the turn-end
guard decides with fm_supervision_needed in bin/fm-supervision-lib.sh,
which also counts registered process-event sources and trusted custom
checks. With an empty fleet but any registered source or check, the
guard blocked every turn end while the plugin declined to arm - a loop
the guard's own repair line could not resolve because it names the
plugin as the fix.

The plugin now delegates the decision to the shared predicate through
bash, keeping the local away-record decline and the x-mode.env arm
override. OpenCode plugin test fixtures now carry the real predicate
their arming path sources, and the arm suite gains six cases asserting
the plugin's decision against the shared verdict over the same
synthetic state directories.

Co-authored-by: Mia Sun <mia@Bigs-Mac-mini.localdomain>
kunchenguid#6792)

* fix(bin): resolve a pending reply only from its own task's status line

Remote reply ingestion handed every corr= token in a mate's payload to
fm_pending_reply_try_resolve together with that mate's own status log,
so one mate echoing another mate's token resolved the other request.
Honor a status-file override only when it is the record's own
parent_status, and match the corr= token as a whole word.

Fixes kunchenguid#6538

* no-mistakes(document): docs: scope remote reply settlement to the asked mate
…nguid#6784)

agent-skill-trigger-index claims to be the complete agent-only trigger
index but omitted operational-home-layout, session-start-recovery,
validation-supervision, ship-landing, scout-completion, and
away-quiet-supervision. Add each with its own description's trigger,
placed beside the related entries.

The decision-hold-lifecycle redirect stub stays out, per triage.

Fixes kunchenguid#6503
…nchenguid#6814)

* test: share a rename-safe agent stand-in across liveness suites

On Ubuntu 26.04, `sleep` is the uutils multicall binary, which refuses to
run when invoked through a symlink named after another utility. The Herdr
descendant process-walk tests built their agent-named process as a `pi`
symlink to the host `sleep`, so the process exited at once, its parent shell
was gone before the walk ran, and both cases read `unknown unreadable` and
failed on that host. The suite stops at its first failure, so every later
case went unrun. The Herdr control smoke test's `claude` symlink has the
same construction.

The tmux liveness suite already solved this with a host-compiled spinner and
a survival-checked `sleep` fallback. That builder moves into tests/lib.sh as
fm_agent_standin, and the tmux suite, both Herdr descendant cases, and the
Herdr control smoke test now use it. When no stand-in can survive a foreign
name, a case skips with the reason instead of failing.

tests/fm-test-fixtures.test.sh gains a portable regression with a fake
multicall `sleep`, so it bites on hosts whose own `sleep` is single-purpose.

* no-mistakes(document): Correct Herdr verification fixture reference

* ci: retrigger cancelled shard
…he Stop hook's group is torn down (kunchenguid#6787)

* fix(bin): keep the supervision host's pass-through successor out of the hook's process group

The successor a main-only pass-through leaves for main shared the Stop hook's
process group, so the harness tearing that group down after the exit-2 rewake
stopped it. The stop published downtime and the next park's first cycle
announced an empty check: rearm-resurface, which woke main again in a loop.
Start that successor in a process group of its own, as the hook's own
handling successor already is.

* no-mistakes(review): Give the at-turn successor left for main its own group

* no-mistakes(document): Document own-group successor for turn-start hand-back too

* no-mistakes(ci): I made the change you asked for: both new teardown tests in tests/fm-supervision-host.test.sh now call the existing `stop_home_processes "$home"` just before `pass`. The tests are `test_successor_left_at_the_turn_survives_the_hook_process_group_teardown` and `test_pass_through_successor_survives_the_hook_process_group_teardown`. No production code and no other tests changed. The rule broken was that a test must not leave a home's watcher or arm processes running after it passes. These two were the only cases in the changed area that broke it. The other host+hook tests already stop their home, and `test_successor_close_during_main_turn_is_delivered_at_the_next_turn_end` leaves its watcher behind too, but it is an older test you said not to touch. The only reason anything was left over is that the successor's arm now sits in its own process group, outside the hook's teardown. `stop_home_processes` kills the watcher by the pid in its lock file, which stops it no matter which group it is in. **Checks run:** - I ran just these two tests from a scratch copy of the suite (since deleted). Both pass in about 13 seconds. - After each test, a process listing filtered to that test's home directory came back empty once the processes had about a second to exit after TERM. - `bash -n` on the test file passes. - `shellcheck` is not installed here, so I did not lint the file. - I did not run the full serial-2 suite locally. Whether it now finishes under its 30-minute limit will only show on the next CI run
…ters (kunchenguid#6823)

* test: use idle composer readiness for Claude tmux guards

* no-mistakes(test): Fix attended supervision test expectations and isolate worker state

* no-mistakes(document): Correct live guard coverage and readiness documentation

* no-mistakes(ci): Captain, fixed SC2100 by quoting the cursor-agent assignment in tests/fm-host-mirror-live-e2e.test.sh. Reproduced the failure before editing; pinned ShellCheck lint on both PR test files, bash syntax checks, and git diff --check now pass

* test: preserve attended successor close assertions

* no-mistakes(test): Fix attended live test watcher takeover expectations

* no-mistakes(document): Correct stale attended guard documentation

* Revert "no-mistakes(document): Correct stale attended guard documentation"

This reverts commit 8e59d89.

* Revert "no-mistakes(test): Fix attended live test watcher takeover expectations"

This reverts commit c0b8510.
* test: order stale watcher-lock fixture races explicitly

* no-mistakes(review): Removed duplicate stale-steal reap call
…ting server (kunchenguid#6920)

* fix(bin): keep herdr composer probes observable-only without autostarting server

- Refuse bare pane identifiers lacking session prefix in fm_backend_herdr_parse_target
- Add fm_backend_herdr_target_observable to passively verify server liveness without autostarting
- Route visible viewport captures through fm_backend_herdr_target_observable
- Detach stdin with </dev/null on background server launch in fm_backend_herdr_server_ensure
- Add unit and regression tests in tests/fm-backend-herdr.test.sh

* fix(bin): drop parse_target colon restriction to preserve existing fixtures

Revert the fm_backend_herdr_parse_target colon check so that single-colon
session targets like sess:p1 in secondmate liveness and other fixtures parse
properly. The probe path remains observable-only via fm_backend_herdr_target_observable.
…kunchenguid#6956)

* test: clear inherited Git repository location in fixture helper

An absolute GIT_DIR inherited from the caller (a linked-worktree hook
exports one) overrides the discovery that git -C implies, so fixture
setup moved the caller's branches and registered fixture worktrees in
it. tests/git-config-helpers.sh now unsets GIT_DIR, GIT_WORK_TREE,
GIT_INDEX_FILE and GIT_COMMON_DIR alongside the config isolation.

Fixes kunchenguid#6953

* no-mistakes(document): Document fixture Git location isolation in CONTRIBUTING
…nchenguid#6830)

* fix(bin): stage contribution-input JSON via temp files

The contribution-input branch passed the whole canonical backlog document to
jq as a single --argjson argv argument. A large fleet's backlog JSON exceeds
Linux MAX_ARG_STRLEN (128 KiB), so jq fails with E2BIG (Argument list too
long) and the contribution-input snapshot emits empty output, breaking the
bearings contribution path.

Write both the backlog and task documents to a temp directory and hand them
to jq with --slurpfile, matching how the full snapshot path already stages
the same pair. Output is unchanged for any backlog that fits in argv.

* no-mistakes(document): Correct contribution cleanup trap comment
)

* fix(bin): arm the busy contract on secondmate launches

A tmux-backed secondmate's active-turn gate can only see a busy verdict from the parent home's record, and those launches never armed it.

* no-mistakes(review): Reopen secondmate busy on blocked Claude Stop; drop muse guard

* no-mistakes(review): Make Claude secondmate Stop guard the sole Stop-state writer

* no-mistakes(review): Record live rewake UserPromptSubmit evidence and add regression

* docs: record Claude secondmate Stop guard as busy writer

* no-mistakes(review): Keep Stop idle hook for older secondmate guards

* no-mistakes(document): Correct stale omp secondmate -e rationale in supervision verification

* no-mistakes(document): Fix skill-relative turnend-guard link in Claude harness reference

* no-mistakes(ci): Root cause: in shard 9, the pure-contract-unit family ran two scripts, tests/fm-rovo-harness.test.sh (14712 ms) and tests/fm-omp-harness.test.sh (10335 ms). Those two durations add up exactly to the failing family's 25047 ms. The failing one was tests/fm-omp-harness.test.sh. Its test_secondmate_launch_relies_on_discovery still asserted the old contract: that an omp secondmate launch names no -e and gets no state/<id>.omp-ext.ts. This PR (issue kunchenguid#4268) deliberately changed that. bin/fm-spawn.sh now arms the busy contract for omp secondmates, so their launch names `-e state/<id>.omp-ext.ts` and writes that extension. The primary extensions are still left to auto-discovery. The harness reference docs were updated to match, but the test was not. The fix is test-only and touches just tests/fm-omp-harness.test.sh. The test now asserts that the secondmate launch names exactly one -e and that it points at the parent-home state/sm.omp-ext.ts. Because only one -e is allowed, the tracked .omp/extensions files are not named a second time, which would load them twice. The test also asserts that the extension file exists, and the header comment for contract 3 was updated. The posture overlay, --cwd, marker, and supervision-model assertions are unchanged. Verification: the host's load average was about 140 on 8 cores, and the full script timed out locally after 590 s having finished only its first 2 tests. So I ran the one affected test function on its own through the real fm-spawn path, and it passed (`ok - fm-spawn: a real omp secondmate launch loads only the busy -e and auto-discovers its primary extensions`). The remaining omp tests were not re-run locally. shellcheck on the file reports only existing info-level notices. The change is left uncommitted for the outer executor

* test: keep the secondmate busy stall gate visible after main's liveness probe

The merged watcher treats a window-name inventory miss as a missing endpoint and exits a later checkpoint on the previous quiet run's recovery wake. The fake pane now answers both list-windows formats, and each observation starts without a leftover downtime marker, so a busy mate still defers the stall and an idle mate still surfaces it.

* no-mistakes(review): Align fm-spawn secondmate comments with omp -e and devin refusal

* no-mistakes(document): Document secondmate busy extensions in configuration reference

* no-mistakes(test): Make live busy-contract guard clean up read-only lab dirs

* fix(bin): pass Claude secondmate busy hooks through --settings

Rewriting a persistent mate home's settings.local.json drops the captain's saved permissions. The hooks now live in a parent-state file Claude Code loads for that session only.

* no-mistakes(review): skip busy arm for raw secondmate launch commands

* no-mistakes(review): retire earlier busy arm on raw secondmate respawn

* no-mistakes(review): retire Stop pointer on relaunch, load --settings in live guard

* no-mistakes(document): Document secondmate Claude settings file and raw-launch exception

* no-mistakes(ci): The check "Behavior portable serial 9" failed because of this PR, and I fixed it with a test-only change; `tests/fm-spawn-dispatch-profile.test.sh` now passes locally in full. Cause: the one failing test was "claude secondmate launch settings JSON does not disable Claude attribution" in `tests/fm-spawn-dispatch-profile.test.sh`. This PR makes a claude secondmate launch pass `--settings` as a file path (`state/<id>.claude-settings.json`) instead of inline JSON. The test helper `claude_settings_json_arg` handed that path string to jq as if it were JSON, so jq reported a parse error. The product behavior is correct: the file does carry `feedbackDrafts` and the attribution-off policy. Invariant: a test that checks the Claude launch settings must read the settings Claude would load, whichever form `--settings` takes (inline JSON or a file path). The only place this must hold is `claude_settings_json_arg`, the single reader of the `--settings` value in the tests. Its two callers, `assert_attribution_policy` and `assert_attribution_policy_absent`, both go through it. Fix: `claude_settings_json_arg` now prints the value when it starts with `{` and prints the file contents otherwise. No product code changed. Verification: I ran `bash tests/fm-spawn-dispatch-profile.test.sh` in the worktree. It ended with "all fm-spawn-dispatch-profile tests passed", including the previously failing secondmate case and the crewmate and keep-ai-trailers cases that use the inline form. I did not run the other tests of shard 9; they passed in the CI run and this change touches only this test file. The change is uncommitted in the worktree (one file modified)
…ailures (kunchenguid#7036)

The large-backlog regression already proved the json and secondmate
home-summary modes stay within exec limits. It now also runs the
contribution-input mode on the same 1200-record backlog, which is the
path kunchenguid#6830 moved off argv. With that fix reverted the test fails with
the field error jq Argument list too long at the contribution-input call.
…urn (kunchenguid#5843)

* fix(teardown): scrub nested repos before return

Treehouse return uses git clean -fd, which leaves a nested git
repository in the pool slot. Scout and forced teardown run
git clean -ffdq first. A return that stays dirty names the
lost slot instead of reporting a clean return.

* no-mistakes(review): Report lost pool slots early and scrub forced child copies

* no-mistakes(review): Drop misleading no-rerun clause from lost-slot message

* no-mistakes(document): Note failed status read in teardown dirty-return header

* no-mistakes(ci): I fixed ci-1 and ci-2 in bin/fm-teardown.sh, and I added tests in tests/fm-teardown.test.sh. Invariant (ci-1): a lost-slot finding must only warn. It must never change the teardown exit status. Two places must obey this: the final status block, and the remote success path that a forced remote retirement uses. - The final block no longer runs `exit 1`. When a slot is lost, teardown writes a lost-slot line to stderr instead of the clean "teardown X complete" line. Then backlog_refresh_reminder runs and teardown exits with its normal status. - Before this change, remote_secondmate_teardown discarded the remote output when the remote run succeeded. Now it sends that output to stderr. Without this, the remote lost-slot warning would not reach the operator once the remote side exits 0. - I updated the header comment to match. Invariant (ci-2): after a return that succeeds, teardown must verify every returned copy, or it must warn that it could not. This invariant is enforced inside teardown_note_dirty_return, which both return sites call (the main WT return and the forced-secondmate child return). Before, a copy that was missing or not a readable git worktree caused a silent `return 0`. Now it sets the lost flag and gives the same warning, with the text "cannot verify: the copy is missing or not a readable git worktree after return". Both call sites run only for a copy that existed before the return. The exit status does not change. Tests: - The dirty-return test now expects exit 0 and the warning. - New test (z3d): a forced secondmate teardown whose child return leaves residue. This is the same command that `retire --force` runs on the remote host. The test expects exit 0 and the warning, and it checks that the task record and the home are removed. - New test (z3e): a return that removes the copy's .git. The test expects exit 0, the "cannot verify" warning that names the copy, and no clean completion line. Verification: - I ran the new and updated tests against the old script. Three failed as expected (exit 1, or no warning). With the fix, all of them pass. - The full tests/fm-teardown.test.sh suite passes: 117 ok, 0 not ok. - shellcheck shows no new warnings. - tests/fm-remote-secondmate-lifecycle-e2e.test.sh is still running. It covers the remote success path that now relays output. Up to now it has no failures, but it has not finished, so I cannot report a final result for it

* no-mistakes(ci): I fixed ci-1 and ci-2 as one exit contract, as the user asked. The changes are in bin/fm-teardown.sh, tests/fm-teardown.test.sh, and tests/fm-remote-secondmate-lifecycle-e2e.test.sh. Invariant (ci-1): when a returned slot is dirty or cannot be verified, teardown must finish every cleanup step and then exit with exit code 4. Exit 4 is used for nothing else. It must hold in two places: the final status of a local teardown, and the remote secondmate retirement caller. - Local: the existing lost-slot flag now leads to `exit 4` (TEARDOWN_LOST_SLOT_EXIT). This exit comes after the task record is removed, the warning is printed, and backlog_refresh_reminder runs. A clean return still exits 0. Refusals and errors exit 1, and an invalid request exits 2. The header documents all of these codes. Exit 3 is only an internal "not remote" return. The ssh transport uses 255. - Remote caller: remote_secondmate_teardown treats a remote exit 4 as "retired with a lost-slot warning". It does the full local retirement (route, registry line, reply source, records, summary refresh), prints the normal completion line on stdout, and then returns 4. The remote control script runs fm-teardown.sh as its last command, and fm-on.sh execs ssh, so the remote 4 reaches the local side unchanged. Invariant (ci-2): remote output goes to local stderr only when it is a lost-slot warning. - After a clean remote retirement (exit 0), the caller no longer prints the captured remote output. - After exit 4, the caller forwards only the lost-slot warning header and the remaining-path lines. To make those lines easy to find, teardown_note_dirty_return now indents each remaining path by two spaces. Tests: - The dirty-return (z3), forced-secondmate dirty-child (z3d), and copy-removed (z3e) tests now expect exit 4 after cleanup. The clean scout return (z1) still expects 0. - The final remote retirement in the e2e test now uses a fake-ssh mode, retire-lost-slot. In this mode the real remote retire runs, and then the fake reports a lost child slot with exit 4. The test checks the following: exit 4; the remote home, parent metadata, and route are removed; stdout has "teardown ios complete (remote"; stderr has the warning and the remaining path; and stderr does not contain the remote completion text. The remote side producing exit 4 is covered by z3d. Verification: - tests/fm-teardown.test.sh: 117 ok, 0 not ok. - tests/fm-remote-secondmate-lifecycle-e2e.test.sh: ALL TESTS PASSED. - shellcheck shows the same warning count as before on all three files. - Against the previous script, both suites fail as expected. In the local suite, dirty-return expected 4 but got 0. In the e2e test, the stdout local-completion check fails

* no-mistakes(ci): Both CI failures came from the lost-slot check that this PR added. Shard 3: tests/fm-secondmate-safety.test.sh "force teardown failed to discard child work". Shard 7: tests/fm-teardown-endpoint-safety.test.sh exited 4. The check ran after the return of every copy. Treehouse return removes a copy that is not a pool slot, so the check reported "cannot verify" and teardown exited 4. Before the fix, both failures happened on my machine. Invariant: only a Treehouse pool slot can be lost by the pool, so the check runs only for a copy that was a pool slot before the return. Fix in bin/fm-teardown.sh: both return sites (the main WT return and the forced-secondmate child return) now run fm_treehouse_pool_slot before the return. They call teardown_note_dirty_return only when the copy was a pool slot. teardown_note_dirty_return lost its pool-slot branch and its unused proj argument; the slot label still comes from the path of the copy. Test fix: in tests/fm-teardown.test.sh, the z3d child copy was not a pool slot. It is now a real pool slot (pool/6/repo plus treehouse-state.json), and the test still expects exit 4 and the warning. Verification: endpoint-safety 27 ok, exit 0. secondmate-safety 79 ok, exit 0. fm-teardown 117 ok, 0 not ok. remote-secondmate-lifecycle-e2e ALL TESTS PASSED. shellcheck count is unchanged (17)

---------

Co-authored-by: Nova Agent B <novaagentb@gmail.com>
…nguid#7047)

* fix(tests): keep backlog suites hermetic against a local .tasks.toml

Fixture homes now write the tracked markdown defaults through a
fm_test_tasks_toml helper instead of copying the checkout's .tasks.toml,
which an operator may override with a beads backend at a live backlog.

The backlog handoff and receive moves pin --backend markdown, because they
already name their markdown files and otherwise resolve the backend from the
caller's working directory. The atomicity suite runs from its scratch root so
its direct tasks-axi fixture calls cannot read the checkout config.

* no-mistakes(review): Add decoy-cwd .tasks.toml regressions for handoff and receive

* no-mistakes(lint): Reuse sha256_file helper to fix SC2015 in remote handoff test
…nchenguid#7076)

* fix(bin): parse whole project name in home seed registry queries

Parse the full project name after the dash in fm-home-seed.sh registry lookups.

This matches the round-3 bootstrap mirror check parser so spaced names resolve.

Cover both the project-less seed refusal guard and registry line lookups in tests.

* no-mistakes(review): Match registry rows by name prefix plus separator

* no-mistakes(document): Note shared registry row-match rule in fm-home-seed
…d#4490)

* fix(codex): preserve announced recovery across checkpoints

* no-mistakes(review): Make announced-recovery checkpoint test reproduce the regression

* no-mistakes(review): Separate 2026-10-07 checkpoint fixture verification from original run

* no-mistakes(test): Defer TERM exit to clean up quiet checkpoint watcher locks

* no-mistakes(document): Update checkpoint recovery and signal documentation

* no-mistakes(ci): Updated both lock-acquire retry loops to honor the watcher’s TERM stop status, so held-marker cleanup exits while retaining stale lock evidence. Set the --stop test’s watcher poll to 1 second to fit its 5-second stop bound. Syntax checks and the full watch-arm suite passed; the targeted held-marker test passed during the triage suite, which timed out after 600 seconds before completing. Did not change or attempt to fix fm-supervision-host.test.sh

* no-mistakes(ci): Removed the cleanup-bound test that incorrectly expected a TERM-stopped watcher to retry a contended lock acquisition. TERM cleanup intentionally stops after the failed attempt; the remaining held-lock test verifies it exits and retains stale lock evidence. The two relevant TERM tests passed, as did shell syntax and diff checks

* Revert "no-mistakes(ci): Updated both lock-acquire retry loops to honor the watcher’s TERM stop status, so held-marker cleanup exits while retaining stale lock evidence. Set the --stop test’s watcher poll to 1 second to fit its 5-second stop bound. Syntax checks and the full watch-arm suite passed; the targeted held-marker test passed during the triage suite, which timed out after 600 seconds before completing. Did not change or attempt to fix fm-supervision-host.test.sh"

This reverts commit 44ce29bfbfa95149a7785efc200f6a00b5bf3a41.

* Revert "no-mistakes(ci): Removed the cleanup-bound test that incorrectly expected a TERM-stopped watcher to retry a contended lock acquisition. TERM cleanup intentionally stops after the failed attempt; the remaining held-lock test verifies it exits and retains stale lock evidence. The two relevant TERM tests passed, as did shell syntax and diff checks"

This reverts commit e1e37067a9369f0c38d7bd1c7a0913b1c54fc28a.

* Revert "no-mistakes(test): Defer TERM exit to clean up quiet checkpoint watcher locks"

This reverts commit 9877bf92134e77414e25cd8e6f122ff4d089473a.

* fix: let checkpoint watcher clean up before timeout

* no-mistakes(review): Scope checkpoint timeout escalation and restore signal docs

* no-mistakes(review): Fix Perl checkpoint timeout escalation

* no-mistakes(document): Clarify checkpoint recovery documentation

* no-mistakes(document): Document isolated checkpoint regression command

* no-mistakes(ci): Tied direct-checkpoint SIGKILL escalation to the effective cleanup bound, preserving the five-second minimum and leaving the supervision-host path unchanged. The targeted checkpoint suite, shell syntax checks, ShellCheck, and diff checks pass. CI was not manually rerun

---------

Co-authored-by: jopo <jopo@JP-M2mini.local>
…uid#4395)

* feat(bin): add Forgejo (tea) as a third forge alongside GitHub and GitLab

Extends the existing provider-tagged PR/MR dispatch in fm-pr-lib.sh,
fm-pr-poll.sh, fm-pr-check.sh, and fm-pr-merge.sh with a forgejo arm,
following the same pattern already established for GitLab. tea addresses a
repository by owner/repo slug only and resolves the host through a named
"tea login" rather than a URL, so the login is matched against the PR's host
fresh at arm and merge time. tea's own merge subcommand exposes no
head-binding flag, so the merge itself calls Forgejo/Gitea's REST API
directly via "tea api" with head_commit_id, verified against a real
disposable instance to behave like --match-head-commit/--sha; that same
verification found that "tea api" reports an HTTP-level failure with exit
status 0, so a merge is confirmed only by reading the pull request back
afterward, never by trusting the command's own exit code.

Adds forgejo as a value of the registry's existing forge= binding (the
closed set becomes none|gerrit|forgejo, with its refusals unchanged), so a
generated brief and its direct-PR Definition of done name tea before any PR
exists and bin/fm-spawn.sh's forge agreement and bin/fm-promote.sh carry it
like gerrit. Documents the new value in docs/configuration.md,
docs/architecture.md, and a new maintainer-verification doc mirroring
docs/gitlab-merge-watch.md.

* no-mistakes(review): Redact private Forgejo host/IP from evidence doc

* no-mistakes(review): Fix doc's tea-login JSON shape; dedupe host validators

* no-mistakes(document): Add Forgejo to README doc index and scripts.md forge list

* no-mistakes(lint): {"summary": "fix(bin): drop unused FORGEJO_LOGIN capture in fm-pr-check.sh"}

* fix(bin): refuse --allow-red on Forgejo instead of dropping it silently

The attended --allow-red waiver landed on main while the Forgejo arm was
being written, so its applicability guard only ever classified GitHub and
GitLab. On a Forgejo pull request the flag parsed, and then nothing read
it: forgejo_verify_mergeable requires the head's combined commit status to
be exactly "success", with no per-check name to match a waiver against.

The merge still refused, so no red Forgejo merge was ever possible, but it
refused without saying the waiver had been ignored. Extend the existing
GitLab guard to cover Forgejo for the same reason GitLab has it: both
collapse their checks into a single head verdict, so the green requirement
is absolute and a named waiver cannot apply.

* fix(bin): poll a Forgejo pull request by number through tea api

The merge watch listed the 50 most recent pull requests and filtered to the
watched index, so in a repository with more newer pull requests a merged
watch never fired. Read the one pull request through tea api instead and wake
only on a boolean merged field of true, since tea api exits 0 on HTTP errors.

Share the tea login match as fm_pr_forgejo_login for every sourcing script and
add fm_pr_forgejo_read_record for the state, merged flag, and head. Arming now
also requires jq, which the poll needs to read the record.

* fix(bin): gate a Forgejo merge on every status page and on draft state

The combined-status endpoint computes its state from one page of contexts, so
a failing context past the first page could leave the head reading green. Read
every page until an empty one and require each to be success. Also refuse a
pull request the API reports as a draft.

* fix(bin): prove a Forgejo task landed from its merged pull request at teardown

pr_is_merged read the recorded pr= only through gh, so a Forgejo task always
fell back to the content check and refused landed work whenever that check was
inconclusive, such as when later default-branch commits conflict with the
merged tree. Read a recorded Forgejo URL through fm_pr_forgejo_read_record and
apply the same containment check against its head.

* feat(bin): read Forgejo pull requests in crew-state and review-diff

fm-crew-state reports a terminal passed run's Forgejo pull request as open,
closed, merged, or unknown through fm_pr_forgejo_read_record, and
fm-review-diff resolves a /pulls/<n> URL to the refs/pull/<n>/head ref
Forgejo serves. Document the by-number read, the paged status gate, and the
draft gate, and mark what the evidence instance did not exercise.

* fix(bin): parse tea logins as JSON and close the remaining Forgejo gaps

The tea login match split each line of `tea login list --output json` on
quotes and read field 4, which only works while tea pretty-prints one field
per line. A login printed as one compact object put the login name where the
url belonged, so arming, merging, and polling refused every Forgejo host.
fm_pr_forgejo_login and the static poll's own copy now parse the list with
jq, matching each login's url host with scheme, userinfo, port, and path
stripped, and still refuse zero or several matches.

--allow-missing is now refused on a Forgejo pull request the way --allow-red
already is, instead of being parsed and ignored: the merge already requires
the head's combined commit status to have succeeded.

The forge=forgejo Definition of done read the draft state back with
gh-axi pr view and cleared it with gh-axi pr ready although the PR is opened
with tea; both publishing modes now read the draft state through tea api and
clear Forgejo's work-in-progress title prefix with tea pulls edit.

* no-mistakes(review): Retry Forgejo merge confirmation read before failing

* no-mistakes(document): Document Forgejo draft gate and merge confirmation retry

* fix(bin): merge Forgejo pull requests with the repository's default style

When the caller named no merge method, a Forgejo merge always sent Do=merge,
so a repository that allows only squash or rebase merges refused every
default call. The style now comes from the repository's own
default_merge_style, read live through the same tea login, and a merge is
refused when that value cannot be read or is not a known style rather than
replaced by one chosen here. A method the caller names still wins.

---------

Co-authored-by: dna <dna@local>
* fix: serialize secondmate liveness relaunches across task set

* no-mistakes(review): Remove relaunch wait override and test bounded contention

* no-mistakes(document): Clarify secondmate relaunch locking and timeout documentation

* chore: keep local Stele binding out of shared template

* no-mistakes(document): Correct stale secondmate recovery timing comment

* chore: exclude local Stele binding from relaunch fix

* ci: retrigger CI after a timed-out test shard

* no-mistakes(document): Correct secondmate recovery ordering documentation
…unchenguid#7172)

* feat(bin): gate firstmate-upstream publication behind a declared home role

Users who clone firstmate and run it as-is got a surprise: when their
agent hit a firstmate bug, it could drive a pull request at upstream
because nothing distinguished the maintainer's home from an ordinary
user's. Every home now resolves to user/operator unless the gitignored
config/firstmate-role grants a maintainer scope, or a single task
carries the captain's recorded --upstream-consent on the brief, spawn,
and promotion. fm-brief, fm-spawn, and fm-promote apply one fail-closed
gate in bin/fm-role-lib.sh; the role is never inferred from gh identity,
remotes, permissions, or CI, and secondmates honor only receipt-proven
inherited grants so a child cannot grant itself. Session start reports
the resolved role with no network call. Ordinary project delivery and
the clone-and-run setup flow are unchanged.

* no-mistakes(review): Harden firstmate role parsing, normalization, and inheritance

* no-mistakes(review): Detect firstmate by lineage; drop consent fallback; fix claims

* no-mistakes(document): Correct and consolidate Firstmate role documentation
Merge kunchenguid/firstmate `upstream/main` (7df545b) into max-metaplanet/firstmate `main` (439281b).
The two histories had no shared ancestry for most of this content because fork PR #29 re-applied upstream work as a single squashed commit, so 376 conflict hunks surfaced across 77 files.

Conflicts were resolved by retaining both behaviours.
Where the two sides touched the same construct, the result is a union rather than a choice: the task-meta key list is the exact set union of both sides' keys, `fm_dod_block` interleaves upstream's `<consent>` parameter with the fork's `<ticket-header>` at both call sites, and the worker launch templates carry the fork's resume wiring together with upstream's settings flag.
A fork line was dropped only where upstream already implements the same thing, and each such equivalence is identified below.

Fork behaviours preserved, with no upstream equivalent: ClickUp ticket dispatch end to end (`--ticket`/`--commit-type` through `fm-spawn.sh`, `fm-brief.sh`, `fm-promote.sh` and `fm-dod-lib.sh`, including the guard that refuses a shared ticket across a batch), Codex seats and guarded renewal, the seat-aware pipeline, Jev dispatch provenance, and the GitHub PR freshness poll in `fm-pr-merge.sh`.

Fork changes dropped against a proven upstream equivalent:

- The fork's string-presence assertions on the generated Pi extension in `tests/fm-spawn-dispatch-profile.test.sh` are dropped because upstream imports that extension and executes `agent_start`, `agent_settled` with both `isIdle()` outcomes, and `turn_end`, asserting the generation binding and `source: "pi-ext"` attribution. Executing the handlers subsumes asserting that their registrations appear in the file.
- The fork's `FM_SIGNAL_GRACE`-based grace in `run_with_perl_timeout` is dropped because upstream generalized the helper to take the grace as an explicit `kill-after-seconds` argument, and the caller passes the fork's five seconds literally as `run_bounded "$SECONDS_ARG" INT 5`. `bin/fm-timeout-lib.sh` owns the shared mechanism selection.
- The fork's single task-set lock refusal in `fm-spawn.sh` is dropped because upstream reports the same refusal through three specific messages that name whether another spawn, a forced teardown, or another operation holds the set.
- The fork's `expected none or gerrit` forge refusals in `fm-project-mode.sh` and `fm-dod-lib.sh` are dropped because upstream extends the same closed set with `forgejo` and names it in the refusal.

`docs/fm-test-portable-shards.md` previously recorded that `serial_unhinted` was zero.
That measurement no longer holds because this merge adds serial scripts the fork's own CI runs never measured, so the text now records that those members pack on the default weight until a green run measures them.

Verified locally: `bin/fm-lint.sh` clean including actionlint over all three workflows, `bin/fm-doc-audience-check.sh` clean over 127 surfaces and 827 local links, and the conflict-sensitive suites `fm-spawn-batch`, `fm-brief`, `fm-review-diff`, `fm-composer-lib` and `fm-test-run` passing.
The batch shared-ticket guard was lost in a first resolution pass and restored after `tests/fm-spawn-batch.test.sh` caught it; that suite now passes.
The review step of the first validation run found these four and then timed out before it could apply them, so they are applied here as a corrective commit on top of the merge rather than by rewriting it.

`fm_backend_send_literal` is restored to the fork's plain dispatcher.
The merge had grafted the dialog-sink preamble from upstream's `fm_backend_send_text_submit` onto this fork-only function, which upstream does not have at all.
That preamble left `rc` unassigned before `return "$rc"`, so both callers died under `set -u` - `restore_insert_mode` in `bin/fm-control.sh` and `bin/fm-lead-restart.sh` - after typing their text.
Two further defects came with the same graft: the copied `label=${6:-}` was taken from a function with three more parameters, so it always read empty here, and `target` and `label` were assigned without `local` and leaked into the global scope.
No dialog-sink guard is added in its place, because neither parent had one in this function.

`bin/fm-spawn.sh` loses two blocks the merge duplicated, neither of which either parent has twice.
The worktree re-assertion pair ran `spawn_enter_recorded_worktree` and `spawn_assert_agent_worktree` a second time, typing an extra `cd` into the worker pane and repeating up to 20 cwd polls before trust setup.
The per-task AI-trailer hook install ran twice; it is idempotent, so nothing broke, but the two copies could drift.

`bin/fm-pr-merge.sh` loses the fork's standalone GitLab `--allow-missing` refusal, which upstream's provider case already covers for GitLab and Forgejo with the identical message and exit status, leaving the fork's copy unreachable.
This is a fifth upstream equivalence, of the same kind the merge commit lists.

Verified: `bin/fm-lint.sh` clean, and `fm-backend-cmux`, `fm-backend-zellij` and `fm-spawn-batch` pass.
No test couples `fm_backend_send_literal` to the dialog sink.
Fork `main` advanced to `344fc301` ("ci: gate CI jobs by changed path and split serial shards to 16") while this branch was in validation.
It is incorporated here as an ordinary merge rather than a rebase, because this branch's history contains upstream's own commits: rebasing onto fork main would replay 184 upstream commits one at a time, discard the reviewed resolution of 376 conflict hunks, and flatten the two-parent ancestry that lets the next upstream sync find a common base.

Three of the six files `344fc301` touches were also changed by the upstream merge, and git auto-merged all three.
Each was then checked for content lost from either side rather than trusted because the merge reported no conflict:

- `.github/workflows/ci.yml` keeps the `changes` gate job, every job's `needs: changes` wiring, and the serial matrix at sixteen shards; the upstream merge's nine-shard matrix is superseded by that.
- `bin/fm-test-run.sh` keeps `PORTABLE_SERIAL_SHARDS=16`, superseding nine, and its selector line now reads `fm-harness-adapter-references.test.sh|fm-project-mode.test.sh|\`, holding both the entry from fork main and the one the upstream merge added to the same pattern.
- `docs/fm-test-portable-shards.md` takes fork main's rewrite of the job layout and path-gating description, which supersedes the upstream merge's "no path skips" wording. Its claim that `serial_unhinted` is now zero is deliberately not restored: the upstream merge adds serial scripts those timing runs never measured, and the coverage guard confirms it, reporting `serial_unhinted=11`.

Verified on the merge result: `tests/fm-ci-workflow.test.sh` and `tests/fm-ci-change-scope.test.sh` pass, `bin/fm-test-run.sh --check-coverage` reports ok with `serial=232 serial_shards=16 serial_max_ms=1353420` inside a 1500000 budget, and `bin/fm-lint.sh` is clean including actionlint over all three workflows.

This branch must land as a merge commit rather than a squash, so the upstream ancestry it carries is preserved for later syncs.
The merge kept upstream's opt-in --herdr-resume-lock-wait branch and the fork's
HERDR_PRESENTATION_RECOVERY_LOCK_ATTEMPTS=300 budget on the default branch at
once. Those two defaults are mutually exclusive: upstream refuses on contention
after its library default of 50 x 0.1s, while the fork waited 30s because that 5s
was shorter than a healthy holder's own critical section.

Upstream's design supersedes the fork's, because --herdr-resume-lock-wait now
serves the caller that would rather wait, so the default no longer needs a long
budget. tests/fm-backend-herdr-presentation-e2e.test.sh asserts that default
refusal, and 30s outlasted its 15s hold and took the lock instead, which is the
Behavior tests (Herdr) failure.

Drop the attempts argument so the default path matches upstream, remove the now
dead constant and its contradicted comment, and stop the refusal message
interpolating the removed budget while keeping the rc 2 branch that reports an
unresolvable session socket separately. The upstream test is unmodified.

No caller depended on the removed 30s wait. The recovery block is guarded by
KIND != secondmate and --relaunch reads kind from the task's recorded meta, so
fm-secondmate-park.sh unpark, the secondmate liveness auto-relaunch and the
remote secondmate control all skip it; the only caller that reaches it is
fm-control.sh --relaunch for ship and scout tasks, which upstream shares and
leaves on refuse-by-default.

Known slow-host limitation: where a holder's critical section exceeds the
opportunistic 5s, one of two simultaneous resumes can refuse instead of waiting.
That is a safe refusal rather than damage, and --herdr-resume-lock-wait opts into
waiting. The concurrent-recovery case in the same suite reproduces it on a host
roughly 57% slower than CI; a bounded middle budget was measured and rejected
because spawn startup plus the budget then outlives the 15s hold, which breaks the
asserted refusal.
@max-metaplanet max-metaplanet changed the title feat(bin): sync upstream firstmate into the fork while keeping fork behaviours feat(bin): merge upstream firstmate into the fork while keeping fork behaviours Oct 14, 2026
@max-metaplanet
max-metaplanet merged commit 1622b14 into main Oct 14, 2026
33 of 34 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.