Skip to content

fix(runtime): spawn hook argv without a login shell - #25

Merged
steipete merged 4 commits into
openclaw:mainfrom
SebTardif:fix/hook-argv-no-shell
Sep 16, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
SebTardif:fix/hook-argv-no-shell

Conversation

@SebTardif

@SebTardif SebTardif commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Imported command hooks ignored args and could not preserve the source application's direct-execution behavior. Honor the documented Claude Code exec form: command plus args launches an executable with literal arguments. String commands retain their existing shell behavior; command arrays are also supported.

On Windows, both forms remain inside the existing kill-on-close Job supervisor. Exec-form commands travel as Base64-encoded JSON and use Windows argument quoting, so shell syntax stays literal while timeout/output-limit cleanup can still terminate descendants. This preserves the existing execution trust boundary: installing a plugin authorizes its code.

Thanks @SebTardif for the original implementation and reproduction. The maintainer follow-up repairs Windows process-tree supervision and adds portable runtime coverage.

Verification

  • A regression first failed because Windows argv hooks spawned node directly rather than the Job supervisor; it now passes.
  • Real child-process tests preserve empty arguments, spaces, quotes, trailing backslashes, shell metacharacters, environment-looking text, and Unicode.
  • A real descendant-process test terminates the command's supervisor and verifies the descendant exits. It runs on macOS, Linux, and Windows CI.
  • Local npm run check: 70 tests passed. npm run pack:check passed.
  • Independent autoreview: no actionable P0–P2 findings on the complete staged candidate.
  • Earlier compiled macOS proof also confirmed literal $(echo INJECTED) and unchanged /bin/sh -lc string execution. No live Gateway session was used; runtime fixtures are synthetic.

README compatibility guidance, the compatibility reference, and the Unreleased changelog are updated. The first Windows run exposed PowerShell 5.1 wrapping the decoded JSON array into a single pipeline object. Direct typed assignment now retains the executable and individual arguments. The existing runtime assertions are unchanged.

Windows runtime verification comes from the PR's Windows CI job.

Accept Claude Code exec-form hook args and command arrays, then spawn
those hooks as argv. String command values still run through /bin/sh -lc.
Plugin install remains trusted code execution.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 15, 2026, 10:47 PM ET / September 16, 2026, 02:47 UTC (Revision 9).

ClawSweeper review

What this changes

Preserve literal arguments in imported command hooks by supporting direct executable invocation while retaining shell execution for strings and Windows process-tree supervision.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 5 items remain

The change remains necessary and the previous supervision bypass is repaired, but the revised Windows decoder prevents argv hooks from starting. GitHub’s Windows failure annotations confirm the new defect.

Priority: P2
Reviewed head: 6c550d47a16438361101659dea5a7e255d628441

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused work with preserved macOS evidence, but a confirmed Windows launch defect and incomplete Windows success evidence block readiness.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Earlier compiled macOS proof remains valid for literal argv and unchanged shell strings. The new Windows launcher fails at executable lookup, so its observed run cannot demonstrate successful argument preservation or descendant cleanup after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Earlier compiled macOS proof remains valid for literal argv and unchanged shell strings. The new Windows launcher fails at executable lookup, so its observed run cannot demonstrate successful argument preservation or descendant cleanup after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Repository policy applied: Read the complete root AGENTS.md; no nested AGENTS.md or matching maintainer notes were found. The patch includes focused execution tests, compatibility documentation, and a changelog entry.
Current main still lacks argv hooks: Current main accepts only string commands in hook discovery and always launches them through the platform shell; args are not preserved.
Latest release also uses string-only launch: GitHub identifies v0.1.0 as the latest release; its launcher accepts only strings. No merged replacement for this argv work was found in the repository’s pull-request listing.
Findings 1 actionable finding [P1] Preserve the decoded argv elements on Windows PowerShell
Security None None.

How this fits together

Babelfish translates installed Claude Code and Codex plugin hooks into OpenClaw lifecycle behavior. Its launcher passes event JSON to child processes and returns their output or blocking decisions.

flowchart TD
  A[Installed plugin hooks] --> B[Hook discovery]
  B --> C{Command format}
  C -->|String| D[Shell execution]
  C -->|Argument array| E[Direct executable launch]
  D --> F[Platform process supervision]
  E --> F
  F --> G[Hook output or failure]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Earlier compiled macOS proof remains valid for literal argv and unchanged shell strings. The new Windows launcher fails at executable lookup, so its observed run cannot demonstrate successful argument preservation or descendant cleanup after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve the decoded argv elements on Windows PowerShell (P1) - On the Windows PowerShell launcher used here, wrapping ConvertFrom-Json in @(...) and casting to string[] collapses the returned array into one space-joined string. Consequently, Get-Command receives the executable plus every argument as its name, and argv hooks never start. The exact-head Windows check confirms this in both the literal-argument and imported-hook tests. Decode into a flat string array while preserving empty elements before resolving element zero.
  • Resolve merge risk (P1) - Windows hooks declaring args now enter the broken decoder and fail before execution, potentially suppressing previously running hook behavior.
  • Resolve merge risk (P1) - Successful Windows literal-argument handling and descendant termination remain unproven after the supervision revision.
  • Complete next step (P2) - Repair Windows argv decoding and supply successful Windows argument-preservation and process-tree cleanup evidence before merge.

Findings

  • [P1] Preserve the decoded argv elements on Windows PowerShell — assets/windows-job.ps1:545-546
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth Production +82 net lines; tests +123 lines The production growth supports direct invocation and supervised Windows launches, with focused discovery, quoting, and cleanup coverage.

Merge-risk options

Maintainer options:

  1. Repair Windows argument decoding (recommended)
    Preserve the decoded array elements and demonstrate successful Windows hook execution and descendant cleanup before landing.

Technical review

Best possible solution:

Decode Windows argv without collapsing array elements, then preserve literal arguments and Job cleanup while keeping existing string-shell behavior intact.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main source demonstrably ignores hook args, and the exact PR head’s Windows check independently captures the new decoder failure. No target code was executed during this read-only review.

Is this the best way to solve the issue?

The direct-launch approach is appropriate, but the current Windows implementation is incorrect; preserve the decoded JSON array before executable lookup rather than coercing a nested array into a string.

Full review comments:

  • [P1] Preserve the decoded argv elements on Windows PowerShell — assets/windows-job.ps1:545-546
    On the Windows PowerShell launcher used here, wrapping ConvertFrom-Json in @(...) and casting to string[] collapses the returned array into one space-joined string. Consequently, Get-Command receives the executable plus every argument as its name, and argv hooks never start. The exact-head Windows check confirms this in both the literal-argument and imported-hook tests. Decode into a flat string array while preserving empty elements before resolving element zero.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0c481cdb9296.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The introduced Windows decoder turns multi-element argv into an invalid executable name, preventing affected hooks from running.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Earlier compiled macOS proof remains valid for literal argv and unchanged shell strings. The new Windows launcher fails at executable lookup, so its observed run cannot demonstrate successful argument preservation or descendant cleanup after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove status: ⏳ waiting on author: Current PR status label is status: 📣 needs proof.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove merge-risk: 🚨 availability: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.

Label justifications:

  • P2: This is a bounded imported-hook compatibility repair with a concrete Windows blocker, without evidence of an urgent deployed regression.
  • merge-risk: 🚨 compatibility: The introduced Windows decoder turns multi-element argv into an invalid executable name, preventing affected hooks from running.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Earlier compiled macOS proof remains valid for literal argv and unchanged shell strings. The new Windows launcher fails at executable lookup, so its observed run cannot demonstrate successful argument preservation or descendant cleanup after the fix. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Repository policy applied: Read the complete root AGENTS.md; no nested AGENTS.md or matching maintainer notes were found. The patch includes focused execution tests, compatibility documentation, and a changelog entry. (AGENTS.md:1, 6c550d47a164)
  • Current main still lacks argv hooks: Current main accepts only string commands in hook discovery and always launches them through the platform shell; args are not preserved. (src/bundle-plugins.ts:244, 0c481cdb9296)
  • Latest release also uses string-only launch: GitHub identifies v0.1.0 as the latest release; its launcher accepts only strings. No merged replacement for this argv work was found in the repository’s pull-request listing. (src/shell-command.ts:54, 5e2ccd634980)
  • Previous supervision finding addressed: The pinned introduced diff routes Windows arrays through the existing Job supervisor and adds native argument quoting. The earlier bypass finding is therefore resolved; the decoder failure is in newly added code. (src/shell-command.ts:66, 6c550d47a164)
  • Windows argv decoder fails before process creation: The Windows check reports Get-Command receiving the executable, -e script, and all test arguments as one executable name. Both literal-argument preservation and imported-hook execution fail; the descendant test receives no PID. These are annotations from the exact reviewed head: https://github.com/openclaw/babelfish/actions/runs/35049125720/job/104645625852 . Full log download was blocked, but the GitHub annotations expose the concrete failure. (assets/windows-job.ps1:545, 6c550d47a164)
  • Source application contract: The PR explicitly claims compatibility with Claude Code exec-form hooks. Its official documentation specifies that args selects direct executable invocation and preserves each argument without shell tokenization: https://code.claude.com/docs/en/hooks#exec-form-and-shell-form . This establishes the relevant external contract; repository ownership of that documentation was not inferred.

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Fix Windows JSON-array decoding without losing empty arguments or adding shell parsing.
  • Add redacted Windows terminal output showing literal arguments and descendant termination after timeout or output overflow; retain a string-hook compatibility check. Remove private paths, endpoints, and credentials before posting. Updating the PR body should trigger review; otherwise ask a maintainer to comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-30T03:28:26.354Z sha f5e4c11 :: needs changes before merge. :: [P1] Keep argv hooks inside Windows Job supervision
  • reviewed 2026-08-30T16:06:20.636Z sha f5e4c11 :: needs changes before merge. :: [P1] Keep argv hooks under Windows Job supervision
  • reviewed 2026-08-30T17:56:28.218Z sha f5e4c11 :: needs changes before merge. :: [P1] Keep argv hooks under Windows Job supervision
  • reviewed 2026-08-31T11:06:26.004Z sha f5e4c11 :: needs changes before merge. :: [P1] Keep argv hooks under Windows Job supervision
  • reviewed 2026-09-01T18:13:46.570Z sha f5e4c11 :: needs real behavior proof before merge. :: [P1] Keep argv hooks under Windows Job supervision
  • reviewed 2026-09-03T10:50:13.390Z sha f5e4c11 :: needs real behavior proof before merge. :: [P1] Keep argv hooks under Windows Job supervision
  • reviewed 2026-09-03T16:30:09.828Z sha f5e4c11 :: blocked before merge. :: [P1] Keep argv hooks under Windows Job supervision
  • reviewed 2026-09-04T08:56:25.206Z sha f5e4c11 :: blocked before merge. :: [P1] Keep argv hooks under Windows Job supervision

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. proof: sufficient Contributor real behavior proof is sufficient. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. P2 Normal priority bug or improvement with limited blast radius. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. P1 Urgent regression or broken agent/channel workflow affecting real users now. labels Sep 1, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient Contributor real behavior proof is sufficient. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(runtime): spawn hook argv without a login shell This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit eece9fd into openclaw:main Sep 16, 2026
10 checks passed
@SebTardif
SebTardif deleted the fix/hook-argv-no-shell branch September 30, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants