Skip to content

[ADR-023] Dynamic Pack Loading, Template, and Pack Binary Inclusion #324

@ohdearquant

Description

@ohdearquant

Summary

Make pack inclusion explicit and strict, add the template/comm/schedule pack scaffolds, remove transitive auto-loading, and update MCP/kkernel force-link surfaces.

Source ADRs

  • F127 ADR-023 (MAJ): Workspace members include pack crates but no khive-pack-template crate (from audit-platform/e1/ADR-023.md)
  • F150 ADR-027 (CRIT): khive-mcp directly depends on every first-party pack crate (kg, gtd, memory, brain). (from audit-platform/e2/ADR-027.md)
  • F151 ADR-027 (CRIT): khive-mcp force-links each pack crate by name so linker sections survive dead stripping. (from audit-platform/e2/ADR-027.md)
  • F152 ADR-027 (CRIT): kkernel repeats the same explicit force-link list for first-party packs. (from audit-platform/e2/ADR-027.md)
  • F153 ADR-027 (CRIT): Production KhiveMcpServer::new catches pack-registration errors, warns, and falls back to kg only. (from audit-platform/e2/ADR-027.md)
  • F154 ADR-027 (CRIT): PackRegistry::register_packs computes a transitive dependency closure and auto-adds required packs even if the caller did not request them. (from audit-platform/e2/ADR-027.md)
  • F156 ADR-027 (MIN): Dynamic pack-loading comments label this mechanism as ADR-063 instead of ADR-027. (from audit-platform/e2/ADR-027.md)
  • F211 ADR-040 (MAJ): The workspace member list includes khive-pack-kg, khive-pack-gtd, khive-pack-memory, and khive-pack-brain, but no khive-pack-comm or khive-pack-schedule entries through... (from audit-rest/r5/ADR-040.md)
  • F212 ADR-040 (MAJ): MCP force-links only BrainPack, GtdPack, KgPack, and MemoryPack (from audit-rest/r5/ADR-040.md)
  • F213 ADR-040 (MAJ): kkernel pack introspection lists whatever pack factories are discovered by inventory (from audit-rest/r5/ADR-040.md)

Files affected

  • crates/Cargo.toml (59 sampled LOC)
  • crates/khive-mcp/Cargo.toml (39 sampled LOC)
  • crates/khive-mcp/src/pack.rs (26 sampled LOC)
  • crates/kkernel/src/lib.rs (28 sampled LOC)
  • crates/khive-mcp/src/server.rs (404 sampled LOC)
  • crates/khive-runtime/src/pack.rs (2677 sampled LOC)
  • crates/kkernel/src/pack_introspect.rs (153 sampled LOC)
  • crates/khive-pack-template/Cargo.toml (new/planned path)
  • crates/khive-pack-template/src/lib.rs (new/planned path)
  • crates/khive-pack-comm/Cargo.toml (new/planned path)
  • crates/khive-pack-comm/src/lib.rs (new/planned path)
  • crates/khive-pack-comm/src/handlers.rs (new/planned path)
  • crates/khive-pack-schedule/Cargo.toml (new/planned path)
  • crates/khive-pack-schedule/src/lib.rs (new/planned path)
  • crates/khive-pack-schedule/src/handlers.rs (new/planned path)
  • crates/khive-runtime/src/runtime.rs (388 sampled LOC)
  • crates/khive-mcp/src/main.rs (82 sampled LOC)

Acceptance criteria

  • All source findings listed above are addressed exactly once in this cluster.
  • Public types, handlers, schema, and docs touched by the affected files agree on the ADR contract.
  • Regression tests cover happy path and edge cases for the changed public APIs or schema behavior.
  • cargo test -p khive-runtime -p khive-mcp -p kkernel passes.
  • cargo clippy --workspace -- -D warnings passes.
  • make ci passes.

Dependencies

  • Depends on: #[ADR-004] Note Kind, Storage, and Curation Operations
  • Depends on: #[ADR-004] Event Observable and Provenance Model
  • Depends on: #[ADR-007] Namespace Token and Runtime API Migration
  • Depends on: #[ADR-003] Runtime Backend and Substrate Coordinator
  • Depends on: #[ADR-010] VCS Git-Native Core and Legacy Removal
  • Depends on: #[ADR-004] HandlerDef Pack Contract
  • Depends on: #[ADR-017] Pack Verb Registry, Wire Names, and Introspection
  • Depends on: #[ADR-016] Request Execution Modes and Presentation Envelope
  • Blocks: #[ADR-004] GTD Pack Schema Plan and Lifecycle Audit
  • Blocks: #[ADR-011] Retrieval, Embed, and Lattice Boundary
  • Blocks: #[ADR-034] kkernel Engine and Admin Commands
  • Blocks: #[ADR-025] Event-Sourced Proposals
  • Blocks: #[ADR-035] Import, Export, Remote Resolver, and Sync

LOC estimate

~800 lines added/120 removed; 9 existing affected file(s) sampled at 3856 current LOC via wc -l, plus 8 new/planned path(s).

Risk notes

  • Same-file dependencies must merge first; dependency list includes the exact overlapping paths.
  • Estimate exceeds the <=500 net target; keep implementation internally staged but preserve one merge cluster because the file surface is tightly coupled.
  • 8 affected path(s) are new/planned and were not present in rg --files --hidden; create them in the owning PR rather than in independent parallel work.
  • Contains CRIT findings; do not defer without owner approval.

Auto-generated by ADR alignment triage

Metadata

Metadata

Assignees

No one assigned

    Labels

    adr-alignmentADR v1 series alignment workadvancedAdvanced layer (ADR-031..046)platformPlatform layer (ADR-016..030)

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions