@@ -6,6 +6,7 @@ import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
66import { auditDreamingArtifacts , repairDreamingArtifacts } from "./dreaming-repair.js" ;
77import {
88 configureMemoryCoreDreamingStateForTests ,
9+ DREAMING_DAILY_INGESTION_NAMESPACE ,
910 DREAMING_SESSION_INGESTION_FILES_NAMESPACE ,
1011 DREAMING_SESSION_INGESTION_SEEN_NAMESPACE ,
1112 readMemoryCoreWorkspaceEntries ,
@@ -214,4 +215,42 @@ describe("dreaming artifact repair", () => {
214215 } ) ,
215216 ) . resolves . toEqual ( [ ] ) ;
216217 } ) ;
218+
219+ it ( "reports ingestion state present from SQLite when legacy JSON is absent" , async ( ) => {
220+ const workspaceDir = await createWorkspace ( ) ;
221+ // Write SQLite ingestion entries but NO legacy session-ingestion.json
222+ await writeMemoryCoreWorkspaceEntries ( {
223+ namespace : DREAMING_SESSION_INGESTION_FILES_NAMESPACE ,
224+ workspaceDir,
225+ entries : [
226+ {
227+ key : "main/session.jsonl" ,
228+ value : { lastSize : 120 , lastMtimeMs : 1_000 , lastContentHash : "hash" , cursorLine : 42 } ,
229+ } ,
230+ ] ,
231+ } ) ;
232+
233+ const audit = await auditDreamingArtifacts ( { workspaceDir } ) ;
234+
235+ expect ( audit . sessionIngestionExists ) . toBe ( true ) ;
236+ } ) ;
237+
238+ it ( "reports ingestion state present from SQLite daily namespace" , async ( ) => {
239+ const workspaceDir = await createWorkspace ( ) ;
240+ // Only daily ingestion namespace has rows
241+ await writeMemoryCoreWorkspaceEntries ( {
242+ namespace : DREAMING_DAILY_INGESTION_NAMESPACE ,
243+ workspaceDir,
244+ entries : [
245+ {
246+ key : "2026-06-10" ,
247+ value : { ingestedAt : Date . now ( ) } ,
248+ } ,
249+ ] ,
250+ } ) ;
251+
252+ const audit = await auditDreamingArtifacts ( { workspaceDir } ) ;
253+
254+ expect ( audit . sessionIngestionExists ) . toBe ( true ) ;
255+ } ) ;
217256} ) ;
0 commit comments