Repository navigation
refactor: simplify private state and process transports - #169379
Conversation
Remove duplicate schemas from typed private worker channels and replace per-command byte accounting with one structural path. Coalesce native resource close and remove unused reattachment and unknown-allocation poison state while retaining execution authority, bounded queues, known-directory cleanup, and native child settlement.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR removes duplicate private-message validators, simplifies request byte accounting, and consolidates native-resource closure. Example: Shutdown after a snapshot allocation reports ENOENT without reporting its directory.
Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep open: this maintainer-owned refactor removes duplicate private transport machinery with explicit, source-supported tradeoffs; no actionable introduced defect was found. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway storage readers and terminal hosts send captured commands over private worker transports; workers return database results, terminal events, and resource-cleanup receipts. flowchart LR
A[Gateway callers] --> B[Typed worker transports]
B --> C[Shared state reader]
B --> D[Snapshot staging]
D --> E[Native resource broker]
E --> F[SQLite child and temporary files]
A --> G[Node PTY helper]
Technical reviewBest possible solution: Retain one typed private transport per owner while preserving external validation, live launch authority, bounded admission, and confirmed native cleanup. Do we have a high-confidence way to reproduce the issue? This is a refactor rather than a reported bug; source inspection confirms the changed lifecycle paths, but this review executed no target code. Is this the best way to solve the issue? The simplification fits the existing owners, and the documented tradeoffs match the actual private senders and retained cleanup checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 670ad6a9b0fc. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -1310, Tests -136. Total -1446 across 15 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 11, 2026, 5:42 PM ET / 21:42 UTC. |
Exact-head CI dispositionReviewed head: CI 38176980643 is failed/cancelled, not green. The exhaustive 206-check census has 70 successes, 122 skips, one neutral, three failures, and ten cancellations. Security-fast and all seven applicable Security High categories passed; dependency and security-sensitive reviews passed. No substantive PR review findings are present. Every failed job and observed failing case
The cancelled 114581618143 — UI 2/7 had already reported the two dark/light Every cancelled job and replacement proofRemote provider: blacksmith-testbox, lease
The initial combined remote command exits 1 because the clean-main control intentionally exposed its inherited failure and Bun was absent. Its candidate UI, six Node groups, small tooling, browser-extension and Slack-lint phases passed individually. This is not represented as an all-green remote run. The PR body retains the full focused proof, clean independent review, zero runtime/Madge cycles, and local broad-scan limitations: large Knip scans reached the unchanged 600s limit; full lint/legacy-store scans produced no verdict; supported changed-file lint and canonical changed-file analysis passed. No CI rerun, empty push, timeout increase, retry, skip, or suppression was added to manufacture green. Pinned Bun prerequisite follow-upStaged the exact checksum-pinned runtime with The documented campaign inherited-failure exception is selected for the exact reviewed head. No failed or cancelled result is reclassified as green; no rerun or source push was used to change the check status. |
) Remove duplicate schemas from typed private worker channels and replace per-command byte accounting with one structural path. Coalesce native resource close and remove unused reattachment and unknown-allocation poison state while retaining execution authority, bounded queues, known-directory cleanup, and native child settlement.
What Problem This Solves
Removes duplicate private-worker schemas and unused recovery machinery from the state, snapshot, and process infrastructure.
User Impact
Normal storage and terminal behavior is unchanged. No config, CLI, Gateway protocol, plugin SDK, persisted schema, retention, or permission changes. Queue accounting now conservatively measures nested command data, so unusually large requests can meet the existing byte limit earlier.
Why This Change Was Made
Private state/snapshot/PTY channels already have typed, version-matched senders. Their second hand-written schema mirrors grow with every command and duplicate the real input/authorization boundaries. The state reader's byte estimator had another command-by-command copy of the same contract; it now measures captured values structurally.
The native-resource broker now joins concurrent close requests through one promise and rejects reuse of an attachment ID that no current client reconnects. Snapshot allocation errors still reach their callers, known directories still get cleaned, and native children still settle; a missing allocation receipt no longer permanently poisons shutdown. The private allocation-error class used only by that removed poison path is gone; wire messages and contention markers stay unchanged.
Best-effort tradeoffs accepted
Evidence
Net production reduction: 1,310 lines (+141 / -1,451), excluding tests, fixtures, test support, generated files, and declarations. Tests reduce by 136 lines; no new skips, retries, timeouts, or lint suppressions. The only ancillary production path outside state/infra/process removes the private plugin-blob predicate orphaned by deleting the reader mirror; its public command/reply types are unchanged.
node scripts/run-vitest.mjs <file> --maxWorkers=1: state reader 34 passed, 657.49s wall (435.971s shared cold-worker compilation); native snapshot resource 10 passed, 464.51s wall (279.394s cold compilation). These are existing native-boundary suites, not new per-test boots; actual test execution is a small fraction of the loaded-host wall time. The retained real-allocation test proves native close precedes resource close. Hosted CI seconds will be recorded when available.All runtime/test/build commands used task-owned HOME, OpenClaw paths, and XDG directories. No real operator state, live Gateway, or deployment was used.
The coverage ledger also records retained candidates: migration witnesses and schema/integrity validation, real parallel-reader lifetimes, write-capable shutdown settlement, kernel process-tree cleanup, execution authorization, and bounded-resource protections. These are not removed merely to increase the deletion total.