Repository navigation
fix(proxy): keep capture writes with the Gateway state owner - #168459
Conversation
|
🦞👀 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 real behavior proof before merge. What this changesThis PR routes proxy capture through the running Gateway or exclusive offline ownership and forwards child capture writes through the parent. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain This PR addresses a current state-ownership defect; the prior IPv6 finding remains, while the method-order and wrapper-dependency findings are fixed. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe proxy CLI receives transport events from its listener and child processes, then sends capture operations to the canonical shared-state SQLite worker. flowchart LR
A[Proxy CLI] --> B[Local proxy listener]
C[OpenClaw child] --> B
B --> D[State owner routing]
D --> E[Running Gateway]
D --> F[Exclusive offline owner]
E --> G[SQLite worker]
F --> G
Technical reviewBest possible solution: Retain the existing state-owner routing, construct valid IPv6 endpoint URLs, and establish final-effect authority fencing. Do we have a high-confidence way to reproduce the issue? Current-main source opens standalone capture persistence directly, establishing the ownership failure; the remaining IPv6 exception is also source-reproducible, but no target code was executed during this review. Is this the best way to solve the issue? Routing through the existing owner addresses the producer boundary and preserves worker persistence, FIFO ordering, and offline custody without introducing a competing storage owner. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 379da8e45692. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: The new capture authority paths require final-effect authorization evidence. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +587, Tests +327, Docs 0, Other 0. Total +914 across 24 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 HistoryReview history (2 earlier review cycles)
Reviewed October 10, 2026, 12:05 PM ET / 16:05 UTC (Revision 3). |
|
|
Merged via squash.
|
…th fixtures check-dependencies has been red on hourly main. Its three Knip scripts failed for separate reasons: - deadcode:full (production pass) reported canUseProfileAsProviderEntryApiKey. #168552 made src/plugin-sdk/plugin-test-runtime.ts, a production root, lazily load isolated-completion.adapter.test-support.ts. That fixture passes the model-auth and prepared-model-runtime namespaces to vi.spyOn. In Knip 6.32.2, any opaque import (here the lazy loaders in the media-understanding runner and config model validation) counts every export of a module as used, unless every namespace importer references only the bare namespace (is-referenced.js hasOnlyNsRefs). The spies flip that, so the facade's dead re-exports surfaced, and deadcode:exports reported nine "exports in used namespace" findings for test seams and the lazy-loaded isProviderAuthError. - deadcode:exports' script scan reported the default export of tools/solid-lint/index.mjs, which Oxlint loads by path through .oxlintrc.json jsPlugins (#168376). - deadcode:unused-files' full-tree scan reported six files that are only loaded by path: scripts/control-ui-parity/{vitest.config,capture-suite, fixtures,scenarios}.ts (`pnpm ui:parity`, #168597), src/proxy-capture/child-transport.process.test-support.ts (resolveRuntimeWorkerUrl in proxy-owner.test.ts, #168459) and test/e2e/qa-lab/runtime/codex-isolated-app-server.fixture.mjs (spawned by the Codex adapter test, #168552). Changes: - Make canUseProfileAsProviderEntryApiKey module-private and drop four other model-auth facade re-exports with no consumers anywhere (EnvApiKeyResult, ProviderEntryApiKeyBindingResolution, ProviderCredentialPrecedence, resolveAwsSdkEnvVarName). Their owners keep their real consumers. - Ignore only nsExports in the production scan for model-auth.ts, model-auth-runtime.ts, model-auth-runtime-shared.ts and prepared-model-runtime.ts. Each has a verified opaque lazy importer; plain unused exports stay reported, and the full-tree scan still audits every export against its test consumers. plugin-test-runtime stays a production root: un-rooting it surfaced 24 false positives, because extension tests import it through the openclaw/plugin-sdk alias. - Register the solid-lint default export as Oxlint-consumed, matching oxlint-boundary-guards.mjs. - Add full-tree entries for the six by-path files. No files are deleted. Proof: deadcode:full, deadcode:unused-files and deadcode:exports all exit 0 on the final tree; the model-auth focused tests pass.
…w#168459) * feat(plugin-sdk): expose local state owner routing for CLI commands * fix(cli): route proxy and Workboard writes through the state owner * fix(workboard): route CLI mutations through the active Gateway * fix(workboard): preserve dispatch without explicit parameters * fix(cli): retain accepted work through capture and dispatch cleanup * fix(plugin-sdk): type and account for the CLI ownership surface * fix(proxy): complete typed capture ownership contracts * fix(proxy): carry child credentials in the existing capture endpoint * test(workboard): preserve state owner module exports * test(proxy): preserve mocked owner and listener exports * test(workboard): prune the retired config mock allowance * test(proxy): prune the retired runtime mock allowance * test(proxy): require actual upstream proxy traversal * test(workboard): load plugin owners through public test surfaces * test(workboard): type owner routing fixtures precisely * fix(proxy): satisfy capture lifecycle type and lint contracts * test(workboard): type the facade export as a standalone function * test(proxy): preserve signal and environment fixture contracts * fix(workboard): report empty worker results for offline dispatch * fix(proxy): preserve method order and wrapper dependencies * test: ratchet removed session accessor fixture debt
…th fixtures check-dependencies has been red on hourly main. Its three Knip scripts failed for separate reasons: - deadcode:full (production pass) reported canUseProfileAsProviderEntryApiKey. openclaw#168552 made src/plugin-sdk/plugin-test-runtime.ts, a production root, lazily load isolated-completion.adapter.test-support.ts. That fixture passes the model-auth and prepared-model-runtime namespaces to vi.spyOn. In Knip 6.32.2, any opaque import (here the lazy loaders in the media-understanding runner and config model validation) counts every export of a module as used, unless every namespace importer references only the bare namespace (is-referenced.js hasOnlyNsRefs). The spies flip that, so the facade's dead re-exports surfaced, and deadcode:exports reported nine "exports in used namespace" findings for test seams and the lazy-loaded isProviderAuthError. - deadcode:exports' script scan reported the default export of tools/solid-lint/index.mjs, which Oxlint loads by path through .oxlintrc.json jsPlugins (openclaw#168376). - deadcode:unused-files' full-tree scan reported six files that are only loaded by path: scripts/control-ui-parity/{vitest.config,capture-suite, fixtures,scenarios}.ts (`pnpm ui:parity`, openclaw#168597), src/proxy-capture/child-transport.process.test-support.ts (resolveRuntimeWorkerUrl in proxy-owner.test.ts, openclaw#168459) and test/e2e/qa-lab/runtime/codex-isolated-app-server.fixture.mjs (spawned by the Codex adapter test, openclaw#168552). Changes: - Make canUseProfileAsProviderEntryApiKey module-private and drop four other model-auth facade re-exports with no consumers anywhere (EnvApiKeyResult, ProviderEntryApiKeyBindingResolution, ProviderCredentialPrecedence, resolveAwsSdkEnvVarName). Their owners keep their real consumers. - Ignore only nsExports in the production scan for model-auth.ts, model-auth-runtime.ts, model-auth-runtime-shared.ts and prepared-model-runtime.ts. Each has a verified opaque lazy importer; plain unused exports stay reported, and the full-tree scan still audits every export against its test consumers. plugin-test-runtime stays a production root: un-rooting it surfaced 24 false positives, because extension tests import it through the openclaw/plugin-sdk alias. - Register the solid-lint default export as Oxlint-consumed, matching oxlint-boundary-guards.mjs. - Add full-tree entries for the six by-path files. No files are deleted. Proof: deadcode:full, deadcode:unused-files and deadcode:exports all exit 0 on the final tree; the model-auth focused tests pass.
What Problem This Solves
Fixes standalone proxy capture writing outside the live Gateway's database owner, including capture written by an OpenClaw child launched with
openclaw proxy run.User Impact
The proxy listener and child process remain local. Capture reads and writes route through the live Gateway, or use exclusive offline ownership through shutdown when the Gateway is stopped. Ambiguous delivery is never replayed locally. Parent-only SIGINT/SIGTERM reaches the child, and capture cleanup settles before ownership is released.
This PR is stacked on #168457 for the shared CLI ownership SDK boundary and inherits its sole main integration pinned to
ff06ae699514. For child commands that mutate other OpenClaw state, run the Gateway first so those writes can route; offline capture retains exclusive parent ownership until the child exits. Generic manually environment-enabled CLI capture outside theproxyinvocation remains a separate follow-up. The released synchronous capture SDK remains supported.Why This Change Was Made
debugProxy.captureis a narrow admin RPC over the existing shared-state worker operations. The CLI reusesrunWithLocalStateOwnerand serializes capture operations in FIFO order. Offline custody spans server stop, response finalization, session end, and lease release, including failure paths.An OpenClaw child sends only session-bound capture writes to a private endpoint on its parent's existing listener. An ephemeral token travels in the existing debug endpoint URL; normal HTTP proxy variables stay credential-free, and resolved settings strip the token before transport or storage. The endpoint cannot read, purge, or execute arbitrary worker commands, revalidates lifetime/session after body preparation, and drains accepted work on stop. A parent-marked endpoint with missing or invalid credentials never selects a SQLite fallback.
No schema, retention, durability, or permission semantics change. Production source: +713/-126 (839 changed lines); tests/fixtures: +366/-40; docs/check metadata: +3/-3. The generated mock allowance baseline shrinks by one retired factory. The added transport is needed because moving the parent alone would leave instrumented child payloads as a second database writer.
Evidence
pnpm test src/cli/proxy-owner.test.ts src/cli/proxy-cli.runtime-cleanup.test.ts --maxWorkers=1ond25682aed604(31.51 seconds command wall; 9.446 seconds summed owner-test durations and 0.080 seconds cleanup-test durations). Later parent-only Workboard normalization leaves this proxy source unchanged.ff06ae699514failed at the intended assertion: all three expected owner RPCs were absent. The candidate routes session, event, and end-session writes. The original parent-only SIGTERM path also failed; the candidate forwards the signal and settles cleanup.run-main.profile-env.test.ts(10.302 seconds summed test durations) in an earlier mixed run whose two owner-suite import failures were subsequently repaired. Existing runtime suite: seventeen passed (26.28 seconds). Existing listener/runtime-owner group: thirty-three passed (123.05 seconds). Those unaffected results are reused, not mislabeled as new final-head executions.c0c38840697d; the remaining seventeen graphs and scripts passed ond25682aed604; extension projects and the final root graph passed on1e2c76b3a3e8. The other three root graphs passed ond25682aed604, and the changed CLI test graph was rechecked on the final head (2.4 seconds). Earlier owned failures were repaired, rather than reported as inherited. The final production delta normalizes the offline Workboard result; subsequent test-only changes do not invalidate the reused graphs.session-incognito-history.worker.ts,server-http.ts,message-tool-execution.ts,subagent-registry-restore.ts,model-catalog-decisions.ts,prepared-model-runtime.full-catalog.ts,session-cold-storage.ts,session-entry-read-runtime.ts,session-transcript-worker-runtime.ts,session-transcript-worker.types.ts, andopenclaw-agent-db-schema.ts. Their blobs are identical to pinned baseff06ae699514; no overall full-lint pass is claimed.OPENCLAW_PITCH. Main fixes it in060b20e595f36; this change adds no environment names or budget allowance. All remaining canonical plan commands were executed separately. Formatting, assertion safety, mock-export and timeout-race checks, dependency/config/SDK boundary checks, Doctor contracts, script/database/media/sidecar guards, coercion/deprecated-API checks and import-cycle checks passed. The touched Workboard page also passed MDX validation.3b7bd1fda1b0and reused for unchanged production exports, import topology and SQLite access. Full build passed on combined head2558c6fea23e(206.26 seconds, Testbox); SDK API diff passed there (393.49 seconds): one subpath / four exports added, no removed or modified direct declarations, and 148 reachable capture-runtime/method-tuple declaration changes. Later changes preserve those exported signatures and are covered by the completed current type stages; no current-head full-build run is claimed..github/actions/setup-release-harness/narrow-lockfile.mjs,src/infra/sqlite-source-fence-admission.ts, and exportedPUBLIC_SESSION_ENTRY_SCRIPT. All three files are byte-identical to the pinned base. The separate all-exports phase passed (69.13 seconds), as did the script and full-tree export scans. No overall Knip pass is claimed.1cb38c03856329000a2d23e23e5d125ec5e42522using Testbox. Run 38067918691: published 2026.9.9 driver, finished update, readiness 200, running version verified, durable and incognito state survived. Command time 14m13s. Candidate tree29c58c023c8ebb58a7d402474759e2c3170400b6was verified before execution; Testbox uses a synthetic checkout commit. No schema changes. A post-result external runner portal sync emitted a timeout warning; the remote command and update proof passed.Shared SQL census context; these CLI branches were not the measured candidate
The shared six-run alternating census compared base
427f926e7c2dwith devices/backup candidate13959252b2d6. Workboard and proxy capture were not in that candidate. Each value is a phase median [min–max]; warmed values are per turn (10 warmed turns per run). Requests count all worker requests. MAIN counts are included without treating movement to another thread as a saving.The raw first-turn and warmed SQL gate did not pass in this census. Excess attribution is indeterminate; this is not a claim that all increases are noise or background work. No statement or request reduction is claimed for this PR. The Gateway adds a lazy
debugProxy.capturehandler; it runs only for explicit capture RPCs. Child transport selection runs only for enabled asynchronous capture, andrun-maindeferral is limited to the standaloneproxycommand. No new SQL statement or worker request is introduced on an ordinary chat turn with capture disabled. Per-operation proxy CLI statement/request totals were not measured; the boundary tests prove routing, capture contents, and settlement, not a call-count reduction. The separate follow-up observations and their limitations are recorded below.Separate remote follow-up observations; neither measured these CLI branches
The designated Hetzner follow-up and the independently retained Testbox follow-up are separate one-pair observations for the devices/backups work. They are not pooled with each other or with the initial six-run census, and neither measured this Workboard or proxy branch.
The Testbox pair compared
427f926e7c2d763e362f59678c6486b6f2f4aec4with devices/backups candidateb2825e4bebc51e76b62b539daf275d50e212182c. Total wall time was 41.840 → 41.774 seconds. Each phase cell below is a one-sample median [min–max]; warmed SQL and requests are per turn across ten warmed turns, while warmed duration covers that whole window.The retained Testbox observation has unchanged warmed MAIN SQL (7.8/turn) and worker requests (195/turn), with all-thread warmed SQL 1023.9 → 1023.4. Its first-turn change is 1813 → 1816 statements, MAIN stays 59, and worker requests fall 264 → 263. Count reconciliation is complete: first-turn SQL is existing admission trios (+6), config-machine reads (+3), exact-entry reads (−1), and catalog reads (−5), net +3. Whole-workload varying operations sum to +7 statements; the only extra requests are session-row-facts (+1) and sessionRows.sharedFacts (+1). Every named varying caller is byte-identical and no retained native SQL stack names changed operational source. Unknown caller labels and unavailable event-level async origins remain explicit limits; the retained Testbox vectors cannot recover the lost Hetzner vectors.
The designated whole-workload observation is lower; the independent Testbox observation is slightly higher. Under the campaign's updated RAW TURN INCREASE and TARGETS ARE AIMS disposition, there is no confirmed PR-caused regression. This is not a claim that the independent Testbox totals decreased, nor a reconstruction of missing attribution. No statement or request saving is claimed for either CLI branch, and their per-operation CLI totals remain unmeasured.
Landing validation
Final candidate:
1cb38c03856329000a2d23e23e5d125ec5e42522. Fixed missing wrapper transitive dependencies and appended the new capture RPC to preserve legacy method ordering. Integrated main and removed the exact stale six-call session-accessor allowance after main removed those fixture calls; no budget was raised.