fix(canvas): validate CLI numeric options#92490
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 13, 2026, 7:38 PM ET / 23:38 UTC. Summary PR surface: Source +12, Tests +82. Total +94 across 2 files. Reproducibility: yes. Source inspection shows current main accepts Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the Canvas-local CLI validation with the added regression coverage, accepting the invalid-input compatibility tightening because it aligns the CLI with the existing tool contract. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main accepts Is this the best way to solve the issue? Yes. Validating in the Canvas CLI owner boundary is the narrowest maintainable fix; changing the gateway or Canvas tool schema would be broader and unnecessary because those contracts already express the desired bounds. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 47759c35063c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +12, Tests +82. Total +94 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
582c314 to
a970ce5
Compare
vincentkoc
left a comment
There was a problem hiding this comment.
No blocking findings.
This is the right fix shape for the Canvas CLI: keep numeric validation inside the plugin CLI boundary, use the shared strict numeric parser, parse --invoke-timeout before node resolution in the shared invoke path, and align snapshot --quality with the existing 0..1 Canvas tool schema.
Verification:
- Focused local:
node scripts/run-vitest.mjs extensions/canvas/src/cli.test.ts --maxWorkers=1— 20 passed. - Autoreview:
.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main ...— clean, no accepted/actionable findings. - Remote changed gate: AWS Crabbox
cbx_b7838c58daba, runrun_bbb58ca536f4,check:changed— passed. - Exact PR head
a970ce594ea6e7284ace519352fc258b1b81cb80— GitHub checks green; only routine supersededauto-responsecancellation ignored.
Code read: extensions/canvas/src/cli.ts, extensions/canvas/src/cli.test.ts, extensions/canvas/src/tool-schema.ts, extensions/canvas/src/tool.test.ts, src/plugin-sdk/number-runtime.ts, extensions/AGENTS.md.
Best-fix verdict: best. Alternatives rejected: per-command timeout parsing would duplicate the invariant; accepting wider quality values would conflict with the model-facing schema.
Summary
This tightens Canvas CLI validation so bad numeric input fails before the command reaches node resolution or the gateway.
The two cases fixed here are:
--invoke-timeout 20ms, which could previously be parsed as invalid and then treated like no invoke timeout was supplied.nodes canvas snapshot --quality 5, even though the CLI documents--quality <0-1>and the Canvas tool schema also bounds quality to0..1.The goal is just to keep the CLI boundary honest and aligned with the Canvas tool contract. This does not change the gateway
node.invokeschema or add new Canvas behavior.Review focus: the validation order in
invokeCanvas, the snapshot quality bounds, and the regression tests proving invalid input does not reach node resolution or gateway invocation.Linked context
Closes #92487
Related #92482
This was not specifically requested by a maintainer.
Real behavior proof (required for external PRs)
Behavior or issue addressed: Canvas CLI accepted invalid numeric options. In particular,
--invoke-timeout 20mscould be treated like no invoke timeout, andsnapshot --quality 5could pass despite the documented/schema0..1range.Real environment tested: Local OpenClaw source checkout on macOS after running
pnpm build, using the builtnode openclaw.mjslauncher.Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: Both invalid inputs fail at the CLI boundary before a successful node/gateway invocation path.
What was not tested: I did not run a live paired canvas node or capture a real canvas screenshot, because this change is limited to validation before node invocation.
Proof limitations or environment constraints:
pnpm check:changedcould not run in this local checkout because the configured Crabbox/Testbox binary failed its basic--version/--helpsanity check before code checks started.Before evidence: Source inspection showed
parseTimeoutMsreturnedundefinedfor invalid values andsnapshot --qualityonly checked for a finite number, not the documented/schema range.Tests and validation
Commands run:
node scripts/run-vitest.mjs extensions/canvas/src/cli.test.ts OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree pnpm test extensions/canvas/src/cli.test.ts extensions/canvas/src/tool.test.ts -- --reporter=verbose ./node_modules/.bin/oxfmt extensions/canvas/src/cli.ts extensions/canvas/src/cli.test.ts --check node scripts/run-oxlint.mjs extensions/canvas/src/cli.ts extensions/canvas/src/cli.test.ts pnpm check:test-types git diff --check pnpm build pnpm check:changedpnpm check:changedstopped before code checks because the local Crabbox/Testbox binary failed its basic sanity check.Regression coverage added:
--invoke-timeoutacrosssnapshot,present,hide,navigate,eval,a2ui push, anda2ui reset.snapshot --qualityvalues.--qualityboundary values0and1.Risk checklist
User-visible behavior changes: yes. Invalid Canvas numeric values now fail immediately instead of being ignored or forwarded deeper into the node path.
Config, environment, or migration changes: no.
Security, auth, secrets, network, or tool execution changes: no.
The main risk is that someone relying on invalid Canvas numeric values will now get a CLI error. That seems acceptable because these values are outside the documented option contract and outside the Canvas tool schema, and the tests cover rejection before node resolution or gateway invocation.
Current review state
Ready for review. Nothing known is waiting on the author side, and there are no bot or reviewer comments to address yet.