Repository navigation
Conversation
The Claude supervision host runs bin/fm-branch-dispatch.mjs, which imports a TypeScript module and so needs a node that strips types natively (22.18.0+ or 23.6.0+). On older Node every attended and away close failed with the generic "branch eligibility could not be computed" because nothing checked the capability and the dispatch calls discarded stderr. - docs/configuration.md "Toolchain" declares the floor, and bootstrap reports a node that cannot load TypeScript as MISSING with the floor and install. - fm_node_loads_typescript (bin/fm-supervision-engine-lib.sh) probes process.features.typescript; the attended readiness check and the away pre-check use it and name the node version and floor. - The three dispatch calls keep node's error line in the ledger row and hand-back instead of discarding stderr. - fm_exec_timed no longer reads bare $BASHPID under set -u, which is unbound on bash 3.2; it asks a child for its parent pid there, keeping the subshell owner logic correct.
|
| case "$first" in heartbeat*) set -- --heartbeat ;; esac | ||
| if ! scope=$(node "$SCRIPT_DIR/fm-branch-dispatch.mjs" scope "$@" --afk 2>/dev/null); then | ||
| HANDLE_WHY="branch eligibility could not be computed" | ||
| if ! scope=$(node "$SCRIPT_DIR/fm-branch-dispatch.mjs" scope "$@" --afk 2>"$DISPATCH_ERRORS"); then |
There was a problem hiding this comment.
Dispatch errors may be readable If the host runs with a
022 umask and its state directory is traversable, the new scope stderr file can be read by another local user while the call runs. The offer redirect has the same issue; wake-prompt already uses umask 077. Create the error file owner-only on all three paths.
| RECEIPTS="$STATE/.supervision-host-receipts" | ||
| PROMPT_FILE="$STATE/.supervision-host-prompt" | ||
| WAKE_FILE="$STATE/.supervision-host-wake" | ||
| DISPATCH_ERRORS="$STATE/.supervision-host-dispatch-errors" |
There was a problem hiding this comment.
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
Authorize the upstream firstmate fix from the supervision-host investigation.
The investigation found that the Claude supervision host (on by default for Claude primaries since #6124) shells out to
node bin/fm-branch-dispatch.mjs, which dynamically imports.pi/extensions/lib/fm-branch-dispatch.ts. That import only works on Node builds with native TypeScript type stripping (22.18.0+ / 23.6.0+). On older Node (18, 20, 22 before 22.18) every attended and away close fails with the generic "branch eligibility could not be computed": attended closes silently pass through, away closes are all handed back to main, and the return brief shows nothing. Firstmate declares no Node floor, its bootstrap and host readiness checks only test thatnodeexists, and the three dispatch calls discard stderr.The fix scope recommended and approved:
docs/configuration.md"Toolchain" (Node with native TypeScript type stripping: 22.18.0+ or 23.6.0+), and havebin/fm-bootstrap.shreport a too-old node with upgrade guidance, as it does for other floors.fm_supervision_host_attended_readyinbin/fm-supervision-engine-lib.shand the away pre-check inbin/fm-supervision-host.sh), e.g.node -e 'process.exit(process.features.typescript ? 0 : 1)', with a specific reason such as "node vX cannot load TypeScript; the supervision session needs Node 22.18+".fm-branch-dispatch.mjscalls in the ledger row instead of2>/dev/null.tests/fm-supervision-host.test.shthat puts anodelacking type stripping first on PATH and asserts the specific readiness reason, plus a bootstrap case for the floor.Also fix the latent bash 3.2 defect found on the same path:
bin/fm-timeout-lib.sh:224uses bare$BASHPIDunderset -u, which is unbound on bash 3.2 (the engine turn dies with "BASHPID: unbound variable"); use the repo's 3.2-safe idiom while keeping the owner logic correct, with a bash 3.2 regression.What Changed
Added
fm_node_loads_typescripttobin/fm-supervision-engine-lib.sh. It checksprocess.features.typescriptto confirm Node can strip TypeScript types natively (floor: 22.18.0+ or 23.6.0+). Three callers now use it:fm_supervision_host_attended_readyand the away pre-check inbin/fm-supervision-host.sh, which used to check only thatnodeexists. They now give a specific reason, such as "node vX cannot load TypeScript; the supervision session needs Node 22.18.0+ or 23.6.0+".bin/fm-bootstrap.sh, which now reportsMISSING: node (... cannot load TypeScript; requires <floor>; install: ...).The floor is declared in the
docs/configuration.mdToolchain section.docs/supervision-host.mdand the bootstrap-diagnostics skill are updated to match.The three
fm-branch-dispatch.mjscalls (scope,wake-prompt,offer) no longer send stderr to/dev/null. They write it to.supervision-host-dispatch-errors, and a newdispatch_causehelper adds the first error line to the ledger reason. For example, "branch eligibility could not be computed: " replaces the generic message.fm_exec_timedinbin/fm-timeout-lib.shused bare$BASHPID, which is unbound underset -uon bash 3.2. It now falls back to a 3.2-safe way of getting its own pid. New regression tests cover the old-Node readiness reason, the bootstrap floor report, and the bash 3.2 timeout path.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change follows the approved four-part scope plus the BASHPID fix, and every new path traced correctly: the capability probe, the bootstrap MISSING line, stderr capture and cleanup on the success and failure paths of all three dispatch calls, and the bash 3.2 fallback, which uses /bin/sh's $PPID to get the current shell's pid. Each fix has a behavioral regression test.
Testing
I ran bootstrap and the readiness function against real old Node builds on this machine (v18.16.0 and v22.2.0). Both report the specific "cannot load TypeScript; requires 22.18.0+ or 23.6.0+" reason; v22.22.2 and v24 pass silently. I reproduced the bash 3.2 "BASHPID: unbound variable" crash on the base commit, and the same call runs the command on this branch. The three targeted test files all pass (exit 0). The new supervision-host tests start the real host and check attended pass-through, the away hand-back and the ledger rows with dispatch error causes. I did not drive a full Claude primary in a lab for the old-node attended or away close. Those paths were covered by the host test harness, which runs the real host script with a node shim (the real node with type stripping turned off); the real Node 18 and 22.2 checks reached only bootstrap and the readiness function. I removed the lab home afterwards and the worktree is clean.
Evidence: Bootstrap with real node versions first on PATH
Source: Bootstrap with real node versions first on PATH
Evidence: Readiness reason and raw dispatch stderr on real old/new node
Source: Readiness reason and raw dispatch stderr on real old/new node
Evidence: bash 3.2 BASHPID before/after
Source: bash 3.2 BASHPID before/after
base: line 224: BASHPID: unbound variable rc=127 branch: bounded-command-ran rc=0Evidence: Supervision host test output
Source: Supervision host test output
Evidence: Timeout lib test output
Source: Timeout lib test output
Evidence: Bootstrap test output
Source: Bootstrap test output
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-supervision-host.sh:1030- The intent asks to keep "the first stderr line" of the dispatch calls.dispatch_cause(bin/fm-supervision-host.sh:1030) instead prefers node's<Name>Error[ [CODE]]:line and falls back to the first nonblank line. This is a deliberate refinement: when an ESM import fails uncaught, node's first stderr lines are only a source location (node:internal/...:NNN, athrowexcerpt and a caret), so the literal first line would still hide the cause. The fallback covers the controlled exits 2 and 3, which print a single line. No action needed.✅ **Test** - passed
✅ No issues found.
bin/fm-bootstrap.shin a throwaway lab home (bin/fm-lab-home.sh create), once each with real node v18.16.0, v22.2.0, v22.22.2 and v24.16.0 first on PATHSourcedbin/fm-supervision-engine-lib.shand calledfm_supervision_host_attended_readywith real node v18.16.0, v22.2.0 and v22.22.2Rannode bin/fm-branch-dispatch.mjs offerdirectly on real node v18/v22.2/v22.22 to see the stderr thatdispatch_causekeeps/bin/bash3.2.57 withset -u: calledfm_exec_timedin a subshell, using the base-commit lib and then the changed libbash tests/fm-timeout-lib.test.sh(includes the new bash-3.2 and no-BASHPID cases)bash tests/fm-bootstrap.test.sh(includes test_node_typescript_floor)bash tests/fm-supervision-host.test.sh, which runs the real host process (includes the 3 new node-floor and dispatch-cause tests)✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.