Skip to content

feat: add crash and reboot resilience for firstmate - #51

Closed
tommy230 wants to merge 14 commits into
kunchenguid:mainfrom
tommy230:fm/crash-resilience
Closed

tommy230 wants to merge 14 commits into
kunchenguid:mainfrom
tommy230:fm/crash-resilience

Conversation

@tommy230

Copy link
Copy Markdown

What Changed

  • Adds crash/reboot autostart support with install/status/uninstall helpers, a systemd unit, and a resume watchdog that recreates the firstmate tmux session when needed.
  • Hardens runtime coordination by moving wake locking to atomic O_EXCL file locks, preserving legacy lock compatibility, and tightening spawn/teardown safety checks.
  • Documents the new recovery/autostart flow and adds focused coverage for autostart rendering, resume behavior, lock exclusivity, spawn worktree validation, teardown guards, and wake queue locking.

Risk Assessment

⚠️ Medium: Captain, the review found no material merge blockers, but the change touches systemd startup, tmux recovery, and custom shell locking, so residual cross-environment risk is higher than a small bounded patch.

Testing

Captain, I ran the targeted regression tests for lock atomicity, resume/autostart behavior, spawn worktree detection, teardown safety, and wake-queue supervision; then manually demonstrated the operator-facing CLI flow for autostart rendering and fm-resume session resurrection. All checks passed, with no UI surface involved, so no screenshot evidence was applicable.

Evidence: Relevant shell test transcript
ok - wake-queue lock is mutually exclusive under contention (4 workers)
ok - lock reclaims a dead holder but never a live one
ok - lock preserves fresh legacy empty-pid directories
ok - fm-resume creates the session and launches firstmate with the right context
ok - fm-resume is idempotent (no duplicate session)
ok - fm-resume --watch does not create an empty session after launch inference failure
ok - fm-resume --watch does not create an empty session after harness binary lookup failure
ok - fm-install-autostart renders firstmate.service from the active checkout
ok - spawn accepts a registered worktree outside the project tree
ok - local-only worktree with HEAD on a fork remote is torn down (fix holds)
ok - local-only worktree with truly unpushed work is refused (safety preserved)
ok - local-only worktree with work merged into local main is torn down (no regression)
ok - no-mistakes worktree with HEAD on origin is torn down (no regression)
ok - no-mistakes worktree with truly unpushed work is refused (no regression)
ok - local-only worktree with unpushed work is torn down under --force (escape hatch)
ok - untracked generated hook files do not block teardown
ok - tracked .claude/settings.local.json changes block teardown
ok - supervise daemon state root is scoped by FM_HOME
ok - concurrent append plus drain preserves queue records
ok - signal written while no watcher runs is caught on next run
ok - stale wake is queued before suppressor state is advanced
ok - check output is queued before cadence suppression
ok - simultaneous watcher starts leave exactly one live process
ok - two atomic drains cannot consume the same records twice
ok - drain collapses obvious duplicate heartbeat and signal records
ok - killed watcher stale lock is reclaimed
ok - live watcher lock with stale heartbeat is actionable
ok - guard warns when queued wakes are pending
ok - guard orders watcher re-arm after queued wake drain
ok - routine signal self-handles
ok - captain-relevant status verbs escalate
ok - check + unknown escalate; heartbeat self-handles
ok - transient stale self-handles and records a persistence marker
ok - stale + terminal status escalates immediately
ok - persistent stale escalates after threshold and clears its marker
ok - resumed (busy) stale clears its marker without escalating
ok - multiple escalations flush as a single batched digest
ok - batch flush measures max-delay from the first append, not the last
ok - catch-all scan escalates a missed terminal once, not twice
ok - handle_wake routes routine->self and captain->escalate
ok - INJECT_SKIP forces self-handle, bypassing captain-relevant classification
ok - is_wake_reason distinguishes watcher wake reasons from singleton-status stdout
ok - terminal-stale escalate removes its marker so housekeeping does not re-escalate
ok - captain signal escalate marks seen so the catch-all scan does not re-fire
ok - _collapse_newlines replaces newlines with literal separator
ok - afk flag absent: daemon does not inject, buffer preserved
ok - afk flag present: daemon injects with sentinel marker prefix
ok - injected digest is single-line (no embedded newlines)
ok - busy-guard defers injection when supervisor pane is busy
ok - marker detection: marker -> stay afk, no marker -> exit afk
ok - /afk invocation is exempt from afk exit (no self-cancel)
ok - should_exit_afk returns false when afk is not active
ok - strip_injection_marker removes the sentinel marker cleanly
ok - pane_input_pending detects partial input on the cursor line
ok - pane_input_pending: blank cursor line is not pending
ok - pane_input_pending: bare prompts are not pending (idle)
ok - composer guard defers injection when pane has pending input
ok - swallowed Enter: type-once + Enter-retry, no concatenation
ok - normal inject: exactly one digest, one Enter, no duplicates
ok - classify_signal dedupes against the catch-all scan seen marker
ok - classify_stale dedupes against the signal path seen marker
Evidence: Rendered firstmate.service
[Unit]
Description=Firstmate persistent supervisor session (crash/reboot resilience)
Documentation=https://github.com/kunchenguid/firstmate
# Wait for the Windows drive mounts; the orchestrator account config lives under
# /mnt/c. Non-fatal if the mount unit name differs - the resume script retries.
After=local-fs.target

[Service]
Type=simple
User=captain
WorkingDirectory="/Users/thomascarney/.no-mistakes/worktrees/73d6a10257e9/01KVTJ77EVGGTJX83VHV0SGHAN"
Environment="HOME=/var/folders/kg/vqcvwwlx3xs4wblm4wpvpkz00000gn/T/no-mistakes-evidence/01KVTJ77EVGGTJX83VHV0SGHAN/home"
Environment="FM_FIRSTMATE_COMMAND=exec /var/folders/kg/vqcvwwlx3xs4wblm4wpvpkz00000gn/T/no-mistakes-evidence/01KVTJ77EVGGTJX83VHV0SGHAN/fake-codex --dangerously-bypass-approvals-and-sandbox"
# The watchdog: ensure the firstmate tmux session exists, re-checking forever.
# On VM boot this recreates the session; if the loop itself ever dies, Restart
# brings it back. The loop re-execs nothing destructive - it no-ops when the
# session is already live.
ExecStart="/Users/thomascarney/.no-mistakes/worktrees/73d6a10257e9/01KVTJ77EVGGTJX83VHV0SGHAN/bin/fm-resume.sh" --watch
Restart=always
RestartSec=10
# Kill ONLY the watchdog loop on stop/restart, never the tmux server it guards.
# This makes firstmate survive `systemctl restart firstmate` and decouples the
# supervisor session's lifetime from this unit: the service is a guardian, not
# the owner. To fully stop firstmate, kill its tmux session directly.
KillMode=process

[Install]
WantedBy=multi-user.target
Evidence: Autostart installer CLI transcript

installed and enabled firstmate.service firstmate will now auto-resurrect on every boot and self-heal if it dies. --- unit --- enabled: no active: no --- session --- firstmate tmux session: not present

installed and enabled firstmate.service
firstmate will now auto-resurrect on every boot and self-heal if it dies.
--- unit ---
enabled: no
active: no
--- session ---
firstmate tmux session: not present
Evidence: fm-resume create transcript

fm-resume: created session 'evidence-firstmate' running firstmate

fm-resume: created session 'evidence-firstmate' running firstmate
Evidence: fm-resume idempotent transcript

fm-resume: session 'evidence-firstmate' already live

fm-resume: session 'evidence-firstmate' already live
Evidence: Firstmate launch evidence

fake codex launched: cwd=/Users/thomascarney/.no-mistakes/worktrees/73d6a10257e9/01KVTJ77EVGGTJX83VHV0SGHAN args=--dangerously-bypass-approvals-and-sandbox

fake codex launched: cwd=/Users/thomascarney/.no-mistakes/worktrees/73d6a10257e9/01KVTJ77EVGGTJX83VHV0SGHAN args=--dangerously-bypass-approvals-and-sandbox

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (8) ✅
  • ⚠️ bin/fm-wake-lib.sh:98 - Legacy directory locks with an empty or not-yet-written pid are reclaimed immediately. During a rolling update, an old mkdir-based holder can create the directory before writing pid; this branch will remove that fresh live lock and allow a second holder. Apply the same fresh-empty stale grace used for file locks before rm -rf.
  • ⚠️ bin/fm-resume.sh:32 - Autostart defaults are machine- and harness-specific: the service launches Claude with /mnt/c/Users/Owenz/.claude-orchestrator. In this shared repo, a default install on another user, another Windows profile, or a Codex/opencode firstmate will resurrect the wrong command or fail. Decide whether to render configured harness/bin/config into the unit or keep this intentionally single-machine.

🔧 Fix: Captain, fix autostart and legacy lock races
1 error still open:

  • 🚨 tests/fm-lock-exclusivity.test.sh:1 - CI executes every tests/*.test.sh directly, but this new test and tests/fm-resume.test.sh were added with mode 100644, so the behavior-test job will hit Permission denied before running them. Commit both with executable mode 100755.

🔧 Fix: Captain, make new tests executable
2 issues (1 error, 1 warning) still open:

  • 🚨 systemd/firstmate.service:10 - The systemd unit always runs the resumed session as root. A normal captain running firstmate as their own user will get a separate root-owned tmux server, root HOME/config/auth, and tmux attach -t firstmate from their account will not see the resurrected session. Render the intended user into the unit or make this a user service.
  • ⚠️ bin/fm-teardown.sh:398 - The dirty check now ignores any status line containing .claude/settings.local.json, including tracked or modified files. If a project tracks that path, teardown can proceed and then rm -f it, discarding unlanded work. Restrict the exclusion to the generated untracked file, or rely on the git-info exclude path instead of suppressing tracked changes.

🔧 Fix: Fix autostart user and teardown dirty check
3 issues (2 warnings, 1 info) still open:

  • ⚠️ bin/fm-install-autostart.sh:118 - firstmate_command failures are hidden by the nested command substitution, so an unknown harness or missing binary can still install a unit with FM_FIRSTMATE_COMMAND= blank. Capture the raw command with command=$(firstmate_command) || return 1 before quoting, so install fails instead of writing a broken autostart unit, captain.
  • ⚠️ bin/fm-resume.sh:93 - In --watch mode, ensure_session || true disables errexit inside the function; if firstmate_command fails here, the function continues, creates the tmux session, sends only cd <root> &&, and future iterations no-op because the empty session now exists. Explicitly return on launch-command failure before tmux new-session.
  • ℹ️ bin/fm-install-autostart.sh:173 - The status fallback never runs when systemctl is-enabled or is-active fails because the failing command is piped into sed without pipefail; a missing unit prints neither enabled: no nor active: no. Use an if or enable pipefail for these checks.

🔧 Fix: Captain, fix autostart failure handling
1 warning still open:

  • ⚠️ bin/fm-install-autostart.sh:152 - The installer needs system privileges for /etc/systemd/system, but the unit is rendered in the same process that performs the privileged install. A normal user run can infer the active harness but fails at install; a sudo run can write the unit but commonly loses the harness ancestry, user PATH, and nvm-installed binary paths, so default install can fail or require undocumented env overrides. Render the unit as the invoking user before privilege escalation, or document/enforce the required sudo -E/FM_FIRSTMATE_COMMAND flow.

🔧 Fix: Captain, fix autostart privilege split
1 error still open:

  • 🚨 bin/fm-spawn.sh:333 - fm-spawn.sh now accepts only pane cwd paths containing /.treehouse/, but treehouse get can return worktrees outside the project, for example the installed treehouse status reports paths under ~/.treehouse/.... Those valid spawns will wait 60s and fail even though the subshell entered a worktree. Validate the cwd as a git worktree for $PROJ_ABS instead of hardcoding the path substring.

🔧 Fix: Captain, validate spawn worktrees by git registration
2 warnings still open:

  • ⚠️ bin/fm-install-autostart.sh:69 - If FM_FIRSTMATE_HARNESS names a supported harness but the binary is not on PATH and no FM_<HARNESS>_BIN override is set, firstmate_bin returns nonzero but the caller continues with an empty bin because it is invoked under raw_command=$(firstmate_command) || return 1. This can install a unit with a broken exec --... launch command; make each bin=$(firstmate_bin ...) explicitly || return 1, captain.
  • ⚠️ bin/fm-resume.sh:60 - The same missing-binary path exists in direct fm-resume.sh use: a supported-but-unavailable harness can produce an empty exec command, create the tmux session, and then future watchdog iterations no-op because the session exists. Explicitly return when firstmate_bin fails before building the launch command.

🔧 Fix: Captain, guard missing harness binaries
1 warning still open:

  • ⚠️ bin/fm-wake-lib.sh:102 - Legacy stale directory cleanup now uses rm -rf "$lockfile"; if two new processes race on the same stale legacy lock, one can remove the directory while another creates the new O_EXCL file lock, and the delayed rm -rf can delete that live file lock. Move the legacy directory aside first, or remove it with pid-file plus rmdir, so cleanup cannot unlink a replacement lock.

🔧 Fix: Captain, harden legacy lock cleanup
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • tests/fm-lock-exclusivity.test.sh
  • tests/fm-resume.test.sh
  • tests/fm-install-autostart.test.sh
  • tests/fm-spawn-worktree.test.sh
  • tests/fm-teardown.test.sh
  • tests/fm-wake-queue.test.sh
  • Manual bin/fm-install-autostart.sh install using fake systemd tools with FM_UNIT_DST writing rendered-firstmate.service into the evidence directory
  • Manual bin/fm-resume.sh create/no-op run against an isolated tmux socket, verifying the fake firstmate process launched from the worktree with the expected codex bypass argument
  • git status --short to confirm no working-tree artifacts remained
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

root and others added 14 commits June 23, 2026 15:17
…ocal.json in dirty check

fm-spawn waits specifically for a */.treehouse/* cwd rather than any change off
the project dir, so a transient default-cwd reading is never misrecorded as the
worktree. fm-teardown's dirty check ignores the tracked .claude/settings.local.json
that the turn-end hook modifies, so teardown is not blocked by firstmate's own hook.
Crash/reboot resilience: a WSL VM teardown (host sleep, idle timeout, Windows
Update reboot) kills tmux and every crewmate at once and nothing relaunched
firstmate afterward. systemd/firstmate.service runs bin/fm-resume.sh as a
watchdog that recreates the persistent firstmate tmux session on boot and
self-heals if it dies (KillMode=process, so stopping the unit never kills a live
firstmate). bin/fm-install-autostart.sh installs/removes it. Pair with
~/.wslconfig vmIdleTimeout=-1 to prevent the idle teardown in the first place.

Lock correctness: the wake-queue/singleton lock used mkdir as its atomic
primitive, but mkdir is NOT atomic on WSL2's filesystem (verified: 4 concurrent
mkdir calls succeeded on one path in a barrier race), so the lock double-granted
under contention - duplicate watchers, raced wake-queue drains, flaky tests.
Replaced with an O_EXCL (noclobber) create, atomic on Linux, WSL2, and macOS,
which also writes the holder pid in the same step (no empty-pid window). Dead
holders are reclaimed in one call; a live holder's lock is never stolen.

Tests: fm-lock-exclusivity (canonical mutex probe + reclaim) and fm-resume
(base-index-safe create + idempotency) guard both fixes; the singleton-start
test now polls for the invariant instead of a fixed sleep.
@villestenstrom

Copy link
Copy Markdown

@greptileai review

fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
…nchenguid#55)

* docs(toolchain-manifest): add verified opencode row, correct absence notes

Isolated toolchain probes on 2026-08-03 produced the verification this file
was explicitly waiting for on opencode, and disproved one of its stated facts.

The header claimed the local opencode install had "no platform binary". It has
one and it runs: opencode-darwin-arm64/bin/opencode reports 1.18.3. The install
is unusable because the package's postinstall never ran, so bin/opencode.exe is
still the shipped 479-byte error stub and npm produced no PATH symlink. That is
a wiring defect, not a missing build, and the note now says so.

Add the opencode row. This file's rule is that a runtime is listed once its
--version output has been parsed on a real machine, and the header named that as
the pending action. The parse happened twice here: 1.18.3 from the platform
binary above, and 1.17.18 from an isolated scratch-prefix install of the
certified build. certified is transcribed from docs/watcher-continuity.md, not
guessed. The row stays silent until opencode is back on PATH, per this file's
absent-binary contract.

Sharpen the grok note from "not installed here" to the measured cause: the x.ai
installer left a truncated 59170816-byte download under ~/.grok/downloads and an
empty ~/.grok/bin. That is 48.7% of the 121600480-byte certified artifact, and
the partial binary is SIGKILLed on launch as an unsigned Mach-O. No grok row is
added, because no --version output could be parsed.

Pi and quota-axi certified versions are deliberately unchanged. Both were smoke-
tested in isolation this session and both look safe to take, but an isolated
smoke test is evidence for a decision, not a certification.

tests/fm-toolchain-drift.test.sh and tests/fm-dispatch-select.test.sh pass.

* no-mistakes(review): fix opencode manifest row why column and header note

* no-mistakes(review): drop "full" from manifest certification rule

* test(gotmp): link fm-busy-lib.sh into both fake-root fixtures

tests/fm-gotmp.test.sh builds fake FM_ROOT trees and symlinks in the real
scripts that fm-teardown.sh resolves. bin/fm-tmux-lib.sh has sourced
bin/fm-busy-lib.sh since kunchenguid#51, but neither fixture links it, so the teardown
subprocess could not load its tmux adapter and the suite failed on
"teardown exited non-zero with a valid tasktmp".

This is pre-existing on the default branch and unrelated to this branch's
change: bin/ and tests/fm-gotmp.test.sh were both byte-identical to the base
commit, and the only other file this branch touches is a data file no test in
this suite reads. It is fixed here only because it blocks this lane's
validation.

Two fixtures needed the link, not one. test_teardown_skips_gracefully_without_tasktmp
builds its own fake root inline rather than calling make_fake_root, so it
duplicates the symlink block and drifted the same way.

Verified: all 4 assertions in tests/fm-gotmp.test.sh now pass, and
tests/fm-toolchain-drift.test.sh (9) and tests/fm-dispatch-select.test.sh (8)
still pass. bin/fm-lint.sh is clean.

* feat(primary): warn instead of blocking on Kimi version drift

bin/fm-primary.sh gated the Kimi primary on exact string equality with
KIMI_VALIDATED_VERSION. Kimi ships a self-updater, so that gate turned every
publisher release into an unscheduled outage of the certified primary rather
than leaving it merely uncertified. It then stayed down permanently: the pinned
0.27.0 build no longer exists anywhere on the captain's machine, not in
~/.kimi-code/bin and not in the /tmp lab docs/kimi-harness.md records, so no
value of FM_KIMI_BIN could satisfy it.

Drift now warns on stderr and launches. The functional gate is unchanged:
`kimi doctor` against the managed home still fails a launch closed when the
integration is actually broken, as do the managed-path symlink refusals. This
is the reasoning bin/fm-toolchain-lib.sh already applies fleet-wide; its header
cited this exact pin as the counter-example and now records that it was fixed.

Cursor keeps its exact-match block deliberately. Its Stop turn-end hook is
unverified rather than merely drifted (docs/cursor-harness.md), so drift there
is not the same class of problem.

KIMI_VALIDATED_VERSION moves to 0.31.1 because that build's primary hook
mechanics were re-verified live today, so the warning now fires only on
genuinely unevidenced builds. Verified in a scratch FM_HOME, scratch Kimi
source home, and scratch managed home, with the captain's ~/.kimi-code read
through symlinks and never written, and with the plugin's hook commands
swapped for logging stubs so the probe never ran Firstmate's real guards:

  - sessionStart skill injection PASS. The model reported the injected
    system-reminder and emitted its token instead of answering the prompt.
  - PreToolUse (Bash) PASS. PRETOOL_FIRED logged when the model ran a command,
    and the command was permitted.
  - Stop turn-end PASS. STOP_FIRED logged once per completed turn.
  - `kimi doctor` against the managed home: all config files valid.

The plugin manifest schema fm-primary.sh writes is still accepted unchanged.
Evidence recorded in docs/kimi-harness.md, which the toolchain manifest's
certified column now transcribes.

Stale claims updated where this change makes them false: the kimi manifest row,
bin/fm-toolchain-lib.sh's header, AGENTS.md, docs/configuration.md, and the
harness-adapters skill. Dated historical certification records in
docs/architecture.md and the worker sections are left alone; they remain
accurate history.

tests/fm-primary.test.sh now asserts the new contract - drift warns, reaches
the launch command, and doctor still fails closed. All 12 assertions pass, as
do fm-toolchain-drift (9), fm-kimi-worker (5), fm-gotmp (4), and
fm-dispatch-select (8). bin/fm-lint.sh is clean.

* no-mistakes(review): revert kimi certified to 0.27.0, align docs and fixtures

* no-mistakes(review): accept both evidenced Kimi builds without warning

* no-mistakes(review): clarify Kimi evidence wording, guard certified constant

* no-mistakes(review): move certified-constant guard into manifest test suite

* no-mistakes(document): align onboarding and Kimi doc scope with warn-not-block

* fix(test-run): map ONBOARDING.md as documentation-only source

The changed-test map had no entry for ONBOARDING.md, so the required
fork-surface step failed closed the first time this branch touched that
file. fork-surface.conf already declares the onboarding-guide capability
as documentation-only with proves = none, so the guide belongs in the
same prose branch as README.md rather than owning a behavior family.

The empty-selection fixture now touches ONBOARDING.md alongside
README.md so the classification stays covered.
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
kunchenguid#59)

* fix: restore stock macOS Bash 3.2 brief scaffolding

Hand-port upstream 514f0ab while preserving the fork's brief and lint contracts.

* fix(bin): normalize relative durable paths

Hand-port upstream 6ec5e08 into the fork's spawn, lock, X-mode, and isolated-secondmate paths.

* fix(bin): allow session-local todo tools in the subagent guard

Hand-port upstream 7cbb3f6 while retaining the fork's tracked status-line boundary and exact delegation guard.

* test: replace temp-root source assertions with behavioral coverage

Adapt upstream a2d5f26 by moving GOTMPDIR coverage through the real spawn interface. Retain fork capability tests and shard ownership that upstream deleted because they protect declared fork-surface contracts.

* fix(bin): preserve full task contract in no-mistakes intent

Hand-port upstream 68641a3 into the fork's generated no-mistakes brief without changing faster delivery paths.

* fix(bin): parse punctuated secondmate registry entries safely

Adapt upstream 1e24757c8e394532579a3ac0d43fe87dddc626b0 around this fork's isolated secondmate homes. Centralize suffix parsing and binding validation while preserving seeded-home, operational-directory, and cleanup boundaries.

* test: register and tighten the secondmate parser adaptation

Declare the converged upstream 1e24757 surface, preserve established nested-home refusal wording, and keep the touched snapshot script ShellCheck-clean.

* fix(bin): scope registry defects to the entry under validation

Add a scoped validation mode so a defect in one secondmate registry entry stops
only that entry, and keep strict mode for a deliberate whole-registry audit.
A malformed or unresolvable line for an unrelated secondmate must never abort
spawning or tearing down a healthy one, and only the duplicate and overlap
checks the expected entry genuinely takes part in can refuse it.

Tolerate an absent binding in scoped mode and report it through
SECONDMATE_REGISTRY_MATCH_FOUND, so a caller holding other proof of ownership
can still reach guarded cleanup. A binding that exists but points elsewhere
still refuses in either mode.

Name a refused symlinked registry as its own condition instead of returning the
same empty result as an unregistered id, so read paths can report the real
cause.

Trim trailing whitespace from every parsed field, which the parsers this
library replaced all did, and resolve paths inside a subshell so the caller's
working directory is never relocated. Collapse the ten repeated temp-directory
removals into one cleanup owned by the entry point.

* fix(bin): consolidate the durable path normalizer behind one owner

Five near-identical copies of the relative-path normalizer had drifted across
brief, spawn, afk launch, and bootstrap, all spelling the same resolution and
the same operator diagnostic. Give them one owner in bin/fm-path-lib.sh, keep
that diagnostic byte-identical because three test files assert on it, and keep
bootstrap reporting through its own arm-failed path rather than exiting.

Normalize FM_HOME in teardown through the same owner. The registry isolation
check resolves that home with a resolver that refuses a relative path, so a
relative FM_HOME refused every guarded secondmate and child home removal - the
exact bug class this batch exists to close.

Resolve inside a subshell so no caller's working directory is relocated, and
declare the new fork-only path in fork-surface.conf.

* fix(fork-surface): point the normalizer capability at its landed commit

The declaration was written alongside the implementation and briefly referenced
an amended-away commit, which resolves as a dangling object but is not in this
branch's history and would rot exactly like the stale pre-merge refs already
corrected on the default branch. Point it at the commit that actually carries
bin/fm-path-lib.sh.

* fix(bin): stop unrelated registry entries blocking spawn and teardown

Spawn and teardown validated the whole secondmate registry and refused on the
first defect anywhere, so one malformed or unresolvable line for an unrelated
secondmate aborted work on a perfectly healthy one. That changes which worker
runs the captain's work and strands guarded cleanup. Both now validate in
scoped mode: defects of the entry being acted on still refuse, along with the
duplicate and overlap checks that entry genuinely takes part in.

Validate a nested secondmate against its parent home's own registry rather than
the top-level one. Nested entries are only ever registered in the parent, and
teardown already reads that file, so a forced teardown of a secondmate owning a
nested secondmate refused with a binding it could never have found.

Tolerate an absent binding when the on-disk marker has already proved ownership,
so a home deregistered early or orphaned by a partial decommission stays
removable through the guard instead of only by hand.

Source the registry library explicitly in spawn and update instead of relying on
fm-ff-lib.sh pulling it in, and drop the unreachable projects default.

* fix(bin): name a refused registry symlink without changing its established wording

Keep the operator-facing "unavailable or unsafe" phrasing the seeding tests
assert on, and append the actual cause so a symlinked registry is no longer
indistinguishable from a missing one.

Link the libraries teardown really sources into both fake-root fixtures. The
path library is new, and the busy library has been a transitive requirement of
the tmux adapter since kunchenguid#51, so without them the teardown subprocess failed
before reaching the behaviour under test. Drop the fakebin and backends
scaffolding, which nothing writes into now that the adapter is an inline stub.

* fix(bin): report a refused registry symlink on every read path

The shared lookup refuses a symlinked secondmate registry, which is right, but
three read paths had no error branch and turned that refusal into silence: the
live-secondmate listing and the nudge retry both fell through as "no home", and
backlog handoff reported that the secondmate had no home at all. An operator who
symlinked the registry saw every secondmate look unregistered with nothing
naming the real cause.

Each read path now distinguishes a refused registry from an unregistered id and
says which one it hit. The listing reports once per listing rather than once per
secondmate. A silent wrong answer is the failure class this fleet never accepts.

* test: restore the lint severity contract and stop leaking task temp roots

The canonical-set refactor dropped the two guards that kept bin/fm-lint.sh from
lowering severity below the CI default or blanket-excluding checks CI enforces,
and put nothing in their place. Prove that contract through the real lint
interface instead of grepping the owner's source: a fixture carrying a
default-severity finding must still fail, and must still name it.

Follow symlinks when building the expected inventory. The owner globs those
directories and a glob includes symlinked scripts, so plain -type f would
false-fail as soon as a symlinked test is added - a pattern this suite already
uses elsewhere.

Derive the task temp root from the meta value spawn publishes rather than
repeating spawn's own spelling, so a directory left by an earlier failed run
cannot make the assertion pass spuriously. Clear every spawn's root from one
exit trap: the leak was suite-wide, not confined to the three cases that
lacked an explicit cleanup line.

* fix(bin): give the snapshot one registry grammar and stop conflict probes failing open

The fleet snapshot carried a second, hand-maintained copy of the registry suffix
grammar that had already drifted from the shared parser: it accepted a looser id
charset and an empty scope, so lines the parser rejects were reported as healthy
bindings while every other consumer refused the registry. Feed jq records the
shared parser produced instead, and report a line it rejects as malformed rather
than as a home.

Separate "no conflict found" from "registry entry is malformed" in the home
assignment probes. Both returned 1, and the callers gate on empty output, so a
malformed registry read as a clean bill of health and skipped the duplicate-home
and duplicate-id guards entirely.

* test: cover the scoped-validation and shared-grammar rulings

Prove the behaviour the rulings settled rather than the shape of the code.
A healthy secondmate still tears down when unrelated registry entries are
malformed or point at a vanished home. A home whose registry entry was already
removed is still removable once its on-disk marker proves ownership, while a
binding that exists and points elsewhere still refuses and says so. The fleet
snapshot and the shared parser agree on entries the parser rejects, so a bad id
or an empty scope can no longer surface as a healthy home in one consumer while
every other one refuses it.

* fix(fork-surface): repoint capability refs at their rebased commits

Rebasing onto the current default branch rewrote the two commits this batch's
capability entries named, leaving them pointing at objects that are no longer in
this branch's history. They still resolve while the old objects survive, so the
check stays green and the rot is invisible - the same stale pre-merge reference
class already corrected on the default branch. Point both at the commits that
actually carry the declared paths.

* no-mistakes(review): name refused registry symlinks on every read path

* no-mistakes(document): docs: cover new path and registry libs, teardown normalization
@qwery1357

Copy link
Copy Markdown

Refresh the installed page on the TB14 (after merge)

Pull, then copy the page over the installed copy. This works at a cmd prompt (D:\>):

git -C D:\aos pull --ff-only && copy /Y D:\aos\docs\migration\checklist.html "D:\AI-PM-OS\AOS Captain Steps.html"

Reload the page in the browser afterwards. Ticks are kept: they live in the browser's storage, keyed aos-captain-steps-v2.

fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 18, 2026
…a job's report (kunchenguid#51)

* feat(bin): read a call's or job's report from the Factory pane with r or a click, and ask scouts for a page beside their report

* no-mistakes(review): Allow indented Lavish launch line in fm-read fork-surface anchor

* no-mistakes(document): List scout page.html in the home layout inventory

* no-mistakes(review): Make r on a factory read only drawn jobs

* no-mistakes(document): Clarify that r on a factory reads the first shown job

---------

Co-authored-by: Starship <[email protected]>
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 18, 2026
Brings in the Factory pane report line (kunchenguid#51) so the pipeline sees the
branch on top of the current main and keeps the upstream merge commit
intact instead of replaying its commits.
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.

3 participants