Repository navigation
perf(sessions): publish complete commit receipts instead of invalidating known facts - #166519
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 maintainer review before merge. Reviewed October 7, 2026, 6:26 AM ET / 10:26 UTC (Revision 5). ClawSweeper reviewWhat this changesSession writers publish complete committed metadata to existing Gateway projections, reducing repeated database reads while invalidating incomplete or superseded facts. Merge readiness✅ Ready for maintainer review The prior qualification blocker is resolved by the recorded coordinator acceptance, and no actionable code or security finding remains. Current main still lacks this optimization. Priority: P2 Review scores
Verification
How this fits togetherSession database writers feed committed metadata into the Gateway’s resident session rows and membership projections. Those projections supply session lists, display metadata, and event visibility without repeatedly reading unchanged database facts. flowchart TD
A[Session writes] --> B[Existing database writer]
B --> C[Committed metadata receipt]
C --> D{Complete and current?}
D -->|Yes| E[Resident session projections]
D -->|No| F[Invalidate uncovered facts]
F --> G[Existing worker readers]
G --> E
E --> H[Session lists and observers]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +435, Tests +728, Docs +13. Total +1176 across 47 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep committed-fact publication with the existing writers and projections, preserving fresh database admission and live authorization at later effect boundaries. Do we have a high-confidence way to reproduce the issue? Not applicable as a new bug report: current-main source confirms redundant invalidation, and the captured before/after Gateway workload measures the resulting database work. No target code was executed during this read-only review. Is this the best way to solve the issue? Yes. Publishing complete postimages from the existing writer transaction avoids a competing cache owner while preserving invalidation for incomplete or superseded facts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8f436000418b. 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 (4 earlier review cycles)
|
Merge main without rebasing the reviewed receipt optimization. Update the existing Gateway shutdown fixture to pause the combined sessionRows.sharedFacts request so it continues proving accepted-read settlement before home cleanup.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
What Problem This Solves
Warmed chat turns repeatedly reacquire session membership and display metadata after writes that already know the committed values. Replacement settlement marks every surviving row invalid, and post-commit adapters can discard the receipt again.
Why This Change Was Made
Publish complete entry, membership, category, participant, Board-presence, and activity-watermark postimages from the existing writer transaction. The existing compact membership and resident row projections adopt them before public observers. Partial or unknown receipts invalidate uncovered facts, and newer unknown outcomes retire older pending receipts. Native member edits and transcript publications fence late coverage.
ACP producers publish their own normalized metadata or explicit absence. Missing ACP and repository facts prepare together through the existing shared-state reader, with physical identity captured before yielding. Lifecycle and observer adapters publish runtime-only notifications after their entry owner has published stored facts.
User Impact
Less SQLite work and fewer worker requests per chat turn. Resident presentation keeps its event-driven lifetime; it does not become a foreign-commit certificate or authorize later effects. New database-backed phases retain their normal freshness checks. Schemas, durability, retention, and permissions are unchanged. No existing Gateway-context service method changes signature or replaces a synchronous SDK method.
Placement receipts remain a follow-up after the placement lane. Overlaps: #166444 and #166447, plus the parallel discovery, entry, restart, and compaction lanes. The second lander must integrate current main. The former umbrella #162433 is closed and is not an active owner.
Evidence
The unchanged synthetic
chat.sendharness ran three fresh fixtures before and after, including first turn, ten warmed turns, a child, control RPCs, cron, committed compaction, and graceful shutdown. Counts include every thread and background work; elapsed times on the busy host are not latency claims.Three-run medians. Projection group: 479.3 → 248.4 statements and 69.9 → 36.4 requests per warmed turn. Warmed SQL falls 7.38%, requests 8.67%, and projection SQL 48.17%. Membership refresh falls from 12 requests / 156 SQL to zero. The design's ~40 projection statements / ~6 requests and overall <500 statements per warmed turn are not reached. Remaining projection costs include row facts (94.2 SQL), placement (82.6), activity summaries (29.6), and shared facts (27.5).
Two raw phase totals exceed +2%, with exact request/statement attribution:
The native MAIN entry path stays 28 → 28 SQL per warmed turn. The total MAIN increase reflects periodic credential refresh, placement/publication reconciliation, and cron overlapping the measured window. Five shutdown-only audit
BEGIN IMMEDIATEattempts returnedSQLITE_BUSY; the existing retry path then committed successfully and both affected runs shut down cleanly. These failed attempts are disclosed separately from successful-statement counts, and no rerun was used to remove them.Node 26.10.0 / SQLite 3.53.4 / macOS 27.0.1. Candidate fixture wall times: 152.2s, 193.2s, 271.0s. Source/build manifests remained unchanged across all three runs. Subsequent local variable renames and a test-import cleanup are bound as a mechanical post-measurement delta.
Calibration independently reconciles eight native calls, two prepares, seven successful statements, and zero failures on MAIN and a worker. The focused real ACP create/update/close boundary observes zero caller-thread SQL before and after. The static database worker ratchet is 836 → 836 T1 sites: this lane removes redundant work from already-worker-owned operations.
Regression proof covers foreign commits, complete category/participant facts, native revocation before observers, partial and unknown receipts, late revisions/incarnations, unknown successors, shared-store replacement, and accepted Board/watermark/ACP facts. Six of seven initial new cases failed against the original baseline for the intended defect; the pre-existing native-revocation case passed.
Validation uses
pnpm test <files> --maxWorkers=1. The original eight-file focused pass took 1,213.99s on the loaded host: 113 passed, with five fixture/unknown-settlement expectation failures. Three fixtures now persist their claimed members, and unknown outcomes assert unavailable facts; all five corrected cases passed in the selected receipts rerun. Previously passing unaffected cases were reused.The two later test repairs match the real boundaries: the first transcript sequence is zero, and the shared-source barrier must stop the row read rather than a membership refresh. Neither weakens the receipt/freshness assertions. The new receipt suite has eight passing cases across the final selected runs.
Earlier focused commands in the Testbox run were reported passing with frozen-source verification. The workflow itself ended cancelled, so it is not an overall successful CI run; the lease is stopped. Fresh integrated local proof below supersedes the build/import checks:
server.sessions.store-paths,session-utils.acp-perf, ACP control/change, row-change gateway): 5 files / 25 tests, 104.953s. No host-owner routing additions were required.Static gates:
node scripts/check-changed.mjs --base 25affa738b0eebdc741938573d5807b3362d8dbepasses (1,195.77s, including all 27 core test type graphs and dead-export scans); madge 0 cycles; worker ratchet passes with T1 836 → 836 (reduction 0); env-name guard 464/464 with zero new names;git diff --checkpasses. SDK API diff completed against the pinned base and commit2d78b09cf635: no entrypoints added/removed and no direct export signature changes; 131 exports have changed reachable declaration hashes across eight internal declarations (receipt/event additions, partial retained facts, and declaration/module moves). These reachable changes were inspected; digest3677640c. SDK command wall: 771.08s, including temporary-worktree cleanup. P2 Codex autoreview is scoped-clean, with no accepted/actionable findings. No CI wall-time estimate is inferred from this busy-host local timing.Production LOC: +687 / −252 / net +435 across 33 production files (939 changed lines). No new
OPENCLAW_*names. Published-driver update cell is not applicable: existing owners, transport and admission rules are unchanged; this changes receipt payloads and an existing reader's operation vocabulary.Landing follow-up
Integrated main at
a86dd383534f8b3b6d1ebdc7e4b7601db65c6ad3without conflicts in merge commit73eda7eabb74653b1fabc4068a3dbf71dbc8c722. The production patch is unchanged. The original CI run 37592483581 exposed a stale shutdown-fixture barrier: it waited foracpSessions.metadataafter this PR moved the projection read tosessionRows.sharedFacts. Five pre-fix repetitions failed identically; five main-baseline repetitions passed. The repaired two-case file passes with its resource-lifetime assertions intact (134.31s test-runner wall on the loaded macOS host; original CI failing case 5.932s). The PR context check's required heading is also corrected.Post-integration proof: core production types and all 27 core test type graphs pass; madge reports zero cycles. Runtime process build graph and four relevant import-closure files pass (5 files, 16 tests, 204.37s command wall); PR wrapper inventory passes (28.97s command wall). Fresh P2 Codex autoreview of the integrated tree and fixture repair is scoped-clean. An earlier proposed cross-session receipt-ordering concern was rejected after inspecting the canonical-path FIFO through publication and every alternate publisher; connection incarnations are independent.
Released contract inspection covered
v2026.10.1-beta.1andv2026.9.8: the changed functions are not reachable exports of the released Plugin SDK, runtime API, or documented SDK subpaths. The moved watermark type preserves its original export and shape. The integrated SDK report completed in 673.08s with digestb8c5e0fc: no entrypoints added/removed and no direct export signature changes. The 131 reachable declaration hashes reduce to eight inspected internal declaration changes. No compatibility shim is needed.Five-run integrated statement qualification
Five fresh fixtures per revision ran the same workload and recovered native/census instrumentation on separate isolated Linux machines, Node 26.10.0 / SQLite 3.53.4. The workload is byte-identical to the surviving original harness; the observer's workstation census path was made relative. The original raw observer manifest is unavailable, so this is a matched new comparison, not a claim of byte-identical historical instrumentation. All ten fixtures completed, with zero failed SQL statements. Candidate command output and complete artifacts were recovered, but the broker timed out while saving its terminal receipt; the observations are retained without claiming a successful broker terminal receipt.
All other phase medians are unchanged or lower. Control-plane main samples are
[55, 55, 59, 59, 59]; candidate samples are[63, 63, 63, 63, 63]. This is outside the measured baseline range and is not being classified as variance.The control-plane attribution is exact across all ten runs:
[0, 0, 4, 4, 4][8, 8, 8, 8, 8]The five requests are one pending-input-history read, one history-page read, two mention snapshots, and one mention mutation. MAIN/helper SQL is zero during control. The extra median four statements are one existing shared-state timer tick: read/set busy timeout,
wal_checkpoint(PASSIVE), restore timeout. Raw stacks lead through the unchanged scheduler/WAL owners (sqlite-wal.ts,openclaw-state-db-open.ts); census marks them after completion of the first-turn worker-open request. Total periodic work remains 52 shared-state plus 28 agent-state statements per run. The optimization moves the phase boundary relative to unchanged maintenance; no extra foreground request or receipt-triggered SQL was found.Coordinator-approved phase move (2026-10-07): the control-plane median 59 → 63 is one unchanged four-statement shared-state WAL tick crossing a phase boundary. Foreground SQL remains 55 and full-run periodic SQL remains 80 in every run. First-turn+control sums are main [6051, 6049, 6058, 6054, 6054] versus PR [5814, 5810, 5814, 5810, 5810], medians 6054 → 5810. The adjacent second-session+control windows used for the clarified timing-dependent-background-work gate are main [7380, 7397, 7510, 7385, 7397] versus PR [6790, 6802, 6788, 6763, 6807], medians 7397 → 6790; every candidate run is lower. The strict individual first-turn and warmed-turn gates remain separate and pass, and compaction decreases. The coordinator approved this phase move under the clarified combined-window rule; checkpoint cadence and the harness are unchanged.
Current CI failure classification
Current-head CI run 37598303434 completed with 63 successful jobs, 22 skipped jobs, one failed root (
checks-node-changed) and its failed aggregate.security-fastpasses. The root isx-publication-owner-composition.e2e.test.ts:544: anonymous public HTTP expected 200, received 503. Five repetitions on main and five on the PR both yieldpass, fail, fail, fail, fail. Main walls are 379.90/34.64/34.61/34.76/34.59s; candidate walls are 374.27/34.45/34.37/34.58/34.42s, including a first-run build on each machine.The fixture, anonymous-reader/cache/admission/routes, and execution-cleanup inputs are byte-identical between main and the CI-tested merge. The actual CI checkout
a2cfa859986c97d9f81bd280d4c9890fdc207e5ehas ordered parents5dcf668765dea9dfc8101e163804c77ca52bdb53and this PR head; its tree matches Git's merge of those parents. Native inherited-failure evidence is prepared. A race betweenchildWrittenand later execution settlement is supported by source, but the exact 503 branch remains unobserved; baseline reproduction does not claim the PR cannot affect failure frequency. No CI rerun was used to hide this failure.ClawSweeper completed its exact-head review at 09:39 UTC with no actionable code or security findings; its remaining qualification request is covered by the SDK, repeated SQL, and baseline-failure evidence above. The coordinator approved the fully attributed phase move under the clarified adjacent-window rule.
The coordinator independently identified the inherited public-HTTP failure as a fixture settlement race. Its test fix is commit
1444b89d06184c72031119533396ca38a8601c71, being published directly to main by the owning lane. If that fix is on main at merge admission, this branch will integrate it and obtain green exact-head CI; otherwise the explicit native admin exception covers only this named, identically reproduced main failure. No other failure is waived.