Repository navigation
fix(memory): stream session memory exports in bounded pages - #196480
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. What this changesStreams session memory exports in acknowledged pages and migrates indexing, dreaming ingestion, and memory-forget to consume them. Example: Export a session containing 20,000 messages of 15,000 characters each.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a remaining large-session export failure on main, and inspection found no actionable introduced defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSession storage supplies transcript records to the memory export worker; its renderer produces text, provenance, and hashes for indexing, dreaming, and forgetting. flowchart TD
A[Session storage] --> B[Transcript export worker]
B --> C[Shared renderer and incremental hashes]
C --> D[Acknowledged export pages]
D --> E[Memory index chunker]
D --> F[Dreaming ingestion]
D --> G[Memory forget]
Technical reviewBest possible solution: Complete the existing export owner's paged cutover while preserving hashes, reset boundaries, backpressure, and live disclosure authority. Do we have a high-confidence way to reproduce the issue? Main still constructs complete exports, and the PR records a baseline worker OOM with a roughly 300 MB transcript; this read-only review did not rerun it. Is this the best way to solve the issue? Paging through the existing worker exchange removes the remaining whole-export allocation at its owner and updates the affected consumers together without adding a competing renderer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2b4ca2dcdc28. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +536, Tests +653, Docs +3, Other +5. Total +1197 across 50 files. Added test files: 3. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 (7 earlier review cycles)
Reviewed November 11, 2026, 12:59 AM ET / 05:59 UTC (Revision 8). |
8a11e4a to
9b788e5
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The session memory export rendered a whole session into one string inside the 512 MB transcript worker and returned it to the main thread. #196158 halved the peak, but sessions above roughly 240 MB of message text still exhausted the worker, and the full text still landed on the main heap. The renderer now emits ~1 MB pages over the existing session-entries channel, reads large transcripts in 2 MiB slices, and computes the persisted entry hash and dreaming prefix hash incrementally (byte-identical to the previous formula). buildSessionEntry/buildSessionEntries keep their shape; memory indexing, startup eligibility, dreaming ingestion and memory-forget move to streamSessionEntry/streamSessionEntries. Snapshot-based export paths made dead by the cutover are removed. Refs #196132 Co-authored-by: obviyus <[email protected]>
The session export worker holds the shared compute permit while it waits for indexing to take each page. Indexing in the shared pool then waited for that permit, so one-permit hosts (two CPUs) deadlocked. Chunk session pages in a one-worker pool that runs under the export's permit, and dispatch the chunker only once its export delivers, so a queued chunker never waits on a queued export. Co-authored-by: obviyus <[email protected]>
A consumer that revoked the selected actor's authority inside onPage still received later pages because authority was checked only after rendering. Assert live authority immediately before every page and reset delivery. Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
ea47716 to
73430f6
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Heads-up: this change appears to break two memory-core integrity regressions, deterministically.
Both point at the same rewritten region: this change replaces the index preparation with a worker-backed streaming path and rewrites Evidence (tree =
I could not reproduce locally (the extension test bundles need the pinned Bun runtime and the extension build, which do not run on this Windows host), so this report is CI-log evidence only — but it is deterministic on the affected tree, not a flake. |
…#196480) * fix(memory): stream session memory exports in bounded pages The session memory export rendered a whole session into one string inside the 512 MB transcript worker and returned it to the main thread. openclaw#196158 halved the peak, but sessions above roughly 240 MB of message text still exhausted the worker, and the full text still landed on the main heap. The renderer now emits ~1 MB pages over the existing session-entries channel, reads large transcripts in 2 MiB slices, and computes the persisted entry hash and dreaming prefix hash incrementally (byte-identical to the previous formula). buildSessionEntry/buildSessionEntries keep their shape; memory indexing, startup eligibility, dreaming ingestion and memory-forget move to streamSessionEntry/streamSessionEntries. Snapshot-based export paths made dead by the cutover are removed. Refs openclaw#196132 Co-authored-by: obviyus <[email protected]> * fix(memory): keep session export indexing live under one compute permit The session export worker holds the shared compute permit while it waits for indexing to take each page. Indexing in the shared pool then waited for that permit, so one-permit hosts (two CPUs) deadlocked. Chunk session pages in a one-worker pool that runs under the export's permit, and dispatch the chunker only once its export delivers, so a queued chunker never waits on a queued export. Co-authored-by: obviyus <[email protected]> * fix(memory): revalidate incognito authority before each export page A consumer that revoked the selected actor's authority inside onPage still received later pages because authority was checked only after rendering. Assert live authority immediately before every page and reset delivery. Co-authored-by: obviyus <[email protected]> * test: allocate test lines for paged session memory export coverage Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: obviyus <[email protected]>
* fix(memory): stream session memory exports in bounded pages The session memory export rendered a whole session into one string inside the 512 MB transcript worker and returned it to the main thread. #196158 halved the peak, but sessions above roughly 240 MB of message text still exhausted the worker, and the full text still landed on the main heap. The renderer now emits ~1 MB pages over the existing session-entries channel, reads large transcripts in 2 MiB slices, and computes the persisted entry hash and dreaming prefix hash incrementally (byte-identical to the previous formula). buildSessionEntry/buildSessionEntries keep their shape; memory indexing, startup eligibility, dreaming ingestion and memory-forget move to streamSessionEntry/streamSessionEntries. Snapshot-based export paths made dead by the cutover are removed. Refs #196132 Co-authored-by: obviyus <[email protected]> * fix(memory): keep session export indexing live under one compute permit The session export worker holds the shared compute permit while it waits for indexing to take each page. Indexing in the shared pool then waited for that permit, so one-permit hosts (two CPUs) deadlocked. Chunk session pages in a one-worker pool that runs under the export's permit, and dispatch the chunker only once its export delivers, so a queued chunker never waits on a queued export. Co-authored-by: obviyus <[email protected]> * fix(memory): revalidate incognito authority before each export page A consumer that revoked the selected actor's authority inside onPage still received later pages because authority was checked only after rendering. Assert live authority immediately before every page and reset delivery. Co-authored-by: obviyus <[email protected]> * test: allocate test lines for paged session memory export coverage Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: obviyus <[email protected]> (cherry picked from commit e881eb8) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 9c7100ce7686c74daf4b644e96666c64c2dde192) Co-authored-by: vincentkoc <[email protected]>
Release-specific port of openclaw#196480 and its type-boundary companion. Preserve complete-entry SDK builders while memory indexing uses paged exports, bounded slices and generation reset. Retain cold, archive and incognito paths. Independent local review waived by Dallin; exact-head CI pending. Observer reset concern remains assigned for an incremental correction before qualification. (cherry picked from commit e881eb8) Type-boundary companion d2b99a1. Co-authored-by: RomneyDa <[email protected]>
Backport-of: openclaw#196158 and openclaw#196480. Only the rendered export remains materialized for the existing consumer.
Backport-of: openclaw#196158 and openclaw#196480. Only the rendered export remains materialized for the existing consumer.
Related: #196132, follow-up to #196158
What Problem This Solves
Fixes: the session memory export (used by memory indexing, dreaming ingestion and memory-forget) still runs its 512 MB transcript worker out of memory once a session holds about 240 MB of message text. #196158 halved the peak, but the export still built the whole session as one string in the worker and returned it to the main thread.
User Impact
User impact: very large sessions no longer crash the export worker or abort the Gateway during memory sync or dreaming, regardless of session size. Indexed content and stored hashes are unchanged.
Why This Change Was Made
session-entriesworker channel and never builds the whole text. Transcripts over 4 MB are read in 2 MiB slices.buildSessionEntry/buildSessionEntrieskeep their shape (they collect pages). Memory indexing, startup eligibility, dreaming ingestion and memory-forget move tostreamSessionEntry/streamSessionEntries. Thememory-core-host-engine-sessionssubpath is private-local, so droppingmatchesSessionEntryPrefixHashthere is not a public break.session-accessor.sqlite-export-read.ts(line cap).Evidence
Incognito authority per page (
src/config/sessions/session-actor-memory-search.test.ts, real session actor owner,runWithSessionActorStoragewith a selected authority): a two-message transcript of 600k chars each spans two export pages; the consumer's firstonPagecallback revokes authority. Recorded on head6b5c7e4, clean env:The stream rejects with
Memory disclosure was revokedand the consumer received exactly one page (["User: first"]). Before the per-page check (5db31b7), the same test delivered 3 pages after revocation. The check runs immediately before every page and reset delivery inbuildSessionEntryFromSnapshot, so successive deliveries are each gated on live authority.session-files-large-export.test.ts(20,000 messages x 15,000 chars, ~300 MB; runs withOPENCLAW_SESSION_EXPORT_STRESS=1):625945b: fails withERR_WORKER_OUT_OF_MEMORYinsessionTranscript.session-entries.buildSessionEntries,buildSessionEntryand the paged API; >400 pages, none over 600K chars. Worker heap peaked at ~63-70 MiB (temporary probe, removed).manager-session-export-equivalence.test.ts: mixed session (user/assistant/tool calls and results, heartbeat, compaction, two resets, appends, long wrapped messages). Indexed chunks with provenance, source and entry hashes, and dreaming candidates across first scan, append, capped continuation and prefix mismatch are byte-identical to the parent; the test pins that fingerprint.packages/memory-host-sdk/src/host157 passed;extensions/memory-core1830 passed / 67 skipped;src/config/sessions/session-memory-entry.worker.test.tsand related worker tests pass.pnpm check:changed: everything passes exceptPlugin SDK surface budget(identical 3877 > 3865 onorigin/main) and the dead export scan (no hits in changed files).Remaining limits, not addressed here: