1 Commits
Author SHA1 Message Date
583350034e feat(knowledge-base): add the Knowledge Base loader (#7) (#53)
Implement Knowledge Base loading and indexing per MASTER_SPEC §15.11, §27.3 in
compiler/common/knowledge_base.py.

- KnowledgeBaseEntry: frozen model of a canonical concept.
- KnowledgeBase: immutable, with id->entry and alias->id indexes and
  get / resolve_alias / lookup accessors (read-only mappings).
- load_knowledge_base: reads every *.json (array of entries) from a directory,
  delegates full validation to validate_knowledge_base (#9), and on any finding
  raises Fatal SC0004 KnowledgeBaseError with the findings attached -- indexes
  are built only after validation passes, so a failed load leaves no partial
  state.
- KnowledgeBaseLoader: caches the Knowledge Base after first get(); reload() is
  explicit and side-effect-free on failure (the previous KB is kept). No
  automatic file watching. Optional structured logger.

Tests: multi-file load, id/alias lookups, expand/deprecated preservation, empty
dir, invalid KB / duplicate id / invalid JSON -> SC0004, caching identity,
reload picks up changes, reload failure keeps the previous KB, and immutability.

Co-authored-by: kunail0804 <kunail0804@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 19:36:31 +02:00