Repository navigation
fix(bin): stop no-mistakes status probes from fetching and leaking processes - #91
Merged
Merged
Conversation
…ocesses Firstmate's read-only no-mistakes probes run in core worktrees, which are partial clones. no-mistakes resolving a run commit the copy does not hold made the promisor fetch it, measured at about 10 seconds and about 500 MB per call, on every supervision pass. Export GIT_NO_LAZY_FETCH=1 for the probe child so a missing object answers "absent" immediately, which is what the attribution rules already expect, and do the same for this library's own fm_nm_resolve_commit, whose contract already claimed it never fetches. The probes' timeout wrapper also duplicated the mechanism selection that bin/fm-timeout-lib.sh owns, and its GNU timeout arm sent TERM to the group with no KILL escalation and no reap. A probe that ignored TERM survived the bound reparented to init and kept working, piling up another copy every pass. Route the wrapper through fm_run_timed, the single owner, which runs the command in its own process group and escalates TERM to KILL on every mechanism it selects.
… exporting it ShellCheck reads the exported PATH and mechanism override in one subshell as possibly lost in the next (SC2030/SC2031). Set them as command prefixes, the shape tests/fm-timeout-lib.test.sh already uses, so lint passes without a suppression.
…g the environment CI's source-following ShellCheck ties the shell-variable read back to the export inside fm_nm_run_bounded's subshell and reports SC2031. What must not leak is what a later child would inherit, so read the exported environment instead; nothing here exports the variable, and the assertion still fails when it is present.
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.
Problem
Firstmate's read-only no-mistakes probes - the
axi statuspath andfm_nm_run_checkedinbin/fm-crew-state.sh, the custody check inbin/fm-dod-lib.sh, and the pre-teardown run lookup inbin/fm-teardown.sh-run inside core worktrees, which are partial clones. When no-mistakes resolved a
run commit the copy did not hold, the promisor fetched it: about 10 seconds and
about 500 MB per call (
upload-pack: not our ref ...), paid on everysupervision pass.
bin/fm-nm-run-lib.shalso carried its own copy of the timeout-mechanismselection that
bin/fm-timeout-lib.shalready owns, and that copy's GNUtimeoutarm passed no-k: it sent TERM to the process group and neverescalated or reaped. A probe that ignored TERM survived its deadline reparented
to init and kept working, so another copy accumulated every pass.
Change
fm_nm_run_boundedexportsGIT_NO_LAZY_FETCH=1for the probe's ownsubshell. A missing object now answers "absent" immediately, which is what
this library's attribution rules already expect. It is exported rather than
passed through
env, so the supervision hot path gains no PATH dependency.Every no-mistakes call made through this library is a read-only probe plus
teardown's own
axi abort; none of them may fetch, and the header says so.fm_nm_resolve_commitdoes the same for firstmate's own lookup. Its contractalready claimed it never fetches; in a partial clone that was not true, and it
is the second source of the same promisor fetch on the same hot path.
fm_nm_boundednow routes throughfm_run_timed, deleting the duplicatedmechanism selection. The single owner runs the command in its own process
group and escalates TERM to KILL on every mechanism it selects.
bin/fm-timeout-lib.shpasses the caller's stdin through its asynchronouslaunches (
<&0). Both the external-timeout and bash mechanisms start thebounded command in the background, where bash substitutes
/dev/null; withoutthis,
bin/fm-pipeline-spend.sh, which feedspython3 -a heredoc throughfm_nm_bounded, would have lost its program.bin/fm-crew-state.shdescribing the removed "no timeout toolreturns 1" path was made wrong by the change and is corrected.
Tests
tests/fm-nm-run-lib.test.shis new and runs each case against every boundmechanism available on the host. All four cases were confirmed to fail against
the pre-change code:
GIT_NO_LAZY_FETCH=1, runs in the worktree it was given, anddoes not leak the variable into its caller;
ignore TERM, so only an escalation to KILL across the whole group ends them,
and the test asserts the descendant has stopped working afterwards rather than
only that its pid is gone;
fm_nm_resolve_commitanswers absent for a commit only the promisor holds,with a non-vacuity check that the same lookup without the guard does fetch it.
The orphan was reproduced directly against a faithful GNU
timeoutstand-in:with the previous library the probe and its descendant both survived the bound
with ppid 1 and kept running; with this change both are gone.
Targeted suites run locally, all green:
fm-nm-run-lib,fm-timeout-lib,fm-crew-state,fm-dod-lib,fm-pipeline-spend,fm-teardown,fm-test-run,fm-gotmp.bin/fm-lint.shandbin/fm-doc-audience-check.share clean.
Follow-up, out of scope here
How no-mistakes itself resolves a run commit is an upstream no-mistakes matter.
Disabling lazy fetching stops firstmate paying for it; the upstream CLI could
avoid touching the object store for that answer at all.