Skip to content

refactor(exec): share package-manager option scans - #139482

Merged
steipete merged 1 commit into
mainfrom
steipete/cleanup-exec-option-scans
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/cleanup-exec-option-scans

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #135868

What Problem This Solves

Maintainer-requested cleanup supporting the #135868 split: package-manager command analysis repeats option scanners and reconstructs the same option sets at several call sites. That duplication makes it harder to keep reusable exec approvals and mutable-script detection consistent.

This is the independent clean-broad companion lane; it extracts none of the numbered recovery stages.

Why This Change Was Made

Share the existing option scanner with pnpm and Yarn command extraction, combine the two context-option scans with their distinct stopping rules, and prepare the unchanged package-manager option sets once. npm still detects context options after the command until --; leading scans still stop at the first command or unknown flag.

Production LOC: +103 / -231 (net -128), one file, 334 changed lines. Tests, tooling, and docs: +0 / -0. No compatibility path, public export, supported option, or approval rule is removed.

User Impact

No intended behavior change. Existing package-manager commands retain the same execution target, reusable-approval restrictions, and mutable-file binding.

Evidence

  • The baseline parser is byte-identical to stable tag v2026.9.2. Its context restrictions come from fix: reusable exec approvals apply to approved arguments #112946; these are retained.
  • A temporary differential probe compared 543,008 synthetic invocations against that baseline, including npm/npx/bunx/pnpm/Yarn, Windows executable spellings, empty tokens, separators, unknown flags, value-taking options, shell modes, nested commands, and context options. Classification, unwrapped argv, and context decisions were identical.
  • node scripts/run-vitest.mjs src/infra/exec-approvals-allow-always.test.ts src/infra/exec-wrapper-trust-plan.test.ts src/node-host/invoke-system-run-plan.test.ts: 178 tests passed.
  • git diff --check: passed. No build required: imports and packaging boundaries are unchanged.
  • Exact-head CI for 084f5176217b1ff993119c123a17ed4c987ba5e1: passed; the CI watcher returned GREEN.
  • Independent Codex local and branch reviews through P2: scoped-clean, no accepted/actionable findings.
  • ClawSweeper review on de402b243ab59884c908a5d855c15276d68ca863: no findings and no before-merge or rank-up actions. The review confirmed the scanner stopping rules and read-only option-set consumers.
  • node scripts/check-changed.mjs: passed the complete selected core/coreTests plan, including all type shards, three export scans, and architecture guards.

Deletion rationale: the removed walkers used the same token/value/unknown-option rules as the retained scanner; the context scans differed only at positional tokens, unknown flags, and the delimiter, now explicit in the scan scope. Existing owner-boundary tests remain intact. The exported pnpm option sets have only read-only production consumers in mutable-file operand detection.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@steipete
steipete marked this pull request as ready for review September 5, 2026 22:53
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 7:11 PM ET / 23:11 UTC.

ClawSweeper review

What this changes

Shares package-manager argument scanners and prepares reusable option sets while preserving command extraction and execution-approval behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a useful, maintainer-requested cleanup that is absent from current main. The reviewed changes preserve parsing and approval restrictions; no actionable defect was found.

Priority: P3
Reviewed head: 084f5176217b1ff993119c123a17ed4c987ba5e1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable refactor with preserved semantics and useful reported validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The authoritative repository context identifies a member-authored refactor with no material authority change, so the external-contributor proof gate does not apply; reported differential and boundary-test results support scanner equivalence but are not live execution proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The authoritative repository context identifies a member-authored refactor with no material authority change, so the external-contributor proof gate does not apply; reported differential and boundary-test results support scanner equivalence but are not live execution proof.
Evidence reviewed 7 items Introduced change preserves scanner semantics: The complete pinned merge-base-to-head diff preserves value consumption, case-sensitive -C handling, unknown-option behavior, empty tokens, shell-mode rejection, and command tails. The combined context scanner explicitly retains the distinct leading and before-terminator stopping rules.
Cleanup remains absent from main and latest release: Fetched main, v2026.9.2, and the pinned merge base all resolve this file to blob 0ca2ca69fec1c083268ea378007f9be0b392278b; the reviewed head resolves to b4def660ec35c62396bd10bec19d1fab2d2536b7. The release and main retain the pre-refactor implementation.
Approval consumer retains its existing restrictions: The unchanged approval consumer blocks context-changing and unsafe package-manager invocations and bounds recursive unwrapping. The patch changes no authority producer, persisted grant, principal selection, or final execution owner; the material authority-change trigger does not apply.
Findings None None.
Security None None.

How this fits together

OpenClaw analyzes package-manager commands before matching reusable execution approvals and binding mutable script files. These scanners identify the inner command and options that change its execution context.

flowchart TD
  A[Package-manager command] --> B[Shared option scanner]
  B --> C[Inner command classification]
  B --> D[Context-changing options]
  C --> E[Reusable approval matching]
  D --> E
  C --> F[Mutable script binding]
  E --> G[Existing execution policy]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -128. Total -128 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 103 231 -128
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 103 231 -128

Review metrics

None.

Technical review

Best possible solution:

Use the shared scanners while retaining the existing option sets, stopping rules, and approval-boundary coverage.

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

Not applicable: this PR proposes behavior-preserving cleanup rather than a reported runtime defect; source inspection supports equivalence.

Is this the best way to solve the issue?

Yes: reusing the existing scanner removes connected duplication while preserving the distinct npm and leading-option parsing rules.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded internal cleanup with no intended user-facing behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The authoritative repository context identifies a member-authored refactor with no material authority change, so the external-contributor proof gate does not apply; reported differential and boundary-test results support scanner equivalence but are not live execution proof.

Evidence

What I checked:

  • Introduced change preserves scanner semantics: The complete pinned merge-base-to-head diff preserves value consumption, case-sensitive -C handling, unknown-option behavior, empty tokens, shell-mode rejection, and command tails. The combined context scanner explicitly retains the distinct leading and before-terminator stopping rules. (src/infra/package-manager-exec-wrapper.ts:198, 084f5176217b)
  • Cleanup remains absent from main and latest release: Fetched main, v2026.9.2, and the pinned merge base all resolve this file to blob 0ca2ca69fec1c083268ea378007f9be0b392278b; the reviewed head resolves to b4def660ec35c62396bd10bec19d1fab2d2536b7. The release and main retain the pre-refactor implementation. (src/infra/package-manager-exec-wrapper.ts, c91b1eaab768)
  • Approval consumer retains its existing restrictions: The unchanged approval consumer blocks context-changing and unsafe package-manager invocations and bounds recursive unwrapping. The patch changes no authority producer, persisted grant, principal selection, or final execution owner; the material authority-change trigger does not apply. (src/infra/exec-approvals-allowlist.ts:313, 084f5176217b)
  • Shared option sets have read-only consumers: The other production consumer uses the exported pnpm sets only through membership checks while identifying mutable file operands. No consumer mutates these sets, so preparing combined sets once does not introduce observable mutation drift. (src/infra/system-run-mutable-file-operand.ts:602, 084f5176217b)
  • Existing boundary coverage: The inspected test accepts bound inner-command approvals and rejects stale outer grants, pnpm cwd/build options, and npm package/workspace context, including trailing workspace options. These tests remain unchanged. The PR body reports 178 passing focused tests, 543,008 equivalent synthetic invocations, and a passing changed-code gate; those executions were not rerun during this read-only review. (src/infra/exec-approvals-allow-always.test.ts:1887, 084f5176217b)
  • Related work and review continuity: The supplied discussion identifies this as an independent cleanup supporting feat(triage): start installation-owned recovery after update and startup failures #135868 and preserving restrictions associated with merged fix: reusable exec approvals apply to approved arguments #112946. The previous completed review retained no findings or rank-up moves. Its earlier head object was unavailable for direct comparison; the complete current introduced patch was reviewed independently. (084f5176217b)

Likely related people:

  • pgondhi987: 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)

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 (1 earlier review cycle)
  • reviewed 2026-09-05T22:58:33.815Z sha de402b2 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/cleanup-exec-option-scans branch from de402b2 to 084f517 Compare September 5, 2026 23:06
@steipete
steipete merged commit 0cebe40 into main Sep 5, 2026
179 checks passed
@steipete
steipete deleted the steipete/cleanup-exec-option-scans branch September 5, 2026 23:20
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* origin/main: (95 commits)
  perf(build): avoid unrelated gateway artifact scans (#127757)
  fix(update): deliver terminal progress after long updates (#139289)
  fix(ui): show session hover cards for local chat URLs (#139384)
  perf(ui): reuse unchanged transcript key snapshots (#139400)
  fix(ui): make subagent sessions view-only (#139381)
  fix: open agent state on SQLite builds without extensions (#139487)
  perf(skills): detach cached metadata from source strings (#139478)
  fix(ui): show primary user in multi-agent profile hero (#136736)
  perf(sessions): stop decoding the session row four times per SQLite entry patch (#136361)
  refactor(exec): share package-manager option scans (#139482)
  fix(ci): authorize frozen mobile release candidates (#139441)
  fix: avoid session deletion slowdown in large session stores (#139467)
  perf(gateway): reuse node invocation idle timers (#139354)
  fix(auth): preserve selected profiles across plugin scopes (#139413)
  fix(discord): retain voice input until transcription completes (#139484)
  fix(agents): name Gateway storage failures in run-failure copy (#139409)
  fix: keep subagent checks responsive in large session stores (#139450)
  fix(memory): index notes when optional embeddings cannot start (#139463)
  fix: refresh pending approvals when reopening chat (#139457)
  fix(tooling): preserve Git hook choices during install (#139461)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant