Skip to content

refactor(canvas): reuse canonical node CLI helpers - #135303

Merged
steipete merged 3 commits into
mainfrom
codex/qa50-canvas-node-cli-owner
Sep 1, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/qa50-canvas-node-cli-owner

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Canvas duplicated the node CLI’s option registration, invoke envelope, terminal theme, and error wrapper. This refactor delegates those responsibilities to their existing owners through the typed openclaw/plugin-sdk/node-cli-runtime facade and deletes the Canvas copies. Canvas retains its own node selection, Gateway caller, transport deadline, blank invoke-timeout handling, and legacy inventory fallback. Commands, defaults, requests, errors, and presentation are unchanged.

The supported SDK subpath is registered in package exports, the canonical entrypoint inventory, both SDK documentation pages, and the measured surface budget. Its four exports declare existing command flags, construct invocation data, adapt terminal styling, and wrap CLI outcomes; they expose no privileged Gateway caller and change no credential, authorization, configuration, protocol, or persistence behavior. This is a deliberate narrow SDK compatibility commitment.

The complete nine-file change removes 28 production lines: 25 added / 53 deleted, including all facade and metadata growth. Runtime TypeScript alone decreases by 36 lines. Tests add 100 physical lines (96 nonblank); docs add 13 (11 nonblank). No pure move or test deletion counts toward the production reduction. No performance improvement is claimed.

The PR also repairs the native-child lifecycle in an installer cancellation test exposed by Windows CI. It observes the actual child’s readiness, waits for child closure before removing its files, and retains the original 750 ms bound on the next namespace-queue admission. The bound starts immediately after abort and observes the next bundle’s HTTP request, before cold extraction and prewarming. The first cancellation, second complete result, and child cleanup remain separately asserted. This changes the fixture, not the installer. A deliberate 1500 ms delay in the second queue task passes the preceding fixture but fails the corrected 750 ms assertion; the original source was restored byte-for-byte after each probe. No test deadline, retry count, or environment was relaxed.

Validation on the final candidate:

  • All 27 installer cases pass; the cancellation case completed in 167 ms. Final test formatting, scoped types, lint, and diff checks exited zero.
  • The complete 31 selected gates passed on the preceding candidate. All eight other files and guarded inputs are identical; only the final eight-line responsiveness assertion postdates that run and has the focused proof above. The gates include SDK inventory (149 entrypoints, 4368 exports, 2602 callable exports), package/export checks, doctor cases, full type/lint graphs, native declaration emission (8390 files), and import cycles.
  • Fresh managed Codex high/P2 review of the complete nine-file candidate passed all seven review passes with no actionable findings. The reviewer received complete source owners and preserved proof, with unchanged input hashes.
  • Original Canvas/node/SDK/doctor coverage contains 115 distinct maintained cases. A built CLI against an isolated loopback WebSocket Gateway matched baseline and candidate across 21 scenarios, comparing full stdout, stderr, exits, signals, connection counts, request order, and parameters. Only 13 generated idempotency UUIDs were normalized after validating their UUIDv4 shape and uniqueness.
Built CLI boundary Cases Observed baseline/candidate behavior
Canvas/present help 2 Exact output, zero Gateway requests.
Present placement, JSON flag placement, hide JSON, navigate 5 Exact invocation parameters, request ordering, and complete result envelopes.
Invoke timeout and legacy inventory fallback 2 Exact deadlines; fallback remains node.list → node.pair.list → node.invoke.
Invalid/blank invoke and Gateway timeouts 4 Exact actionable errors and no connections.
RPC failures and authorization hints 5 Exact human/JSON failure streams and existing hints.
Parent JSON option rejection 1 Existing unknown-option failure and no requests.
Core invoke sibling, supplied/generated keys 2 Supplied key preserved; generated UUID validated; existing deadline retained.

The comparable built-CLI corpus SHA-256 is f8aca059d0276632f3933022a79618db7052eda7d06cf2e4fcf127b086fb29be. This proves the command and local Gateway wire boundary, not a live macOS panel, external node, or captured connect-frame identity. The unchanged Canvas-specific caller owns connection identity. The local installer run is macOS/Node 24.19 evidence; native Windows CI on the published commit is still required before landing.

The branch incorporates reviewed main at 91067e340a18; the SDK budget conflict was resolved using the actual export inventory. Earlier Windows readiness/teardown failures, failed source-bootstrap attempts, and the original tee-wrapped build’s missing outer exit are retained as failed or limited evidence. Later successful commands carry their actual exit codes; none of those earlier attempts is counted as a pass. A pre-existing node CLI registration snapshot mismatch remains a named follow-up. Exact-head hosted CI remains the landing gate.

The latest ClawSweeper review at18:47UTC covers this exact head and reports no correctness or security finding. Its remaining SDK-direction request is explicitly dispositioned below.

SDK contract decision and review disposition: retain node-cli-runtime as the supported four-helper entry point documented in this PR. I read the complete current SDK guide and ownership rules, and the facade plus both owning modules. The guide’s additional SDK/security-owner acceptance gate applies to shortened compatibility windows, source-incompatible shipped types, or wider trust, authority, or persistence boundaries. This change does none of those: it exports only getNodesTheme, runNodesCommand, buildNodeInvokeParams, and nodesCallOpts, with no privileged Gateway RPC export. Separate owner acceptance is therefore not required by that gate; no separate approval is claimed. This explicitly addresses the prior ClawSweeper decision/rank-up request while retaining the normal branch-review and CI requirements.

Final CI33544343366 passed on e40e2a5d3dc6:224 successful jobs,12 intentional skips, both Windows jobs and the required gate green. Actual Windows checkout 4b0becb8619d merged the head into 9030d86e7be9, using Node22.23.2 and pnpm12.1.0. The installer’s27 cases all passed, including the cancellation/queue/child-cleanup case. Its658ms is total test duration, not a separately measured handoff latency. The final gate and actual ciArtifacts build passed; no skipped lane or earlier limited build is relabeled as executed proof.

Fresh whole-nine-file high/P2 review passed all seven passes, and the final code/metadata reduction remains28 production lines, with100 test lines and13 documentation lines added. The initial local commit hook could not find Node and wrote no commit; supplying the already installed runtime allowed the unchanged reviewed bytes through the normal hook, commit and push.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes scripts Repository scripts extensions: canvas size: S maintainer Maintainer-authored PR labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 2:47 PM ET / 18:47 UTC.

ClawSweeper review

What this changes

The PR replaces Canvas-local node CLI option, invocation, terminal-output, and error helpers with a new documented plugin-sdk/node-cli-runtime facade, while strengthening a worker-bundle cancellation test.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for a Plugin SDK-owner decision: this adds a typed, documented third-party SDK contract, and the prior review’s request for explicit contract direction is not resolved in the supplied discussion. The implementation itself has no blocking correctness finding.

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

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused, net-negative refactor and supplied behavior evidence are good, with one remaining public-API direction decision.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply; the captured PR body nevertheless supplies built-CLI parity and native-child test evidence for the changed paths.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply; the captured PR body nevertheless supplies built-CLI parity and native-child test evidence for the changed paths.
Evidence reviewed 8 items Public SDK contract: The entrypoint catalog treats every entry absent from the private-local list as a typed public SDK subpath; adding this entry therefore creates an external contract, not only an internal Canvas refactor.
Focused canonical delegation: The new facade re-exports the existing core node CLI helpers, while Canvas retains its node resolution and Gateway call owner.
Existing core behavior: The delegated helpers already own the shared Gateway options and idempotent node-invoke envelope, plus standard terminal error handling and authorization hints.
Findings None None.
Security None None.

How this fits together

Canvas registers a plugin-owned node command that resolves a target and invokes it through the Gateway. The proposed facade sits between plugin commands and the core node CLI helpers, making their flags, invocation envelope, output, and failure presentation reusable.

flowchart LR
  A[Plugin node command] --> B[Node CLI SDK facade]
  B --> C[Core node CLI helpers]
  C --> D[Gateway client]
  D --> E[Paired node action]
  E --> F[Terminal result]
Loading

Decision needed

Question Recommendation
Should plugin-sdk/node-cli-runtime be a supported third-party Plugin SDK contract, rather than a Canvas-local refactor detail? Approve the narrow public contract: Record that third-party node-command plugins may rely on these four documented helpers and merge the focused delegation.

Why: The code correctly exposes a narrow generic seam, but choosing to support its four helper behaviors across external plugins is a durable API-direction decision rather than a mechanical repair.

Before merge

  • Resolve merge risk (P1) - Publishing plugin-sdk/node-cli-runtime commits OpenClaw to preserve the four helpers’ option, invoke-envelope, output, and error behavior for third-party plugins; no explicit Plugin SDK-owner acceptance is present in the supplied review context.
  • Complete next step (P2) - A human must decide whether this new public Plugin SDK contract should exist; there is no narrow mechanical repair to queue first.
Agent review details

Security

None.

PR surface

Source -36, Tests +100, Docs +13, Config +4, Other +4. Total +85 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 2 14 50 -36
Tests 2 116 16 +100
Docs 2 13 0 +13
Config 1 4 0 +4
Generated 0 0 0 0
Other 2 7 3 +4
Total 9 154 69 +85

Review metrics

Metric Value Why it matters
Production versus test delta production +25/-53 (net -28); tests +116/-16; docs +13/-0 The runtime refactor is net-negative, but the added package, catalog, and documentation entries make the public SDK commitment material before merge.

Merge-risk options

Maintainer options:

  1. Record SDK-owner acceptance (recommended)
    Before merge, make the intended third-party compatibility commitment explicit for the four exported helpers.
  2. Keep the reuse Canvas-local
    If no supported external contract is intended, remove the new public subpath and preserve the refactor behind Canvas-owned code.

Technical review

Best possible solution:

Either record explicit acceptance of this narrow third-party node-CLI SDK contract and retain the facade, or keep the helpers Canvas-local until a supported cross-plugin need is established.

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

Not applicable: this PR does not report a broken existing behavior. Its captured body does provide terminal evidence of a built-CLI parity corpus for the refactored command path.

Is this the best way to solve the issue?

Unclear: delegating to the existing core owners is a maintainable implementation, but whether those owners should become a supported third-party SDK contract needs explicit direction.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a focused CLI refactor and test-strengthening change, not an urgent user-facing regression.
  • merge-risk: 🚨 compatibility: The new typed and documented Plugin SDK subpath creates a compatibility promise for third-party plugins.
  • 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: Repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply; the captured PR body nevertheless supplies built-CLI parity and native-child test evidence for the changed paths.

Evidence

What I checked:

  • Public SDK contract: The entrypoint catalog treats every entry absent from the private-local list as a typed public SDK subpath; adding this entry therefore creates an external contract, not only an internal Canvas refactor. (scripts/lib/plugin-sdk-entries.mts:33, e40e2a5d3dc6)
  • Focused canonical delegation: The new facade re-exports the existing core node CLI helpers, while Canvas retains its node resolution and Gateway call owner. (src/plugin-sdk/node-cli-runtime.ts:3, e40e2a5d3dc6)
  • Existing core behavior: The delegated helpers already own the shared Gateway options and idempotent node-invoke envelope, plus standard terminal error handling and authorization hints. (src/cli/nodes-cli/rpc.ts:95, e40e2a5d3dc6)
  • SDK catalog guard: The existing contract test derives typed package exports from the public entrypoint list and verifies that documented subpaths are cataloged, so this public/private classification is mechanically meaningful. (src/plugins/contracts/plugin-sdk-subpaths.test.ts:489, e40e2a5d3dc6)
  • Current-main check: The fetched current-main tree contains neither the new facade path nor its package export, so the central refactor is not already implemented on main. (d17027cfdc5e)
  • Test change scope: The installer production owner already aborts prewarming through its supplied signal and releases the namespace queue after the queued operation completes; the PR changes the test fixture to observe real child readiness, queue admission, and closure. (src/node-host/node-worker-bundle-installer.test.ts:713, e40e2a5d3dc6)

Likely related people:

  • 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.

  • Record explicit Plugin SDK-owner direction on whether the four-export subpath is a supported third-party contract.

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 (2 earlier review cycles)
  • reviewed 2026-09-01T15:48:59.626Z sha dd7fcc5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-01T16:56:10.950Z sha f424e60 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 1, 2026
@steipete
steipete merged commit f512082 into main Sep 1, 2026
299 of 301 checks passed
@steipete
steipete deleted the codex/qa50-canvas-node-cli-owner branch September 1, 2026 18:50
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation extensions: canvas maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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