Skip to content

feat(memory-core): ingest session transcripts into dreaming corpus - #62227

Merged
vignesh07 merged 5 commits into
mainfrom
codex/dreaming-session-indexing
Apr 7, 2026
Merged

vignesh07 merged 5 commits into
mainfrom
codex/dreaming-session-indexing

Conversation

@vignesh07

Copy link
Copy Markdown
Member

Summary

  • add dreaming session-transcript ingestion with checkpointed cursors in memory/.dreams/session-ingestion.json
  • append per-day session corpus snippets to memory/.dreams/session-corpus/YYYY-MM-DD.txt and feed them into short-term recall scoring
  • decouple session ingestion from agents.*.memorySearch flags so dreaming only depends on dreaming/workspace config
  • include session-corpus files in short-term path detection for promotion ranking and doctor stats

Validation

  • pnpm test -- extensions/memory-core/src/dreaming-phases.test.ts extensions/memory-core/src/short-term-promotion.test.ts
  • pnpm tsgo
  • pnpm check

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime extensions: memory-core Extension: memory-core size: L maintainer Maintainer-authored PR size: XL and removed size: L labels Apr 7, 2026
@vignesh07
vignesh07 force-pushed the codex/dreaming-session-indexing branch from 5942c3d to 8697d1a Compare April 7, 2026 02:14
@vignesh07
vignesh07 marked this pull request as ready for review April 7, 2026 02:14
@vignesh07
vignesh07 merged commit 338c7b8 into main Apr 7, 2026
43 of 46 checks passed
@vignesh07
vignesh07 deleted the codex/dreaming-session-indexing branch April 7, 2026 02:14
@vignesh07

vignesh07 commented Apr 7, 2026 •

Copy link
Copy Markdown
Member Author

Landed via temp rebase onto main.

  • Gate: pnpm test -- extensions/memory-core/src/dreaming-phases.test.ts extensions/memory-core/src/short-term-promotion.test.ts src/memory-host-sdk/dreaming.test.ts src/memory-host-sdk/host/session-files.test.ts
  • Land commit: 8697d1a
  • Merge commit: 338c7b8

@greptile-apps

greptile-apps Bot commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds checkpointed session-transcript ingestion into the dreaming corpus, writing per-day corpus snippets to memory/.dreams/session-corpus/YYYY-MM-DD.txt and feeding them into short-term recall scoring. The implementation is solid: deduplication via seenMessages, cursor-based progress tracking in session-ingestion.json, and atomic state writes via rename are all well-handled.

Confidence Score: 5/5

Safe to merge; no P0/P1 issues found.

Both findings are P2 style/maintenance concerns that do not affect correctness, data integrity, or runtime behavior. The deduplication, cursor checkpointing, and file-state tracking are sound.

No files require blocking attention; src/gateway/server-methods/doctor.ts has a duplicated path-detection function worth unifying via the host SDK in a follow-up.

Comments Outside Diff (1)

  1. src/gateway/server-methods/doctor.ts, line 175-188 (link)

    P2 Duplicated path-detection logic out of sync risk

    This local isShortTermMemoryPath is a hand-copied duplicate of the one exported from extensions/memory-core/src/short-term-promotion.ts (lines 763–772). Both match the same three patterns — memory/YYYY-MM-DD.md, memory/.dreams/session-corpus/YYYY-MM-DD.(md|txt), and bare YYYY-MM-DD.md basenames. If a new corpus path pattern is added in the extension (e.g. a .md variant for the session corpus), the doctor stats will silently under-count without a corresponding update here.

    The plugin boundary prevents core from importing extension internals directly, but src/memory-host-sdk/ already exists as the bridge layer. Exposing isShortTermMemoryPath (or the named regex constants) through that layer would keep a single source of truth.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/gateway/server-methods/doctor.ts
    Line: 175-188
    
    Comment:
    **Duplicated path-detection logic out of sync risk**
    
    This local `isShortTermMemoryPath` is a hand-copied duplicate of the one exported from `extensions/memory-core/src/short-term-promotion.ts` (lines 763–772). Both match the same three patterns — `memory/YYYY-MM-DD.md`, `memory/.dreams/session-corpus/YYYY-MM-DD.(md|txt)`, and bare `YYYY-MM-DD.md` basenames. If a new corpus path pattern is added in the extension (e.g. a `.md` variant for the session corpus), the doctor stats will silently under-count without a corresponding update here.
    
    The plugin boundary prevents core from importing extension internals directly, but `src/memory-host-sdk/` already exists as the bridge layer. Exposing `isShortTermMemoryPath` (or the named regex constants) through that layer would keep a single source of truth.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/gateway/server-methods/doctor.ts
Line: 175-188

Comment:
**Duplicated path-detection logic out of sync risk**

This local `isShortTermMemoryPath` is a hand-copied duplicate of the one exported from `extensions/memory-core/src/short-term-promotion.ts` (lines 763–772). Both match the same three patterns — `memory/YYYY-MM-DD.md`, `memory/.dreams/session-corpus/YYYY-MM-DD.(md|txt)`, and bare `YYYY-MM-DD.md` basenames. If a new corpus path pattern is added in the extension (e.g. a `.md` variant for the session corpus), the doctor stats will silently under-count without a corresponding update here.

The plugin boundary prevents core from importing extension internals directly, but `src/memory-host-sdk/` already exists as the bridge layer. Exposing `isShortTermMemoryPath` (or the named regex constants) through that layer would keep a single source of truth.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/memory-core/src/dreaming-phases.ts
Line: 857-884

Comment:
**Full corpus file read just to count lines**

`appendSessionCorpusLines` reads the entire corpus file on every call only to compute `existingLineCount` for the returned `MemorySearchResult` line numbers. As session-corpus files grow over time this read becomes increasingly expensive.

`SessionIngestionFileState` already tracks `lineCount` and `lastContentLine` per session file — the per-day corpus line count could be stored in a parallel state map (keyed by day) so that subsequent calls skip the full read entirely.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "changelog: note dreaming session corpus ..." | Re-trigger Greptile

Comment on lines +857 to +884
let existing = "";
try {
existing = await fs.readFile(absolutePath, "utf-8");
} catch (err) {
if ((err as NodeJS.ErrnoException)?.code !== "ENOENT") {
throw err;
}
}
const normalizedExisting = existing.replace(/\r\n/g, "\n");
const existingLineCount =
normalizedExisting.length === 0
? 0
: normalizedExisting.endsWith("\n")
? normalizedExisting.slice(0, -1).split("\n").length
: normalizedExisting.split("\n").length;
const payload = `${params.lines.map((entry) => entry.rendered).join("\n")}\n`;
await fs.appendFile(absolutePath, payload, "utf-8");
return params.lines.map((entry, index) => {
const lineNumber = existingLineCount + index + 1;
return {
path: relativePath,
startLine: lineNumber,
endLine: lineNumber,
score: SESSION_INGESTION_SCORE,
snippet: entry.snippet,
source: "memory",
};
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Full corpus file read just to count lines

appendSessionCorpusLines reads the entire corpus file on every call only to compute existingLineCount for the returned MemorySearchResult line numbers. As session-corpus files grow over time this read becomes increasingly expensive.

SessionIngestionFileState already tracks lineCount and lastContentLine per session file — the per-day corpus line count could be stored in a parallel state map (keyed by day) so that subsequent calls skip the full read entirely.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/memory-core/src/dreaming-phases.ts
Line: 857-884

Comment:
**Full corpus file read just to count lines**

`appendSessionCorpusLines` reads the entire corpus file on every call only to compute `existingLineCount` for the returned `MemorySearchResult` line numbers. As session-corpus files grow over time this read becomes increasingly expensive.

`SessionIngestionFileState` already tracks `lineCount` and `lastContentLine` per session file — the per-day corpus line count could be stored in a parallel state map (keyed by day) so that subsequent calls skip the full read entirely.

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8697d1a8c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +966 to +970
const unchanged =
Boolean(previous) &&
previous.mtimeMs === fingerprint.mtimeMs &&
previous.size === fingerprint.size &&
previous.contentHash.length > 0 &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recompute transcript hash before treating file as unchanged

The fast-path treats a transcript as unchanged solely from mtimeMs/size plus cursorAtEnd, so once a file has been fully scanned it can be skipped forever without re-reading content. If a transcript is rewritten with the same size and preserved/coarse mtime (common with some copy/restore flows or low-resolution filesystems), new content will never be ingested into session corpus or recall signals because buildSessionEntry is bypassed and contentHash is never recomputed.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant