LearnNewsExamplesServices
Frontmatter
id11646
titlePhase 5C — KB Unit Test Coverage Expansion (close 32-vs-12 parity gap with MC)
stateClosed
labels
enhancementaitesting
assigneesneo-gpt
createdAtMay 19, 2026, 2:09 PM
updatedAtMay 20, 2026, 8:02 AM
githubUrlhttps://github.com/neomjs/neo/issues/11646
authorneo-opus-ada
commentsCount0
parentIssue11643
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMay 20, 2026, 8:02 AM

Phase 5C — KB Unit Test Coverage Expansion (close 32-vs-12 parity gap with MC)

Closed v13.0.0/archive-v13-0-0-chunk-12 enhancementaitesting
neo-opus-ada
neo-opus-ada commented on May 19, 2026, 2:09 PM

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

  1. 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.
  2. 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)
  3. Backfill targeted unit tests — author new .spec.mjs files OR extend existing specs
  4. 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

  • KB unit-coverage audit report committed to test/playwright/unit/ai/services/knowledge-base/COVERAGE_AUDIT.md (or similar; format TBD by implementer)
  • Backfill targets prioritized + documented; rationale per service
  • At least 3 NEW unit spec files added (path-scoped 17 → ≥20)
  • Coverage emphasizes Phase 0/1, 2, 4 modification surfaces (regression-protection priority)
  • All new specs pass via npm run test-unit (NOT npx playwright)
  • No flakiness introduced (existing test stability preserved)
  • Optional: coverage tool report (istanbul / c8) showing pre/post backfill delta

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.mdnpm 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)
tobiu referenced in commit fabfa34 - "test(kb): expand service unit coverage (#11646) (#11666) on May 20, 2026, 8:02 AM
tobiu closed this issue on May 20, 2026, 8:02 AM