Context
Surfaced 2026-05-08 during PR #10933 (Phase 3 unit-row re-add) CI run 25524203756. Originally classified as part of G6 (27 did-not-run) in the #10924 G5 triage matrix. The G6 cohort collapsed from 27 → 1 after G1-G4 skip-guards landed; this is the residual.
Identified by @neo-gpt's epic-resolution review at #10924 comment 4401514682 as the load-bearing did-not-run blocker.
The Problem
test/playwright/unit/ai/graph/Database.spec.mjs (the foreign-key cascade test) is reported as did not run because SQLite.initSchema() throws:
TypeError: Cannot read properties of undefined (reading 'exec')
at ai/graph/storage/SQLite.mjs:76
this.db.exec('DROP TABLE IF EXISTS Edges');
this.db is undefined at the time initSchema runs. Under workers:1, a sibling spec runs first and closes/nulls the SQLite singleton's db reference (e.g., FileSystemIngestor.spec.afterAll at line 105-110 explicitly calls db.close() then GraphService.db = null). When Database.spec then tries to initSchema against the same singleton, the db field is gone and the next consumer can't initialize.
The Architectural Reality
ai/graph/storage/SQLite.mjs:76 — initSchema accesses this.db.exec(...) without a defensive open-state check
ai/graph/storage/SQLite.mjs:200 — same surface, also flagged via #10934 (FileSystemIngestor removeNodes close-then-reuse)
test/playwright/unit/ai/graph/Database.spec.mjs — the consumer that "did not run" because init failed
- Sibling specs that close the singleton:
FileSystemIngestor.spec.afterAll (verified), likely others
This is the SAME root cause as #10934 (FileSystemIngestor) but at a different consumer surface. Both reflect the closed-singleton-then-reuse pattern. Investigation may resolve both with a single SDK-level fix.
The Fix (TBD via investigation)
Two candidate paths (likely shared with #10934):
- SDK-level (preferred if scope-shared with #10934): defensive
this.db open-state check in SQLite.initSchema (and sibling mutators); self-heal via re-init OR throw a clearer error pointing to the lifecycle violation
- Spec-level: refactor sibling
afterAll to NOT close shared singletons (use scoped factory pattern instead)
Recommend coordinating with #10934 as a single fix-track unless investigation shows divergent surfaces.
Acceptance Criteria
Out of Scope
- Migrating SQLite singleton to per-test instances (too aggressive)
- Cross-spec singleton-lifecycle epic-shaped audit (separate concern; this ticket is targeted)
Avoided Traps
- Filing as G6 umbrella instead of a single concrete sub-ticket: rejected — the umbrella was 27 did-not-run, now 1 residual; one sub-ticket is the right granularity
- Bundling with #10934: kept as separate tickets because the consumer surfaces differ (Database.spec init vs FileSystemIngestor remove); fix may converge but tickets stay separate for traceability
Related
- Surfacing CI run: 25524203756
- Identified via: @neo-gpt's epic-resolution review (Lane 3 of the Path A 3-lane plan)
- Sibling root-cause: #10934 (FileSystemIngestor singleton SQLite-close — same closed-singleton-reuse pattern at a different consumer surface)
- Substrate config:
test/playwright/playwright.config.unit.mjs workers: 1 in CI
Origin Session ID: 7e897a0b-33ce-4d6c-b1a9-a1ff93e4e571
Retrieval Hint: query_raw_memories(query="Database.spec SQLite initSchema closed-db reuse workers 1 G6 did-not-run residual #10924 PR 10933")
Context
Surfaced 2026-05-08 during PR #10933 (Phase 3 unit-row re-add) CI run 25524203756. Originally classified as part of G6 (27 did-not-run) in the #10924 G5 triage matrix. The G6 cohort collapsed from 27 → 1 after G1-G4 skip-guards landed; this is the residual.
Identified by @neo-gpt's epic-resolution review at #10924 comment 4401514682 as the load-bearing did-not-run blocker.
The Problem
test/playwright/unit/ai/graph/Database.spec.mjs(the foreign-key cascade test) is reported asdid not runbecauseSQLite.initSchema()throws:TypeError: Cannot read properties of undefined (reading 'exec') at ai/graph/storage/SQLite.mjs:76 this.db.exec('DROP TABLE IF EXISTS Edges');this.dbis undefined at the timeinitSchemaruns. Underworkers:1, a sibling spec runs first and closes/nulls the SQLite singleton'sdbreference (e.g.,FileSystemIngestor.spec.afterAllat line 105-110 explicitly callsdb.close()thenGraphService.db = null). When Database.spec then tries toinitSchemaagainst the same singleton, thedbfield is gone and the next consumer can't initialize.The Architectural Reality
ai/graph/storage/SQLite.mjs:76—initSchemaaccessesthis.db.exec(...)without a defensive open-state checkai/graph/storage/SQLite.mjs:200— same surface, also flagged via #10934 (FileSystemIngestorremoveNodesclose-then-reuse)test/playwright/unit/ai/graph/Database.spec.mjs— the consumer that "did not run" because init failedFileSystemIngestor.spec.afterAll(verified), likely othersThis is the SAME root cause as #10934 (FileSystemIngestor) but at a different consumer surface. Both reflect the closed-singleton-then-reuse pattern. Investigation may resolve both with a single SDK-level fix.
The Fix (TBD via investigation)
Two candidate paths (likely shared with #10934):
this.dbopen-state check inSQLite.initSchema(and sibling mutators); self-heal via re-init OR throw a clearer error pointing to the lifecycle violationafterAllto NOT close shared singletons (use scoped factory pattern instead)Recommend coordinating with #10934 as a single fix-track unless investigation shows divergent surfaces.
Acceptance Criteria
WORKERS=1— Database.spec did-not-run after FileSystemIngestor.specGraphService.db.storage.db(FileSystemIngestor confirmed; audit others)npm run test-unitinvocations on CI substratedid not runcount reaches 0 in the unit summaryOut of Scope
Avoided Traps
Related
test/playwright/playwright.config.unit.mjsworkers: 1in CIOrigin Session ID:
7e897a0b-33ce-4d6c-b1a9-a1ff93e4e571Retrieval Hint:
query_raw_memories(query="Database.spec SQLite initSchema closed-db reuse workers 1 G6 did-not-run residual #10924 PR 10933")