Skip to content

fix: narrow Herdr presentation lock scope - #7430

Merged
kunchenguid merged 11 commits into
kunchenguid:mainfrom
ironerumi:fm/fm-6454-upstream
Nov 26, 2026
Merged

kunchenguid merged 11 commits into
kunchenguid:mainfrom
ironerumi:fm/fm-6454-upstream

Conversation

@ironerumi

@ironerumi ironerumi commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Intent

The developer wanted PR 7430 to fix Herdr recovery contention by limiting the session-wide presentation lock to projected layout mutation, releasing it before worker-copy allocation and remaining launch setup while preserving abort cleanup’s lock reacquisition. Default recovery should still refuse actual lock contention, with --herdr-resume-lock-wait providing explicit waiting. They required deterministic, file- or FIFO-synchronized tests covering recovery during sibling allocation, mutation-free default refusal, and concurrent opt-in recoveries replacing only their own husks, including proof that the allocation regression test fails with the old release point. No live Herdr lab session was allowed; documentation should reflect the narrowed lock scope, and the PR should identify scenario coverage and known baseline test failures.

What Changed

  • Release Herdr’s session presentation lock after projected layout mutation, before worktree allocation and launch setup; retain default contention refusal and explicit recovery waiting.
  • Add a stateful Herdr fixture and FIFO-synchronized coverage for recovery during sibling allocation, mutation-free contention refusal, and opt-in recoveries replacing only their own husks; update presentation end-to-end scenarios.
  • Document the narrower lock scope and centralize reclaim layout guidance under restart recovery.

Risk Assessment

✅ Low: The bounded lock-scope change releases both projected-create and exact-recovery paths before allocation while preserving abort cleanup reacquisition and behavioral regression coverage.

Testing

Focused fake-backend recovery-lock, worktree-entry, and abort tests passed. Guarded live-lab preflights failed for absolute and relative isolated configurations; their refusal transcript was retained. All three live scenarios remain untested. No lab or fleet lifecycle was started, and disposable fixtures were removed.

  • Live validation: ⚠️ inconclusive - 0 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Exact recovery proceeds while a sibling projected spawn is blocked allocating its worktree ⏸️ untested no Focused fake-backend behavioral test passed, but is not live evidence. Guarded live-lab preparation failed with both absolute workspace-contained configuration (136-byte socket exceeds 103-byte limit)…
Default exact recovery refuses actual session-lock contention without mutating the projection ⏸️ untested no Focused fake-backend behavioral test passed, but no real Herdr scenario ran. Absolute isolated lab preparation exceeded the socket-path limit; the relative-path workaround lacked the required running-…
Opt-in waiting serializes concurrent exact recoveries and replaces only each task’s own husk ⏸️ untested no Focused fake-backend behavioral test passed, but no real Herdr scenario ran. Both workspace-contained preparation routes were blocked: absolute socket path too long and relative configuration missing…
Evidence: Guarded live-lab preflight refusals

Source: Guarded live-lab preflight refusals

Absolute isolated config: prepare refused a 136-byte socket path (maximum 103). Relative isolated config: prepare refused because no running default-session tripwire exists. No lab provisioned or fleet lifecycle commands issued.

Target: 7c77ffe049abc002b8c7082d8628813d966bd4ce

Absolute worktree-contained config, shortest allowed lab name:
fm-herdr-lab: session 'fm-lab-a' would bind a 136-byte socket path, over the 103-byte sun_path limit: {run-worktree}/.test-6454-tmp/c/herdr/sessions/fm-lab-a/herdr-client.sock
prepare exit=1

Relative worktree-contained config workaround:
fm-herdr-lab: fleet-state tripwire requires exactly one running default session
prepare exit=1

Disposable prepared-state files remaining:

No provision, stop, or delete issued; neither attempt established the mandatory tripwire.
  • Outcome: ⚠️ 1 warning across 1 run (3m58s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

⚠️ **Rebase** - 1 warning
  • ⚠️ tests/fm-backend-herdr-presentation-e2e.test.sh - merge conflict rebasing onto origin/main
✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (0 of 3 scenarios were driven live against the product); untested: Exact recovery proceeds while a sibling projected spawn is blocked allocating its worktree, Default exact recovery refuses actual session-lock contention without mutating the projection, Opt-in waiting serializes concurrent exact recoveries and replaces only each task’s own husk
  • Live validation: ⚠️ inconclusive - 0 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Exact recovery proceeds while a sibling projected spawn is blocked allocating its worktree ⏸️ untested no Focused fake-backend behavioral test passed, but is not live evidence. Guarded live-lab preparation failed with both absolute workspace-contained configuration (136-byte socket exceeds 103-byte limit)…
Default exact recovery refuses actual session-lock contention without mutating the projection ⏸️ untested no Focused fake-backend behavioral test passed, but no real Herdr scenario ran. Absolute isolated lab preparation exceeded the socket-path limit; the relative-path workaround lacked the required running-…
Opt-in waiting serializes concurrent exact recoveries and replaces only each task’s own husk ⏸️ untested no Focused fake-backend behavioral test passed, but no real Herdr scenario ran. Both workspace-contained preparation routes were blocked: absolute socket path too long and relative configuration missing…
  • TMPDIR="$PWD/.test-6454-tmp" bash tests/fm-spawn-herdr-lease.test.sh — exit 0; retained output at ~/.no-mistakes/evidence/01M8CA9SQRFM9D8TFH95QWF7EW/targeted-lease-tests.log.
  • bin/fm-herdr-lab.sh prepare fm-lab-a with absolute worktree-contained HOME, XDG_CONFIG_HOME, and lab-state directory — refused overlong socket path.
  • bin/fm-herdr-lab.sh prepare fm-lab-a with relative worktree-contained XDG_CONFIG_HOME — refused missing running-default-session tripwire.
  • Removed disposable worktree fixtures; verified clean git status and no remaining processes naming the disposable fixture root.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @ironerumi for bringing the #6454 fix upstream.

I read the tip (b6246e4e) against main 7099556d, not just the description. Recovery now passes mode recovery into spawn_herdr_presentation_order_lock_acquire, which allows 300 × 0.1s tries instead of 50 before the same hard refusal. Clean projected creates keep the 50-try bound and flat fallback, and --herdr-resume-lock-wait still opts into the unbounded wait. The e2e now forces the hold past the old window using FIFOs and a counting sleep shim instead of a wall-clock race, and it checks both the recovery and the 300-try refusal. No workflow or CI-script changes, nothing touching secrets. Your live Herdr 0.9.5 lab evidence is in the body, and the attestation matches the head.

contract-class: restore. On main, the default (no-flag) concurrent cross-home recovery in tests/fm-backend-herdr-presentation-e2e.test.sh is already expected to succeed, and it fails only when a legitimate holder outlives the 5s window. This brings that existing default path back without adding a new surface. Persistent contention still refuses.

Status: CI run 38974337684 is still in progress. Nothing is needed from you right now. If it goes green and stays mergeable, this is eligible to land. I'll come back once CI finishes.

@ironerumi

Copy link
Copy Markdown
Contributor Author

The only non-green job, Behavior portable serial 2, hit the 30-minute cap while the unchanged tests/fm-supervision-host.test.sh took 27.7 minutes here versus 20.6 minutes on main. This PR does not change that test; please re-run the job.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @ironerumi. You're right about the red check. I re-checked live, and head b6246e4e hasn't changed since my last review.

CI: on run 38974337684, Behavior portable serial 2 has now been CANCELLED at the 30-minute ceiling on both attempts (attempt 2 job 117231484758). There was no failing assertion before the cancel. In that shard, tests/fm-supervision-host.test.sh (which this PR doesn't touch) exited 0 after about 27.7 minutes, and then the shard ran out of budget. That's the known #7255 shard ceiling. Main hits it too: run 38977810251 on main 15ad1bd6 cancelled serial 2 the same way this evening. Every other check on this head is green, including Behavior tests (Herdr), which runs your updated e2e, and PR must be raised via no-mistakes. I'm not re-running it again, because another re-run won't clear a budget ceiling.

Contract-class: restore. Main already specifies that two homes recovering at the same time on default flags "serialize on the named session lock and each replace only their own exact husk" (tests/fm-backend-herdr-presentation-e2e.test.sh). The 5 s bounded try breaks that whenever a legitimate concurrent spawn holds the lock longer, which is the bug in #6454. This head keeps the same refusal and the same message, and lengthens only the recovery bound (300 tries, about 30 s of retry delay). Clean creates keep the 50-try bound and the flat fallback, and unbounded waiting stays behind the explicit --herdr-resume-lock-wait opt-in. The documented default "refuses on contention" now applies after 30 s instead of 5 s, and I've noted that timing change for Kun. The diff touches only bin/fm-spawn.sh, three docs, and the Herdr e2e: no workflows, no network, no secrets.

VISION.md, rule by rule: One captain (aligns: no spurious recovery refusal under ordinary concurrency, and persistent contention still refuses). Authority explicit (aligns: unbounded wait stays opt-in). Scripts own the mechanics (aligns: a bounded retry count, plus a deterministic FIFO test instead of a wall-clock race). Restart a non-event (aligns: recovering an existing journal is more reliable). Delegation with a spine (aligns: behavioral coverage of both the recovery and the bounded refusal). Outlives any vendor (aligns: Herdr backend plumbing only). Scope (aligns).

Outcome: waiting on Kun's decision. This is not waiting on you, and there's nothing more you need to do. Under a strict green gate I won't squash-merge while a required check shows cancelled. Whether to land it despite the #7255 ceiling is Kun's call, and I've passed it to him.

ironerumi added a commit to ironerumi/firstmate that referenced this pull request Nov 23, 2026
What: bin/fm-spawn.sh releases the session-wide presentation-order lock as
soon as the projected layout mutation is done, instead of holding it through
launch handoff; the e2e suite's concurrent resume opts into lock waiting.

Carried until upstream: kunchenguid#7430 (issue kunchenguid#6454), open, CI
green, currently conflicting with upstream main.

Sources: #69, #100.
# Conflicts:
#	tests/fm-backend-herdr-presentation-e2e.test.sh
…tion

A clean projected create or an exact resume now holds the session-wide
Herdr presentation-order lock only for the projected layout mutation and
releases it before the remaining spawn setup and the launch handoff. A
concurrent recovery therefore no longer gives up while a sibling spawn
finishes unrelated setup. Abort cleanup still re-acquires the lock before
any projection cleanup.

This replaces the earlier longer recovery retry: a resume again makes one
bounded attempt and refuses on contention by default, and the e2e suite's
concurrent resume opts into --herdr-resume-lock-wait so the two recoveries
serialize.
@ironerumi ironerumi changed the title fix: stabilize Herdr presentation recovery under lock contention fix: release Herdr presentation lock before spawn setup Nov 25, 2026
@ironerumi ironerumi changed the title fix: release Herdr presentation lock before spawn setup fix: hold the Herdr presentation lock only for the projected layout mutation Nov 25, 2026
ironerumi added a commit to ironerumi/firstmate that referenced this pull request Nov 25, 2026
…144)

What: updates item 17cb6f9 (release the Herdr presentation lock after the
layout mutation) to the version kunchenguid#7430 now carries.
bin/fm-spawn.sh releases the session-wide presentation-order lock at the end
of the shared projection/layout branch, before the Treehouse lease and slot
claim, so a sibling exact recovery is not refused while another projected
spawn is still allocating its copy.

Ported from kunchenguid#7430's head (fm/fm-6454-upstream): the lock-release move, its
docs/herdr-backend.md line, and the deterministic lease-suite coverage with
its stateful Herdr fake (tests/fixtures/herdr-projection-fake.py). The fork's
Treehouse fake keeps its no --root call shape.

Co-authored-by: YifuGu <[email protected]>
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @ironerumi. I read the new head 17c3701b (your earlier reviewed head was b6246e4e) against main 2f000eb4, which the head contains. It still merges cleanly onto current main cf24bc44.

Diff review (stands in for Greptile, offline since Nov 14): safe, no P1. The earlier longer-retry approach is gone. bin/fm-spawn.sh now releases the session-wide presentation-order lock right after the projected create or reclaim binding, before Treehouse allocation, and the later release before the launch Enter is removed. A default resume still refuses on contention, --herdr-resume-lock-wait still opts into waiting, and abort cleanup re-acquires the lock before any projection cleanup. The tests are deterministic (real fm-spawn.sh, fake Herdr and Treehouse, FIFO-synchronised) with a negative control.

Contract class: restore. Main already says concurrent recoveries serialize on the named session lock and each replace only their own husk. Closes #6454, and the Closes line is right. The no-mistakes attestation binds this head with no skipped steps. No threads, quick checks pass.

Not ready for Full yet: the live validation is 0 of 3, because your recorded decision prohibits real Herdr sessions. That leaves the lock-scope change with only fake-Herdr evidence, and this surface is live-testable, so I'm not adding full-ci. Kun decides whether the deterministic evidence is enough, or whether you can run the three scenarios on a real Herdr. Nothing is needed from you before that decision.

@ironerumi

Copy link
Copy Markdown
Contributor Author

Live validation on a real Herdr: 3 of 3 scenarios pass at head 17c3701b, and a live negative control with the pre-fix bin/fm-spawn.sh reproduces #6454.

Setup. Herdr 0.9.5, real Treehouse (test pools under a private TREEHOUSE_ROOT), tests/fm-backend-herdr-presentation-e2e.test.sh run unmodified at 17c3701b. Every Herdr call went through bin/fm-herdr-lab.sh on a named lab session (fm-lab-fm-herdr-present-22614-22100), never default. Lock timestamps come from a read-only 5 ms poller on the session's order-*.lock directory under /tmp/firstmate-herdr-presentation-<uid>, attributed by holder pid, because fm-spawn.sh doesn't log lock events itself.

Whole suite: 25/25 cases ok, ending with real Herdr lab validation completed on Herdr 0.9.5 with the fleet-session tripwire intact (exit 0, 21 min). The duplicate-token case listed under "Known unrelated failure" also passed here.

Scenario Live case Result
Exact recovery proceeds while a sibling projected spawn is allocating its copy default exact resume proceeds while a sibling projected spawn is allocating its copy ✅ pass (fails on pre-fix code)
Default exact recovery refuses real session-lock contention without mutation default resumed identity refuses session lock contention ✅ pass
--herdr-resume-lock-wait serializes concurrent exact recoveries, each replacing its own husk concurrent cross-home recoveries replace exact husks under one session lock with no focus drift + --herdr-resume-lock-wait waits out session lock contention instead of refusing ✅ pass

1. Sibling allocating. The sibling is parked inside treehouse get --lease. Its lock was already released, and the default resume got the lock:

23:08:35.314 ACQUIRED fm-spawn allocation-held-primary
23:08:39.178 RELEASED fm-spawn allocation-held-primary   # before its lease; now parked in treehouse
23:08:40.906 ACQUIRED fm-spawn wheel-child-resume         # default resume, no wait flag
23:08:44.267 RELEASED fm-spawn wheel-child-resume         # reached its own lease; exit 0

Negative control: I swapped in bin/fm-spawn.sh from base 2f000eb4 and left the test file unchanged. The holder kept the lock for 25.3 s through allocation (23:29:29.084 → 23:29:54.393). The resume never acquired it and refused: error: herdr presentation recovery could not acquire its session lock; refusing a concurrent resume. The suite stopped there with not ok - default exact resume did not reach allocation while sibling lease was held.

2. Default refusal. An unrelated process held the lock 23:11:30.366 → 23:11:45.472. No spawn acquired it in that window. The resume exited nonzero with refusing a concurrent resume, and the recorded pane id and focus were unchanged.

3. Opt-in serialization. Two homes ran concurrent --herdr-resume-lock-wait resumes:

23:10:17.845 ACQUIRED fm-spawn resume-wave-primary
23:10:22.925 RELEASED fm-spawn resume-wave-primary
23:10:23.049 ACQUIRED fm-spawn resume-wave-bravo     # 124 ms after release
23:10:27.716 RELEASED fm-spawn resume-wave-bravo

Both exited 0, each kept its workspace, got a new pane, and left neither old husk behind. Focus didn't change. Waiting out a 30 s holder: RELEASED 23:12:17.327 → ACQUIRED fm-spawn lock-refuse-resume-r1 23:12:17.446, exit 0, with the husk replaced.

The abort-cleanup case (concurrent post-create abort cleanup stays serialized with exact focus restoration) also passed live.

Teardown. Both lab sessions were removed with the helper's teardown, and the fleet-state tripwire passed. The session directories are gone, no lab processes remain, and the test pools are empty.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @ironerumi for running the three scenarios on a real Herdr, and for the negative control with the pre-fix bin/fm-spawn.sh. The lock timeline from the 5 ms poller is exactly the evidence this needed.

Where it stands on 17c3701b (unchanged since my review this morning, and it merges cleanly onto main 4b1d93d2): live validation is now 3 of 3 on Herdr 0.9.5, plus the abort-cleanup case and the whole 25-case suite. The pre-fix control reproduces #6454 (refusing a concurrent resume). That closes the only gap I'd left for Kun. Everything else holds: diff review safe (no P1), the no-mistakes attestation binds this head with no skipped steps, quick checks pass, 0 review threads, and Fixes #6454 is right.

Contract class: restore. VISION is as in my earlier comments.

I'm adding full-ci now. It's the last gate. If the full suite passes on this head, this restore merges. Nothing is needed from you.

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

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate.

@ironerumi the labelled Full run on head 17c3701b (run 45851368710) failed in one lane only, Lint 3, and the failure is in this PR's own new test file:

In tests/fm-spawn-herdr-lease.test.sh line 407:
PROJECTION_PIDS+=("$!")
^-- SC2031 (info): ! was modified in a subshell. That change might be lost.

CI lints changed files with ShellCheck 0.11.0's full extended checks (FM_LINT_CHANGED=1), so info-level findings fail there too. Every other lane passed. Either keep the &/$! capture out of the subshell or command group that ShellCheck flags, or add a narrowly scoped # shellcheck disable=SC2031 with a one-line reason if the capture really is in the parent shell.

This PR is now waiting on you, not on a captain hold. I'm leaving the full-ci label on, so your next push re-runs Full. Please send the fix through git push no-mistakes so the attestation binds the new head with zero skipped steps.

Run the projection lock holder as a backgrounded function so ShellCheck's
extended analysis no longer reports SC2031 on the parent's $! capture.
@ironerumi ironerumi changed the title fix: hold the Herdr presentation lock only for the projected layout mutation fix: narrow Herdr presentation lock scope Nov 26, 2026
@kunchenguid
kunchenguid merged commit 4fc4cae into kunchenguid:main Nov 26, 2026
34 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @ironerumi — really appreciate you taking the time on this.

(Squashed as 4fc4caec on head 7c77ffe0: the Lint 3 fix kept everything else identical, and the labelled Full suite passed on it. The PR body lost its Fixes #6454 line in the last no-mistakes raise, so I'm closing #6454 by hand.)

rub-a-dub-dub added a commit to rub-a-dub-dub/firstmate that referenced this pull request Nov 27, 2026
* ci: pack every job to ~15 min from measured timings, warn at 20 min, faster lint (kunchenguid#8431)

* Port of kunchenguid#7390: per-secondmate Treehouse pool outside the home (kunchenguid#8718)

* fix(bin): spawn a secondmate's ships from a pool of its own clone

Treehouse names a pool from the repository basename and origin URL alone, so a
secondmate home's standalone clone of a project resolved to the same default
pool as the root home's clone, whose slots are worktrees of the root clone.
fm-spawn then stopped at Claude trust registration with "not a worktree of
project".

The root home keeps Treehouse's default pool unchanged. Every other local home
now passes `treehouse --root <home state>/treehouse get`, so its slots are
worktrees of its own clone; a remote home is the root of its own machine and
keeps the default. The worktree-of-project checks are untouched.

* fix(bin): require treehouse --root support at bootstrap

A local secondmate spawn now types `treehouse --root <dir> get`, and --root
arrived in treehouse 2.2.0 while --lease dates from 1.8.0, so a treehouse that
passed the lease-only gate could still lack it. Bootstrap now reports such an
install as an upgrade request.

* no-mistakes(test): Teach secondmate-pool test fake tmux to list windows

* no-mistakes(document): Raise CI Treehouse pin to 2.3.0 for --root

* test(spawn): cover a local secondmate's Herdr lease from its own pool

* fix(bin): keep secondmate Treehouse pools outside the home

Root a local secondmate's pool at
${TREEHOUSE_ROOT:-$HOME/.treehouse}/fm-secondmate/<home-id> so a slot's
ancestors never include that home's CLAUDE.md or AGENTS.md.

Co-authored-by: Kun Chen <[email protected]>

* fix(bin): refuse in-home Treehouse roots and drop secondmate pools on teardown

Review-2 corrections on the outside-home pool move: ignore a relative
TREEHOUSE_ROOT, refuse a root under the home, skip fm-secondmate pools in
the duplicate-clone check, drop the unused state-dir parameter, and remove
a secondmate's per-home pool when the home is removed.

Co-authored-by: Kun Chen <[email protected]>

---------

Co-authored-by: Hamish Gray <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Kun Chen <[email protected]>

* Raise Treehouse pin to 3.1.8 and floor to 3.0.1 (kunchenguid#8733)

* fix(bin): treat a watcher beacon stamped ahead of the clock as fresh (kunchenguid#8720)

* fix(guard): treat a beacon stamped ahead of the clock as fresh

fm_watcher_supervision_verdict ran a negative beacon age through its digit
test, so a beacon one or two seconds ahead of the guard's clock read left the
watcher looking down and printed the full banner. Clamp a negative age to 0
before the test, matching fm_watcher_healthy.

* no-mistakes(document): document future-stamped beacon guard coverage

* feat: follow captain-named PRs with direct outcome lines (kunchenguid#8598)

* feat: follow requested PRs without model turns

* no-mistakes(review): announce only new PR conditions; bound poll pass

* no-mistakes(review): validate check timeout; always read one follow

* no-mistakes(test): load private Calm mod copy in live follow test

* no-mistakes(document): index PR follow in script, layout and Calm docs

* fix: expose PR follow guidance only after opt-in

* no-mistakes(document): note opt-in follow line in session-start header

* no-mistakes(review): prove Pi follow surface by lock owner alone

* no-mistakes(review): accept only published follow surface values

* fix: tolerate missing Pi session start context

* no-mistakes(review): keep Calm replay and shown cursor in one sequence

* feat(bin): add opt-in answer words for captain-hold answers (kunchenguid#8161)

* Preserve selected captain answers

* no-mistakes(review): Guard option answers and keep one selected line

* no-mistakes(review): Say when the selected-answer line is absent

* no-mistakes(document): Document option-word guard and selected answer

* no-mistakes(ci): Fixed both Greptile findings in bin/fm-captain-hold.sh and extended tests/fm-captain-hold-lifecycle.test.sh. The timed-out prior agent had left uncommitted edits in this worktree covering both findings; I reviewed them, kept them, simplified the marker matching to one pattern set, and aligned the help text. ci-2 (spaces bypass the option guard). Invariant: an answer that is only an option selection never closes a call without its displayed words, regardless of surrounding blanks. is_option_selection now trims leading and trailing whitespace before matching, so both intake points (load_decision for direct `answer`, and the keyed `answers` row loop) reject `A ` and ` b`. The keyed label check uses a new is_blank helper, so a whitespace-only label counts as missing. The original answer and label text are still what gets stored. Help text for `answer` and `answers` now says surrounding blanks are ignored and a blank label skips the row. Tests: shapes `A ` and ` b` added to the direct-answer refusal loop and the keyed-answer skip loop, plus a keyed row `A` with label ` ` asserting the `skipped:` message and `held: yes`. ci-3 (first-line answers missed). Invariant: an `Answer as shown to the captain:` marker wins over `Answer:` wherever either appears, including on the first line. resolution_block now prefixes the decision text with one newline and matches `\nAnswer as shown to the captain: ` and `\nAnswer: ` against that prefixed text, so a first-line marker is found by the same pattern as any later line, and the displayed-answer arm is checked first. Multi-line text with no marker still writes no Selected answer line, and single-line free text is still selected whole. Tests: a decision file starting with `Answer: Off until checks pass.` and one starting with `Answer as shown to the captain: ...` followed by `Answer: A`, both asserting `Selected answer: Off until checks pass.`. Verification: shellcheck -x passes on both files. A direct harness sourcing is_blank, is_option_selection, and resolution_block confirmed every reported sequence. bin/fm-test-run.sh tests/fm-captain-hold-lifecycle.test.sh ran the whole suite: every test passed up to the final one, test_archived_answer_in_a_user_configured_archive_satisfies_the_gate, which failed with "compatible tasks-axi is required". That test redirects HOME, and on this host tasks-axi is a node script behind a mise shim that refuses to run under a redirected HOME (mise "config not trusted" error, reproduced with HOME=tmpdir tasks-axi --version). It is a host environment issue, not caused by this change. Rerunning test_answer_records_and_closes, test_option_answers_keep_their_displayed_words, and both archive tests with /home/firstmate/.local/share/mise/installs/node/22.23.1/bin ahead on PATH passed all four. Changes are confined to bin/fm-captain-hold.sh and tests/fm-captain-hold-lifecycle.test.sh; no full-ci label was requested or added

* no-mistakes(review): Ignore blank answer labels and drop skill step 8

* no-mistakes(document): Document blank-label handling in keyed answers

* no-mistakes(ci): I added the missing interview example to `.agents/skills/captain-hold-lifecycle/SKILL.md`, under step 5 of the operating sequence. The Greptile Review finding ci-1 was correct: the step described the interview in prose but showed no concrete call. Invariant: the skill must show one concrete interview that registers a call, presents a keyed question, feeds the answer, and verifies closure. Step 5 is the only place in the changed area that describes the interview, so there are no sibling sites. The example uses task id `sample-start-state` and the question `Should the feature start enabled? A: Off until checks pass. B: On now.`. It shows three commands: `bin/fm-captain-hold.sh hold` to register the call, a `printf 'sample-start-state\tA\tOff until checks pass.\n'` row piped into `bin/fm-captain-hold.sh answers --source "captain interview"`, and `tasks-axi show sample-start-state --full`. A closing sentence says the last command must print `state: done` and `Selected answer: Off until checks pass.`. I took the command shapes and expected output from the existing test `test_option_answers_keep_their_displayed_words` in `tests/fm-captain-hold-lifecycle.test.sh` and from the usage header of `bin/fm-captain-hold.sh`. The example omits `--repo` because `hold` defaults a new task's repo to `firstmate`. The change is 11 added lines in that one file. I changed no code and no tests. Not tested: I did not run the example commands or any test suite, because the driver instructions for this round say it is documentation-only and to run no tests. The commit named in the driver instructions (38e0f30) touches only `bin/fm-captain-hold.sh` and the test file, so it took no example away from the skill

* fix: make answer-word enforcement opt-in

* no-mistakes(review): List hold-answer-words in home layout inventory

* fix: publish extension packages on macOS before making them read-only (kunchenguid#8744)

installPackage made the staged package root 0555 and then renamed it into
the content-addressed store. macOS rename(2) refuses to move a directory its
owner cannot write, so every extension package install failed with EACCES.
Keep the staged root owner-writable for the rename, then set the installed
root to 0555; installed-package validation is unchanged.

tests/fm-extension-binding.test.sh restores owner write before moving an
installed package aside and restores 0555 when moving it back.

Fixes kunchenguid#8739.

* fix: report an incompatible remote tasks-axi as OUTDATED (kunchenguid#8743)

bin/fm-remote-doctor.sh reported an installed but incompatible tasks-axi as
`required tasks-axi=MISSING (incompatible)`, telling the operator to install a
tool that is already present. It now reports `OUTDATED (incompatible)` while
an absent tasks-axi stays `MISSING`; both still fail readiness and name
tasks-axi among the required-tool gaps, and the worker-probe parser accepts
an OUTDATED result instead of rejecting the probe as invalid.

The entrypoint's pinned DOCTOR_SHA256 follows the new doctor bytes.

Fixes kunchenguid#8740

* feat(bin): add opt-in reports to the PR health monitor (kunchenguid#8773)

* feat(bin): add opt-in reports to the PR health monitor

Each new report needs its own config file and stays off until that file exists.
A failing check, required or not, wakes only after a second pass still sees it.
Approved and green never starts a merge.
A merged or closed pull request names the account once and is not read again.
A change request on an older commit waits on the reviewer.

* no-mistakes(review): Baseline already-final PRs silently when final report is on

* no-mistakes(review): Gate final report on open_seen marker

* no-mistakes(review): Drop open_seen on flag-off reads

* no-mistakes(review): Clear open_seen on each flag-off poll

* fix(lock): never record an omp daemon worker as the session (kunchenguid#8731)

omp's daemon broker (omp __omp_worker_daemon_broker) runs every bash call made with name, carries the bare process name omp, and is shared by every omp in one project directory, so it outlives sessions and its parent is whichever omp started it. A named bin/fm-session-start.sh call recorded the broker in state/.lock, which then pinned the home's lock: every later session saw another live firstmate session holding it and supervision never started (omp 18.8.0-18.8.4).

The lock library now rejects omp __omp_worker_* processes as harnesses and stops its ancestry walk at one, so a worker-pinned lock reads stale and the session reclaims it, and a lock-taking script run under a worker refuses with a message naming the cause instead of recording the wrong pid. The omp protocol and harness reference say to run lock-taking scripts as ordinary bash calls.

(cherry picked from commit defe8dc)

Co-authored-by: Aviv Laufer <[email protected]>

* feat: add opt-in Pi Bash timeout cap (kunchenguid#8445)

* feat(pi): add opt-in bash timeout cap

* no-mistakes(review): Convert Pi Bash timeout caps from milliseconds to seconds

* no-mistakes(document): Clarify Pi Bash timeout configuration and scope

* no-mistakes(ci): Captain, added the missing test-duration hint and documented its provisional local measurement. The coverage guard now passes within both limits. Five focused test runs, lint, and documentation checks passed. Full suite remains blocked by the maintainer’s full-ci label requirement; that external approval condition needs no code change

* test(pi): isolate timeout test extension state

* no-mistakes(test): Reject Pi Bash timeout settings above native timer limit

* feat(pi): add opt-in bash timeout cap

* no-mistakes(review): Convert Pi Bash timeout caps from milliseconds to seconds

* no-mistakes(document): Clarify Pi Bash timeout configuration and scope

* no-mistakes(ci): Captain, added the missing test-duration hint and documented its provisional local measurement. The coverage guard now passes within both limits. Five focused test runs, lint, and documentation checks passed. Full suite remains blocked by the maintainer’s full-ci label requirement; that external approval condition needs no code change

* test(pi): isolate timeout test extension state

* no-mistakes(test): Reject Pi Bash timeout settings above native timer limit

* chore: align test runner with main timing source

* no-mistakes(review): Remove duplicate timeout timing note

---------

Co-authored-by: mehulbhagwani <[email protected]>
Co-authored-by: Pitch Perfekt Collective <[email protected]>
Co-authored-by: Kun Chen <[email protected]>

* fix: narrow Herdr presentation lock scope (kunchenguid#7430)

* fix(spawn): give presentation recovery a longer bounded lock wait

* no-mistakes(document): Updated Herdr lock-recovery documentation

* no-mistakes(document): Restored authoritative Herdr reclaim fallback rule

* no-mistakes(document): Clarified Herdr reclaim documentation ownership

* fix(spawn): release the Herdr presentation lock after the layout mutation

A clean projected create or an exact resume now holds the session-wide
Herdr presentation-order lock only for the projected layout mutation and
releases it before the remaining spawn setup and the launch handoff. A
concurrent recovery therefore no longer gives up while a sibling spawn
finishes unrelated setup. Abort cleanup still re-acquires the lock before
any projection cleanup.

This replaces the earlier longer recovery retry: a resume again makes one
bounded attempt and refuses on contention by default, and the e2e suite's
concurrent resume opts into --herdr-resume-lock-wait so the two recoveries
serialize.

* no-mistakes(review): Release presentation lock before allocation

* no-mistakes(test): Cover Herdr recovery lock scope deterministically

* no-mistakes(document): Consolidate Herdr reclaim recovery guidance

* no-mistakes(lint): Check replacement endpoint command status directly

* test(spawn): capture the lock holder pid outside a subshell

Run the projection lock holder as a backgrounded function so ShellCheck's
extended analysis no longer reports SC2031 on the parent's $! capture.

* test: make behavior fixtures portable and isolated on macOS (kunchenguid#8756)

* test: portable fixtures for macOS hosts and hermetic operator environments

Fixture-only changes so these suites pass on a macOS operator host and no
longer read or write the operator's live environment: a GNU stat shim
(fm_fake_gnu_stat) for fixtures that fake a non-Darwin uname, sed -i.bak,
canonical /tmp socket paths, a PATH_MAX-aware deep-path case,
order-independent directory reads and structurally built manifest
corruptions, FIFO gates in place of sleeps, scrubbed dispatch credentials,
a scratch FM_HOME in the spawn-batch and teardown cases, and wider bounds
in two timing-sensitive cases.

Fixes kunchenguid#8741

* no-mistakes(test): Fix watcher timing; extension install still blocked

* no-mistakes(test): Stabilize source race; extension install still blocked

* test: keep the late-launch check main-equivalent so it holds on non-exec bash

* no-mistakes(review): add missing fm-pi-bash-timeout serial timing hint row

* no-mistakes(review): revert out-of-scope fm-pr-poll quoting sweep to parent spelling

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Hamish Gray <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: Tiago <[email protected]>
Co-authored-by: YifuGu <[email protected]>
Co-authored-by: Tim Kleinschmidt <[email protected]>
Co-authored-by: Aviv Laufer <[email protected]>
Co-authored-by: Mehul Bhagwani <[email protected]>
Co-authored-by: mehulbhagwani <[email protected]>
Co-authored-by: Pitch Perfekt Collective <[email protected]>
hoang-ross-dinh added a commit to hoang-ross-dinh/firstmate that referenced this pull request Nov 30, 2026
* origin/main: (99 commits)
  feat(bin): reclaim returned Treehouse pool slot disk at teardown (kunchenguid#8778)
  fix(omp): consume every watcher wake omp merges into one message (kunchenguid#8711)
  fix: keep watcher liveness beacon fresh during long cycles (kunchenguid#8823)
  feat(calm): add selectable spaceship working presentation (kunchenguid#8769)
  fix(bin): pin secondmate retirement process-event calls to the retiring home's state (kunchenguid#8785)
  fix(bin): read the PR scan past a review wait on the same PR (kunchenguid#8786)
  fix: support wrapped Claude composer readback (kunchenguid#8501)
  fix: support newer Codex releases for native Stop parking (kunchenguid#8174)
  fix(calm): pass Claude Code 2.1.326 strict plugin validation (kunchenguid#8565)
  fix(watch): absorb turn-end wakes after a user-aborted no-mistakes run (kunchenguid#8708)
  feat(bin): choose a codex account per ship or scout from a declared list (kunchenguid#8457)
  fix(bin): exec the herdr lab server launch so a timed-out provision cancels it (kunchenguid#8779)
  fix(bearings): stop truncating Charted Next titles and reasons on the lavish board (kunchenguid#6357)
  test: make behavior fixtures portable and isolated on macOS (kunchenguid#8756)
  fix: narrow Herdr presentation lock scope (kunchenguid#7430)
  feat: add opt-in Pi Bash timeout cap (kunchenguid#8445)
  fix(lock): never record an omp daemon worker as the session (kunchenguid#8731)
  feat(bin): add opt-in reports to the PR health monitor (kunchenguid#8773)
  fix: report an incompatible remote tasks-axi as OUTDATED (kunchenguid#8743)
  fix: publish extension packages on macOS before making them read-only (kunchenguid#8744)
  ...

Resolved conflicts by hunk:
- bin/fm-procevent.sh
- bin/fm-spawn.sh
- bin/fm-test-run.sh
- docs/configuration.md
- docs/fm-test-portable-shards.md
- docs/scripts.md
- tests/fm-session-lock-ancestry.test.sh
- tests/fm-spawn-batch.test.sh
- tests/fm-spawn-dispatch-profile.test.sh
- tests/fm-turnend-guard.test.sh
- tests/lib.sh

Carried the local recap publish timing hint into tests/fm-test-ci-timings.tsv.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants