Skip to content

refactor(memory): use SQLite transcript identities - #117334

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-sqlite-transcript-ingestion-0801-2d45
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-sqlite-transcript-ingestion-0801-2d45

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Memory Core still treated live session transcripts as mutable JSONL files after SQLite became the canonical transcript store. That left obsolete file discovery, marker parsing, byte/newline delta accounting, fallback paths, and stale sync state in the hot path. It also hid two connected correctness gaps: ordinary persisted SessionManager appends could complete without a typed transcript event, and compressed reset/delete archives were read as compressed bytes instead of materialized JSONL.

Why This Change Was Made

This moves the owner boundary to the canonical storage contract:

  • live transcripts are addressed and synchronized only by typed SQLite identity (agentId, sessionId, sessionKey)
  • reset/delete cold history remains an explicit file-backed archive corpus
  • Memory Core resolves events against one corpus snapshot and drops file-era marker/path fallbacks and delta thresholds
  • SessionManager publishes the canonical typed target after a persisted append
  • compressed archives are materialized through the existing archive codec before Memory/QMD parsing

Removed production paths include live JSONL discovery, SQLite marker recovery, canonical path parsing, byte/newline delta reads, delta state snapshots, and filename-to-identity fallbacks. Handwritten production delta: +107 / -576 = -469 LOC. Tests: +280 / -434 = -154 LOC. No schema version, configuration, dependency, protocol, or public plugin-SDK change.

User Impact

Memory indexing now follows the storage facts that actually exist: active SQLite transcripts update from typed commit events, while reset/delete archives remain searchable as durable history. This repairs persisted append notifications and makes compressed archived conversations readable to Memory Core and QMD without restoring legacy live-file behavior.

Evidence

  • Real persisted SQLite append -> typed internal target -> Memory Core listener -> indexed current transcript.
  • Real deleteSessionEntry({ archiveTranscript: true }) -> emitted archive path -> corpus validation -> indexed archived transcript.
  • Real reset lifecycle -> old SQLite generation retained and exposed only when retained history is requested.
  • Compressed archive parser and QMD export both verify readable materialized content.
  • Focused local: host corpus 39/39, Memory startup/listener 22/22, persisted SessionManager event suite 10/10, plus QMD/yield/reindex focused suites.
  • Broad affected Testbox run: 16 files / 178 tests passed; exact-head final focused Testbox run: 3 files / 69 tests passed.
  • Blacksmith Testbox tbx_01kyycq6z71bydjtetzyj8cfjy: exact-head pnpm check:changed passed all core/core-test/extension/extension-test typecheck, lint, boundary, dead-code, DB-first, and cycle gates with no warnings in 278.9s (run).
  • Exact-head pnpm build passed on Blacksmith Testbox in 179.7s (run).
  • Autoreview: gpt-5.6-sol, xhigh, one 89,658-byte pass; clean, no accepted/actionable findings (patch is correct, 0.98).
  • git diff --check passed.

ClawSweeper Rank-up Move

ClawSweeper optionally suggested rebasing onto current main and rerunning the focused proof. This is intentionally skipped after an exact path and ownership audit: exact head 33cc8adcf1e8c23e74f97b971341899d1d200e3f has merge base 8317e23c1c2bef85989023ea0fcc59b1cfe061a3 with current main 4e47c4cabf8f2901ec781b59d059999211398813, and git diff --name-only 8317e23c1c2..4e47c4cabf8f -- <this PR's 17 touched paths> is empty across 404 intervening main paths.

Newly landed #117343 touches eight src/gateway/session-transcript-* / session-utils.fs* paths and has zero touched-path overlap. It owns Gateway history selection, pagination, anchor reads, and the bounded (mtime,size) archive index cache. This PR independently owns the persist-after-write transcript event, Memory Host corpus identities, Memory Core ingestion, and QMD export. Both consume the existing core materializeSessionArchiveForRead codec contract; neither changes that codec, and this PR only routes it through the existing allowed Memory Host runtime barrel.

Refreshing would therefore invalidate exact-head CI and review proof without exercising a changed owner surface. The branch remains mergeable and exact-head hosted CI is green. Preserved proof includes the broad 16-file / 178-test affected run, final 3-file / 69-test focused run, real persisted SQLite append and delete/archive listener flows, retained-reset SQLite lifecycle, zstd Memory/QMD reads, warning-free exact-head pnpm check:changed, and exact-head pnpm build.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 09:51
@steipete steipete self-assigned this Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. 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. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 7:11 AM ET / 11:11 UTC.

ClawSweeper review

What this changes

This PR makes Memory Core index active session transcripts through typed SQLite identities and commit events, while retaining reset/delete archives as a separately materialized file corpus.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The patch is a coherent root-boundary repair and has no concrete correctness or security finding, but it intentionally removes live JSONL and filename/marker compatibility paths. Because this PR is labeled maintainer and that removal defines the supported upgrade contract for existing transcript state, it should remain open for an explicit owner decision before merge.

Priority: P2
Reviewed head: 33cc8adcf1e8c23e74f97b971341899d1d200e3f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong focused behavior proof and a coherent owner-boundary patch support merge once the transcript-upgrade contract is explicitly confirmed.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides after-fix persisted SQLite append, archive/delete, reset-retention, and compressed-archive behavior evidence, supplemented by exact-head Testbox checks and build output.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides after-fix persisted SQLite append, archive/delete, reset-retention, and compressed-archive behavior evidence, supplemented by exact-head Testbox checks and build output.
Evidence reviewed 8 items Typed event is emitted after a persisted append: The PR obtains the persisted SessionManager target and publishes it with the appended message id and sequence, replacing the prior optional JSONL-file notification path.
Memory Core consumes typed targets before archive-file notifications: The listener first resolves a typed target and queues it directly; file notifications are now restricted to entries that remain in the archive corpus.
Active corpus ownership uses SQLite identity: The new corpus entry builder records active sessions as transcriptSource: "sqlite" with agent, session, store, and optional session-key facts rather than a live JSONL path.
Findings None None.
Security None None.

How this fits together

SessionManager persists agent transcript messages, then publishes typed session targets for in-process consumers. Memory Core and QMD use those targets to index active SQLite transcripts, while archive files remain available for retained reset/delete history.

flowchart LR
  A[SessionManager append] --> B[SQLite transcript store]
  B --> C[Typed transcript update]
  C --> D[Memory Core listener]
  D --> E[Active SQLite transcript index]
  F[Reset or delete archive] --> G[Archive materialization]
  G --> H[Memory and QMD archive index]
Loading

Decision needed

Question Recommendation
Should the supported upgrade contract now be typed SQLite identities for every active transcript, with file-backed reads limited to explicit reset/delete archives? Confirm canonical SQLite active transcripts: Confirm no supported active-transcript upgrade path remains JSONL-only, then merge the canonical typed-identity implementation.

Why: The source repair is internally coherent, but only maintainers can determine whether a released active-JSONL compatibility case remains supported and therefore requires migration rather than removal.

Before merge

  • Resolve merge risk (P2) - Merging removes the live JSONL, marker, and filename-to-identity fallback paths. If any supported upgrade still has an active transcript available only through those paths, Memory indexing would stop seeing it until that state is migrated or otherwise made explicit.
Agent review details

Security

None.

PR surface

Source -469, Tests -154. Total -623 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 10 107 576 -469
Tests 7 280 434 -154
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 387 1010 -623

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/memory-core/src/memory/manager-sync-ops.archive-delta-bypass.test.ts, serialized state: extensions/memory-core/src/memory/qmd-session-exporter.archive.test.ts, serialized state: packages/memory-host-sdk/src/host/session-files.test.ts, serialized state: packages/memory-host-sdk/src/host/session-files.ts, serialized state: packages/memory-host-sdk/src/host/session-transcript-corpus.ts, serialized state: src/agents/session-tool-result-guard.transcript-events.test.ts, and 23 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm the canonical upgrade contract (recommended)
    Accept the compatibility change only after an owner confirms that supported active transcripts are already SQLite-backed and archives are the only remaining file corpus.
  2. Add the missing upgrade handling
    If a released JSONL-only active transcript remains supported, add its narrow migration or preservation path with focused upgrade coverage before merge.
  3. Pause for migration ownership
    Leave this PR open if the release-state contract cannot be confirmed from current evidence.

Technical review

Best possible solution:

Confirm that active transcripts are supported only through the typed SQLite corpus and that retained reset/delete history is the sole file-backed transcript compatibility surface; otherwise add the narrow migration or documented upgrade handling before merging.

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

Yes—at high confidence from source and the PR’s focused persisted-append and archive-lifecycle coverage. This read-only review did not rerun those tests, but the changed producer, typed consumer, and regression cases align on the same current-main transcript contract.

Is this the best way to solve the issue?

Yes, conditionally: publishing the persisted typed target at the producer and consuming it from one SQLite-backed corpus is a better owner-boundary fix than retaining downstream path, marker, and byte-delta reconstruction. The remaining question is upgrade-contract intent, not an alternative implementation layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4e47c4cabf8f.

Labels

Label justifications:

  • P2: This is a bounded correctness and storage-boundary repair for Memory Core rather than an emergency runtime failure.
  • merge-risk: 🚨 compatibility: The diff deliberately removes legacy live JSONL and marker-based discovery paths that may matter during upgrades.
  • merge-risk: 🚨 session-state: The affected corpus selects and indexes persisted session transcript state, including reset/delete history.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix persisted SQLite append, archive/delete, reset-retention, and compressed-archive behavior evidence, supplemented by exact-head Testbox checks and build output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix persisted SQLite append, archive/delete, reset-retention, and compressed-archive behavior evidence, supplemented by exact-head Testbox checks and build output.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the proposed typed-identity repair and the current-main archived-reader refactor that supplies the shared archive-read contract. (role: recent area contributor; confidence: high; commits: 33cc8adcf1e8, 4e47c4cabf8f; files: packages/memory-host-sdk/src/host/session-transcript-corpus.ts, extensions/memory-core/src/memory/manager-session-sync-ops.ts, src/config/sessions/archive-compression.ts)
  • joshavant: The existing SessionManager guard behavior around the newly added publishing seam is attributed to this recent agent-session commit. (role: recent adjacent contributor; confidence: high; commits: 97f8f25f0b9a; files: src/agents/session-tool-result-guard.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-01T09:57:58.488Z sha 5b922d6ae37d18da18886f04532bee4aeedd69ce :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T10:39:22.035Z sha 33cc8ad :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T11:04:25.657Z sha 33cc8ad :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/goal100k-sqlite-transcript-ingestion-0801-2d45 branch from 5b922d6 to 33cc8ad Compare August 1, 2026 10:32
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 1, 2026
@steipete
steipete merged commit 5976994 into main Aug 1, 2026
151 of 153 checks passed
@steipete
steipete deleted the codex/goal100k-sqlite-transcript-ingestion-0801-2d45 branch August 1, 2026 11:38
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Aug 1, 2026
* origin/main:
  refactor(doctor): unify legacy auth migration ownership (openclaw#117361)
  fix(plugins): surface actionable doctor warnings (openclaw#117357)
  fix(ci): use corrected Kova release evaluator (openclaw#116920)
  fix(ci): stabilize release validation assertions (openclaw#117377)
  refactor(memory): use sqlite transcript identities (openclaw#117334)
  fix(plugins): require tracked owners for targeted updates (openclaw#117333)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main:
  refactor(doctor): unify legacy auth migration ownership (openclaw#117361)
  fix(plugins): surface actionable doctor warnings (openclaw#117357)
  fix(ci): use corrected Kova release evaluator (openclaw#116920)
  fix(ci): stabilize release validation assertions (openclaw#117377)
  refactor(memory): use sqlite transcript identities (openclaw#117334)
  fix(plugins): require tracked owners for targeted updates (openclaw#117333)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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