Repository navigation
refactor(sessions): add inactive memory backend to session actor - #169124
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 changes before merge. What this changesThis PR shares session actor execution policies and adds an inactive memory backend for incognito sessions. Example: Production acquires agent:main:dashboard:incognito-declined.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this maintainer-directed inactive refactor open; the earlier wrapper finding is fixed, and no new actionable patch defect was established. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherSession callers submit typed commands to the actor, which returns committed state and receipts through the existing durable writer or explicit memory acquisition. flowchart TD
A[Session callers] --> B[Actor acquisition]
B --> C[Shared executor]
C --> D[Durable writer]
C --> E[Inactive memory backend]
B --> F[Native incognito owner]
Technical reviewBest possible solution: Preserve the shared actor owner and activate memory only with the documented complete consumer cutover. Do we have a high-confidence way to reproduce the issue? This is a staged refactor rather than a bug report; source confirms production incognito acquisition remains unchanged, and no target code was executed during review. Is this the best way to solve the issue? Sharing lifetime, phase, receipt, and pure-policy ownership follows the existing actor design while the approved staging plan prevents competing production writers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3529142cc84f. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
LabelsLabel changes: No label 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 (4 earlier review cycles)
Reviewed October 11, 2026, 11:29 AM ET / 15:29 UTC (Revision 5). |
# Conflicts: # scripts/pr-lib/wrapper-components.txt # src/config/sessions/session-accessor.sqlite-replacement-state.ts # src/config/sessions/session-turn.kernel.ts
Session pending-input and session-actor modules imported MAX_PAYLOAD_BYTES from gateway/server-constants.ts, which pulled a Gateway server module into the standalone state-read and read-only SQLite worker graphs (runtime-process-build-graph.test.ts failed on main since #169124). The shared payload limit now lives in gateway/payload-limits.ts; every importer uses it and server-constants no longer defines it.
…nclaw#169124) ## What Problem This Solves Native incognito sessions still use a separate SQLite owner, so the session actor cannot serve them without main-thread database work. ## User Impact No production behavior changes in this first Phase E step. Production acquisition still declines native incognito; a regression exercises `acquireSessionInputActor` and proves it cannot create a memory owner. The native owner remains authoritative until the complete consumer cutover. ## Why This Change Was Made Extract the shared actor lifetime, phase dispatch, and receipt construction from the durable transport. Add a pure-memory backend behind that same contract, with canonical transcript bytes, pending-input custody, completion and Goal receipts, bounded context, and per-session command ordering. Pure policies are shared with the durable implementation and their old copies are removed. Memory acquisition opens neither SQLite nor a database worker. Caller release drains accepted commands and retains the session; close invalidates handles and removes state. The following PRs add storage operations and migrate consumers while remaining inactive. The final PR selects memory for every incognito flow and deletes the native and pinned-worker owners together. There is no parallel production writer during this sequence. Accepted edges: process exit loses incognito data by design; transport work already handed off may finish during close, with existing teardown at the effect. No revocation generations or new fencing are introduced. No ordinary runtime check is removed in this inactive backend step; native identity/currentness machinery is removed with its owner in the final cutover. Transcript overwrite predicates and custody checks remain because they protect real user data. Talk voice-call metadata retains its separately selected durable owner. ## Evidence Measured against main `d02fb02ca42c` with the unmodified shared workload on one Linux Testbox: M,C,M,C,M,C, then one extra pair to investigate first-turn request placement. The three-pair warmed results were 351.3 [342.9–354.0] → 347.3 [342.9–351.2] statements and 91.5 [91.0–92.3] → 91.3 [90.9–91.6] requests. Four-pair results: | Phase / metric | Base median [min–max] | Candidate median [min–max] | | --- | ---: | ---: | | Warmed all-thread statements/turn | 349.45 [342.9–354.0] | 348.25 [342.9–351.2] | | Warmed all-thread requests/turn | 91.65 [91.0–92.3] | 91.45 [90.9–92.4] | | Warmed database requests/turn | 84.65 [84.0–85.2] | 84.40 [83.9–85.4] | | Warmed MAIN statements/turn | 0 [0–0] | 0 [0–0] | | First-turn statements | 1128 [988–1249] | 1041.5 [988–1162] | | First-turn requests | 198.5 [195–201] | 200 [198–202] | | Whole-workload statements | 9979 [9962–10009] | 9936.5 [9906–10016] | | Whole-workload requests | 1730 [1730–1734] | 1724 [1721–1747] | This inactive PR claims no incognito saving: the shared workload does not exercise incognito. Every actor operation has unchanged whole-workload median statements and requests. Warmed `acceptInput` remains 16 statements/2 requests, `adoptRun` 4/1, `appendTranscriptEvent` 23/2, `deliverySettled` 7/2, and `read` 4/4. `completeTurn` shifts +0.3 statements/+0.1 requests into warmed windows while its whole-workload median stays 96 statements/19 requests. Existing completion scheduling and worker admission account for the small phase differences; no new database operation was added. First-turn extra requests belong to deferred bootstrap/cron/plugin/model-catalog/managed-image work. Combined boot+connect+first-turn medians are 4174 → 4165.5 statements and 301.5 → 301.5 requests. Connect alone rises 50 statements; combined boot+connect rises 1.67%, within the non-turn allowance. Other non-turn medians are unchanged or within 1 statement. The extra individual pair totals were 9962/1730 → 10016/1747 statements/requests; all four workload medians remain lower, as required by median-based gating. All duration ratios are valid (largest first-turn ratio 1.204; warmed ratios 0.948–1.009). One baseline observation stopped after a complete persisted mock answer was classified as a failed terminal outcome. It is retained as an unresolved baseline failure and excluded from incomplete workload statistics; the replacement pair passed. A separate resume attempt hit Testbox-replaced linked-worktree metadata before running the workload; an independent baseline clone resolved the proof setup issue. Neither is claimed fixed by this PR. T1 is unchanged on the measured base: 623 → 623 overall, 57 → 57 in changed files, and 11 → 11 in explicitly incognito-tagged files. On the final integrated base it is 615 → 615 overall and 57 → 57 in changed files. The final activation/deletion PR removes the native-owner call sites; the memory backend itself allocates neither SQLite nor a worker. On integrated head cc8c94e, 117 tests across 13 focused files passed (72s), including every changed test and affected mock-export test. Wrapper closure (31s), core types (17s), session test types (16s), type-aware lint (17s), export collisions (31s), Madge (18s), and T1/dialect ratchets (4s/1s) passed. Candidate and exact-baseline Knip scans are both clean (157s/158s). Earlier UI export findings were fixed by the imported main changes. The published 2026.10.1 driver successfully updated to candidate cc8c94e: update exit 0, readiness HTTP 200, durable transcript retained, incognito transcript absent after restart, and service stop exit 0 (850s complete package/cell step). The first package attempt exposed main's cron declaration shadowing bug; integration imported the existing fix before the successful run. This update proof is reused for the later import-only conflict resolution; no updater or lifecycle behavior changed. Focused remote proof covers durable actor behavior, memory ownership and zero database/worker allocation, read-after-write across handles, close, byte-preserving retries, transcript branching and rollback, pending input settlement, Goal receipts, bounded context, and production-acquisition exclusion. A new relocation retry assertion failed before the reviewed fix and passed after it (7 transcript tests, 1.77 seconds including the test runner). The earlier complete actor selection passed 66 tests in 26.58 seconds; 135 affected existing tests also passed. Core typecheck passed. Two Codex autoreview rounds maximum. No plugin SDK changes. Doctor import-only changes receive the published-driver × candidate update cell. No schema, retention, migration, or durable storage format changes. Review disposition: fixed relocated-input retry identity and the missing transaction-admission authorization callback. The denied-admission regression failed before the callback fix and passed afterward (8 memory tests, 2.47 seconds). One P2 remains for the next inactive storage PR: collected custody with distinct `inputId` and `transcriptInputId` must compare its consumed marker with the transcript ID on retry. Memory activation remains blocked on that correction; no production path can reach it in this PR. Both review rounds are complete; no further review loop was run. Integration preserved main's shared-store actor fix: a turn validates its logical agent against the canonical session key, independently of the physical database owner. The integrated memory smoke passed (8 tests, 27.39 seconds including a cold compiler build). LOC versus the integrated base: production/tooling +4078/−1588 across 75 files; tests +1496/−6 across 8 files; documentation +19/−6. Most production growth is the deliberately inactive memory implementation; final cutover deletes the native and pinned-worker implementation. CI found four extracted runtime modules missing from the maintainer wrapper inventory. Added the exact dependencies; the two failed eager-closure checks and all three source-closure checks now pass. Main integrations preserved shared row projection facts and the MessagePort admission-snapshot optimization, including its mutable-policy regression. SQL measurements are reused because these integrations change no SQL on the extracted paths. The latest integration resolves extracted-helper import conflicts while retaining main's write-postimage facts; it changes no SQL path beyond the already-landed main optimizations. The prior head's CI run `38149426086` found an inherited Windows helper type error and stale chat-admission expectations, both fixed by the imported main commits. Other failures involve existing native worker capacity, ACP lifecycle ordering, compaction text, UI terminal readiness, and a transcript target-cache assertion. Their owning code is unchanged or only imports the identical extracted helper; no PR1 behavioral cause has been found. The cache assertion counts worker target reads, not MAIN statements. Current-head affected tests and static checks run before landing under the authorized relaxed CI policy; no full green CI claim is made. Final-head proof (`1e816ebb`): affected actor/kernel/replacement/transcript-identity and wrapper-closure tests pass in 115s; core types (17s), session test types (15s), changed-file type-aware lint (18s), export collisions (31s), Madge (17s), T1/dialect ratchets (7s/2s), and both Knip scans (159s) pass. Current-head CI `38150937761` repeats six prior failure signatures: native incognito worker capacity in history/progress/subagent lists, the native exact-completion source assertion, ACP abort lifecycle ordering, compaction continuation text, and UI hidden-terminal readiness. These are recorded as inherited/flaky, not fixed or passing. Current-head security checks pass. The completed code review reported no new actionable defect; the earlier wrapper inventory finding is fixed. Landing uses the authorized relaxed inherited-CI policy after all mandatory static checks passed. The native merge route refused inherited CI, then rejected the unchanged-blob qualification for the behavior-preserving completion-predicate extraction. All source-attribution limits remain recorded above. Used the coordinator-authorized head-pinned squash fallback after two native refusals.
Session pending-input and session-actor modules imported MAX_PAYLOAD_BYTES from gateway/server-constants.ts, which pulled a Gateway server module into the standalone state-read and read-only SQLite worker graphs (runtime-process-build-graph.test.ts failed on main since openclaw#169124). The shared payload limit now lives in gateway/payload-limits.ts; every importer uses it and server-constants no longer defines it.
What Problem This Solves
Native incognito sessions still use a separate SQLite owner, so the session actor cannot serve them without main-thread database work.
User Impact
No production behavior changes in this first Phase E step. Production acquisition still declines native incognito; a regression exercises
acquireSessionInputActorand proves it cannot create a memory owner. The native owner remains authoritative until the complete consumer cutover.Why This Change Was Made
Extract the shared actor lifetime, phase dispatch, and receipt construction from the durable transport. Add a pure-memory backend behind that same contract, with canonical transcript bytes, pending-input custody, completion and Goal receipts, bounded context, and per-session command ordering. Pure policies are shared with the durable implementation and their old copies are removed. Memory acquisition opens neither SQLite nor a database worker.
Caller release drains accepted commands and retains the session; close invalidates handles and removes state. The following PRs add storage operations and migrate consumers while remaining inactive. The final PR selects memory for every incognito flow and deletes the native and pinned-worker owners together. There is no parallel production writer during this sequence.
Accepted edges: process exit loses incognito data by design; transport work already handed off may finish during close, with existing teardown at the effect. No revocation generations or new fencing are introduced. No ordinary runtime check is removed in this inactive backend step; native identity/currentness machinery is removed with its owner in the final cutover. Transcript overwrite predicates and custody checks remain because they protect real user data. Talk voice-call metadata retains its separately selected durable owner.
Evidence
Measured against main
0690a2ef175fwith the unmodified shared workload on one Linux Testbox: M,C,M,C,M,C, then one extra pair to investigate first-turn request placement. The three-pair warmed results were 351.3 [342.9–354.0] → 347.3 [342.9–351.2] statements and 91.5 [91.0–92.3] → 91.3 [90.9–91.6] requests. Four-pair results:This inactive PR claims no incognito saving: the shared workload does not exercise incognito. Every actor operation has unchanged whole-workload median statements and requests. Warmed
acceptInputremains 16 statements/2 requests,adoptRun4/1,appendTranscriptEvent23/2,deliverySettled7/2, andread4/4.completeTurnshifts +0.3 statements/+0.1 requests into warmed windows while its whole-workload median stays 96 statements/19 requests. Existing completion scheduling and worker admission account for the small phase differences; no new database operation was added.First-turn extra requests belong to deferred bootstrap/cron/plugin/model-catalog/managed-image work. Combined boot+connect+first-turn medians are 4174 → 4165.5 statements and 301.5 → 301.5 requests. Connect alone rises 50 statements; combined boot+connect rises 1.67%, within the non-turn allowance. Other non-turn medians are unchanged or within 1 statement. The extra individual pair totals were 9962/1730 → 10016/1747 statements/requests; all four workload medians remain lower, as required by median-based gating. All duration ratios are valid (largest first-turn ratio 1.204; warmed ratios 0.948–1.009).
One baseline observation stopped after a complete persisted mock answer was classified as a failed terminal outcome. It is retained as an unresolved baseline failure and excluded from incomplete workload statistics; the replacement pair passed. A separate resume attempt hit Testbox-replaced linked-worktree metadata before running the workload; an independent baseline clone resolved the proof setup issue. Neither is claimed fixed by this PR.
T1 is unchanged on the measured base: 623 → 623 overall, 57 → 57 in changed files, and 11 → 11 in explicitly incognito-tagged files. On the final integrated base it is 615 → 615 overall and 57 → 57 in changed files. The final activation/deletion PR removes the native-owner call sites; the memory backend itself allocates neither SQLite nor a worker.
On integrated head cc8c94e, 117 tests across 13 focused files passed (72s), including every changed test and affected mock-export test. Wrapper closure (31s), core types (17s), session test types (16s), type-aware lint (17s), export collisions (31s), Madge (18s), and T1/dialect ratchets (4s/1s) passed. Candidate and exact-baseline Knip scans are both clean (157s/158s). Earlier UI export findings were fixed by the imported main changes.
The published 2026.10.1 driver successfully updated to candidate cc8c94e: update exit 0, readiness HTTP 200, durable transcript retained, incognito transcript absent after restart, and service stop exit 0 (850s complete package/cell step). The first package attempt exposed main's cron declaration shadowing bug; integration imported the existing fix before the successful run. This update proof is reused for the later import-only conflict resolution; no updater or lifecycle behavior changed.
Focused remote proof covers durable actor behavior, memory ownership and zero database/worker allocation, read-after-write across handles, close, byte-preserving retries, transcript branching and rollback, pending input settlement, Goal receipts, bounded context, and production-acquisition exclusion. A new relocation retry assertion failed before the reviewed fix and passed after it (7 transcript tests, 1.77 seconds including the test runner). The earlier complete actor selection passed 66 tests in 26.58 seconds; 135 affected existing tests also passed. Core typecheck passed.
Two Codex autoreview rounds maximum. No plugin SDK changes. Doctor import-only changes receive the published-driver × candidate update cell. No schema, retention, migration, or durable storage format changes.
Review disposition: fixed relocated-input retry identity and the missing transaction-admission authorization callback. The denied-admission regression failed before the callback fix and passed afterward (8 memory tests, 2.47 seconds). One P2 remains for the next inactive storage PR: collected custody with distinct
inputIdandtranscriptInputIdmust compare its consumed marker with the transcript ID on retry. Memory activation remains blocked on that correction; no production path can reach it in this PR. Both review rounds are complete; no further review loop was run.Integration preserved main's shared-store actor fix: a turn validates its logical agent against the canonical session key, independently of the physical database owner. The integrated memory smoke passed (8 tests, 27.39 seconds including a cold compiler build).
LOC versus the integrated base: production/tooling +4078/−1588 across 75 files; tests +1496/−6 across 8 files; documentation +19/−6. Most production growth is the deliberately inactive memory implementation; final cutover deletes the native and pinned-worker implementation.
CI found four extracted runtime modules missing from the maintainer wrapper inventory. Added the exact dependencies; the two failed eager-closure checks and all three source-closure checks now pass. Main integrations preserved shared row projection facts and the MessagePort admission-snapshot optimization, including its mutable-policy regression. SQL measurements are reused because these integrations change no SQL on the extracted paths.
The latest integration resolves extracted-helper import conflicts while retaining main's write-postimage facts; it changes no SQL path beyond the already-landed main optimizations. The prior head's CI run
38149426086found an inherited Windows helper type error and stale chat-admission expectations, both fixed by the imported main commits. Other failures involve existing native worker capacity, ACP lifecycle ordering, compaction text, UI terminal readiness, and a transcript target-cache assertion. Their owning code is unchanged or only imports the identical extracted helper; no PR1 behavioral cause has been found. The cache assertion counts worker target reads, not MAIN statements. Current-head affected tests and static checks run before landing under the authorized relaxed CI policy; no full green CI claim is made.Final-head proof (
1e816ebb): affected actor/kernel/replacement/transcript-identity and wrapper-closure tests pass in 115s; core types (17s), session test types (15s), changed-file type-aware lint (18s), export collisions (31s), Madge (17s), T1/dialect ratchets (7s/2s), and both Knip scans (159s) pass.Current-head CI
38150937761repeats six prior failure signatures: native incognito worker capacity in history/progress/subagent lists, the native exact-completion source assertion, ACP abort lifecycle ordering, compaction continuation text, and UI hidden-terminal readiness. These are recorded as inherited/flaky, not fixed or passing. Current-head security checks pass. The completed code review reported no new actionable defect; the earlier wrapper inventory finding is fixed. Landing uses the authorized relaxed inherited-CI policy after all mandatory static checks passed.The native merge route refused inherited CI, then rejected the unchanged-blob qualification for the behavior-preserving completion-predicate extraction. All source-attribution limits remain recorded above. Used the coordinator-authorized head-pinned squash fallback after two native refusals.