Skip to content

refactor(scripts): share required option arguments - #133095

Merged
vincentkoc merged 2 commits into
mainfrom
refactor/script-option-argument
Aug 30, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
refactor/script-option-argument

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Thirteen scripts duplicated the same strict split-option invariant: read exactly the next argument and reject missing, empty, or dash-prefixed values. The local wrappers could drift independently, including inside copied runtime closures.

Why This Change Was Made

The architectural owner is now scripts/lib/arg-utils.runtime.mjs, which exports requireOptionArgument; its declaration lives beside it. The thirteen exact local wrappers were removed and their callers now use the shared helper without migrating different-contract siblings.

All copied-runtime closures are complete:

  • docs sync copies the argument runtime into .openclaw-sync/lib/, and its workflow path trigger includes the runtime source.
  • Docker packaging's runtime fixture copies the argument runtime required by the packaged script.
  • OpenGrep's isolated merge-base fixture copies the argument runtime required by the imported helper.

Existing caller behavior is preserved, including equals-form parsing in Docker packaging, downstream normalization in the Claude usage debugger, and downstream trimming and validation in the code-mode matrix. This is an internal behavior-preserving refactor with no Codex protocol or runtime involvement.

User Impact

No user-visible behavior changes. Script option handling now has one owner, while existing diagnostics and caller-specific normalization remain unchanged.

Production/tooling: +85/-160 (net -75). Tests/test support: +57/-0.

No changelog entry: this is an internal behavior-preserving refactor.

Evidence

The two new tests meet the test-audit value bar:

  • owner-boundary coverage proves the helper preserves whitespace and rejects undefined, empty, -, -h, and --next with the exact diagnostic.
  • a real docs-sync boundary smoke runs the actual CLI into a temporary publish tree, then executes the copied MDX checker against valid minimal MDX. It uses no source-string assertions or test-only production export.

Validation:

node scripts/run-vitest.mjs test/scripts/arg-utils.test.ts test/scripts/docs-sync-publish.test.ts
# post-rebase: 2 files passed; 85 tests passed

node scripts/run-vitest.mjs test/scripts/run-opengrep.test.ts
# 1 file passed; 6 tests passed; stale-base scan includes src/pr.ts and excludes src/main-only.ts

node scripts/run-vitest.mjs test/scripts/full-release-validation-at-sha.test.ts src/scripts/ci-changed-scope.test.ts
# 2 files passed; 139 tests passed

node scripts/run-vitest.mjs extensions/qa-lab/src/code-mode-model-matrix.test.ts test/e2e/qa-lab/runtime/package-openclaw-for-docker.e2e.test.ts
# 2 files passed; 75 tests passed; 3 platform tests skipped

node scripts/run-tsgo.mjs -p tsconfig.scripts.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/scripts.tsbuildinfo
# passed

node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.root.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test-root.tsbuildinfo
# passed

node --import ./scripts/tsx.mjs scripts/run-oxlint-shards.mts --only=core
# passed

pnpm lint:scripts
# passed

git diff --check origin/main..HEAD
# passed

node scripts/check-changed.mjs --dry-run -- <all 21 changed paths> selected coreTests, scripts, testRoot, and tooling. The bounded changed gate passed after running its remaining checks directly in the sparse worktree.

The aggregate node --import ./scripts/tsx.mjs scripts/check-workflows.mts could not finish because its pinned pre-commit==4.6.2 was unavailable from the configured package index. Its actionlint stage passed, and the equivalent remaining checks passed:

uvx --from 'zizmor==1.29.0' zizmor --config .github/zizmor.yml --persona=regular --min-severity=medium --min-confidence=medium .github/workflows/docs-sync-publish.yml
# no findings

node scripts/generate-ci-git-owner.mts --check
# passed

python3 scripts/check-composite-action-input-interpolation.py
# passed

After rebasing onto cfddfc2f700ea456c66b887d70716b83d3ac0ea2, stable patch ID, changed-path hash, numstat hash, and git range-diff all confirmed the reviewed patch was unchanged.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 30, 2026
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts docker Docker and sandbox tooling size: M maintainer Maintainer-authored PR labels Aug 30, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 30, 2026 05:29
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 1:57 AM ET / 05:57 UTC.

ClawSweeper review

What this changes

The PR consolidates duplicated required split-option validation into a shared scripts helper, updates 13 parser consumers, and carries the helper into isolated docs, Docker, CI, and OpenGrep runtime closures.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness finding. Current main has not absorbed this refactor, and MEMBER authorship plus the protected maintainer label require normal human review before merge.

Priority: P3
Reviewed head: 3a32e8645bae54d04cf6e4da3d552a158af6593a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A clean, net-negative consolidation with focused consumer and copied-runtime coverage; normal maintainer review and exact-head CI remain.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: this is a MEMBER-authored internal refactor with no user-visible flow; the submitted tests directly cover the shared parser and copied docs-publish closure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: this is a MEMBER-authored internal refactor with no user-visible flow; the submitted tests directly cover the shared parser and copied docs-publish closure.
Evidence reviewed 8 items Shared owner and preserved invariant: The introduced helper reads only the following argument and preserves the prior rejection condition for missing, empty, and dash-prefixed values.
Copied docs runtime is complete: The docs publisher copies the newly imported runtime helper into the same isolated support tree as the MDX checker, and the copy loop materializes every listed dependency.
Focused owner and boundary coverage: The new helper test covers preservation and each rejected argument class; the docs-sync test invokes the published copied MDX-checker closure rather than asserting source text.
Findings None None.
Security None None.

How this fits together

Repository scripts parse command-line inputs for documentation publishing, Docker packaging, release validation, and CI routing. Their parsers either run in the repository or are copied into isolated runtime trees used by automation.

flowchart LR
  A[Script command line] --> B[Option parsers]
  B --> C[Shared required-value helper]
  C --> D[Repository automation]
  D --> E[Copied runtime closures]
  E --> F[CI publishing and packaging]
Loading

Decision needed

Question Recommendation
Should a scripts/docs owner approve this behavior-preserving refactor once required exact-head checks are complete? Approve after ordinary review: Accept the consolidation after a responsible maintainer confirms the exact-head required checks.

Why: The patch is authored by a MEMBER and carries the protected maintainer label, so this workflow must not close or merge it automatically.

Before merge

  • Resolve merge risk (P1) - The supplied exact-head check rollup is incomplete, so required CI still needs to complete before merge.
Agent review details

Security

None.

PR surface

Tests +57, Config +1, Other -76. Total -18 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 57 0 +57
Docs 0 0 0 0
Config 1 1 0 +1
Generated 0 0 0 0
Other 15 84 160 -76
Total 21 142 160 -18

Review metrics

Metric Value Why it matters
Production versus test delta production/tooling +85/-160 (net -75); tests/test support +57/-0 The consolidation removes duplicated production logic while adding direct helper and copied-runtime closure coverage.

Stored data model

Persistent data-model change detected: unknown-data-model-change: scripts/code-mode-model-matrix.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one shared helper for the common split-option invariant, retain consumer-specific normalization and equals-form parsing, and merge after ordinary maintainer and exact-head CI review.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one shared helper for the common split-option invariant, retain consumer-specific normalization and equals-form parsing, and merge after ordinary maintainer and exact-head CI review.

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

Not applicable: this is a behavior-preserving refactor rather than a reported product defect. The relevant parser and copied-runtime paths are source-readable and covered by focused tests.

Is this the best way to solve the issue?

Yes. The affected callers share the exact required split-option invariant, while the patch deliberately leaves caller-specific trimming, validation, and equals-form parsing in place.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5a5be1690599.

Labels

Label justifications:

  • P3: This is a behavior-preserving internal scripts refactor with no user-facing product 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: Not applicable: this is a MEMBER-authored internal refactor with no user-visible flow; the submitted tests directly cover the shared parser and copied docs-publish closure.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: 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.

  • Let the required exact-head CI rollup complete before merging.

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 (3 earlier review cycles)
  • reviewed 2026-08-30T05:28:53.527Z sha 71bfc4a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T05:34:49.648Z sha 71bfc4a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T05:50:38.809Z sha 3a32e86 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer disposition for the August 30, 2026 ClawSweeper review: #133095 (comment)

  • Decision: proceed through the normal maintainer landing path at exact head 3a32e8645bae54d04cf6e4da3d552a158af6593a.
  • Before merge: completed. Independent native review found no findings and recommends READY FOR /prepare-pr; 389 focused tests passed with 3 platform skips, exact-head CI is green, and Testbox-backed scripts/pr prepare-run passed.
  • Stored data model: skipped as a classifier false positive. scripts/code-mode-model-matrix.ts only replaces a local CLI next-token validator with the shared helper; no stored schema, migration, persistence, retention, or upgrade behavior changes.
  • Rank-up moves: none listed. No mechanical repair remains.

Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/33295343467

@vincentkoc
vincentkoc merged commit 63f265c into main Aug 30, 2026
187 of 188 checks passed
@vincentkoc
vincentkoc deleted the refactor/script-option-argument branch August 30, 2026 06:17
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
* refactor(scripts): share required option arguments

* test(scripts): copy option helper into OpenGrep fixture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker and sandbox tooling 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. scripts Repository scripts 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