Repository navigation
fix(daemon): exec the Claude hook and status line commands so sh becomes Node (#3416) - #3427
Conversation
…mes Node (mvschwarz#3416) The plugin's hooks/claude.json commands and the status line and activity relay entries that launch writes into .claude/settings.local.json now start with `exec`. Under dash, `sh -c` otherwise stays as a parent of every Node hook, so each event cost two processes. OpenRig owns the generated settings entries by their exact shape, so parseManagedClaudeNodeCommand (and the matchers in claude-owned-settings.ts and restore-check that use it) and the relay's own settingsRelayPath accept one plain leading `exec`: a launch replaces, and rig down takes back, both the shape earlier versions wrote and the new one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…nterpreter (mvschwarz#3416) The bash 3.2 behind macOS /bin/sh exits 126 when `exec` can't find the pinned interpreter; dash and current bash exit 127. Both mean the shell couldn't run it, and the test now also checks that nothing ran in its place (the collector's sidecar isn't written again). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The
This PR's own daemon job (run 44115350172) is still waiting for a macOS runner. The same commit passed |
openrig-review
left a comment
There was a problem hiding this comment.
Approved at 73ffe7b. The Claude hook and status line commands OpenRig writes now exec their Node process, so the shell is replaced rather than kept alive beside it, and the settings matchers recognise the new shape. Both review halves are clear, and required CI passes at this head. Thank you, @billbenetti.
|
Thanks, @billbenetti, this is now merged into The known limit, as the change records it: a daemon older than this change doesn't recognise the |
…tch (#3416) (#3439) Item 2 of #3416 (item 1 is #3427, already on main). The activity relay is a fresh Node process for every Claude hook event, and its first global fetch loaded Node's bundled HTTP client each time. It now posts with node:http, or node:https for an https base URL: the same body to the same URL with the same bearer token, at most 1.5 s, every error swallowed, so the daemon records exactly what it did before. One behaviour is tighter: the connection closes as soon as the daemon's response headers arrive, so a peer that sends headers and then stalls the body no longer keeps the hook process alive. The author measured roughly half the child CPU per event in a same-host microbenchmark; that is their measurement, not a measured daemon or fleet responsiveness gain. No new refusal, setting or error code.
|
@billbenetti, thanks again: this is now released in OpenRig 0.7.19. |
What a user gets
Refs #3416 (item 1; items 2 and 3 come separately). Every OpenRig Node hook and the seat status line now start with
exec, so the/bin/sh -cthat Claude Code runs them through becomes the Node process instead of waiting on it. On Debian/Ubuntu, where/bin/shis dash and does not exec the last command ofsh -c, each hook event costs one process instead of two (about 500 fewershprocesses a minute on the 90-seat host from the issue). Exit codes, stdout and stdin are unchanged.hooks/claude.json: the 14 plugin hook commands start withexec "${OPENRIG_NODE:-node}" …..claude/settings.local.jsonstart withexectoo.parseManagedClaudeNodeCommand(and through itisOwnedCollectorCommand,isOwnedRelayCommandand restore-check) and the relay's ownsettingsRelayPathaccept one plain leadingexec, so both the shape earlier versions wrote and the new one stay OpenRig's: a launch replaces either,rig downtakes either back, and the plugin's relay still stays quiet when the settings relay (in either shape) is registered for the event.docs/reference/claude-status-line.md(copy the collector command into a wrapper without its leadingexec) and the plugin README (the settings relay shape may start withexec).How you verified it
On
49a41912fplus this change (rebased ontofe0d346dfwith no overlap), Linux (/bin/sh= dash), Node 22, focused Vitest with--maxWorkers=2; I did not run the fullnpm teston this host.claude-hook-node-invocation.test.ts:exec(5 kinds × 2 prefixes);/bin/sh -c, are the Node process itself (process.pidequals the spawned child's pid), with a pinned and a legacy interpreter;execand runs as the shell's own pid;exec/exec\tbefore the old shape and refuseexec exec …,exec -a name …,'exec' …,execnode …,exec <script>alone,exec, and other wrappers.claude-core-plugin-load.test.ts: the plugin relay deduplicates against a pinned settings relay with and withoutexec.rig-teardown.test.ts:rig downrestores the person's settings bytes when the relay hooks and the status line are in either shape.restore-check-service.test.ts: the activity-hook check is green for the relay command withexec(barenodeand an absolute interpreter), next to the existing shapes.claude-activity-hook-delivery.test.ts: disable strips the owned relay in both shapes; the other expectations of the generated shape are updated there and inclaude-collector-unchanged-write,claude-context-collectorandpermission-stop-relay.startupclassic-clear cases, theprovider-switch-cliintegration, 2claude-relay-project-cleanupgit-clean cases, and the relay asset's 0755 mode, which my sandbox copy doesn't keep). Control: the new tests against the base sources fail in 25 cases, everyexeccase.tsc --noEmitforpackages/daemonis clean.Anything you were unsure about
claude-code-adapter.ts(launch artery), but aruntime: stubseat never goes through the Claude adapter, and the stub does not run Claude Code's hooks or status line, so a stub scenario cannot see either shape. The coverage is the tests above, which execute the real generated and shipped commands through/bin/sh.execshape, so after a downgrade it would treat those entries as the person's own (no refresh, and its relay would be added next to the existing one). Upgrade is covered: the matchers accept both shapes.If this is security-related
Not security-related.
CHANGELOG.mdedit🤖 Generated with Claude Code
Summary by CodeRabbit
execto run Node directly, replacing the invoking shell.execremain recognized during refresh, cleanup, and duplicate-event suppression, preserving compatibility with previously generated settings.exec.