Frontmatter
| title | >- |
| feat | implement ConceptService for deterministic ontology graph traversal |
| author | tobiu |
| state | Merged |
| createdAt | Apr 17, 2026, 3:08 PM |
| updatedAt | Apr 17, 2026, 3:14 PM |
| closedAt | Apr 17, 2026, 3:14 PM |
| mergedAt | Apr 17, 2026, 3:14 PM |
| branches | dev ← agent/10032-concept-service |
| url | https://github.com/neomjs/neo/pull/10048 |

Input from Claude Opus 4.6 (Antigravity):
✦ ## PR Review: ConceptService Implementation (#10032)
Evaluation Metrics
Dimension Score Notes Architectural Alignment ✅ 9/10 Service placed in ai/services/per #10040 vision. Decoupled from SQLite graph.Content Completeness ✅ 9/10 All 7 APIs implemented. Comprehensive JSDoc with @summary tags. Test Coverage ✅ 10/10 16 specs covering happy paths, error cases, and production graph validation. Semantic Anchoring ✅ 9/10 @class, @summary, @param, @returns on all public methods. Architecture Notes
Service Placement Decision: The initial implementation was placed in
ai/graph/(graph DB internals), thenai/daemons/services/(DreamPipeline phases). Final locationai/services/was chosen because ConceptService is a standalone SDK service, not a graph DB component or a daemon-specific phase. This aligns with the Hybrid Swarm Broker blueprint (Discussion #10040).Decoupled Storage: The JSONL-backed in-memory Map approach intentionally avoids coupling to the Native Edge Graph's SQLite backend, which is undergoing the Multi-Tenant refactor (#9999). This makes the concept ontology portable and version-controllable via git.
Weight Formula:
tier_score + uniqueness_score + coverage_deficitprovides deterministic prioritization without LLM inference. The formula correctly identifies tier-1, unique-to-Neo concepts without guides as the highest priority gaps (weight 1.3).Graph Ingestion Tags
- [KB_GAP] The
serializeForLLMoutput should be indexed by the Knowledge Base to provide agents with instant ontology context priming.- [RETROSPECTIVE] The migration path (ai/graph → ai/daemons/services → ai/services) demonstrates the importance of the
ai/services/*convention established in #10040. Future services should be placed here directly.- [TOOLING_GAP] The ConceptService currently loads JSONL synchronously via
fs.readFileSync. For the Swarm Broker architecture (#10040), this should be migrated to async I/O when the service runs inside a Worker Thread.
Summary
Implements the ConceptService — the runtime SDK interface for the Concept Ontology graph. This service loads the version-controlled JSONL concept graph from
.neo-ai-data/concepts/and exposes deterministic query APIs for gap detection, coverage analysis, and LLM context priming.This is the foundational service layer for replacing the GapInferenceEngine's fragile regex-based token matching with graph-traversal-based gap detection.
Architectural Context
The ConceptService is placed in
ai/services/ConceptService.mjs(notai/graph/orai/daemons/services/) to align with the emerging Services-Based OS architecture (Discussion #10040). Theai/graph/directory contains the custom graph DB internals (Database, Store, NodeModel); this service is a consumer of the ontology data, not a graph DB implementation.Design Decision: Decoupled from Native Edge Graph
The concept graph is stored as standalone JSONL files and loaded into a pure in-memory Map structure. This intentionally avoids coupling to the SQLite-backed Native Edge Graph, which is undergoing the Multi-Tenant Memory Core refactor (#9999).
Changes
ai/services/ConceptService.mjs[NEW]Singleton service extending
Neo.core.Basewith 7 public APIs:loadGraph()— Parsesnodes.jsonl+edges.jsonl, builds bidirectional edge indexesgetConceptTree(maxTier)— Builds nested hierarchy from the tier-0 anchorgetConceptCoverage(conceptId)— Returns EXPLAINED_BY, IMPLEMENTED_BY, EXEMPLIFIED_BY edgesfindGuideGaps(minWeight)— Deterministic gap detection sorted by weighted priorityclassifyConcept(classPath)— Reverse lookup: file path → concepts it implementsserializeForLLM(maxTier)— Compact tree with Unicode connectors for context priminggetSummary()— Diagnostics: coverage %, gap counts, severity breakdownWeight formula:
tier_score + uniqueness_score + coverage_deficitai/services.mjs[MODIFIED]Registered ConceptService import and export in the SDK.
test/playwright/unit/ai/services/ConceptService.spec.mjs[NEW]16 Playwright unit tests covering:
Validation
Production Ontology Status
Origin Session ID: c9bf0d61-a58d-42ba-a030-6426dc5fe270
Resolves #10032