Skip to content

fix(sessions): keep authority current after committed session changes - #167875

Merged
steipete merged 9 commits into
mainfrom
dbasync/sw2sessions
Oct 9, 2026
Merged

steipete merged 9 commits into
mainfrom
dbasync/sw2sessions

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes retained session facts missing committed category, entry, and transcript changes, including changes whose worker reply is lost or arrives after a newer native write.

Related: #167570 (merged foundation). This is the session publication follow-up, targeting main.

User Impact

Supported synchronous session methods still commit and install their facts before returning. Worker writes publish through native commit receipts before ordinary completion. Observed lifecycle and context revocation cannot be undone by restoring old values. No schema, stored-byte, permission, retention, configuration, SDK removal, or deprecation-window change.

Why This Change Was Made

The existing session entry and transcript owners now carry transaction-captured postimages through the shared receipt pipeline. Member, owner, category, participant, and compound SessionManager writes preserve newer field assignments and fence incomplete membership. Transcript facts install privately, before public observers, without duplicating presentation notifications. Received commits use an installation frame independent of a reentrant native transaction's rollback scope. Proven failed COMMITs preserve captured context; unknown outcomes remain fenced. Silent transcript commits advance the existing projection freshness counter without duplicating notifications.

Exact anchor validation and native final-authority guards remain. These receipts do not certify arbitrary raw SQL, foreign writers, or exclusion through a different database's commit.

Evidence

PR head: b1f8ba6439dee22cace975708c5959912aa2552e. Coordinator-approved head: 4d400c10631fe830044c0c16d4df233a5ca36e75. Measured and SDK-reviewed S2 head: 0a26d3384d9d6c1b473a14d4f86cfe4c954cd820; pinned measurement baseline: cc17325f3a491a4240cc8e2a3a58435b1431499a. The parent has merged, so this PR targets main. The initial conflict-only integration incorporated main 432ade6f500de6cdb0bcd4b0948a07bf466672f1; the recorded SQL and SDK results remain evidence for their exact original source pair.

  • Node 26.10: 195 tests across 15 files passed in 1,073.42 seconds; the final three fixture follow-ups passed in 48.59 seconds. The six focused correction regressions also passed.
  • Repository-pinned Bun 1.4.3 canary: 68 tests across eight files passed in 111.13 seconds, with Bun executing the test and SQLite workers. These runs cover native/worker authority, durable/incognito sharing, raw same-handle guards, transcript/context revocation, rollback and historical migrations.
  • Tests ran through pnpm test <focused files> --maxWorkers=1. Those historical local runs do not measure CI seconds. Final-head CI is tracked in run 37980793245.
  • Production types and all 27 core test graphs passed. Pre-integration changed-file checks completed, including format, lint, schema/SQLite ratchets, plugin boundaries, SDK export registration, and import-cycle checks (zero runtime cycles). That Knip run reported three inherited findings in untouched files: bindCliQuestionAnswerAuthority, prepareSessionEventTargetForHost, and RESTART_CONTINUATION_CONTEXT_PREFIX; the two S2 leftovers it found were removed.
  • Scoped Codex review completed with no actionable findings, including the final follow-up changes. Final candidate runtime build passed in 68.66 seconds.
  • After the conflict-only main integration: 108 tests across six files passed (pnpm test <focused files> --maxWorkers=1, 1,210.78 seconds wall time). Production types and the agent-sessions, config/CLI, and state/logging test-type graphs passed; the integration review was scoped-clean at P0/P1. Main’s during-delivery watermark/owner checks were migrated into the extracted worker publisher, and both sides’ watermark regressions were retained. The combined cold-storage worker crossed its line limit; its three unchanged private data types moved to the existing type-contract module. Production types and scoped lint passed after that type-only relocation, and all 61 changed files passed formatting.

SDK API comparison against the pinned main base passed: no added/removed entrypoints, no direct-export declaration changes, 153 reachable export closures and 18 reachable declaration changes. The changes carry private receipt/publication types and optional lifecycle facts; no synchronous method is removed or made asynchronous. Acknowledgement digest: b9c54e9a.

Three alternating baseline/candidate pairs passed the SQL statement gates for the shared Gateway workload and affected operations. First-turn all-thread SQL fell 2,631 → 2,510; warmed SQL fell 1,044.1 → 1,041.3 per turn, with warmed MAIN at zero. Typed mutation statement/request counts were unchanged. Full tables and background attribution are below.

The receipt contract adds three one-way native COMMIT envelopes per warmed turn (two transcript appends and one participant write) and five on the first turn (four transcript appends and one participant write). These are not new requests or round trips. The later native-settlement envelopes remain necessary: COMMIT evidence survives worker loss before cleanup, while settlement proves the worker has finished. Envelope exception approved by the coordinator on October 9, 2026. Peter’s decision is that “we control the database and the process and all state”: the campaign will remove runtime freshness probes (approximately 231 PRAGMA data_version calls per warmed turn), with complete in-process write receipts supplying the replacement mechanism. This approval accepts S2’s measured +3 warmed-turn / +5 first-turn receipt messages. Probe removal is follow-up work, not a saving claimed by this PR.

  • Negative controls reproduced native and worker category loss, four same-handle raw revocation failures, two committed sharing reply-loss failures, transcript/lifecycle revoke-and-restore acceptance, false context revocation after a real failed worker COMMIT, and stale watermark reuse after a silent native append on the pre-fix source.
  • Published-driver × candidate update acceptance passed on Testbox: published 2026.9.9 → candidate 4d400c10631fe830044c0c16d4df233a5ca36e75 (run 37967308610). The managed Gateway was replaced, readiness returned 200, version/build matched, durable history survived, and incognito history was cleared. The cell took 264.763 seconds; build, package verification, and cell together took 847 seconds. Package SHA-256: b31e28cdfcce96929f5f75ea4c8f614f59bc048e681d9a3ac994ddf0b4d2ac9a. The lease is stopped. Later landing repairs do not change schema, stored bytes, package layout, or updater paths; this is explicitly earlier-source update evidence, not a claim of a repeated final-head cell.

Landing correction and released SDK check

CI run 37963426058 exposed the same missing wrapper dependency inventory reported by ClawSweeper. Commit 550442d8afc18f90c7222d361e6d3a795dc6d14c adds the two missing runtime modules to scripts/pr-lib/wrapper-components.txt; runtime code is unchanged. The initial run's two wrapper-closure failures were PR-caused; other unfinished jobs were cancelled by fail-fast, not passing coverage.

node scripts/run-vitest.mjs test/scripts/eager-import-closure.test.ts test/scripts/runtime-process-build-graph.test.ts src/auto-reply/reply/get-reply.imports.test.ts --maxWorkers=1 passed all 28 tests across three files in 258.29 seconds on the corrected tree. P2 Codex autoreview of the inventory correction is scoped-clean. The earlier complete-candidate review and integrated-runtime proof remain applicable; no new SQL measurement is claimed.

Conflict-only integration bc86a6f1e44d5dceba9f6dbd2d064bc7557f3cc3 merges main 3e90389813229bd33c169fb07b883b567847224e. The only conflicts were adjacent S2/S3 documentation sections and the generated worker inventory; both sections were retained and the inventory regenerated. S3 (#167731) conversation receipts auto-merged in their separate registry function, preserving both owners. No S2 runtime conflict resolution or SQL-path change was needed. After integration, production types, all 27 selected core test-type graphs, madge (zero cycles), documentation formatting and git diff --check passed. The original paired SQL proof is reused under the conflict-only landing rule.

Released SDK inspection against v2026.10.1-beta.1 and v2026.10.1-beta.2 confirms that src/plugin-sdk/sqlite-runtime.ts exports openOpenClawAgentSqliteWorkerStore. This PR adds only optional observer/admission hooks; it preserves the released callable signature and existing callers. api.runtime.gateway.subscribeSessionChanges keeps its signature, while callbacks now observe fully installed private facts. No released export is removed or changed from synchronous to asynchronous. Existing config/infra/agent-support fork projects and the explicit worker-store inventory cover host-owned test routing.

Final landing repairs

The next integrated CI run, 37968294551, exposed three owner defects and stale fixtures. c74a170858fd splits legacy UPDATE execution from the managed RETURNING path so Kysely infers the row type, preserving both SQL statements and execution counts. 5b396f63d8b5 keeps unchanged native authority usable inside an owned transaction while tentative mismatches remain unavailable without permanently revoking rollback-restored state; installs a committed branch's local SessionManager identity before identity observers, including ordinary reply loss; and consumes committed category deltas with retained row facts so exact selection does not synchronously reload unrelated rows.

Existing receipt, participant, recovery-interceptor, and projection fixtures now assert the committed result, preserved state, no replay, and current authority. A native-write final guard deliberately performs one indexed row read after an observed native mutation, then reuses that result; the fixture retains an exact one-read bound rather than incorrectly requiring zero. The category regression still requires zero host SQL and now also requires zero B worker rereads while A and independent structural C remain properly isolated.

Validation: the initial wrapper/build-graph/import-closure run passed 28 tests in 258.29 seconds. The affected provider/recovery group passed its 50 unaffected-or-repaired cases; the two category failures were subsequently repaired. The configuration group passed 76 cases, with its only new negative-control fixture corrected to use a valid no-op native write. Final branching/native-authority coverage passed 27 tests; final category/accepted-facts/exact-read coverage passed all 44 tests across three files in 153.36 seconds. Production types, all 27 selected test-type graphs, scoped lint, formatting, and diff checks pass. Three P2 landing review rounds completed scoped-clean; the final category follow-up also received direct owner/source review and executable zero-SQL proof, following the review-convergence limit. No SQL measurement is being relabeled as final-head evidence.

The isolated main comparison reproduced the exact Slack preview mismatch (expected [0,1,2], received [0,0,1,2]) on main 3e90389813229bd33c169fb07b883b567847224e, run 37973798008. Its second selected case passed; the earlier timeout was not reproduced and is not claimed fixed. The writer-held reader-pool cleanup failure in session-accessor.recovery.test.ts also occurred on main run 37966817049, job 113943358309. A previous UI failure concerned unchanged mocked-Gateway history-prefetch expectations after main b0fb3ac33212; S2 storage is not reachable in that mock flow. Final-head CI 37980793245, attempt 1, completed with 103 successful jobs, 22 intentional skips, three inherited root failures and their failed aggregate. There were no cancelled jobs. The inherited roots are UI job 113991117480 (unchanged mock-Gateway history-prefetch expectation), Slack job 113991120566 (the exact request-count mismatch reproduced on main), and recovery job 113991120925 (the exact writer-held close failure reproduced on main). The other 15 progress cases passed, including the formerly timed-out case. security-fast and the applicable security-analysis jobs passed. Native admin admission retains the failed result, each source-equality qualification and the downstream aggregate; it does not claim green CI.

The tested checkout is 31cae8c581179cb1c19c8e0af5de142140a62577, with ordered parents main 73b9d2fe2018ca3f6747aab22051f51eb024a4ce and PR b1f8ba6439dee22cace975708c5959912aa2552e. Its tree equals Git's merge of those parents. The complete UI tree and relevant recovery/request-recorder inputs match the baseline. This uses the explicitly authorized inherited-failure exception; no failed test was rerun merely to obtain green.

Final integration and focused validation

eeeaed95dac4 integrated main bfe4592a7e81; b1f8ba6439de resolves the subsequent overlap with main fb516f82d57f and its prepared/CLI writer work (#167715). The worker keeps runWithCliHistoryWriter around captured row changes, and the host retains live CLI writer authority checks plus S2's receipt publication. Neither side's semantics was removed. All integrations are merge commits, not rebases.

The final fixtures retire database owners before temporary-directory deletion and verify that branch observers see the committed local identity before later retargeting. The static worker inventory now recognizes only the existing unregistered-handle branch of advanceTranscriptMutationAtInTransaction as migration/CLI work. Its guard cannot propagate into callbacks or the managed runtime branch. A regression keeps historical unconditional execution classified as T1 and rejects callback/else runtime growth. This fixes a counting artifact from splitting typed UPDATE execution; it does not loosen the budget or change SQL counts.

On this integrated tree, seven focused suites (ratchet, async SessionManager messages, CLI history, transcript authority, before-deliver, runtime build graph, and reply import closure) passed in 265.50 seconds. All 12 branch/maintenance tests passed in 206.68 seconds. Production types, all 27 core test graphs, root type graphs, the agents-sessions type graph, scoped lint/format, and madge (zero cycles) passed. The committed database-worker ratchet passes against the integrated main parent. Final CI elapsed times were 108 seconds for checks-fast-baseline-ratchets, 210 seconds for checks-node-compact-small-7, and 732 seconds for checks-node-changed-compact-large-20-2; all passed. These are complete job times, not per-test CPU costs. Three P2 landing review rounds completed scoped-clean; the final integration and guard classification received independent source review and focused regression proof under the review-convergence rule. The earlier paired SQL, released SDK diff, and published-driver update proof remain explicitly bound to their recorded sources; no landing SQL rerun is claimed.

Coverage and retained limits
Family Coverage
Entry creation, replacement, patch, reset, deletion, and lifecycle cleanup Existing native entry publications and worker replacement receipts; lifecycle flags, permissions, membership, owner/category facts, and explicit removal.
Sharing side data Native and worker member/owner/category/participant publications; pending custody, exact candidate/receipt agreement, committed reply loss, and later native supersession.
SessionManager persistence Message and anchored-message append, compaction/reset/custom/info/custom-message/label/leaf/summary, raw persist, suffix removal, static append, prepared rewrite, initialization and branch entry companions use the existing producers and commit pipeline.
SDK and core adapters Existing synchronous and awaited adapters inherit those producers. Opaque native callback contracts remain native; no Promise wrapper is claimed as a worker migration.
Cold materialization and projection reconciliation Explicit content-unchanged facts; neither installs a replacement context generation.
Accepted input and CLI writers Their existing custody and live-writer validators remain authoritative. A transcript summary is not a replacement for those guards.

Exact arbitrary anchor membership is still checked by the native projection reader. The private context postimage is not a complete anchor set, including intermediate branch exclusion and restoration for through-anchor consumers. Offline alias/canonical repair, artifact-copy repair, and legacy ACP provenance retain conservative invalidations and their repair custody.

The managed same-handle guard observes raw identity/settings changes without relying on data_version, which does not change for writes on that handle. Its slow path reuses one canonical indexed row read; unchanged uses issue no SQL. Unobserved raw ABA, partial batches, callbacks, unfinished iterators, complete raw write-set settlement, and foreign recertification remain incomplete. Their guards are retained; no global completeness or guard-retirement claim is made. Conversation catalogue/link publication remains with its separate owner.

Change size and inventory

Final reviewed head against integrated main fb516f82d57f: production/tooling +2,899 / −770 lines in 53 files; tests +1,338 / −103 in 19 files; documentation +65 / −3 in one file; generated inventory +37 / −36 in one file. The larger portion is committed-receipt custody and transcript authority coverage; the existing owners remain authoritative, and the superseded worker publisher and unused helpers were removed.

The measured source inventory reports 619 files / 2,449 expressions, with T1 at 757, unchanged from the pinned measurement baseline. The inventory was regenerated again after the conflict-only main integration (618 files / 2,428 expressions, T1 717); those main-line changes are not attributed to S2. Inventory regeneration is not a claim of runtime statement savings.

Paired SQL, transport, raw-guard and timing evidence

SQL and transport measurement

SQL statement gates: passing with the attributed non-turn/deferred-startup rules below. Envelope gate: explicitly approved exception, October 9, 2026. The candidate adds three one-way COMMIT envelopes per warmed turn and five on the first turn in touched operations; these are real added transport work, not numeric noise or SQL requests. The approval applies to this measured receipt-message cost; SQL gates and correctness proof remain required.

Three alternating main/candidate pairs ran on the same macOS host for each workload: pinned main cc17325f3a491a4240cc8e2a3a58435b1431499a and candidate 0a26d3384d9d6c1b473a14d4f86cfe4c954cd820. Both used source-mapped qaRuntime, Node v26.10.0, pnpm 12.5.1, isolated synthetic state and the same observer. All six shared runs completed 13 top-level turns, the child turn, control RPCs, cron, committed compaction and graceful shutdown. Calibration independently matched 8 native calls / 2 prepares / 7 successful statements / 0 failures on MAIN and a worker.

The table reports medians; arrows are main → candidate. ALL includes MAIN, worker threads and helper processes. Requests are operation dispatches. Envelopes count recognized send-side requests, frames, completions, admission/control messages and commit/settlement/attachment messages once; receive observations are excluded. SQL prepares and failed native executions are excluded from successful statement counts and reported separately. These are instrumented observations, not an unloaded-host latency benchmark.

Shared phase ALL SQL MAIN SQL Requests Envelopes Candidate/main wall ratio
Boot 2330 → 2330 1942 → 1942 57 → 57 153 → 153 0.914
Connect 314 → 386 70 → 70 49 → 64 150 → 206 0.981
First turn 2631 → 2510 73 → 73 279 → 262 1045 → 982 0.946
Warmed turn (10-turn mean) 1044.1 → 1041.3 0 → 0 194.4 → 193.8 707.9 → 708.4 0.974
Second session + child 3686 → 3698 71 → 72 622 → 624 2271 → 2294 0.999
Control plane 33 → 34 0 → 0 5 → 5 14 → 14 0.996
Cron 1222 → 1222 44 → 44 175 → 175 703 → 710 1.000
Compaction 673 → 727 43 → 43 85 → 86 242 → 248 0.992
Shutdown 870 → 817 150 → 150 112 → 111 479 → 475 0.956

Shared elapsed seconds by pair: main [53.68, 52.47, 58.04], candidate [51.19, 51.61, 53.68]. Every comparable shared phase has a median wall ratio below 1.5. First-turn ALL falls by 121; warmed ALL falls by 2.8 per turn, with warmed MAIN remaining zero.

Non-turn attribution and combined windows

Adjacent window Main runs 1/2/3 Candidate runs 1/2/3 Median delta
boot+connect+first-turn 5266, 5275, 5277 5225, 5226, 5228 -49
control+cron 1255, 1254, 1258 1257, 1233, 1255 0
compaction+shutdown 1548, 1560, 1543 1540, 1540, 1544 -8
  • Connect +72: deferred startup work shifted from the first-turn window into connect: cron load/schedule/mutation (src/cron/store.ts:77, src/cron/service/runtime-mutation.ts:97), delivery recovery/retention, health snapshots, device/bootstrap and plugin-state maintenance. The extra request families are present in baseline traces and the combined startup window decreases in every pair. These owners are unchanged by S2; this applies the deferred-startup rule, while the first turn independently passes its strict gate.
  • Second-session +12 (+0.33%): existing coalesced row/placement reads, a child-entry read and outbound queue sweep vary within the ordinary read flow. session-row-facts requests are [25,24,23] → [23,25,25]; placement projection [30,31,30] → [31,31,31]; outbound queue [1,1,2] → [2,2,1]. Row backfill is [3,3,3] → [3,3,4] (unchanged median). Native participant projection is [10,11,10] → [11,11,11], through the existing child-command entry resolution path. Relevant unchanged stacks include session-row-placement-projection.ts:103, session-row-transcript-backfill.ts:41, session-row-projection-backfill.ts:78, and resolveSessionKeyForRequestInternal in src/agents/command/session.ts. This is within the non-turn 2% allowance. Whole-workload row-fact requests fall from median 121 to 120; deterministic mutation dispatch counts do not grow.
  • Control +1: periodic PRAGMA wal_checkpoint(PASSIVE) counts [0,0,1] → [2,1,0], from unchanged sqlite-wal-checkpoint.ts:144 → sqlite-wal.ts:344 → gateway-scheduler.ts. Control requests stay at five; control+cron has equal medians.
  • Compaction +54 / shutdown −53: unchanged memory-core admission, STRICT-table and FTS work crosses the phase boundary. Recorded stacks include extensions/memory-core/src/memory/manager-publication.worker.ts:214 → migrateSqliteSchemaToStrictInTransaction in src/infra/sqlite-strict.ts:280. The same SQL/stack groups appear in baseline traces. Combined medians decrease by eight; pair 3 increases by one, retained in the table and covered by the current median-based non-turn rule.

Touched-operation audit: metadata append is exactly 49 requests / 1,409 SQL statements in every run on both sides; initialize is 2 / 11; turn prepare 13 / 169; turn commit 13 / 637; entry replacement 6 / 172; participant writes 13 / 112. Patch prepare remains 88 dispatches, with one existing cached-entry SELECT shifting into preparation (SQL [273,273,274] → [274,274,274]); commit remains 169 dispatches and drops two median SQL statements ([2629,2628,2627] → [2626,2627,2625]). Combined patch legs decrease from median 2901 to 2900. The transcript UPDATE gains RETURNING projections but remains one execution: three per warmed turn and twenty in the second-session phase. First/warmed exact-entry, target-inventory and backfill dispatches do not increase; no repeated publication-driven refresh loop was observed.

Commit-envelope cost — approved exception

Shared phase Native COMMIT Native settlement Attachment
Boot 6 → 6 18 → 18 2 → 2
Connect 7 → 10 19 → 32 1 → 4
First turn 26 → 28 102 → 89 77 → 74
Warmed turn (10-turn mean) 18 → 21 66.6 → 66.6 54 → 54
Second session + child 64 → 83 214 → 214 162 → 162
Control plane 1 → 1 1 → 1 0 → 0
Cron 22 → 29 78 → 78 61 → 61
Compaction 2 → 3 15 → 15 11 → 11
Shutdown 1 → 1 90 → 90 39 → 39

The warmed addition is exactly +2 session.metadata.append native-COMMIT envelopes and +1 participant native-COMMIT envelope per turn, in every candidate run, from zero for these operations in baseline. The first turn adds +4 metadata-append and +1 participant native-COMMIT envelopes; unrelated startup reductions mask these in aggregate counts. The matched operations’ native-settlement/attachment counts and SQL requests do not grow. Emission is the COMMIT publication at sqlite-worker-operation-admission.ts:533; the later native-settlement also contains the committed receipt. The coordinator explicitly approved this +3 warmed-turn / +5 first-turn cost on October 9, 2026, for the complete in-process receipt mechanism that supports the planned removal of runtime freshness probes. It is an approved exception, not noise allowance or a claim that this PR removes those probes.

Affected sharing operations and raw compatibility guard

Three separate alternating component pairs each used one isolated state owner and ten successful calls per ordinary operation; no Gateway boot per operation, mocks, production test hooks or measured setup/verification queries. MAIN below is the component process main thread. Native/worker mutation results and final state were checked.

Component window ALL base → candidate MAIN base → candidate Requests base → candidate Envelopes base → candidate Wall ratio
03.native.add 5 → 5 5 → 5 0 → 0 0 → 0 1.038
04.native.remove 6 → 6 6 → 6 0 → 0 0 → 0 1.089
05.native.owner 4 → 4 4 → 4 0 → 0 0 → 0 1.167
06.worker.add 8 → 8 0 → 0 3 → 3 17 → 18 1.071
07.worker.remove 9 → 9 0 → 0 3 → 3 17 → 18 1.044
08.worker.owner 8 → 8 0 → 0 3 → 3 17 → 18 1.060
09.worker.participant 11 → 11 0 → 0 3 → 3 17 → 18 1.028
10.worker.category 39 → 39 0 → 0 4 → 4 22 → 23 1.095
13.raw.unchanged 0 → 0 0 → 0 0 → 0 0 → 0 0.726
15.raw.final-guard 0 → 1 0 → 1 0 → 0 0 → 0 1.503
17.raw.restored-guard 0 → 0 0 → 0 0 → 0 0 → 0 0.358

The worker sharing operations add exactly one native-COMMIT envelope per successful mutation; native-settlement/attachment and operation request counts remain unchanged. Native add/remove/owner and worker add/remove/owner/participant/category statement counts match exactly in all three pairs. All comparable mutation windows have median wall ratios ≤1.167.

The raw changed-handle guard is different required behavior, not a latency-equivalence comparison: baseline accepts a raw permission change and its restoration; candidate refuses both with SESSION_DELIVERY_GENERATION_UNAVAILABLE. Candidate executes exactly one indexed session-node/retained-window SELECT on the first final check, with no transaction, request or transport envelope; unchanged checks remain zero SQL, and the permanently refused restored check remains zero SQL. Raw first-check times (ms) are [0.692,0.562,5.639] → [0.869,1.242,1.040], medians 0.692 → 1.040 (ratio 1.503). This is explicitly reported as the retained final-authority guard cost, not waived as measurement noise.

Native failures and timing limits

All six shared runs recorded exactly one failed BEGIN IMMEDIATE / SQLITE_BUSY in the unchanged post-ready plugin startup lease cleanup: server-startup-plugins.ts:69 → withPluginLifecycleLease → releaseOpenClawStateLeaseBestEffort / openclaw-state-lease-storage.ts:157. It occurred in connect for two baseline runs and all candidate runs, and in the first turn for baseline run 3. Native elapsed times were 0.015–0.023 ms; all workload operations still completed. No SQLITE_LOCKED or other native failure class occurred. Component runs had zero native failures.

Warmed native BEGIN elapsed upper-bound medians were 0.581 → 0.562 ms/turn; COMMIT 13.468 → 11.894 ms/turn, over 99.5 → 99.4 intercepted begin/commit calls per turn. These times include execution and scheduling and do not isolate lock waits; only standalone BEGIN/COMMIT and all intercepted failures are timed, not opens/closes or implicit/batched transaction intervals. Zero additional busy failures is not a claim of zero lock waiting.

Raw traces and exact build/source/measurement receipts are retained locally; no raw trace upload accompanies this summary. Historical fixture-only failures (runtime-selection mismatch before SQL, then missing category registration in the setup of an earlier baseline smoke) are preserved separately and were corrected before these paired runs.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: XL labels Oct 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR keeps session permissions, sharing details, categories, and conversation history current after database commits, including when worker replies are lost or delayed.

Example: An operator removes session member guest and the worker reply disappears after the database commits.

  • Before: The caller receives an uncertain-outcome error and retained membership requires reconciliation.
  • After: The confirmed commit publishes the removal and returns the guest record without repeating the mutation.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful repair through existing owners, with sufficient production evidence, resolved prior findings, and no newly identified defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The inspected body records real Gateway workloads and production SQLite runs exercising receipt installation, committed reply loss, supersession, and rejection of revoked/restored permissions and context. Earlier-source runtime and update evidence remains explicitly identified, with integrated-head correction coverage supplied separately; source inspection verifies that no stored-format migration is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Session readers and callbacks can see stale permissions, sharing details, categories, or history after a change has committed.
Reason: The change restores the established commit-before-observer contract. Current-main history connects the author to these owners, and the recorded direction preserves public and stored-data contracts.

Merge readiness

✅ Ready for maintainer review

This PR remains useful work that current main does not provide. Earlier findings are resolved, no new actionable defect was identified, and the remaining CI failures have evidence of causes outside the introduced changes.

Priority: P2
Reviewed head: b1f8ba6439dee22cace975708c5959912aa2552e

Before merge

None.

Findings

None.

Provenance

  • Transcript mutation postimages: original intent not found (ecb6eac: Scoped string history reaches the SQLite accessor split; the original mutation-publication rationale was not established.)
Agent review details

How this fits together

OpenClaw stores session details and conversation history in SQLite. Database workers publish committed facts to the Gateway, where authorization checks, session readers, and plugin callbacks consume them.

flowchart TD
  A[Session mutation] --> B[SQLite transaction owner]
  B --> C{Commit outcome}
  C -->|Confirmed| D[Committed entry and transcript facts]
  C -->|Unknown| E[Fence affected facts]
  D --> F[Install current session state]
  F --> G[Authorization checks and observers]
  E --> G
Loading

Technical review

Best possible solution:

Keep committed-fact publication in the existing session owners while preserving final authority checks and synchronous SDK completion.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main publication paths and the recorded lost-reply, late-receipt, and revoke-and-restore negative controls establish concrete reproduction scenarios. This read-only review did not execute target code.

Is this the best way to solve the issue?

Yes: transaction-captured facts belong in the existing entry, transcript, and commit-publication owners, and the patch preserves native final guards rather than creating competing authorization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 58ba7ede092e.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit da67a08 adds src/infra/sqlite-post-commit.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: da67a08b20eb; files: src/infra/sqlite-post-commit.ts)

PR surface

Source +2103, Tests +1235, Docs +63, Other +26. Total +3427 across 74 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 51 2865 762 +2103
Tests 19 1338 103 +1235
Docs 2 102 39 +63
Config 0 0 0 0
Generated 0 0 0 0
Other 2 34 8 +26
Total 74 4339 912 +3427

Review metrics

Metric Value Why it matters
Production versus tests Production +2,865/−762 LOC; tests +1,338/−103 LOC Production growth supports receipt custody and authority installation through existing owners, with fault, rollback, and ordering coverage.
Accepted receipt transport cost +3 one-way COMMIT envelopes per warmed turn; +5 on the first turn The recorded owner decision accepts this measured cost while retaining separate native settlement.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs bounded session-publication failures without evidence of a widespread urgent outage.
  • merge-risk: 🚨 compatibility: Released worker and plugin callback surfaces are affected, with optional hooks and committed-fact ordering preserving their existing callable contracts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-09T17:09:46.956Z sha 4d400c1 :: needs changes before merge. :: [P2] [P2] Include the new publication modules in the wrapper inventory
  • reviewed 2026-10-09T17:57:22.000Z sha bc86a6f :: blocked before merge. :: [P2] [P2] Adopt the committed branch before notifying identity observers | [P2] [P2] Update recovery fault injection for the wrapped admission facts | [P2] [P2] Accept the finalizer receipt in the held-reply fixture | [P2] [P2] Migrate the Gateway category uncertainty fixture to commit receipts
  • reviewed 2026-10-09T18:45:41.310Z sha eeeaed9 :: needs changes before merge. :: none
  • reviewed 2026-10-09T19:43:39.015Z sha b1f8ba6 :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 3:58 PM ET / 19:58 UTC (Revision 5).

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 9, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Oct 9, 2026
Preserve unchanged authority inside native transactions and adopt committed branches before identity notifications. Apply committed category deltas through the projection owner without native reloads, and align focused fixtures with confirmed receipt semantics.
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Oct 9, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Oct 9, 2026
Merge current main while preserving CLI writer authority and transaction-local session receipt capture. Classify only the guarded raw migration UPDATE as bootstrap work, retain runtime and historical SQL in the ratchet, and repair delivery teardown and post-publication branch fixtures.
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@steipete
steipete merged commit 7a82a47 into main Oct 9, 2026
205 of 210 checks passed
@steipete
steipete deleted the dbasync/sw2sessions branch October 9, 2026 20:08
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…openclaw#167875)

* fix(sessions): publish committed entry and transcript authority

* fix(sessions): preserve actor receipts and typed publication callbacks

* fix(scripts): include session publication in wrapper inventory

* fix(sessions): infer transcript publication query rows

* fix(sessions): settle receipt observers and retain row facts

Preserve unchanged authority inside native transactions and adopt committed branches before identity notifications. Apply committed category deltas through the projection owner without native reloads, and align focused fixtures with confirmed receipt semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant