Repository navigation
perf(sessions): reuse actor replica for entry and target reads - #168677
Conversation
…odules Merge current main while preserving shared physical admission, cancellation, reader validation birthtime, and live deletion authority. Split worker usage, pool construction, failure settlement, and schema owner types to keep the existing line caps.
Checkpoint the single-owner cutover, cache invalidation regressions, and request-owned read transactions. Keep explicit migration verification. Paired measurement and final validation are still in progress.
Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions.
Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity.
Merge current main and preserve its optional settlement-only receipt delivery through the extracted owner. Keep the worker refusal error with the leaf contract to stay within the existing admission line cap. End the marker-free read-only fixture transaction normally; dedicated rollback and explicit revocation coverage remains unchanged.
Preserve snapshot-local reuse without freshness queries, publish dedicated archive writes, and remove Workboard polling. Retain native authority and settlement boundaries. Checkpoint reviewed corrections and focused regression repairs; final integrated proof remains in progress.
Define inactive typed durable phases, versioned hot snapshots, complete commit receipts, pure bookkeeping reducers, and unknown-outcome fencing. Share lifetime and settlement vocabulary with the existing incognito actor without changing routing or persistence.
|
Landing review at Final-head Testbox proof: 57 tests across all six selected files passed (44 seconds). Type-aware oxlint, export-name collisions, formatting, and the database dialect ratchet passed. Knip reports only the same untouched-file exports seen in main CI: Both failed PR test jobs are inherited from main run 38112256403:
Using the explicitly authorized inherited-failure exception and head-pinned REST squash fallback after native worktree operations exceeded the ten-minute stall threshold. The interrupted native operation was joined and its exact retained lock recovered. No product fix beyond the conflict-only merge was needed; no update cell applies. |
…law#168677) * perf(sqlite): checkpoint shared admission across workers (WIP) * test(sqlite): align worker fixtures with shared admission * perf(sqlite): avoid repeated quarantine reads in retained scopes * docs(sqlite): define single-owner database freshness * perf(sqlite): replace runtime probes with writer publications Checkpoint the single-owner cutover, cache invalidation regressions, and request-owned read transactions. Keep explicit migration verification. Paired measurement and final validation are still in progress. * test(sqlite): align first-admission coverage and deletion fixtures Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions. * build(sqlite): include shared admission in compiled wrappers Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity. * test(sqlite): use the canonical settlement owner in publication proof * fix(sqlite): complete writer custody and snapshot cache lifetimes Preserve snapshot-local reuse without freshness queries, publish dedicated archive writes, and remove Workboard polling. Retain native authority and settlement boundaries. Checkpoint reviewed corrections and focused regression repairs; final integrated proof remains in progress. * fix(sqlite): retain integrity and worker admission through cleanup * test(sqlite): preserve reader coverage in existing fixture owners * fix(sqlite): preserve cache receipts across sibling writers and temp DDL * fix(workboard): type the replacement card-list promise * fix(sessions): integrate receipt-based list revision reads * perf(sessions): reuse committed entry facts across ordered reads * refactor(sessions): identify fused query as worker-only * fix(sessions): preserve receipt facts across read phases * docs(sessions): clarify retained listing and alias guards * refactor(sessions): define shared session actor contract Define inactive typed durable phases, versioned hot snapshots, complete commit receipts, pure bookkeeping reducers, and unknown-outcome fencing. Share lifetime and settlement vocabulary with the existing incognito actor without changing routing or persistence. * refactor(sessions): update actor cutover contract * refactor(sessions): add inactive phase actor backend * fix(sessions): preserve actor projection readiness and held facts * perf(sessions): reuse retained transcript initialization facts * test(sessions): split admitted cohort lifecycle coverage * test(sessions): service actor fixture admission synchronously * refactor(sessions): use shared string validation for entry facts * feat(sessions): contract update 2 for existing incognito owners * fix(sessions): preserve query builder method binding * fix(sessions): reacquire incognito projection claims after actor commits * test(sessions): distinguish model metadata from context messages * refactor(sessions): separate actor contracts and share mutation executors * docs(sessions): explain actor assertion invariants * refactor(sessions): share native transcript presence query * test(sessions): explain actor eviction mock isolation * test(sessions): align actor fixtures with typed owner contracts * fix(sessions): preserve actor callback bindings and audit inactive APIs * fix(sessions): keep host config out of worker transport bundles * feat(sessions): contract update 3 for scoped receipts and command preimages * fix(sessions): reject mutations during actor authority admission * fix(sessions): retain actor state across unrelated pending writes * fix(sessions): preserve incognito transaction settlement contract * test(sessions): keep scoped receipt fixtures within storage contracts * refactor(sessions): separate receipt and transcript helper responsibilities * fix(sessions): use scoped entry receipt for the adopted window * fix(sessions): complete integrated actor reader references * fix(sessions): finish actor validation cleanup * chore(sessions): shrink moved assertion baseline * refactor(sessions): simplify actor replica validation * perf(sessions): reuse actor replica for entry reads Share entry projections with the receipt-maintained MAIN actor replica, preserving ordered reads and complete snapshot coverage. Unrelated session writes retain warm entry facts; native entry postimages refresh them without a worker read. * perf(sessions): reuse prepared storage targets Reuse registry-owned target selection and current entry facts for runtime transcript access. Keep family inventories on the existing reader because sibling-row dependencies are not complete. Preserve canonical-path metadata in cached entry results. * fix(sessions): retain entry receipts through metadata notices * fix(sessions): keep queued receipt slots through unchanged markers * chore(sessions): explain replica receipt iteration snapshot * fix(sessions): restore replica subscription after cache reset
The actor facts introduced by 3bbc221 (#168677) make a raw same-inode corruption probe the wrong way to fault a prepared identity. Close its existing owner synchronously after durable kill intent is recorded, and retain the partial-cancellation and healthy-sibling assertions. Remove the redundant raw-read throw and file rewrite; raw corruption coverage remains in chat.abort-errors.test.ts. The child case failed on the baseline because the cached read did not throw. No production authority checks or behavior change.
The actor facts introduced by 2cdcb4e (openclaw#168677) make a raw same-inode corruption probe the wrong way to fault a prepared identity. Close its existing owner synchronously after durable kill intent is recorded, and retain the partial-cancellation and healthy-sibling assertions. Remove the redundant raw-read throw and file rewrite; raw corruption coverage remains in chat.abort-errors.test.ts. The child case failed on the baseline because the cached read did not throw. No production authority checks or behavior change.
* fix(sessions): resolve cached transcript targets through their owner resolveSessionTranscriptRuntimeTarget returned the requested key whenever a retained entry row named the requested session ID. That does not prove transcript ownership: an isolated cron run's row is written after its base row and owns the shared transcript. After sessions.abort retained the base row's facts, chat.inject on the base key hit the ownership check on every attempt, while the uncached path wrote to the owner. Retained facts carry no window owner, so drop the cached branch and always read the persisted session-ID index, as the uncached path does. Each resolution that used the cached branch now costs one runtime-target worker request (one SQL statement, 1.2 when qualified); measured locally that is about 0.5-1.8 ms at p50 per resolution, and the gateway concurrency benchmark shows no difference beyond its noise. Publishing a proven owner from actor state and write postimages would keep the cached branch for those sources. Proof: a Gateway WebSocket regression (sessions.abort, then two chat.inject calls) and a resolver case for the shared session ID fail on main and pass with the fix. The #168677 pin keeps its behavioral checks (current transcript and lifecycle revision) without a read-count bound. Refs #168677 * fix(sessions): preserve transcript ownership after cached entry reads Resolve durable transcript targets through the admitted owner lookup when cron base/run rows share a session ID. Preserve owner lifecycle revisions and cover two ordered chat.inject calls after sessions.abort warms the row. Close the steering fixture's extra tool-authority snapshot, which retains one entry predicate and polluted the following Goal cleanup assertions. Check zero retained facts at the originating fixture without changing the production accounting or existing Goal assertion. Fixes #170136 Co-authored-by: Serghei <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Serghei <[email protected]>
…aw#170137) * fix(sessions): resolve cached transcript targets through their owner resolveSessionTranscriptRuntimeTarget returned the requested key whenever a retained entry row named the requested session ID. That does not prove transcript ownership: an isolated cron run's row is written after its base row and owns the shared transcript. After sessions.abort retained the base row's facts, chat.inject on the base key hit the ownership check on every attempt, while the uncached path wrote to the owner. Retained facts carry no window owner, so drop the cached branch and always read the persisted session-ID index, as the uncached path does. Each resolution that used the cached branch now costs one runtime-target worker request (one SQL statement, 1.2 when qualified); measured locally that is about 0.5-1.8 ms at p50 per resolution, and the gateway concurrency benchmark shows no difference beyond its noise. Publishing a proven owner from actor state and write postimages would keep the cached branch for those sources. Proof: a Gateway WebSocket regression (sessions.abort, then two chat.inject calls) and a resolver case for the shared session ID fail on main and pass with the fix. The openclaw#168677 pin keeps its behavioral checks (current transcript and lifecycle revision) without a read-count bound. Refs openclaw#168677 * fix(sessions): preserve transcript ownership after cached entry reads Resolve durable transcript targets through the admitted owner lookup when cron base/run rows share a session ID. Preserve owner lifecycle revisions and cover two ordered chat.inject calls after sessions.abort warms the row. Close the steering fixture's extra tool-authority snapshot, which retains one entry predicate and polluted the following Goal cleanup assertions. Check zero retained facts at the originating fixture without changing the production accounting or existing Goal assertion. Fixes openclaw#170136 Co-authored-by: Serghei <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Serghei <[email protected]>
What Problem This Solves
Warm chat turns repeatedly discover the same session store and reload the same session entry, despite the session actor already publishing committed facts. This is the Phase C entry/target reader lane, stacked on #168602.
User Impact
Reduces database work during ordinary turns without changing session data, public APIs, configuration, or update behavior. Cold entries, historical session-ID lookups, and reads requiring missing membership/participant facts continue through the existing bounded worker read.
Why This Change Was Made
Entry readers now share the actor's bounded MAIN replica instead of maintaining a second entry cache. Complete commit receipts refresh entry-only facts without certifying transcript/custody state; source-only metadata notices preserve those facts. Cache lifecycle resets clear residency and lazily restore the receipt subscription. Ordered cohorts keep their existing writer ordering and before/after consistency check. Native writes without a sealed postimage invalidate the projection and require one cold read before reuse.
Store selection reuses registry- and physical-identity-bound results. Fixed-store inventory also observes in-process writes; family/scoped inventories retain discovery because their sibling row dependencies are not exhaustively captured. Current-session transcript selection consumes the prepared entry; historical/keyless selection retains the persisted index. ACP metadata and subagent-run maintenance remain with their existing independent owners.
Evidence
Pinned comparison: base
6e8a0034934cvs candidate15defc052238; three alternating pairs (M,C,M,C,M,C) on the same AWSc7a.8xlarge, using the shared workload. Warmed values are each run’s mean of ten turns, summarized as median [min–max].Warmed all-thread request reduction: 30.7/turn (18.1%); database requests: −15.7/turn; SQL: −2.1/turn; MAIN SQL unchanged at 11.2/turn. This is a smaller saving than the lane aim: remaining exact-entry, ACP/subagent, and family-inventory reads keep this subsystem above the ≤10-request/≤30-statement target. They are not claimed as removed.
The original first-turn median is +15 SQL (+0.91%), so the RAW TURN INCREASE rule triggered the one extra alternating pair. The AWS lease expired during that attempt; a replacement hit the regional vCPU limit. The completed extra pair used one Hetzner
ccx33, the same pinned commits, Node 24.21.0, pnpm 12.9.0, and the same workload. It is reported separately rather than pooled into the original three-pair statistics.Gate disposition: pass by the permitted entire-workload redistribution check. Both entire-workload SQL and requests fall in the extra pair; no duration ratio exceeds 1.5. The original warmed median falls, and the extra first turn falls. The extra warmed shift is +3 SQL/turn (+0.45%): corpus inventory contributes +3.3, unassigned/MAIN +1.1, tombstones +0.7,
session.entry.read+0.5; inventory −1.3, runtime target −1.0, shared facts −0.3, exact entries −0.1, and ACP metadata −0.1 offset it. These are observed phase-placement/count differences, not a claim that all individual operation totals shrink.Whole-workload operation evidence for the extra pair:
The extra-pair baseline finished before a
/tmpcollection quota failure; its intact original output was validated and reduced in place. Candidate output used the root filesystem. One queuedprewarmrequest lacked an owner stack in the reducer: it remains counted in total requests and is labeled unclassified rather than guessed as database/CPU work. No SQL/request was dropped, no workload was altered, and no additional successful pair was run.Validation used one retained AWS Crabbox and the pinned stacked base above. Final head: 52 tests passed across five focused files, with
pnpm test src/config/sessions/session-entry-read-ordered.test.ts src/config/sessions/session-actor-replica.test.ts src/config/sessions/session-accessor.transcript-identity.test.ts src/config/sessions/session-transcript-worker-readers.test.ts src/config/sessions/session-actor.test.ts --maxWorkers=1taking 62 seconds wall time on the remote worker (62 runner-seconds; hosted CI timing is not claimed). Coverage includes post-write entry freshness, scoped invalidation, registry reassignment, fixed-store visibility, sibling-family writes, cold-read ordering, and full actor-state preservation. The final combined run also exercises cleanup and receipt resubscription between suites.Production typechecking, formatting, lint, Madge (18 seconds), T1 (no growth), and dialect checks pass. Changed-file dialect groups are all 0 → 0. The full core-test typecheck passed in 408 seconds at
0abee34139b4; the subsequent change only repairs the internal replica subscription lifecycle, and final production typechecking and all focused tests passed. No test graph changed afterward.check:changedwas run remotely and stopped at the inherited environment budget (456 vs 455, reproduced on the exact base). Its expanded gates were then run individually so that the early failure did not hide later checks. Remaining out-of-scope failures: UI E2E test-root budget 722 vs advisory 720; unused exports intools/solid-lint/index.mjs,src/cli/update-cli/update-command-post-activation-inspections.ts, and two session-channel fixture exports; Knip reports 16 unused files, unused@solidjs/signals, and unlisted@solidjs/compiler. None are in this lane's changed files. No budgets or baselines were loosened.Diff size: production +475/−268 (net +207), tests +206/−9 (net +197), docs +10. The old independent entry-facts cache and subscriber are removed; the existing bounded actor pool owns those facts.
Two Codex autoreview rounds completed before the final targeted validation fixes. The repeated list-projection finding was rejected because direct list projections are ineligible for retention; partial/full snapshot coverage remains. The sibling-family inventory finding was accepted by removing that optimization and adding a sibling-write regression. No further review round under the lane's two-round cap.
No schema, migration, Doctor, updater, plugin-loading, service-lifecycle, or SDK changes; the published-driver update cell and SDK API diff do not apply.