Provide a live, versioned semantic memory layer (KGS) that stores semantic artifacts and projections, supports deterministic snapshots, and powers runtime queries for agents, compilers, and UI shells.
| ADR ID | Decision Title | Impact on This Plan |
|---|---|---|
| ADR-004 | Semantic Core Formalization | KGS is an explicit projection of the semantic core (no “magic” inference). |
| ADR-006 | Knowledge Layer Implementation | Defines graph-first querying and storage concerns. |
| PRD ID | Requirement Title | Satisfied By (SDS) | Acceptance Criteria |
|---|---|---|---|
| PRD-006 | Semantic Context for AI | SDS-003 | KGS query returns stable, structured context. |
| PRD-007 | Dynamic Knowledge Discovery | SDS-003 | Graph queries and snapshots work across versions. |
| SDS ID | Service/Component | Bounded Context | SEA-DSL Spec File | Implementation Status |
|---|---|---|---|---|
| SDS-003 | Knowledge Graph Service | semantic-core |
N/A | MVP (doc) |
graph TD
ADR4[ADR-004: Semantic Core] --> PRD6[PRD-006: Semantic Context for AI]
ADR6[ADR-006: Knowledge Layer] --> PRD7[PRD-007: Knowledge Discovery]
PRD6 --> SDS3[SDS-003: Knowledge Graph Service]
PRD7 --> SDS3
Updated 2025-12-30: Added specific dependencies from gap analysis section 1.1 (Knowledge Graph & Reasoning).
| Dependency | Type | Version | NPM/PyPI Package | Justification | ADR/SDS Reference |
|---|---|---|---|---|---|
| Oxigraph | Rust Binary / Python | 0.4.x |
oxigraph (Rust), pyoxigraph (Python) |
Production-grade RDF triple store with built-in SPARQL 1.1 engine. Preferred for performance. | ADR-006, SDS-003 |
| RDFLib | Python Library | 7.1.x |
rdflib |
Fallback RDF store for development/testing; SPARQL support. | ADR-006, SDS-003 |
| Comunica | Node.js Library | 3.x |
@comunica/query-sparql |
Execute SPARQL queries in Node.js for TypeScript adapters. | SDS-003 |
| pySHACL | Python Library | 0.29.x |
pyshacl |
Validate knowledge graph integrity against SHACL shape constraints. | SDS-003 |
| OWL-RL | Python Library | 7.1.x |
owlrl |
Enable logical inference over OWL ontologies (RDF reasoning). | ADR-006 |
1
2
3
4
5
# Python dependencies (in pyproject.toml)
pip install pyoxigraph rdflib pyshacl owlrl
# Node.js dependencies (in package.json)
pnpm add @comunica/query-sparql
1
2
3
4
5
6
// Knowledge Graph Port (abstracts Oxigraph/RDFLib/Comunica)
interface KnowledgeGraphPort {
querySparql(query: string): Promise<SparqlResult>;
validateShacl(shapeUri: string, dataGraph: string): Promise<ValidationReport>;
inferOwl(ontologyUri: string): Promise<InferenceResult>;
}
1
2
3
4
/
├── docs/specs/semantic-core/sds/003-knowledge-graph-service.md
├── tools/** # compilers + schema gates
└── libs/<ctx>/**/src/gen/** # generated runtime-facing code
| Cycle | Branch | Wave | Files Modified | Files Created | Specs Implemented |
|---|---|---|---|---|---|
| C1A | cycle/p002-c1a-kgs-contracts |
1 | docs/specs/semantic-core/sds/003-knowledge-graph-service.md |
— | SDS-003 (API & snapshot contract) |
| C1B | cycle/p002-c1b-snapshot-model |
1 | docs/specs/shared/sds/001-sea-data-model-schemas.md (if needed) |
— | Snapshot + change-set schema |
| C2A | cycle/p002-c2a-kgs-projections |
2 | tools/* (projection scripts) |
— | Deterministic projection & query helpers |
docs/specs/semantic-core/sds/003-knowledge-graph-service.mddocs/specs/shared/sds/001-sea-data-model-schemas.md (only if changes required)tools/ast_to_ir.py, tools/ir_to_manifest.py (as needed), plus any new tooling under tools/docs/specs/shared/reference/009-traceability-matrix.md for PRD-006/007 → SDS-003.| Risk | Likelihood | Impact | Mitigation Strategy |
|---|---|---|---|
| Premature “reasoning” in KGS leads to non-determinism | Medium | High | Prefer SPARQL-first, materialized projections, and explicit rules (SDS-003). |
| Snapshot/versioning grows too complex early | Medium | Medium | Start with immutable snapshots + linear history; add merges later. |
| Type | ID | Document |
|---|---|---|
| SDS | SDS-003 | docs/specs/semantic-core/sds/003-knowledge-graph-service.md |