Repository navigation
feat(bin): refuse dispatch into operator-declared no-go paths - #3
Merged
Merged
Conversation
Add config/no-go-paths, a local and gitignored list of absolute directory prefixes that agent work must never be dispatched into. An absent file means no restriction, so behavior is unchanged for every home that does not opt in, and no tracked material ever names an operator's private paths. bin/fm-no-go-lib.sh owns the matching so other scripts can adopt it later: comments, blanks, trailing slashes, and a leading ~ are handled, and matching is on a path-component boundary over both the literal and physically resolved forms, so /a/b blocks /a/b and /a/b/c but never /a/bc and a symlinked alias cannot route around a prefix. A malformed line refuses rather than being silently skipped. fm-spawn.sh refuses at two points. The project directory (or a secondmate's resolved firstmate home) is checked before any window, worktree, temp root, hook, state, or metadata exists, so a refused dispatch leaves nothing behind. The final worktree is checked once its provider reveals it, which cannot be before the backend window exists; that limitation is documented rather than engineered around, and declaring the pool root closes it. config/no-go-paths is inherited by secondmate homes, so a secondmate's own crewmates are held to the same boundary. Also classify docs/sdev-backend.md and docs/examples/landing-policy.json, which were already unclassified on main and failed the documentation audience check independently of this change.
The required Herdr lane failed at its first step with `curl: (56) Connection died, tried 5 times before giving up` after 166 ms. Those five tries are curl's own same-connection retries, all fired inside the same instant, so one reset from the release CDN decided the lane's result before any test ran. Both pin installers now use the bounded, backed-off retry that bin/fm-install-shellcheck.sh already owned, and tests/fm-install-pins.test.sh drives the real installers with a scripted curl to prove recovery after a transient failure, the bounded give-up, the growing pause, and that nothing is installed when every attempt fails.
Owner
Author
|
CI note for future readers: the "Behavior tests (Herdr)" lane failed once in this PR for a transient reason and passed on re-run. It was not a test or code failure. The job aborted at the toolchain install step, before any Herdr test executed: Separately, "Behavior portable serial" was cancelled by fail-fast in that same attempt, so its result was not a verdict. On re-run it produced a real failure in this branch own tests/fm-spawn-no-go-paths.test.sh, which is being fixed here. For the record, the same job fails on main from a different test (tests/fm-documentation-audiences.test.sh, the documentation-audience drift this branch fixes), so the two failures are unrelated. |
santhosh2011
pushed a commit
that referenced
this pull request
Sep 16, 2026
…kunchenguid#3578) * fix(bin): let verified harness ancestry outrank retained markers (#3) * fix(bin): let a structural harness ancestor outrank a retained marker bin/fm-harness.sh treated a verified environment marker as unconditionally authoritative, so a Codex session started from an environment that had retained CLAUDECODE=1 detected as claude. Session start then emitted Claude's Stop-owned supervision protocol to a Codex primary, and every turn end was blocked for missing Claude recovery. The defect is the precedence boundary, not any one harness. codex, opencode, kimi, and muse publish no identity marker at all, so with markers winning outright any retained CLAUDECODE renamed them; the Cursor-before-Claude ordering was a point patch on the same class of problem, and the launch-time marker clearing only ever covered sessions fm-spawn started. Markers and ancestry are now separate evidence layers that detect_own arbitrates: - no ancestry match, or no marker: the single available layer answers, unchanged; - same harness family: the marker's finer verdict stands, so a launch-selected pi-signed is not flattened to pi by an ancestry walk that can only see the shared launcher name; - different harness with a structural (command-name) ancestor: ancestry wins, because only ancestry proves who owns the process tree; - different harness with only a bare-interpreter script-path match: the marker wins, since a harness-shaped path in some node process's arguments is weaker evidence than a harness publishing its own identity. The correction is symmetric: a retained CURSOR_AGENT no longer renames a claude worker nested under cursor either. Adds fm-harness.sh ancestry [<pid>], ancestry evidence with no marker layer, so a real harness process can be asked what the walk makes of it. tests/fm-harness-precedence.test.sh is the portable regression, built from real renamed processes with no harness installed. Every case drives the two layers apart and asserts each alone as well as the combination, so no case can pass vacuously; it also pins Codex's real two-process install topology, since the fix depends on the native binary being what a tool subprocess meets first. The opt-in drift guard gains the matching live half: each installed harness's real running process must still be identified by the ancestry walk, and it fails naming the harness and version when a release changes that name. Documentation follows the corrected contract in the script header, the harness-adapters detection section, the codex, opencode, kimi, and cursor references, and a dated verification record. * fix(tests): drop the unused argument pass-through in the shim-topology helper bin/fm-lint.sh refused the branch: run_shim declared a `[ancestry]` argument and forwarded "$@", but every call site that varies the environment or passes the ancestry subcommand invokes the shim entry point directly, so the helper is only ever called with no arguments (ShellCheck SC2120/SC2119). Behavior is unchanged: with no arguments "$@" expanded to nothing. * fix(bin): examine the top of the process chain instead of assuming init harness_ancestry stopped as soon as the next pid was 1, on the assumption that pid 1 is always init and can never be a harness. Inside a PID namespace that assumption inverts: the harness itself is pid 1, so the walk never examined the one process that proves who owns the tree, reported no ancestry at all, and handed the verdict straight back to a retained marker. A real Codex session under `codex sandbox`, holding CLAUDECODE=1 and CLAUDE_CODE_ENTRYPOINT=cli, is exactly that shape: it resolved claude and rendered Claude's Stop-owned supervision protocol even with the marker-vs-ancestry precedence boundary in place. The same probe now resolves codex and renders the Codex foreground checkpoint. A host's real pid 1 (init, systemd, launchd) matches no harness name, so examining it costs one ps call and can introduce no false positive; the walk still stops once that top process has been read, and a non-numeric or zero ppid still ends it. tests/fm-harness-precedence.test.sh pins the namespace shape with a fake ps that reports every process as bash with ppid 1 and pid 1 as the harness. The case asserts the marker still answers alone when pid 1 is host-shaped, so it cannot pass vacuously, and it fails against the previous stop condition. * docs(verification): record the real-Codex retained-marker evidence The existing record proved the precedence boundary with the portable regression and recorded each installed harness's process name behind the ancestry walk, but it had no evidence from a real Codex process actually holding a retained Claude marker, which is the failure the boundary exists for. Adds the dated before/after result from codex-cli 0.152.0 under `codex sandbox`, with the exact command and the decisive verdict and rendered protocol on each side, and records the second boundary that shape exposed: the walk must examine the top of the process chain, because inside a PID namespace the harness is pid 1. Refreshes the portable regression's observed output for the case it gained. * no-mistakes(review): blind ancestry in marker-pinned harness tests * no-mistakes(review): blind ancestry in the Pi guard-routing test * no-mistakes(review): classify precedence suite, dedupe ps stub, soften claims * no-mistakes(review): model the spawn-and-wait Codex shim topology * no-mistakes(document): correct stale muse marker-clearing detection claims * no-mistakes: apply CI fixes * fix(bin): examine the top of the chain in the lock and nudge walks too The pid-1 defect corrected in bin/fm-harness.sh survived unchanged in the two other harness-ancestry walks, on the exact topology the branch verified against a real Codex process. bin/fm-session-lock-lib.sh's fm_harness_ancestry_pids stopped as soon as the next pid was 1, so a firstmate whose harness is pid 1 of its own PID namespace could not find that harness at all and did not recognize its own session lock. bin/fm-sessionstart-nudge.sh carried the same stop plus a blanket rejection of a lock pid of 1, so the same session was told to run session start again on every turn. Both walks now compare the top process before stopping, matching the shape used in bin/fm-harness.sh. For the lock walk this is safe because fm_harness_process_matches rejects a host's real pid 1. For the nudge, `kill -0` still gates the lock pid, and on a host an unprivileged `kill -0 1` fails, so a lock file that wrongly names pid 1 leaves the hook silent rather than acting on init. Each walk gains one regression case. The lock case drives a deterministic process table whose pid 1 is the harness and asserts a host-shaped pid 1 still finds nothing, so it cannot pass vacuously. The nudge case needs a real PID namespace, because the builtin `kill -0` gate cannot be reached through a fake ps, and it first proves the same fixture nudges with no lock present; it skips explicitly where unprivileged namespaces are unavailable. * no-mistakes(review): assert comm-strength detection from subprocess vantage in drift guard * fix(bin): verify the live harness guard at the strength the guarantee needs The marker-versus-ancestry boundary this branch ships is a strength claim: detect_own hands an args-strength verdict straight back to a retained foreign marker, so a harness is only protected where the ancestry walk reaches it at comm strength. The installed-harness drift guard probed the pane process alone. Under an interpreter shim the pane process IS the shim, whose own script path is args strength, while the native binary that carries comm strength is its child. The guard therefore observed args for Codex, passed, and would have kept passing if a release stopped spawning that native child at all, while real sessions silently regressed to the original bug. fm-harness.sh gains `ancestry-subtree`, which asks the walk from the pane process and every descendant of it, the vantage a tool subprocess actually occupies. The guard now requires comm strength somewhere in that set and requires every vantage to name the same harness. This supersedes the preceding commit's in-guard leaf walk, which reached the same vantage but left the logic inside the test file, where CI could not pin it and nothing else could reuse it. A harness-dependent check needs both halves: `tests/fm-harness-precedence.test.sh` now carries a portable case proving the subtree probe reaches a strength the top-of-session probe cannot, mutation checked twice, once against the pre-change script and once by disabling descendant enumeration. The subtree walk also avoids depending on tty and process-group semantics that differ between Linux and macOS. Verified live: codex-cli 0.152.0 reports [args codex;comm codex] and Claude Code 2.1.257 reports [comm claude]. * no-mistakes(review): narrow drift guard to the upward vantage path * no-mistakes(review): judge only comm-strength vantages in drift guard * no-mistakes(document): drop duplicated rationale in detection precedence evidence * no-mistakes(review): fix pid-1 nudge case vacuity and descent no-arg expansion * no-mistakes(document): drop branch-relative phrasing in detection precedence evidence * no-mistakes(review): guard remaining empty positional expansions in fm-harness * no-mistakes(document): scope cursor marker-ordering claim to the marker layer * no-mistakes(review): Prefer comm-strength leaves in equal-depth descent ties * no-mistakes(document): Document comm-strength descent tie-break --------- * no-mistakes(review): Blind ancestry in stale gemini/rovo marker-precedence tests * no-mistakes(document): Add missing equal-depth-tie test line to precedence evidence transcript * no-mistakes(review): Fix stale/vacuous agy precedence test, add agy to precedence suite and docs * no-mistakes(document): Fix stale kimi.md marker doc missed by ancestry-precedence fix --------- Co-authored-by: NewAiCoder <170579485+NewAiCoder@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
The developer wanted firstmate to mechanically refuse any dispatch that would land in a directory the operator has declared off limits, replacing the current reliance on firstmate's discipline plus a note in data/. The mechanism had to ship without hardcoding the captain's actual path in tracked material: a local, gitignored, optional config/no-go-paths file holding one absolute path prefix per line, ignoring blanks and # comments, tolerating trailing slashes, expanding a leading ~ to $HOME, with absence meaning no restriction and no behavior change. Enforcement belonged in bin/fm-spawn.sh, checking the resolved project directory, the final worktree path, and the resolved firstmate home for secondmate launches, matching canonicalised absolute paths on a path-component boundary so /a/b blocks /a/b and /a/b/c but never /a/bc, exiting non-zero with a message naming the offending path and matching prefix before any worktree, window, meta or state file exists, while a refused pair in a batch dispatch must not stop the other pairs. They required the matching logic in a single shared helper following bin/'s existing library convention, docs in AGENTS.md section 2, docs/configuration.md and docs/examples/no-go-paths, shellcheck-clean scripts, one sentence per line and plain dashes in Markdown, colocated tests covering absent-file, exact match, nested path, sibling prefix, comments/blanks, ~ expansion, trailing slash and refusal-leaves-nothing-behind, and no agent co-author on the commit. They insisted on a written plan and a stop for approval before any code was written. On review they approved the plan and additionally decided that config/no-go-paths must be folded into FM_INHERITABLE_CONFIG with a test and an AGENTS.md clause because an off-limits root is a machine-wide fact a secondmate must not route around, asked that the plan file be kept out of the commit, and accepted the stated limitation on the worktree-stage refusal as something to document in docs/configuration.md rather than engineer around.
What Changed
bin/fm-no-go-lib.sh, the single owner of no-go prefix matching against an optional localconfig/no-go-paths(one absolute prefix per line,#comments and blanks ignored, trailing slashes tolerated, leading~expanded), plusbin/fm-path-state-lib.sh, a tri-state exists/provably-absent/undeterminable path classifier. Matching is on a path-component boundary against both the literal and physically resolved forms, so/a/bblocks/a/band/a/b/cbut never/a/bc. An absent file means unrestricted; a malformed line, an unreadable file, or an unclassifiable path refuses instead of being read as no restriction.bin/fm-spawn.shnow asserts the guard on the resolved project directory, the final task worktree, and a secondmate's resolved firstmate home, exiting non-zero with the offending path and matching prefix. The project and secondmate checks run before anything is created; the worktree check runs as soon as the provider reveals its path and arms an EXIT-trap teardown that removes the worktree and closes the window this dispatch created (treehouse destroy,sdev destroy --force), only for a workspace this invocation created whose checkouts are provably clean, warning with the reason otherwise. Batch dispatch is unaffected: a refused pair does not stop its siblings.no-go-pathsintoFM_INHERITABLE_CONFIGand made its propagation failure fatal for a secondmate launch viafm_config_inherit_boundary_failed, while excluding it from the config-reread instruction allowlist so its bytes are never inlined for an agent.bin/fm-config-inherit-lib.shnow classifies primary sources and destinations through the new path-state library, so an unusable or unreadable source is an error rather than a mirrored absence. Documented inAGENTS.md,docs/configuration.md,docs/scripts.md,docs/examples/no-go-paths, and the secondmate-provisioning skill, with a newtests/fm-spawn-no-go-paths.test.shsuite andbin/fm-test-run.shfamily routing for the new scripts.Risk Assessment
Testing
test
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-no-go-lib.sh:95- fm_no_go_prefixes uses[ -f "$file" ] || return 0, so a config/no-go-paths that EXISTS but is not a regular file (dangling symlink, directory) is silently treated as "absent = unrestricted" and the guard is disabled fleet-wide. This contradicts the library's own stated principle two comment blocks above ("a silently dropped line is a protection the operator believed was in force") and its unreadable-regular-file path, which correctly fails closed (the redirect fails, the function returns non-zero, fm_no_go_match returns 2, fm_no_go_assert refuses). Concrete sequence: operator manages local config via dotfiles and createsconfig/no-go-pathsas a symlink into ~/dotfiles; later reorganises dotfiles so the link dangles; every subsequent fm-spawn.sh dispatch into the declared off-limits directory now succeeds with no message. Fix: distinguish absent ([ -e "$file" ] || [ -L "$file" ]false -> unrestricted, unchanged) from present-but-not-a-regular-file (-> stderr error and return 2, same as a malformed line).bin/fm-config-inherit-lib.sh:51- no-go-paths is added to FM_INHERITABLE_CONFIG and AGENTS.md:73, docs/configuration.md:291 and this file's header all assert a secondmate "cannot route around" the boundary, but propagation failure is non-fatal. propagate_inheritable_config recordsskippedfor a destination_allows_inherited_item failure WITHOUT setting rc (lines 452-457), and returns rc=1 only for a copy/remove error; bin/fm-spawn.sh:841 then downgrades any non-zero towarning: secondmate <id> inheritance failedand launches the secondmate anyway. Concrete sequence: the primary's config/no-go-paths copy fails (mktemp/cp failure in copy_inheritable_file, full or read-only disk, or a destination guard miss) -> warning on stderr, secondmate launches -> that home's config/no-go-paths is absent or stale -> its own fm-spawn.sh finds no prefixes and dispatches its crewmates straight into the operator's declared off-limits directory, with the primary exiting 0. Either make a no-go-paths propagation failure fatal for the secondmate launch, or soften the "cannot route around" wording in AGENTS.md, docs/configuration.md and this header to match the eventually-convergent guarantee that inheritance actually provides.bin/fm-spawn.sh:1437- The task-worktree refusal fires only in the case where a worktree has ALREADY been created inside a declared no-go path, and nothing removes it. spawn_abort_cleanup (bin/fm-spawn.sh:294-351) cleans the herdr projection, the orca worktree/terminal and the two locks, but has no treehouse or sdev branch, soexit 1here leaves a full git worktree (treehouse) or multi-repo workspace (sdev new) sitting inside the operator's off-limits directory, plus the backend window. docs/configuration.md:288 states only "still ahead of every state, metadata, hook, and temp artifact, but after the backend window has been created" - it never says a checkout now exists inside the declared prefix and is not cleaned up, which is the fact an operator needs to act on. Behaviour is also inconsistent across providers: an orca refusal at this same line does remove its worktree via ORCA_ABORT_CLEANUP. The later-refusal timing was explicitly accepted as a documented limitation, so this is about the accuracy of that documented limitation (and optionally tearing down the just-created treehouse/sdev worktree on refusal), not about re-engineering the check's position.bin/fm-no-go-lib.sh:149- fm_no_go_assert encodes a 3-way status dispatch (0 refuse, 1 allow, 2 malformed-refuse) as an if/else whose else branch recovers the condition's status via$?, then re-tests it. Correct today, but it depends on$?surviving into the else branch and on no command being inserted beforestatus=$?. A direct call pluscase "$status" in 0) ...;; 1) return 0;; *) return 1;; esacstates the same contract without that ordering dependency.🔧 Fix: harden no-go guard: fail closed, fatal inheritance, clean abort
3 issues (2 warnings, 1 info) still open:
bin/fm-config-inherit-lib.sh:471- propagate_inheritable_config selects its branch with[ -f "$src" ], so a primary config/no-go-paths that EXISTS but is not a readable regular file (dangling symlink, directory) is classified as "the primary has no value" and falls into the absence-mirror branch at lines 504-505, whichrm -fs the boundary file out of the secondmate home and records it aspushed / mirrored primary absencewith rc 0. This is the same fail-open the fix round closed in fm_no_go_prefixes/fm_no_go_config_readable, still reachable one layer up, and here it does not merely read as unrestricted - it destroys downstream state. Concrete sequence: the operator's config/no-go-paths is a symlink into ~/dotfiles (the scenario the original finding named); they reorganise dotfiles so it dangles; bin/fm-bootstrap.sh:403 runs the locked secondmate sweep at the next primary session start (or the operator runs bin/fm-config-push.sh:170) - neither caller runs fm_no_go_assert, so nothing refuses - and every secondmate home's config/no-go-paths is deleted, exit 0; a live secondmate then dispatches a crewmate, its own fm-spawn.sh finds no config, and the dispatch lands in the operator's declared off-limits directory. The primary's own dispatches do fail closed and are loud, which narrows but does not close the window. docs/configuration.md:296 ("That inheritance is enforced, not best-effort") is false for this state. Earliest shared boundary: fm-no-go-lib.sh is already sourced into this file, so classify $FM_NO_GO_FILE's source with fm_no_go_config_readable before the[ -f "$src" ]branch - present-but-unusable becomes an error that sets FM_CONFIG_INHERIT_BOUNDARY_FAILED=1, sets rc=1 and continues, and never reaches absence-mirroring; genuinely absent keeps the existing unrestricted default..agents/skills/secondmate-provisioning/SKILL.md:82- config/no-go-paths was added to FM_INHERITABLE_CONFIG (bin/fm-config-inherit-lib.sh:66) and AGENTS.md:73 now points at the secondmate-provisioning contract for it, but this skill's two enumerations of that contract still omit it: line 82 lists the propagated inherited local material, and line 103 lists the allowlisted items that produce a per-home config-reread instruction. The line 103 list is doubly wrong because fm_config_reread_is_allowlisted_item derives the allowlist from FM_INHERITABLE_CONFIG itself, so no-go-paths IS already inlined into reread instructions in code while the doc says otherwise. This is the doc the firstmate is instructed to load before launching or pushing inherited material into a secondmate home (AGENTS.md:219), and no test enforces the two lists against FM_INHERITABLE_CONFIG. Add config/no-go-paths to both enumerations.bin/fm-spawn.sh:1539- The new teardown is armed at bin/fm-spawn.sh:1437 (sdev) and :1539 (treehouse) and disarmed at :1877, so it fires on every exit in that span, not only the no-go worktree refusal - the busy-state guards at :1599/:1607/:1617 and anyset -eabort in the hook-installation block now silently remove the worktree and close the window. That is defensible (no agent has been launched yet at any point in the span, and it matches ORCA_ABORT_CLEANUP's identical span) and the twoinspect window $Tmessages that would have been contradicted (:1425, :1534) both sit before the arm point while kimi_spawn_fail's sit after the disarm. Noting the widened scope as a deliberate tradeoff: a bareset -eabort in that block now leaves no window to inspect and no diagnostic beyond the exit status.🔧 Fix: treat unusable inherited source as error, not absence
5 issues (4 warnings, 1 info) still open:
bin/fm-spawn.sh:317- spawn_abort_worktree_root_is_clean discards git status's exit code:[ -z "$(git -C "$dir" status --porcelain 2>/dev/null)" ]. A failing git status produces empty stdout, which the test reads as "clean", so the abort proceeds totreehouse return --force(bin/fm-spawn.sh:358) - which per bin/fm-teardown.sh:5 hard-resets the worktree. This contradicts the function's own comment two lines above (bin/fm-spawn.sh:308: "an unreadable repo - is something this abort must not touch") and the operator's stated rule that cleanup must warn and leave rather than delete something uncertain. Every other probe in the function correctly uses|| return 1. Failure scenario: the armed span runs from :1539 to :1877 and covers hook writes into $WT/.claude and the busy-state arm, so an abort in it can hit a worktree whose git dir is read-only or whose index cannot be refreshed;git rev-parse --show-toplevelstill succeeds (no write),git status --porcelainexits non-zero with empty stdout, the tree is declared clean, andtreehouse return --forceremoves and hard-resets a worktree whose dirtiness was never actually established. Fix:local out; out=$(git -C "$dir" status --porcelain 2>/dev/null) || return 1; [ -z "$out" ].bin/fm-config-inherit-lib.sh:66- Adding no-go-paths to FM_INHERITABLE_CONFIG also enrolls it in the config-reread allowlist, because fm_config_reread_is_allowlisted_item (bin/fm-config-inherit-lib.sh:580) derives that allowlist from FM_INHERITABLE_CONFIG itself. So whenever the boundary file changes, its exact bytes - the operator's private absolute paths, which docs/configuration.md:269 says are the reason nothing tracked ever names them - are inlined into a per-home instruction file and sent to the live secondmate agent under FM_CONFIG_REREAD_FRAMING (bin/fm-config-inherit-lib.sh:574): "They are defaults/rules and do not remove your judgment to choose differently when warranted." That sentence is the opposite of the contract stated in AGENTS.md:73 and docs/configuration.md:295 ("a secondmate cannot route around a machine-wide restriction"), and .agents/skills/secondmate-provisioning/SKILL.md:107 now documents the inlining as intended. Failure scenario: operator edits config/no-go-paths, bin/fm-config-push.sh pushes it, and every live secondmate receives a message listing the off-limits absolute paths framed as advisory defaults it may override - while fm-spawn.sh mechanically refuses regardless, so the instruction is both contradictory and an unnecessary disclosure of the private paths. The mechanical guard still holds, so this is a contract/wording problem, not an escape. Either exclude no-go-paths from the reread allowlist (fm-spawn reads the file itself; the agent needs no action) or give it its own non-advisory framing.docs/configuration.md:290- docs/configuration.md:290 states unconditionally that the worktree refusal "removes the worktree and closes the window this dispatch itself created, so a refusal at either point leaves nothing behind". The treehouse branch does remove (bin/fm-spawn.sh:358), but the sdev branch archives instead:sdev -p <proj> end <slug>(bin/fm-spawn.sh:370), which docs/sdev-backend.md:69 describes as archiving the workspace, not deleting it. Failure scenario: the operator declares their SDEV_HOME root off limits (docs/sdev-backend.md:4 names /Users/santhosh/code/shamrock as this captain's SDEV_HOME); any sdev-backed dispatch resolves WT to $SDEV_HOME/projects/<project>/<slug>, hits the refusal at bin/fm-spawn.sh:1552, and the cleanup archives the workspace - the archive destination is sdev-owned and, being under SDEV_HOME, most plausibly still inside the declared off-limits root.sdev end's output is also fully discarded (>/dev/null 2>&1), so the operator gets only a generic warning if it fails. Either narrow line 290 to say the sdev provider archives the workspace withsdev endrather than removing it, or confirm and document that the archive lands outside the declared prefix. The sdev unwind path is also the one branch with no test coverage in tests/fm-spawn-no-go-paths.test.sh.bin/fm-test-run.sh:669- families_for_changed_path maps bin/fm-no-go-lib.sh to backend-dispatch and pure-contract-unit only. But bin/fm-config-inherit-lib.sh:42 now sources that library and branches on FM_NO_GO_FILE at three points (bin/fm-config-inherit-lib.sh:506, :517, :530) to decide the fatal-boundary flag, and that behavior is covered exclusively by tests/fm-secondmate-harness.test.sh, whose family issecondmate(bin/fm-test-run.sh:148). The script header states "--changed is conservative: it over-selects related families rather than under-selecting", so this arm violates its own contract. Failure scenario: a change to bin/fm-no-go-lib.sh alone that renames FM_NO_GO_FILE (say to "no-go") breaks[ "$item" = "$FM_NO_GO_FILE" ]against the literalno-go-pathsentry in FM_INHERITABLE_CONFIG, so a failed boundary propagation silently stops being fatal and the secondmate launches unrestricted - andfm-test-run.sh --changednever runs the secondmate family that would catch it. Addprintf '%s\n' secondmateto that arm.tests/fm-spawn-no-go-paths.test.sh:351- Two gaps in the new worktree coverage. (1) The safety-critical branch of the new teardown - spawn_abort_worktree_root_is_clean / spawn_abort_treehouse_worktree_is_removable returning false, so the abort warns and leaves the directory alone (bin/fm-spawn.sh:352, :362) - has no case at all; every worktree test exercises only the removable path, so a regression that made the cleanup unconditional would still pass. A dirty-worktree variant of test_worktree_refusal_unwinds_the_worktree_and_window would cover it: same fixture plus one untracked non-excluded file in $wt, asserting the worktree survives and the warning names it. (2) test_worktree_outside_a_no_go_path_completes (line 351) and test_completed_spawn_keeps_its_worktree_and_window (line 395) build identical fixtures via make_worktree_case and both assert expect_code 0 on the same no-config control; the second only adds[ -d "$wt" ]and the kill-window absence. Folding those two assertions into the first removes a full duplicate spawn from the suite.🔧 Fix: prove worktree cleanliness, remove sdev workspace, hide boundary
3 warnings still open:
bin/fm-no-go-lib.sh:99- fm_no_go_config_readable classifies the boundary file with[ ! -e "$file" ] && [ ! -L "$file" ] -> return 1(absent = unrestricted), but both tests also return false when the file exists and the PARENT directory cannot be searched. I verified this empirically: with config/ at mode 000 and a real no-go-paths inside it, that condition takes the absent branch. So fm_no_go_prefixes returns 0 with no output, fm_no_go_match returns 1 (allowed), and every dispatch proceeds unrestricted with no message - the exact fail-open the round-1 and round-2 hardening closed for the file itself, still reachable one level up at /Users/santhosh/.no-mistakes/worktrees/8b8809369225/01KZV2FH8NWCP582YHF5NKXQ40/bin/fm-no-go-lib.sh:99. Failure scenario: the operator keeps config/ as a symlink into an encrypted or removable volume that is not mounted, or tightens it tochmod 600 config(owner-readable, not searchable); fm-spawn.sh:1022 and :1611 then allow a dispatch straight into the declared off-limits directory, and the library's own stated contract two comment blocks above ("Absent is the ONLY unrestricted state") plus docs/configuration.md:278 are both false for that state. Fix at the same classifier: before concluding absence, test the config directory itself - if$1's parent exists in any form ([ -e ]or[ -L ]on the directory) but is not a searchable directory, emit the same stderr error and return 2, while a parent that does not exist at all keeps returning 1 so the absent-means-unrestricted default and its tests are untouched.bin/fm-config-inherit-lib.sh:137- inheritable_source_state uses the same[ ! -e "$src" ] && [ ! -L "$src" ] -> return 1shape at /Users/santhosh/.no-mistakes/worktrees/8b8809369225/01KZV2FH8NWCP582YHF5NKXQ40/bin/fm-config-inherit-lib.sh:137, so an unsearchable PRIMARY config/ directory is classified as state 1 (genuinely absent) for every item, not state 2. Round 3 stopped state 3 from reaching the absence-mirror, but this input never becomes state 3, so it falls to the branch at lines 538-548 andrm -f "$dest"deletes each secondmate home's inherited copy - including config/no-go-paths - recordingpushed / mirrored primary absencewith rc 0 and no boundary flag. Failure scenario: the operator's config/ is a symlink into an unmounted volume (or loses its search bit); bin/fm-bootstrap.sh:403 runs the locked secondmate sweep at the next session start, or bin/fm-config-push.sh runs mid-session, and every live secondmate home has its boundary file deleted and every other inherited item wiped, exit 0, silently. The primary's own fm_no_go_assert at bin/fm-spawn.sh:957 does not catch it either, because it fails open on the same input (see the companion finding), so the secondmate launches with no boundary at all and its crewmates dispatch into the declared off-limits directory. docs/configuration.md:297 ("That inheritance is enforced, not best-effort") is false for this state. Fix symmetrically with the no-go classifier: classify the source's parent directory before concluding absence - a present-but-unsearchable src_config is state 2 (propagation error, destination untouched, boundary flag for no-go-paths), while a genuinely missing config dir keeps mirroring absence exactly as today so the existing absence-mirror tests stay green.docs/configuration.md:290- docs/configuration.md:290 states that the worktree refusal "removes the worktree and closes the window this dispatch itself created, so a refusal at either point leaves nothing behind", but the treehouse branch at /Users/santhosh/.no-mistakes/worktrees/8b8809369225/01KZV2FH8NWCP582YHF5NKXQ40/bin/fm-spawn.sh:411 runstreehouse return --force, whose own help is "Terminate lingering processes and return a worktree" / "--force: Clean, reset, and return without prompting" - it returns the worktree to the pool, it does not remove it.treehouse destroyis that tool's removing verb, and docs/configuration.md:166 already acknowledges the pool-slot model. So after a refusal the worktree directory still exists at its pool path, which in the scenario this feature guards is inside the operator's declared off-limits directory. Line 291 half-corrects this ("goes back to its pool"), which leaves the paragraph internally contradictory and applies a weaker standard than the operator's round-3 ruling on the SDev branch ("Do not leave the doc asserting removal while the code archives"). The test cannot catch this: the fake at tests/fm-spawn-no-go-paths.test.sh:288-299 implementstreehouse return --forceasgit worktree remove --force, so test_worktree_refusal_unwinds_the_worktree_and_window's centralassert_absent "$wt"(line 390) asserts an outcome the real verb never produces - the assertion would pass with production leaving the directory in place. Either narrow line 290 to say the treehouse provider releases its pool slot rather than deleting the directory (and soften the test's assertion to match, e.g. assert the slot was returned rather than that the path is gone), or confirm that a pooled slot inside a declared prefix is acceptable residue and say so explicitly.🔧 Fix: classify path state tri-state; destroy no-go worktree
2 warnings still open:
bin/fm-config-inherit-lib.sh:338- propagate_shared_captain_preferences still classifies its source with the exact two-state shape the round-4 fix was introduced to eliminate:if [ -e "$src" ] || [ -L "$src" ]. Both tests are also false when the entry exists but its PARENT cannot be searched, so an unsearchable primary data/ is read as "the primary has no value" and falls into the absence branch. bin/fm-path-state-lib.sh:21 states it is "the single owner of that classification; do not reimplement it", and this is the one remaining reimplementation on the propagate_secondmate_inheritance path (bin/fm-config-inherit-lib.sh:452 calls propagate_inheritable_config, now tri-state, and then this function, still two-state). I reproduced it directly: with a real data/captain-shared.md present and data/ at mode 000, the function takes the absence branch, quarantines the destination's live copy to a hidden .captain-shared.md.quarantine.<ts>.<sha> name, recordsdata/captain-shared.md pushed mirrored primary absence after quarantining local copy at ..., and returns rc 0. Failure scenario: the operator's data/ is a symlink into an unmounted volume or loses its search bit; bin/fm-bootstrap.sh's locked secondmate sweep (or bin/fm-config-push.sh) runs at the next session start; every live secondmate home loses its shared captain-preference file, the operation reports success, and nothing warns. Unlike the config/no-go-paths case this is displacement rather than deletion (the bytes survive under the quarantine name), but the live inherited file is gone and the caller is told the push succeeded. Fix at the same boundary the other sites now use: classify $src with fm_path_state before the branch - UNDETERMINABLE becomes an error that leaves the destination untouched and sets rc=1, PROVABLY ABSENT keeps today's quarantine-and-mirror behavior exactly so the existing absence-mirror assertions stay green.bin/fm-spawn.sh:447- The treehouse branch of spawn_abort_remove_task_worktree selects its verb on SPAWN_WORKTREE_ABORT_NO_GO (bin/fm-spawn.sh:417): destroy for the no-go refusal,treehouse return --forcefor every other abort. The sdev branch never consults that marker - it runssdev destroy --forceunconditionally for any abort in the armed span.sdev --helpdocuments destroy as "force-remove a task (worktree + offset + entry; no archive)", so an ordinary abort now hard-removes the workspace, its port offset, and its ledger entry where before this change it left them in place. docs/configuration.md:295 asserts the opposite: "Every other abort in that window keeps the ordinary recycling verb ... which hands the worktree back to the pool for the next spawn." Failure scenario: an SDev-backed project with NO config/no-go-paths at all (or an allowed path). The workspace is armed at bin/fm-spawn.sh:1516 and disarmed at :1959; in between,bin/fm-busy-event.sh armfails and bin/fm-spawn.sh:1689 exits 1 for a claude/opencode/pi harness (ormkdir -p "$TASK_TMP/gotmp"at :1643 trips set -e). The EXIT trap then force-removes the workspace and its ledger entry, with only the generic spawn error on stderr - an operator following the documented "recycled back to the pool" model has no reason to expect that. No data is lost (SPAWN_SDEV_CREATED plus the per-repo clean probe both hold), so this is about which verb the non-refusal path should use, not safety. Either gate the sdev branch on SPAWN_WORKTREE_ABORT_NO_GO the way the treehouse branch does (withsdev end --poolor a plain leave-in-place as the ordinary verb), or narrow docs/configuration.md:295 to say the SDev provider force-removes on every abort in that window. The existing sdev coverage (tests/fm-sdev-spawn.test.sh:230) only exercises the no-go refusal, so neither choice is currently pinned.🔧 Fix: scope sdev force-remove to refusal; classify captain source
1 warning still open:
bin/fm-config-inherit-lib.sh:427- The round-5 fix moved propagate_shared_captain_preferences' SOURCE onto fm_path_state but left its DESTINATION on the exact two-state shape the shared owner was introduced to eliminate:elif [ -e "$dest" ] || [ -L "$dest" ](bin/fm-config-inherit-lib.sh:427). Both tests are also false when the destination exists but its parent cannot be searched, so an unsearchable secondmatedata/falls through torecord_inheritable_config_result ... unchangedat line 452 and the function returns 0. Compare bin/fm-config-inherit-lib.sh:560-570, where propagate_inheritable_config now classifies the destination tri-state and errors on UNDETERMINABLE - the same decision, opposite handling, one function apart. bin/fm-path-state-lib.sh:21 declares itself "the single owner of that classification; do not reimplement it", and the operator's round-5 instruction was that this function is "the last reimplementation left on the propagate_secondmate_inheritance path"; the source half was converted, this half was not. Reproduced directly: primarydata/present with captain-shared.md genuinely absent, secondmatedata/at mode 000 holding a live captain-shared.md -> propagate_shared_captain_preferences returns rc 0 and recordsdata/captain-shared.md unchanged, while the destination copy that primary absence should have quarantined and removed survives untouched. Failure scenario: the operator deletes data/captain-shared.md, a secondmate home's data/ has lost its search bit (or is a symlink into an unmounted volume), bin/fm-bootstrap.sh:403's locked sweep or bin/fm-config-push.sh:170 runs -> that home keeps stale captain preferences the primary retracted and the push is reported as fully converged with no warning. Not destructive (nothing is deleted or displaced), but it is a false success report on the one remaining unconverted classification site. Fix symmetrically with the sibling: classify $dest with fm_path_state before the branch - UNDETERMINABLE becomes an error that leaves the destination untouched and sets rc=1, PROVABLY ABSENT keeps today'sunchangedresult so the existing absence-mirror assertions stay green.🔧 Fix: classify captain-shared destination through shared path helper
1 warning still open:
bin/fm-test-run.sh:669- tests/fm-sdev-spawn.test.sh has no arm in family_for_basename, so it resolves tounclassified(bin/fm-test-run.sh:192), and no families_for_changed_path arm ever emitsunclassified. select_changed (bin/fm-test-run.sh:791-798) only adds a script when family_for_basename(basename) equals a wanted family, so that file is reachable under --changed ONLY via thetests/*.test.sh->__script__:arm, i.e. when the test file itself is edited. This change adds the sole coverage of the sdev abort-verb split to that file: test_sdev_workspace_inside_a_no_go_path_is_refused_and_removed and test_sdev_ordinary_abort_leaves_the_workspace_offset_and_ledger pinsdev destroy --forceto the no-go refusal only (bin/fm-spawn.sh:447-457), which is precisely the regression the previous round caught. Failure scenario: someone edits spawn_abort_remove_task_worktree in bin/fm-spawn.sh and drops the[ "$SPAWN_WORKTREE_ABORT_NO_GO" != 1 ] && return 0gate, so every abort in the armed span (bin/fm-spawn.sh:1516 to :1959 - e.g. abin/fm-busy-event.sh armfailure) force-removes the workspace, its port offset, and its ledger entry;fm-test-run.sh --changedselects backend-dispatch, pure-contract-unit and secondmate for that path (bin/fm-test-run.sh:669-676), none of which contain fm-sdev-spawn.test.sh, so the suite stays green. The script header states --changed over-selects rather than under-selects, and the identical class of gap for bin/fm-no-go-lib.sh was already accepted and fixed in an earlier round. Prefer emittingprintf '%s\n' "__script__:fm-sdev-spawn.test.sh"from this arm over classifying the file into backend-dispatch: the test hard-requiresyq(tests/fm-sdev-spawn.test.sh:60,72,132) with no skip gate, so folding it into a family would add that dependency to every script in the family.🔧 Fix: classify sdev spawn suite into backend-dispatch family
2 infos still open:
bin/fm-config-inherit-lib.sh:370- propagate_shared_captain_preferences has THREE existence classifications, not two, and only two were converted. Round 5 moved the source (line 343) and round 6 moved the absence-branch destination (line 432) onto fm_path_state, but the src-EXISTS branch still tests its destination with the two-state shape the shared owner was introduced to eliminate:if [ -e "$dest" ] || [ -L "$dest" ]at line 370. bin/fm-path-state-lib.sh:21 declares itself "the single owner of that classification; do not reimplement it", so this is the last reimplementation left in the function the last two rounds were converting. Reachable input: primary data/captain-shared.md present and valid, secondmate data/ unsearchable (mode 000, or a symlink into an unmounted volume) with a live captain-shared.md inside. Both tests answer false, so the code takes the "destination does not exist" path; the guard that looks like it would catch that does not, because shared_captain_dir_safe (lines 233-242) only checks-dand! -Land returns 0 for a mode-000 directory. Execution then reaches copy_shared_captain_file, whose mktemp into the unsearchable dir fails with EACCES. Outcome today is fail-closed and non-destructive: record_inheritable_config_result ... error "failed to copy", rc=1, destination untouched, nothing quarantined or removed. So the behavioral invariant ("callers must fail closed on UNDETERMINABLE") does hold here - what is wrong is that the diagnostic names "failed to copy" rather than the unsearchable directory, and the site is inconsistent with its two converted siblings one branch away. The new coverage does not reach it either: test_undeterminable_destination_is_reported_as_failure pins only the src-ABSENT destination path, so this branch would keep passing if it later grew a destructive step. Routing line 370 through fm_path_state the way lines 432-437 already do would close it, but given the outcome is already correct this is a note, not a blocker - the operator has twice asked for convergence rather than expansion.bin/fm-path-state-lib.sh:30- fm_path_state_reason is defined but never called anywhere in bin/ or tests/. bin/fm-path-state-lib.sh:26-27 instructs callers to "Read it through fm_path_state_reason rather than the variable", yet all four consumers read the global directly: bin/fm-no-go-lib.sh:107 and bin/fm-config-inherit-lib.sh:345, :434, :575 all interpolate $FM_PATH_STATE_REASON. So the library's own stated access contract is violated by every one of its callers, and the accessor is dead code introduced by this branch. Either drop the function and the sentence, or use it at the four sites; today the header documents a convention the codebase does not follow, which is the kind of drift that makes the next reader trust the wrong thing.✅ **Test** - passed
✅ No issues found.
adocs/scripts.md:9- docs/scripts.md is the bin/ toolbelt inventory but omits 18 scripts unrelated to this change: fm-cd-command-policy.mjs, fm-cd-pretool-check.sh, fm-doc-audience-check.sh, fm-herdr-session-cleanup.sh, fm-install-shellcheck.sh, fm-landing-policy.sh, fm-lint.sh, fm-procevent-lavish.sh, fm-procevent-lib.sh, fm-procevent.sh, fm-push-transition-lib.sh, fm-run.sh, fm-sdev-registry.sh, fm-secondmate-registry-lib.sh, fm-ship-multi.sh, fm-startup-memory-budget-lib.sh, fm-startup-memory-budget.sh, fm-transition-lib.sh. Pre-existing drift, not caused by this change; this change's own two new libraries were added. Nothing enforces coverage, so the table silently decays. Follow-up worth considering: a coverage assertion in bin/fm-doc-audience-check.sh or fm-lint.sh that fails when a bin/ script has no scripts.md row, which would make the table self-maintaining instead of relying on each author remembering.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.