Repository navigation
feat(memory-core): ingest session transcripts into dreaming corpus - #62227
Conversation
5942c3d to
8697d1a
Compare
Greptile SummaryAdds checkpointed session-transcript ingestion into the dreaming corpus, writing per-day corpus snippets to Confidence Score: 5/5Safe 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;
|
| 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", | ||
| }; | ||
| }); |
There was a problem hiding this 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.
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.There was a problem hiding this comment.
💡 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".
| const unchanged = | ||
| Boolean(previous) && | ||
| previous.mtimeMs === fingerprint.mtimeMs && | ||
| previous.size === fingerprint.size && | ||
| previous.contentHash.length > 0 && |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
memory/.dreams/session-ingestion.jsonmemory/.dreams/session-corpus/YYYY-MM-DD.txtand feed them into short-term recall scoringagents.*.memorySearchflags so dreaming only depends on dreaming/workspace configValidation
pnpm test -- extensions/memory-core/src/dreaming-phases.test.ts extensions/memory-core/src/short-term-promotion.test.tspnpm tsgopnpm check