Repository navigation
refactor(media): track generated-HTML provenance through the shared-state worker - #164424
Conversation
…workers Move lookup, upsert, and stale-marker cleanup to the existing shared-state reader and writer registries. Capture the physical store before filesystem waits, preserve exact-byte HTML trust and conditional cleanup, and reconcile native commit receipts without replaying unknown outcomes. Keep media APIs asynchronous and preserve schema, retention, durability, and update behavior. Verify zero caller-thread SQL, transaction and commit refusal, lost-reply settlement, import boundaries, and the real Gateway close prelude.
|
🦞👀 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. Reviewed October 3, 2026, 7:58 PM ET / 23:58 UTC (Revision 9). ClawSweeper reviewWhat this changesMoves generated-HTML trust-marker reads, writes, and cleanup into the existing shared-state database workers while preserving public media signatures. Merge readiness✅ Ready for maintainer review This PR remains useful and has no identified blocking correctness or security findings. The final SDK report resolves the previous review’s sole remaining hold. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw stages generated HTML for outbound delivery and records which exact bytes are trusted. Media reload and cleanup consume those records before allowing delivery or removing stale markers. flowchart TD
A[Generated HTML] --> B[Outbound staging]
B --> C[Shared-state workers]
C --> D[SQLite trust markers]
D --> E[Path and byte validation]
E --> F[Allowed media delivery]
D --> G[Conditional stale-marker cleanup]
H[Gateway shutdown] --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +213, Tests +430, Docs +10. Total +653 across 14 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep provenance persistence with the existing shared-state workers and retain exact-byte trust validation at the media boundary. Do we have a high-confidence way to reproduce the issue? Not applicable as a refactor; current-main source establishes caller-thread SQL, and reported negative controls exercise the changed production boundaries. Is this the best way to solve the issue? Yes. Reusing the existing reader/writer registries removes the synchronous path without adding a competing storage owner or changing the released media contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ccc0020633ba. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Keep context-aware pruning in the private provenance owner so captured stores survive filesystem waits without changing the released zero-argument cleanup declaration carried by SDK types. Gate the real shutdown regression at that owner and protect the parameter and return contract with a type test.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…tate worker (openclaw#164424) * refactor(media): move generated-HTML provenance through shared-state workers Move lookup, upsert, and stale-marker cleanup to the existing shared-state reader and writer registries. Capture the physical store before filesystem waits, preserve exact-byte HTML trust and conditional cleanup, and reconcile native commit receipts without replaying unknown outcomes. Keep media APIs asynchronous and preserve schema, retention, durability, and update behavior. Verify zero caller-thread SQL, transaction and commit refusal, lost-reply settlement, import boundaries, and the real Gateway close prelude. * fix(media): preserve the cleanup SDK declaration Keep context-aware pruning in the private provenance owner so captured stores survive filesystem waits without changing the released zero-argument cleanup declaration carried by SDK types. Gate the real shutdown regression at that owner and protect the parameter and return contract with a type test.
What Problem This Solves
Generated-HTML staging, reload checks, and scheduled cleanup performed shared-state SQLite work on the Gateway main thread.
Why This Change Was Made
Move provenance lookup, upsert, selection, and cleanup into the existing shared-state reader/writer registries. Capture the physical store and marker bytes before filesystem waits, retain synchronous worker transactions and live transaction/commit grants, and reconcile acknowledged native receipts without replaying unknown outcomes. Cleanup compares the complete selected row inside its transaction, preserving markers updated while file inspection waits.
Realpath/outbound-root validation, link restrictions, SHA-256/size matching, and fail-closed lookup behavior remain at the existing media boundary. The scheduler retains accepted cleanup through the real Gateway close prelude before database teardown; the lifecycle regression starts the real Gateway and drives its actual close order.
The released zero-argument
pruneStaleTrustedGeneratedHtmlMarkers(): Promise<void>declaration is preserved. Internal cleanup callers pass their captured context directly to the private provenance owner. An exact type regression caught the optional-argument declaration leak before this repair and passes afterward. There is no deprecated alternate implementation or changed released signature.User Impact
No change to which HTML is trusted, media API signatures, schemas, retention, durability, or update behavior. No new worker service, persistent cache, or OPENCLAW_* environment name. All six host SQL sites are cut over, with no retained synchronous provenance path and no added host SQL in grant callbacks.
Final production diff against integrated main
7b9615fc20fe61de6d32cb77bf5b2f0f3bed5e5a: +314 / -101 / net +213. Tests/test support add 430 lines; docs add 10. T1 inventory at the original merge base4ab382220e2cca1deedb2c2549982f91c0fb5c64: 1,233 → 1,227.Bounded recent-PR overlap review found no competing provenance migration. The image optimize/load/filename hunks in #120119 are untouched. #162530 adds a separate media stream helper; #163296 adds a separate worker domain. #164391's shared error-identity functions are untouched. #162433 remains the explicitly excluded umbrella draft.
Evidence
Final reviewed head:
563ce35fbcc48c850a967d972198e7f877d7bc57. Main was integrated with merge commit8ddd9a236ee7d60ef44ee1c916ff7440f63fbb97to obtain the SDK tooling fix from #164466; compatibility repair563ce35preserves the released declaration.node scripts/run-vitest.mjs <files> --maxWorkers=1: 669.28 s wall, including 150.168 s one-time compiled-worker preparation. Covers the real staging/reload flow, both cleanup entry points, zero caller-thread provenance SQL, transaction/commit refusal and error identity, known-commit lost replies, unknown-outcome non-replay, store/byte capture, concurrent-upsert preservation, real Gateway close, and the SDK type contract.test/scripts/runtime-process-build-graph.test.ts,src/auto-reply/reply/get-reply.imports.test.ts,src/state/openclaw-state.worker.imports.test.ts, andsrc/worker/worker.runtime-imports.test.ts.git diff --checkpass. Production, full-tree, and script unused-export scans pass with zero findings. Fresh independent Codex P2 autoreview of the staged repair is scoped-clean, with no actionable findings.node scripts/check-changed.mjs --base 4ab382220e2cca1deedb2c2549982f91c0fb5c64passed in 1,964.85 s, including type-aware lint, unused-export scans, cycles, schema/storage guards, and policy guards. Only pre-existing max-lines warnings were reported.web-media.tsandstore.ts: all four selected regressions failed for the intended caller-SQL, store/byte capture, concurrent-upsert cleanup, and original-store cleanup reasons (77.95 s wall); the candidate passes all four. The SDK exact-signature type test independently failed before the compatibility repair with TS2741 and passes afterward.Released-SDK attribution on the final head: zero changes introduced by this PR. The fixed tool from #164466 compared integrated main
7b9615fc20fe61de6d32cb77bf5b2f0f3bed5e5ato563ce35fbcc48c850a967d972198e7f877d7bc57: 0 added/removed entrypoints and 0 affected exports. Independently verified report digest:ff7b090f43d2d90e4cd883d95840d6b752475a7a1769e295fb4cbb558a6ffb64. This resolves the accidental declaration leak; the earlier unrepaired comparison reported 124 reachable-export changes.The local v2026.9.8 → final-head report is complete. Source bindings: release
fc23bc864e4553c2d215e479eeec47b67a0bf943, head563ce35fbcc48c850a967d972198e7f877d7bc57, fixed tooling7b9615fc20fe61de6d32cb77bf5b2f0f3bed5e5a. Status:checked; independently recomputed digest:3a7f33365263f2f8a0b7f87101697cd3781ff8ce34dfc84d9754ed9d14a68878. Release-wide results: 1 entrypoint added, 8 removed; 2,219 affected exports (1,098 reachable declarations, 55 signatures, 59 additions, 1,007 removals). These are inherited main differences: the separate comparison from integrated main to this exact head is empty. The release-wide surface is not claimed unchanged. No SDK change is introduced by this PR, and the report prerequisite is satisfied. Main-relative comparison exited 0 in 970 s including cleanup; the released comparison exited 0 in 954 s, with all temporary SDK checkouts and owned processes cleaned up.Final-head CI passed: run 37161192927, head
563ce35fbcc48c850a967d972198e7f877d7bc57; the exact-head watcher finished GREEN. No failed final-head checks or reruns. The CI job API reports 11,630 total job-seconds for this run (aggregate workflow cost, not isolated new-test time). Final-head ClawSweeper review completed at 2026-10-03T23:33:52Z: durable review. No correctness or security findings; the signature and attribution concerns are resolved. Its sole remaining request was to record the final released-SDK report, now supplied above. The initial, earlier PR-context failure was corrected by using the repository template headings.