Repository navigation
feat(memory): backfill retained session transcripts - #115162
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 8:04 AM ET / 12:04 UTC. ClawSweeper reviewWhat this changesAdds a dry-run-by-default Merge readinessKeep this PR open for explicit maintainer handling: it is protected by the Priority: P2 Review scores
Verification
How this fits togetherMemory Core turns eligible session content into a daily corpus, then uses dreaming to derive staged memory candidates and reversible diary entries before any later durable promotion. This PR adds an operator-triggered path for retained transcript identities while keeping ordinary nightly ingestion default-off for that extra history. flowchart LR
A[Retained SQLite transcripts] --> B[Session backfill command]
C[Optional archive files] --> B
B --> D[Ownership and provenance gates]
D --> E[Existing dreaming ingestion]
E --> F[Daily corpus and checkpoints]
E --> G[Short-term staged candidates]
E --> H[Reversible diary blocks]
G --> I[Later memory promotion]
Decision needed
Why: The implementation is a new CLI capability that reads retained session state and writes shared ingestion artifacts; the PR body records the intended contract, but the protected maintainer label requires an explicit human merge decision on the final base. Before merge
Agent review detailsSecurityNone. PR surfaceSource +958, Tests +533, Docs +60. Total +1551 across 17 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Rebase or merge-refresh this branch onto current Do we have a high-confidence way to reproduce the issue? Not applicable: this PR introduces a new operator command rather than fixing a reported current-main failure. The supplied redacted runtime transcript provides an after-fix execution path for the new behavior. Is this the best way to solve the issue? Yes, conditionally: routing retained transcripts through the existing provenance-gated ingestion and staging primitives is preferable to a parallel memory writer, provided the final merge result preserves the opt-in reader and shared-artifact contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 89b6d85cdd86. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
* feat(memory): enumerate retained session transcripts * feat(memory): add session transcript backfill * test(memory): cover session backfill workflows * docs(memory): document session transcript backfill * fix(memory): preserve oldest session backfill ordering * fix(memory): harden session archive backfill * test(memory): prove owner-turn provenance gating * fix(memory): persist session backfill progress * fix(memory): preserve ranged backfill progress * fix(memory): order per-file backfill candidates * fix(memory): retain paged backfill diary entries * fix(memory): preserve rem backfill diary history * fix(memory): adapt backfill to retained session identity * fix(memory): keep rem backfill preview-only * fix(memory): satisfy backfill CI guards
Related: #114819
Additional instructions
Allow edits from maintainers is enabled for this repository-owned branch.
What Problem This Solves
The provenance-gated memory system landed in #114819, but retained and archived session transcripts still had no bounded operator path into the dreaming ingestion pipeline. Useful older owner-authored facts therefore remained outside the per-day corpus, claim convergence, and gated short-term staging flow.
Why This Change Was Made
Adds
openclaw memory session-backfill, a dry-run-by-default command that walks retained SQLite transcript identities and optionally supplied archive files through the dreaming ingestion primitives landed by #114819. It preserves per-day corpus files, source-line provenance, canonical claim-hash convergence, ingestion caps and checkpoints, and provenance-gated staging rather than creating a parallel memory writer.--applystages trusted candidates and writes reversible diary blocks;--remwrites deterministic diary previews without staging;--rollbackclears the shared grounded backfill artifacts; and--archive-filestreats caller-supplied files conservatively. The command never writesMEMORY.mdorUSER.md. This PR was AI-assisted and reviewed with the repository autoreview workflow.User Impact
Operators can preview and selectively ingest useful retained session history without promoting it directly into durable memory. Repeated runs are bounded and idempotent, retained SQLite identities are opt-in at the corpus seam, foreign archives cannot self-assert owner trust, and durable promotion remains a separate dreaming or
memory promotedecision.Evidence
28630a9a6501from feat(memory): provenance-gated memory with dreaming on by default #114819, then adds two focused reconciliation fixes for current-main SQLite identity handling and REM/apply mutual exclusion.tbx_01kym3dbvh74ha1my7vksbtdx0/ https://github.com/openclaw/openclaw/actions/runs/30349869899:pnpm test extensions/memory-core/src/session-backfill.test.ts: 11/11 passed.pnpm test extensions/memory-core/src/cli.test.ts: 75/75 passed.pnpm test packages/memory-host-sdk/src/host/session-files.test.ts: 38/38 passed.pnpm test extensions/memory-core/src/dreaming-narrative.test.ts: 29/29 passed.pnpm docs:check-mdx: passed across 758 files.node scripts/check-changed.mjs -- <16 changed files>: passed all core/extension typecheck, lint, SDK-surface, max-lines, database-first, and architecture lanes on the final tree (20m37s).--rem --applycould stage despite preview-only semantics) was fixed and regression-tested. Two non-actionable findings were rejected against direct evidence: TSGo had already proven the claimed duplicate property did not exist, and currentmainexplicitly defines SQLite as the only runtime session store while legacy JSONL import remains doctor-owned.deadcode:dependencies,deadcode:exports,docs:map:check, anddocs:check-mdxthen passed on Blacksmith Testbox run https://github.com/openclaw/openclaw/actions/runs/30355485044.origin/main; the final exact-head gate now passes without removing or restoring max-lines baseline entries.Redacted runtime proof (real retained-session data)
https://gist.github.com/steipete/8cf515b9ba777ef3b010127bfe3e054b
Run from this PR's head against a copy of a live gateway state directory containing
today's real retained SQLite session transcripts (synthetic QA conversation content):
proof-1-dryrun.txt— default dry-run enumerates 1 day / 42 owner-turn candidates,stages nothing.
proof-2-apply-rerun-rollback.txt—--applystages 42; the immediate rerun stages0 ("No new hash-untracked trusted session candidates" — per-message hash tracking makes
reruns idempotent);
--rollbackremoves exactly the 42 staged entries and 1 diaryblock, restoring the pre-apply state.
Maintainer decision: SDK seam confirmed
includeRetainedSqliteon the memory-host session-transcript corpus reader is approvedas a supported ADDITIVE contract: opt-in, default-off (nightly ingestion behavior
unchanged), retained entries surfaced as a distinct artifact kind. Same additive-contract
policy as recorded on #114819.