Repository navigation
refactor(state): simplify private reader and error transport - #169754
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. |
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
|
Codex review: needs changes before merge. What this changesThis PR consolidates private state-reader command capture, cleanup adaptation, error typing, payload retention, and schema checks. Example: A state query fails and forced worker retirement also fails.
Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-directed simplification has distinct remaining value, and inspection found no actionable introduced defect. Priority: P3 Before merge
FindingsNone. Agent review detailsHow this fits togetherGateway callers submit captured state-read commands to retained SQLite workers and receive results or typed errors after cleanup settlement. flowchart TD
A[Gateway callers] --> B[Captured read command]
B --> C[Snapshot and admission owners]
C --> D[SQLite read worker]
D --> E[Result and error hydration]
D --> F[Retained cleanup owner]
F --> E
E --> A
Technical reviewBest possible solution: Land the private-owner simplification after current CI failures are attributed and the enforced landing gate is satisfied. Do we have a high-confidence way to reproduce the issue? This is an authorized refactor rather than a reported product bug; source inspection verified the affected contracts without executing target code. Is this the best way to solve the issue? The change uses existing owners, preserves authority and retirement checks, and documents its accepted diagnostic tradeoff. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 37064938ac97. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -337, Tests -2. Total -339 across 10 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 HistoryReview history (6 earlier review cycles)
Reviewed October 12, 2026, 7:26 AM ET / 11:26 UTC (Revision 7). |
4755f08 to
9bed863
Compare
|
Exact-head landing evidence for CI 38239731304, attempt 1, tested merge Every failed job is accounted for:
The hosted failure-classification table called both roots unknown, because scheduled main had no matching job. The independent main reproductions above, not that table or merely untouched filenames, establish inheritance. The original broad two-file replay was interrupted after passing unrelated cases and is partial proof, not a pass. Test-name selection then narrowed attribution to the eleven failed cases with their order, assertions and deadlines unchanged; it adds no committed test skips. Proof gap accepted (coordinator)The coordinator accepted the original head The requested one-time original-head local run completed239 passing tests and two unchanged120s ownership timeouts: “refuses unauthorized Doctor admission before staging a public snapshot” and “allows read-only access without the external marker” (2032.23s wrapper). They remain unresolved, not proven pure host load, inherited or fixed by passing replays. The full changed check passed initial guards,18-file format, production types and12core test graphs before its verified orphaned owner was stopped for required conflict repair, exit143. No full changed-check pass is claimed. Current production candidate proof: 149/149 focused tests across eight files,874.84s wrapper; exact9bed production/state-logging/infra type graphs pass after an isolated frozen install; final ten-file lint/format pass with zero warnings/errors; runtime/static cycles0/0; suppressions3/3,84.87s. Fresh P2 review had two concerns declined against source: failedHealth supports no callback input, and the canonical GitHub selector already handles absent storage. This review is not described as scoped-clean; earlier scoped-clean reviews remain historical. The restored PhaseE caller's stale import initially blocked main replay setup. Another owner independently published the identical compatible cutover in main Test/build payloads used task-owned HOME/OpenClaw/XDG/temp paths. No real operator-state inspection or recovery occurred. No task-owned remote lease remains. No CI rerun, unchanged repush, timeout/retry/skip/suppression change was used. Remaining production delta: +67/-404 =337 lines removed, plus2 net test lines removed across10files. The original596-line cut overlapped removals independently landed in #169648; these are not counted twice. Native admin admission stays pinned to exact9bed and retains the individual inherited-failure evidence above. |
|
Landing via the inherited-red admin exception at exact head 9bed863.
|
…w#169754) * refactor(state): simplify private reader and error transport * refactor(state): retire unused private error predicates
Related: #168947
What Problem This Solves
Private state readers maintain duplicate command snapshots, error identity declarations, retained-operation adaptation and identity fallback checks despite having one typed in-process owner.
User Impact
No normal user-visible behavior, configuration, stored format, SQLite durability, retention or permissions change. Queue snapshot isolation, live authority, native cleanup settlement and error recovery metadata remain intact. Rare unsupported internal inputs and simultaneous cleanup failures have the explicit best-effort treatment below.
Why This Change Was Made
Capture commands with one deep clone, use the existing retained-operation mapper, infer error identities from their producer, and retain private error payloads in a WeakMap. Reuse the existing receipt and schema-fact readers instead of repeating their checks.
This is the third and final authorized state simplification pass: 337 net production lines removed (67 added / 404 deleted), plus 2 net test lines removed, across 10 files. The originally reviewed cut removed 596 production lines; main's #169648 independently landed the overlapping parser/predicate removals while this PR waited. The conflict-only rebase does not count them twice. Measurement excludes tests, fixtures, test support, generated code and declarations.
Best-effort tradeoffs accepted
The original cut's private graph-parser and dead-predicate removals below are already on main through #169648; this PR retains main's encoder privacy/scalar guard, single name/message capture and version check. The remaining diff adds no schema or public-contract change.
Proof gap accepted (coordinator)
The cancellation exception below records the original head's proof gap. GitHub subsequently reported a real conflict with main's overlapping #169648, so the standing conflict-only authority was used to publish signed head
9bed8637423a97534be94605e28b3aefc1181fc5. Historical CI is not represented as CI for that repaired head. Its new hosted attempt is terminal, with both failed Node jobs independently reproduced on clean main below. No CI rerun or unchanged repush was requested.The coordinator explicitly accepted the unrun fail-fast cancellation coverage at reviewed head
4755f085f518de70c7167b6c1076cf7b0ef17aeb: Testbox queued and was stopped; the shared Mac is saturated. Missing coverage includes the remaining Node shard plans (93 missing plans plus the unresolved small-27 selection), completechecks-ui (1/1)and sevenchecks-ui-e2eshards, the declaration/SDK/UI tails ofbuild-artifacts, unfinished lint/test-type graphs, and extension package compilation. The extension-lint placeholder job never materialized executable steps. None is claimed passing.Focused/local proof covers all changed test files (78/78), retained reader/error/authority/ownership/profile/cleanup siblings, production types and 28 affected core test graphs, changed-file lint/format, cycles, suppression checks, and five fully covered static jobs. The requested one-time full changed-file check is recorded separately below.
Four inherited red jobs were independently reproduced on clean main
830b3ea72dab162ae689f850448ff62073b0b590: suppression inventory (checks-node-compact-small-2, corrected on main in64f11ced232); rewind SQL count (checks-node-changed-compact-large-2-1); both detached-context admission assertions (checks-node-changed-compact-large-14-1); stale actor-version expectation (checks-node-changed-compact-small-13, corrected on main in0655ff941f8). The CI gate is downstream. Their owners/tests are untouched here. The coordinator authorized the exact-head native admin exception with these failures and gaps named, not relabelled green. Hourly main CI is the broad-proof backstop; any resulting red main is fixed forward. No CI rerun, unchanged repush, or speculative rebase is requested.Evidence
Repaired-head CI 38239731304, attempt 1, is terminal. It tested merge
1850024a8bfdd4dc979e577c835ae3e99a3fdd15, ordered parents main3e3a9a87e58be5b8d291d7bf448e1b7e8f7ba947and exact head9bed8637423a97534be94605e28b3aefc1181fc5. All 147 observed head check runs are terminal. This CI attempt has 83 jobs: 56 success, 3 failure, 24 conditional skips, and no cancelled CI jobs. The failed roots arechecks-node-changed-compact-large-24-1/ 114779653617 (fiveclient-create-authority.test.tscases stop at “User profile catalog is not ready”) andchecks-node-changed-compact-small-19/ 114779653632 (sixserver.sessions-send-resume.test.tscases: three unchanged 120-second timeouts and three admission-result assertions). Both independently reproduce on clean main as detailed below.openclaw/ci-gate/ 114784212080 is downstream. No failure is presumed inherited merely because its test file is untouched. Three cancelled non-CI automation checks carry no product-suite passing claim.The first current-main replay reached no assertions: the restored Phase E reports caller still imported
isSteerConfirmationRewrite, renamed by5a1cd1abf11to the existing canonicaltranscriptRewritePreservesAdmissionowner. Its compiled-subprocess build refused that missing export. Another owner independently published the identical compatible caller cutover in main37064938ac97bc56e6723305f8f6eb4eafe20505; our attempted main push was rejected without a write, and the duplicate local commit was dropped. The unchanged memory-report tests pass 3/3 (344.80s), production types, focused lint and suppressions pass, and independent review is scoped-clean for that caller-only fix. No backend, factory, registry, expiry, federation machinery or tests were deleted or shrunk. The setup failure is not a Talk-failure reproduction.Clean published main
37064938ac97bc56e6723305f8f6eb4eafe20505independently reproduces all five Talk cases with the same “User profile catalog is not ready” signature (321.87s wrapper). The Talk helper lacks the resident-catalog prerequisite after main's #169799 role-policy cutover; its tests/helper and determining catalog/authorization owners are byte-identical between CI baseline, tested merge and reproduced main. A separate main replay reproduces all six resume failures: three unchanged120s preparation timeouts, cancelled-successor admission mismatch and explicit/automatic “Session communication state changed before admission” mismatches (794.15s Vitest; wrapper result retained in evidence). The test and communication-authority owner are also unchanged across all three trees. Thus both current root jobs are inherited; the failed gate is downstream. Hosted classification was unknown because no scheduled-main job matched; these actual reproductions establish attribution. An initial broad main replay was interrupted after unrelated passing cases and is partial proof only. Test-name selection narrows diagnosis without changing committed tests, assertion order or deadlines.Conflict-only integration: GitHub reported CONFLICTING at the original published head
4755f085f518de70c7167b6c1076cf7b0ef17aeb. The signed repaired head is9bed8637423a97534be94605e28b3aefc1181fc5, based on maind2154d5b8f622a4788f7c63f3c706056008f4923. Main's privacy checks and version check are preserved. The repaired production candidate passed all 149 focused tests across eight files (874.84s wrapper), both cycle checks (zero cycles), and lint-suppressions (3/3, 84.87s). The final replayed commit only renames a test-local variable; its production removals were already on main. Fresh P2 review raised two concerns that source inspection disproves: failedHealth declares no callback input and its sole production caller passes only the command type; the GitHub selector already returns an empty map when its table/column is absent. Neither finding was accepted, and that review's engine verdict is not described as scoped-clean.Final-head lint and formatting pass across all ten files (zero warnings/errors). The first rebased production typecheck could not resolve new-main dependencies
pgand@resvg/resvg-js. After a frozen install in a separate task-owned exact-head checkout, production types plus the state-logging and infrastructure test graphs all pass (exit 0). This resolved the missing-dependency diagnostics without a source change. The primary install was not reconciled.The coordinator-requested one-time original-head run completed 239 passing tests and two unchanged 120-second ownership timeouts: “refuses unauthorized Doctor admission before staging a public snapshot” and “allows read-only access without the external marker” (2032.23s wrapper). They remain unresolved, not proven pure host-load failures or inherited regressions, and no passing replay is claimed to fix them. The one-time full changed-file check passed its initial guards, 18-file format, production types and 12 core test graphs before its orphaned owner was stopped ahead of the necessary conflict rebase (exit 143, partial proof). No full changed-check pass is claimed. The older proof below is historical evidence for the original cut, not current-head CI.
Local focused proof covers reader snapshots/queueing/settlement, worker error round trips/redaction/unknown outcomes, validation receipts and worker admission, ownership inspection, profile identities, native snapshot cleanup, session mutation boundaries and the shared retained-operation mapper. The previously failing worker-admission and ownership files pass together after integrating the already-landed main fix
21a1699fbce: 53 tests, 143.66s Vitest / 217.73s wrapper. The other 13 focused files passed unchanged.The new encoder privacy regression fails on the original encoder with
private metadata escaped encoderand passes on the candidate. Independent P2 reviews of both the substantive cut and final cleanup are scoped-clean. Runtime and static import graphs both have zero cycles; final exact-head lint-suppression tests pass 3/3 (67.79s wrapper). The two changed test files pass--maxWorkers=1: 78 tests, 164.65s Vitest / 206.52s wall, dominated by transform/setup rather than test bodies. Production typechecking and all 28 affected core test type graphs pass. The changed-check run then identified three unused predicates; those are removed, and all three dead-export scans pass. Final cleanup-focused error/redaction tests pass; final lint and format pass across all 18 changed files. Native schema-version, media helper, sidecar loader, webhook body-order and both pairing-auth guards pass. The broad local database-first scan was stopped after roughly ten minutes without a result; no completecheck:changedpass is claimed.Exact-head CI 38222788391 tested merge
035938943b5de15a757e2b2bfd47690ca99abe5contoccb7b5f7e5de8e0e6c3bd20030c902d2134e9a15. The fresh exact-head check census is fully terminal. The originating failure ischecks-node-compact-small-2: the type-suppression inventory expected 18 entries and received 19 from untouchedscripts/lib/managed-cleanup-handoff.mts. It reproduces on clean main830b3ea72da; main corrected that inventory in64f11ced232. The failedopenclaw/ci-gateis its downstream aggregate.Three cancelled jobs logged additional failures, all reproduced independently on clean main
830b3ea72da, with none of the failing owners/tests changed by this PR:checks-node-changed-compact-large-2-1/sessions-rewind.test.ts/ “returns editor text for rewind and a new key for fork” (one expected upstream-link read, two observed);checks-node-changed-compact-large-14-1/worker-turn-detached-context.test.ts/ “rejects a missing or removed canonical user admission” at after-snapshot and model-resolution (two failures); andchecks-node-changed-compact-small-13/attempt-transcript-lifecycle-prepare.test.ts/ “uses a stale-version postimage once without replaying a durable append (incognito=false)” (actor version changed before command admission). Passing replays are not claimed to fix any failure.Main subsequently corrected the obsolete stale-actor expectation in
0655ff941f8; this PR does not claim that repair. Fail-fast cancelled 59 jobs; their missing coverage is not counted as passing. Five static jobs now have complete coverage through archived successful steps and local ratchet/Kysely/source-contract completion. The final source-contract tail passed SQLite transaction boundary (263.52s), transcript-reader boundary (4.60s), and session-schema baseline (1.03s), on the exact CI merge with physically owned dependencies and isolated state. There are 32 archived successful Node plans; the first two missing Gateway plans and one serial warm-cache investigation exhausted unchanged native silence budgets without assertion totals under shared-host saturation. A local UI replay completed 65 tests in five files before being explicitly interrupted; no whole UI shard pass is claimed. Native artifact building passed runtime compilation, 96 plugin distributions, bootstrap imports, 54 native module loads and post-build processing, then refused a borrowed compiler outside the proof checkout. A standard Blacksmith Testbox cancellation-recovery request reported a queue and was stopped under the immediate-allocation policy; it produced no remote test proof. The coordinator explicitly accepted the remaining Node, UI, declaration and static gaps for this exact-head landing, with hourly main CI as backstop. No CI rerun, unchanged repush, or branch update has been requested.An earlier ownership/Doctor attempt timed out and produced cascading fixture-handle failures. Subsequent full ownership replays passed on clean main and on the original candidate, but the requested one-time run above again timed out in Doctor and read-only ownership. No fix or inherited-regression claim is made. No test timeouts, retries, skips, suppressions or retained-behavior assertions were weakened. Test/build payloads used isolated HOME, OpenClaw and XDG directories; no operator-state inspection or recovery was performed.
Largest-first provenance coverage
The lane ledger covers lifecycle, validation cache, lease, admission, worker owner, async lifecycle, reader transport, state lease/heartbeat, profiles, credential/consent publication and registry listing. Large retained mechanisms have concrete provenance: #166867 restart admission, #111678/#138693 deletion safety, #152341 idle WAL release, #157273 Doctor recursion, #167662 writer/reader deadlocks, #153508/#154477 revoked authority, #134970 personal credentials, #168094 unknown write outcomes, #158595 consent at push effects, and #169249/#166860 registry publication failures. Their authority and settlement machinery is retained.
The standalone session memory backend (Phase E, #169124/#169227/#169327, restored after #169621) is an explicit maintainer-decided KEEP. Its implementation, factory branch, registry, expiry, federation machinery and tests are untouched.
The private payload cutover includes only the caller DTOs/signatures needed to replace unknown holes. The two generic resource adapters explicitly document the matching SQLite encoder; no broad native transport generic framework or fake validation predicate was added.