fix(memory): export archived qmd session transcripts#57446
Conversation
Greptile SummaryThis PR fixes a silent memory regression where QMD session export only surfaced bare Confidence Score: 5/5Safe to merge — the fix is minimal and well-tested, with no behavioral changes beyond expanding the set of transcript files surfaced to QMD export. The only finding is a P2 style issue (new test placed in the wrong describe block); there are no logic errors, correctness concerns, or data-integrity risks. The core fix correctly reuses the existing isUsageCountedSessionTranscriptFileName helper and the new test validates all the important boundary cases. No files require special attention.
|
| Filename | Overview |
|---|---|
| packages/memory-host-sdk/src/host/session-files.ts | Core one-line fix: replaces the narrow .endsWith('.jsonl') filter with isUsageCountedSessionTranscriptFileName, correctly expanding export to include .reset.* and .deleted.* transcript variants while still excluding .bak.* files and unrelated artifacts. |
| packages/memory-host-sdk/src/host/session-files.test.ts | Adds a well-structured regression test covering the new inclusion of reset/deleted transcripts and the continued exclusion of backups, non-JSONL files, and nested files. Minor style issue: the new test is placed inside describe('buildSessionEntry') rather than its own describe('listSessionFilesForAgent') block. |
| CHANGELOG.md | Changelog entry added for the fix under the correct Memory/QMD category; no issues. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: packages/memory-host-sdk/src/host/session-files.test.ts
Line: 7
Comment:
**New test is nested under the wrong `describe` block**
The new `"includes reset and deleted transcripts in session file listing"` test (lines 26–50) exercises `listSessionFilesForAgent`, but it lives inside `describe("buildSessionEntry", ...)`. This makes the test report misleading (failures or results show up under `buildSessionEntry`) and obscures what is actually being tested.
Consider wrapping the new test in its own block:
```ts
describe("listSessionFilesForAgent", () => {
// move the new test here
});
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(memory): export archived qmd session..." | Re-trigger Greptile
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
Vulnerabilities1. 🟡 Deleted/reset session transcripts included in QMD export and indexing (data retention/privacy regression)
Description
This introduces a privacy/data-retention risk because content a user expected to be removed after a “reset” or “delete” can be:
Data flow / impact:
Vulnerable code: // packages/memory-host-sdk/src/host/session-files.ts
.filter((name) => isUsageCountedSessionTranscriptFileName(name))If RecommendationTreat billing/usage accounting and search/export eligibility as separate concerns.
Example: import {
isPrimarySessionTranscriptFileName,
// or create isIndexableSessionTranscriptFileName
} from "../../../../src/config/sessions/artifacts.js";
export async function listSessionFilesForAgent(agentId: string): Promise<string[]> {
const dir = resolveSessionTranscriptsDirForAgent(agentId);
const entries = await fs.readdir(dir, { withFileTypes: true });
return entries
.filter((e) => e.isFile())
.map((e) => e.name)
// Only index/export primary transcripts by default
.filter((name) => isPrimarySessionTranscriptFileName(name))
.map((name) => path.join(dir, name));
}If reset transcripts are intended to remain searchable, document that clearly and ensure Analyzed PR: #57446 at commit Last updated on: 2026-03-30T09:56:03Z |
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
* fix(memory): export archived qmd session transcripts * test(memory): separate qmd session listing describe
Summary
*.jsonltranscripts, so reset and deleted transcripts dropped out of QMD recall immediately after session resets.listSessionFilesForAgent()now uses the existing usage-counted transcript helper, so live plus.jsonl.reset.*and.jsonl.deleted.*files are exported while backups and unrelated files stay excluded.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
packages/memory-host-sdk/src/host/session-files.tsfiltered strictly onname.endsWith(".jsonl"), which excluded the.jsonl.reset.*and.jsonl.deleted.*transcript shapes produced by session reset/delete flows.listSessionFilesForAgent()covering archived transcript variants.git blame, prior PR, issue, or refactor if known): fix(qmd): include archived session transcripts in file listing #30273 and fix(memory): include archived session transcripts in QMD export #43947 both diagnosed the same stale suffix-only filter on the older path.mainstill carried the narrow filename filter after the memory host refactor.Regression Test Plan (if applicable)
packages/memory-host-sdk/src/host/session-files.test.tslistSessionFilesForAgent()is enough.User-visible / Behavior Changes
memory_searchcan now recall reset and deleted transcript history again instead of only active session files.Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
memory.backend=qmd,memory.qmd.sessions.enabled=trueSteps
.jsonl.reset.*, and.jsonl.deleted.*transcript files in the agent sessions root.listSessionFilesForAgent()through the QMD session export path.Expected
Actual
*.jsonltranscripts were included.Evidence
Human Verification (required)
pnpm test -- packages/memory-host-sdk/src/host/session-files.test.ts;pnpm build.jsonl.reset.*and.jsonl.deleted.*are included;.jsonl.bak.*,sessions.json, non-JSONL files, and nested files remain excluded.Review Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations