Repository navigation
feat(bin): add an opt-in no-mistakes home resolver for host reads - #7348
Conversation
Sites that run one no-mistakes daemon per isolated workspace keep each task's runs in a per-workspace NM_HOME that cannot be derived from the shared gate remote, so crew state, pipeline spend, and teardown read the wrong home. When NM_HOME is unset and config/nm-home-resolver names a site-provided executable, fm-nm-run-lib.sh now calls it with the task copy path and exports the printed home for that one call. Only host reads (axi status, the axi overview, axi logs, runs, daemon status, the state database) and axi abort --run use it. An explicit NM_HOME always wins, and with no file behaviour is unchanged. Fixes kunchenguid#7309
|
Speaking as Kun's firstmate: thank you @rchristensen — tip Contract-class: opt-in (my own read). Unconfigured path is unchanged: with VISION.md: one captain aligns; authority aligns (opt-in grant, never inferred); scripts own the resolver mechanics; restart aligns (no new durable obligation); delegation aligns; vendor-neutral; scope aligns (host no-mistakes reads only). Security: no workflow/secret/network changes. Resolver runs only when configured, bounded to 5s, requires an existing absolute directory answer so a wrong path cannot plant a fresh home. Approved fork CI Attestation: MATCH tip |
|
The 'Behavior portable serial 3' failure ('not ok - bootout did not stop the tracked worker' in tests/fm-remote-job-launchagent.test.sh) and the cancelled 'Behavior portable serial 2' shard look unrelated to this change: that test does not load bin/fm-nm-run-lib.sh or read NM_HOME, and it passes locally on this commit. Could a maintainer re-run those two jobs? Re-running from a fork needs repository admin rights. |
|
Speaking as Kun's firstmate: thanks @rchristensen — agreed, neither failure touches this diff. |
|
Friendly ping on this one: it's the accepted opt-in from #7309 (per-workspace |
|
Speaking as Kun's firstmate: thanks for the ping @rchristensen, and sorry this sat. Nothing is needed from you — no rebase required (it is MERGEABLE against current main). Head CI: the only red is |
|
@kunchenguid are we on the auto-merge path? all looks green to me |
|
Speaking as Kun's firstmate: this is merged. Thank you @rchristensen — really appreciate you taking the time on this. |
Intent
Implement the accepted fix for #7309: an opt-in NM_HOME resolver for host-side no-mistakes reads when each workspace runs its own no-mistakes daemon.
Problem: every host-side no-mistakes read goes through
fm_nm_bounded,fm_nm_run*andfm_nm_state_dbinbin/fm-nm-run-lib.sh, which use the ambientNM_HOMEor default to~/.no-mistakes. When a task's run lives in a per-workspaceNM_HOME, crew state sees no run for the task, pipeline spend cannot find it, and teardown never aborts a parked run. The home cannot be derived from theno-mistakesremote URL, because every workspace of a project shares one gate URL.Accepted direction (maintainer triage on main 33503ab, contract class opt-in):
NM_HOMEis unset and a resolver command is configured, the read paths run it with the worktree path. If it prints a home, thatNM_HOMEis exported for that one call.NM_HOMEalways wins. With nothing configured, behaviour is exactly as today.axi status,runs,logs,daemon status, the state DB) andaxi abort --runonly. It never starts a daemon and never touches launch, account routing orconfig.yaml.config/file or an environment variable) may be chosen in the PR, as long as it is documented and off by default.What Changed
bin/fm-nm-run-lib.shgets an opt-in resolver hook. WhenNM_HOMEis unset andconfig/nm-home-resolvernames an absolute executable,fm_nm_run_boundedandfm_nm_state_dbcall that executable with the worktree path, with a 5-second limit. The answer counts only if the executable prints exactly one line naming an existing absolute directory. That directory is then exported asNM_HOMEfor that one call.axioverview,axi status,axi logs,runs,daemon status, the state DB) and toaxi abort --run <id>. Every other no-mistakes call keeps the ambient home. An explicitNM_HOMEalways wins. If the file is missing or the resolver fails, times out or prints anything unusable, behaviour is the same as before.docs/configuration.mdand in the operational-home-layout skill. New tests cover pipeline spend: finding a resolved workspace home, an explicitNM_HOMEwinning, bad resolver output falling back to the ambient home, and the command scope. A teardown test covers aborting a parked run that lives in a resolved workspace home.Risk Assessment
✅ Low: The opt-in resolver is confined to the intended host reads and run-targeted abort, preserves explicit home precedence, and leaves unconfigured behavior unchanged.
Testing
Both targeted test files passed: fm-pipeline-spend and fm-teardown, including the new resolver tests. I then drove the change live with the real no-mistakes v1.84.0 CLI in a disposable lab. It had a firstmate lab home, a throwaway git project with its gate initialised in its own home (wsA), and a separate fake account home acting as the default
~/.no-mistakes. Reads through the resolver went to wsA.fm-crew-statewent fromunknowntodone · source: run-step · run: 01LABRUNDONE. Pipeline spend went fromsource: unavailabletosource: no-mistakes-statewith the run attributed.axi abort --runwent from "no run with that id" to the wsA daemon accepting the cancel request. An explicitNM_HOMEwon and the resolver was not called. An out-of-scopedaemon stopstayed on the default home and wsA's daemon kept running. Every bad resolver answer fell back to the default home and created no directory. No read started a daemon. The abort fixture is a hand-inserted run row that no daemon was executing, so the cancel request was accepted but the run never reached a terminal state. The full teardown abort flow was not driven live, so that scenario is marked untested; the new teardown unit test covers it. The lab was removed afterwards, and the operator's own daemon (pid 198) was left untouched. There is no UI surface, so all evidence is CLI transcripts.Evidence: Live lib transcript: baseline, opt-in, explicit NM_HOME wins, scope, unusable answers
Source: Live lib transcript: baseline, opt-in, explicit NM_HOME wins, scope, unusable answers
Evidence: Driver script used for the live lib transcript
Source: Driver script used for the live lib transcript
Evidence: Live fm-crew-state and fm-pipeline-spend, resolver off vs on
Source: Live fm-crew-state and fm-pipeline-spend, resolver off vs on
off: state: unknown · source: none ... | spend source: unavailable, runs [] on: state: done · source: run-step · run passed ... · run: 01LABRUNDONE | spend source: no-mistakes-state, runs [01LABRUNDONE]Evidence: Live axi abort --run, resolver off vs on
Source: Live axi abort --run, resolver off vs on
Evidence: Live: resolved reads never start a daemon
Source: Live: resolved reads never start a daemon
Evidence: tests/fm-pipeline-spend.test.sh output
Source: tests/fm-pipeline-spend.test.sh output
Evidence: tests/fm-teardown.test.sh output
Source: tests/fm-teardown.test.sh output
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-pipeline-spend.test.sh(includes the 4 new resolver tests)bash tests/fm-teardown.test.sh(includes test_parked_run_in_a_resolved_workspace_home_is_aborted)Live lab:no-mistakes initin a throwaway repo with NM_HOME=<lab>/wsA, run rows inserted into the real wsA state.sqlite, site resolver mapping <lab>/wt -> <lab>/wsALive:fm_nm_run <wt> runs|daemon status|axi status --runandfm_nm_state_db <wt>, with and without config/nm-home-resolver, using the real no-mistakes CLI (drive.sh)Live: explicitNM_HOME=<lab>/explicitwith the resolver configured; resolver call count recordedLive: out-of-scopefm_nm_run <wt> daemon stopwith the resolver configured; wsA daemon status checked afterwardsLive: resolver that fails (exit 3), prints a missing dir, prints a relative path, or prints two lines; config naming a relative pathLive:bin/fm-crew-state.sh labtaskandbin/fm-pipeline-spend.sh record labtaskagainst the lab FM_HOME, resolver off vs onLive:fm_nm_run_bounded <wt> 30 axi abort --run 01LABRUNPARK, resolver off vs on, against the real wsA daemonLive: wsA daemon stopped, then axi / axi status / runs / daemon status / axi logs run through the resolver; daemon status and process count checked afterwards✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → no changes applied ✅
🔧 No changes applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.
Fixes #7309