Skip to content

Commit 7727c4b

Browse files
committed
fix(memory): use session corpus listing for status-mode dirty detection
Replace resolveSessionTranscriptsDirForAgent + readdirSync with listSessionTranscriptCorpusEntriesForAgentSync so the status-mode dirty check respects configured/fixed custom session stores and ownership filtering, matching the async startup catch-up path. Export listSessionTranscriptCorpusEntriesForAgentSync through the memory-host-sdk and plugin-sdk barrels.
1 parent 9750225 commit 7727c4b

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

extensions/memory-core/src/memory/manager-sync-ops.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
isUsageCountedSessionTranscriptFileName,
2323
listSessionFilesForAgent,
2424
listSessionTranscriptCorpusEntriesForAgent,
25+
listSessionTranscriptCorpusEntriesForAgentSync,
2526
parseCanonicalSessionSyncTargetFromPath,
2627
resolveSessionFileForSyncTarget,
2728
sessionPathForFile,
@@ -1501,33 +1502,35 @@ export abstract class MemoryManagerSyncOps {
15011502
* initialization. Sets sessionsDirty when on-disk session files have no
15021503
* corresponding memory_index_sources rows, so plain `memory status`
15031504
* reports accurate dirty state without performing a full sync.
1505+
*
1506+
* Uses the session corpus listing (same contract as startup catch-up) so
1507+
* configured/fixed custom session stores and ownership filtering are respected.
15041508
*/
15051509
protected detectSessionStartupDirtySync(): void {
15061510
if (!this.sources.has("sessions")) {
15071511
return;
15081512
}
15091513
try {
1510-
const sessionsDir = resolveSessionTranscriptsDirForAgent(this.agentId);
1511-
if (!fsSync.existsSync(sessionsDir)) {
1514+
const corpusEntries = listSessionTranscriptCorpusEntriesForAgentSync(this.agentId);
1515+
if (corpusEntries.length === 0) {
15121516
return;
15131517
}
1514-
const entries = fsSync.readdirSync(sessionsDir, { withFileTypes: true });
15151518
const sessionFiles: MemorySessionStartupFileState[] = [];
1516-
for (const entry of entries) {
1517-
if (!entry.isFile() || !isUsageCountedSessionTranscriptFileName(entry.name)) {
1518-
continue;
1519-
}
1520-
const absPath = path.join(sessionsDir, entry.name);
1519+
for (const entry of corpusEntries) {
1520+
const absPath = entry.sessionFile;
15211521
try {
15221522
const stat = fsSync.statSync(absPath);
1523+
if (!stat.isFile()) {
1524+
continue;
1525+
}
15231526
sessionFiles.push({
15241527
absPath,
15251528
path: sessionPathForFile(absPath),
15261529
mtimeMs: stat.mtimeMs,
15271530
size: stat.size,
15281531
});
15291532
} catch {
1530-
// File may have been deleted between readdir and stat; skip.
1533+
// File may have been deleted between corpus listing and stat; skip.
15311534
}
15321535
}
15331536
if (sessionFiles.length === 0) {

packages/memory-host-sdk/src/engine-qmd.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export {
55
buildSessionEntry,
66
listSessionFilesForAgent,
77
listSessionTranscriptCorpusEntriesForAgent,
8+
listSessionTranscriptCorpusEntriesForAgentSync,
89
loadDreamingNarrativeTranscriptPathSetForAgent,
910
loadSessionTranscriptClassificationForAgent,
1011
normalizeSessionTranscriptPathForComparison,

packages/memory-host-sdk/src/host/session-files.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type { MemorySessionSyncTarget } from "./types.js";
3131

3232
export {
3333
listSessionTranscriptCorpusEntriesForAgent,
34+
listSessionTranscriptCorpusEntriesForAgentSync,
3435
type SessionTranscriptCorpusArtifactKind,
3536
type SessionTranscriptCorpusEntry,
3637
} from "./session-transcript-corpus.js";

0 commit comments

Comments
 (0)