Skip to content

feat(knowledge): ADR-048 Phase 2 — resource kind, knowledge_sections, edit+import verbs#508

Merged
ohdearquant merged 5 commits into
mainfrom
feat/adr048-phase2
May 27, 2026
Merged

feat(knowledge): ADR-048 Phase 2 — resource kind, knowledge_sections, edit+import verbs#508
ohdearquant merged 5 commits into
mainfrom
feat/adr048-phase2

Conversation

@ohdearquant
Copy link
Copy Markdown
Owner

Summary

  • Adds resource as 9th EntityKind with subtypes: atom, runbook, template, prompt, skill, tool
  • V21 migration: knowledge_sections table with FTS5 triggers and 3 indexes
  • SectionType enum (10 variants matching ADR-048 §1): Overview, CoreModel, BoundaryConditions, Formalism, OperationalGuidance, Examples, FailureModes, ExpertLens, References, Other
  • knowledge.edit verb: upsert per-section content with stable IDs on re-edit
  • knowledge.import verb: atlas_md parser with section+atom strategies
  • KNOWLEDGE_HANDLERS expanded from 12 → 14

Merge sequence

Position: 10/10 — merge after #507

Order PR Description Base
1 #499 authorize() → Result main
2 #500 EntityType registry #499
3 #501 Lifecycle tests main
4 #502 Memory/brain/knowledge #499
5 #503 Write-key conflicts #499
6 #504 Vamana ANN index main
7 #505 Brain section posteriors main
8 #506 Runtime backfill/sweep/pipeline main
9 #507 KG namespace isolation main
10 #508 ADR-048 Phase 2 main

Test plan

  • cargo check --workspace clean
  • cargo test --workspace passes (excl. 2 pre-existing memory failures)
  • V21 migration creates knowledge_sections table with FTS5
  • knowledge.edit upserts sections with stable IDs
  • knowledge.import parses atlas_md format

🤖 Generated with Claude Code

ohdearquant and others added 4 commits May 27, 2026 16:54
… edit+import verbs

- Add `resource` as 9th EntityKind (ADR-001 amendment) in khive-pack-kg/vocab.rs;
  aliases: atom, runbook, template, prompt, skill, tool
- V20 no-op placeholder (reserved for brain section posteriors in PR #505)
- V21 migration: `knowledge_sections` table with UNIQUE(atom_id, section_type),
  FTS5 virtual table + insert/update/delete triggers, three covering indexes
- SectionType enum (10 variants) with from_str_loose() heading normalization
- `knowledge.edit` verb: section-level upsert via ON CONFLICT DO UPDATE, preserves
  sibling sections, resolves atom by UUID or slug
- `knowledge.import` verb: atlas markdown ingestion — parses # title + ## headings
  into section-typed atoms; supports section and atom chunk strategies
- Register both verbs in KNOWLEDGE_HANDLERS (14 entries) and dispatch match

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
RuntimeConfig::default() now includes additional_embedding_models with
ParaphraseMultilingualMiniLmL12V2, which gets registered in the DB and
causes note-creation tests to attempt model loading. In CI, the ONNX
model files don't exist, causing 5 integration tests to fail with
"model initialization failed: IO error: No such file or directory".

Fix: explicitly set additional_embedding_models: vec![] in all test
RuntimeConfig blocks that set embedding_model: None.

Also includes cargo fmt and deno fmt fixes for runtime.rs and ADR docs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ohdearquant
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c8159732e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +27 to +29
/// Actionable content agents consume (ADR-048): atoms, domains, skills,
/// tools, templates, prompts, runbooks.
Resource,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enable resource edges before adding the kind

When callers follow ADR-048's resource/atom linking pattern (e.g. resource --annotates--> concept), these newly accepted Resource entities cannot actually be linked: validate_edge_relation_endpoints still treats annotates as note-source-only and the base allowlist has no resource endpoints for the other semantic relations. As a result Phase 2 resources can be created but cannot participate in the intended KG relationships, so either the runtime/pack edge contract needs to be extended or the kind should not be exposed yet.

Useful? React with 👍 / 👎.

Comment on lines +1950 to +1953
json!({
"section_type": stype.as_str(),
"heading": heading,
"content": body,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Merge duplicate section types during import

For markdown files containing two headings that normalize to the same SectionType (especially multiple unknown headings, all mapped to other), this import builds multiple updates with the same section_type. knowledge.edit upserts on UNIQUE(atom_id, section_type), so the later update overwrites the earlier section body and the imported file silently loses content while still counting both updates as imported sections. Group or concatenate same-type sections before calling edit, or reject duplicates explicitly.

Useful? React with 👍 / 👎.

Mark the markdown example block as `text` so the Rust doctest runner
does not attempt to compile it as Rust source.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ohdearquant ohdearquant merged commit e3788fa into main May 27, 2026
3 checks passed
@ohdearquant ohdearquant deleted the feat/adr048-phase2 branch May 27, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant