Context
Sub of Phase 5 Epic #11643 (meta-Epic #11624).
Cross-cutting; can start any time. Audits + backfills KB unit test coverage gaps to approach MC parity.
The Problem
Empirical parity gap (V-B-A grounded; calibrated 2026-05-19T13:42Z per GPT epic-review on #11643 — initial path-glob was too broad):
Path-scoped counts (canonical test/playwright/unit/ai/services/):
memory-core/*.spec.mjs (incl. subtree): 23 specs
knowledge-base/*.spec.mjs (incl. subtree): 17 specs
- KB has ~74% of MC's unit test density
Initial framing (find -path "*memory-core*" → 32 vs *knowledge-base* → 12) swept broader subtrees including ai/daemons/services/ and incorrect path roots. The path-scoped count is the canonical metric.
While the 6-spec delta is smaller than initially framed, substantial coverage gaps likely still exist in:
DatabaseService (570 lines — orchestrator; backup/restore methods; lifecycle)
VectorService (308 lines — embedding pipeline; content-hash delta; #10572 volume gate behavior)
QueryService (222 lines — Chroma query construction)
SearchService (170 lines — file hydration path)
HealthService (374 lines — health surface)
KBRecorderService (450 lines — telemetry pipeline; Memory Core SQLite integration)
ChromaManager (142 lines — Chroma client lifecycle)
Operator framing: "and /unit-tests too" — explicit directive to close the gap.
The Fix
- Audit current KB unit coverage — for each KB service, enumerate public methods + identify which have unit-test coverage vs which don't. Produce gap report.
- Prioritize backfill targets — focus on:
- Methods that will be MODIFIED in Phase 0/1, 2, 4 (regression-protection priority)
- Methods with non-trivial logic (error paths, edge cases, state transitions)
- Methods that interact with shared substrate (Chroma, Memory Core SQLite, AgentIdentity)
- Backfill targeted unit tests — author new
.spec.mjs files OR extend existing specs
- Track parity progress — measure KB spec count after backfill via path-scoped count of
test/playwright/unit/ai/services/knowledge-base/**/*.spec.mjs; target ≥20 specs (~87% of MC's 23 path-scoped count; pragmatic V1 target)
Acceptance Criteria
Out of Scope
- Integration tests (Phase 5A/B own that)
- E2E tests (Phase 2F owns that)
- Closing the FULL 32-spec gap if pragmatic 25+ is achievable in single sub (further backfill can spawn follow-up ticket if needed)
- Refactoring tested code to be more-testable (testing AS-IS; refactoring is separate concern)
- Performance regression testing
Avoided Traps
| Trap |
Why rejected |
| Distributing test backfill across Phase 0/1/2/4 subs silently |
Without explicit cross-cutting ticket, the 32-vs-12 gap closes informally and unmeasurably |
| Targeting 100% method coverage |
Diminishing returns; meta-Epic's other phases will land their own per-feature tests. 80% MC parity is pragmatic V1 |
| Over-engineering test-helper abstractions |
Match existing KB unit test patterns; refactoring helpers is a separate concern |
Related
- Parent: #11643
- Empirical anchor:
find test/playwright/unit/ai -path "*memory-core*" -name "*.spec.mjs" | wc -l = 32; KB equivalent = 12 (verified 2026-05-19)
- Reference patterns:
test/playwright/unit/ai/memory-core/*.spec.mjs (MC unit test conventions)
Origin Session ID
7360e917-1733-4cdd-a6f3-5ac51c34b838
Handoff Retrieval Hints
- Start with the audit phase — gap report INFORMS prioritization; don't backfill blindly
- Memory anchor:
feedback_npx_bypass_test_isolation.md — npm run test-unit not npx playwright
- Memory anchor:
feedback_mcp_test_location.md — KB unit tests under test/playwright/unit/ai/knowledge-base/
KBRecorderService.mjs is high-priority backfill target — 450 lines + extends into Phase 4A
VectorService.mjs:188-274 is high-priority (Phase 0/1C modification surface)
QueryService.mjs:116-128 is high-priority (Phase 0/1D modification surface)
Context
Sub of Phase 5 Epic #11643 (meta-Epic #11624).
Cross-cutting; can start any time. Audits + backfills KB unit test coverage gaps to approach MC parity.
The Problem
Empirical parity gap (V-B-A grounded; calibrated 2026-05-19T13:42Z per GPT epic-review on #11643 — initial path-glob was too broad):
Path-scoped counts (canonical
test/playwright/unit/ai/services/):memory-core/*.spec.mjs(incl. subtree): 23 specsknowledge-base/*.spec.mjs(incl. subtree): 17 specsInitial framing (
find -path "*memory-core*"→ 32 vs*knowledge-base*→ 12) swept broader subtrees includingai/daemons/services/and incorrect path roots. The path-scoped count is the canonical metric.While the 6-spec delta is smaller than initially framed, substantial coverage gaps likely still exist in:
DatabaseService(570 lines — orchestrator; backup/restore methods; lifecycle)VectorService(308 lines — embedding pipeline; content-hash delta; #10572 volume gate behavior)QueryService(222 lines — Chroma query construction)SearchService(170 lines — file hydration path)HealthService(374 lines — health surface)KBRecorderService(450 lines — telemetry pipeline; Memory Core SQLite integration)ChromaManager(142 lines — Chroma client lifecycle)Operator framing: "and /unit-tests too" — explicit directive to close the gap.
The Fix
.spec.mjsfiles OR extend existing specstest/playwright/unit/ai/services/knowledge-base/**/*.spec.mjs; target ≥20 specs (~87% of MC's 23 path-scoped count; pragmatic V1 target)Acceptance Criteria
test/playwright/unit/ai/services/knowledge-base/COVERAGE_AUDIT.md(or similar; format TBD by implementer)npm run test-unit(NOTnpx playwright)Out of Scope
Avoided Traps
Related
find test/playwright/unit/ai -path "*memory-core*" -name "*.spec.mjs" | wc -l= 32; KB equivalent = 12 (verified 2026-05-19)test/playwright/unit/ai/memory-core/*.spec.mjs(MC unit test conventions)Origin Session ID
7360e917-1733-4cdd-a6f3-5ac51c34b838Handoff Retrieval Hints
feedback_npx_bypass_test_isolation.md—npm run test-unitnotnpx playwrightfeedback_mcp_test_location.md— KB unit tests undertest/playwright/unit/ai/knowledge-base/KBRecorderService.mjsis high-priority backfill target — 450 lines + extends into Phase 4AVectorService.mjs:188-274is high-priority (Phase 0/1C modification surface)QueryService.mjs:116-128is high-priority (Phase 0/1D modification surface)