Skip to content

[ADR-032] Brain Profile Orchestration #329

@ohdearquant

Description

@ohdearquant

Summary

Replace scalar in-memory brain state with profile-oriented orchestration, event interpretation contracts, and profile-aware brain verb behavior.

Source ADRs

  • F177 ADR-032 (CRIT): BrainState is still the predecessor scalar model: parameters: HashMap<String, BetaPosterior>, entity_posteriors, total_events, and exploration_epoch. (from audit-rest/r2/ADR-032.md)
  • F178 ADR-032 (CRIT): The only brain fold is EventFold: Fold<Event, BrainState>, initialized with hardcoded recall::relevance_weight, recall::importance_weight, and recall::temporal_weight posteriors. (from audit-rest/r2/ADR-032.md)
  • F179 ADR-032 (MAJ): The registered verb surface is only brain.state, brain.config, brain.events, brain.reset, and brain.emit. (from audit-rest/r2/ADR-032.md)
  • F180 ADR-032 (MAJ): BrainPack stores only runtime, an in-memory Mutex, and EventFold (from audit-rest/r2/ADR-032.md)
  • F182 ADR-032 (MAJ): Brain depends only on khive local crates plus serde/uuid/chrono (from audit-rest/r2/ADR-032.md)
  • F183 ADR-032 (MAJ): interpret() maps raw verbs including brain.emit into a single global signal stream (from audit-rest/r2/ADR-032.md)
  • F226 ADR-042 (MAJ): BrainPack exposes state/config/events/reset/emit (from audit-rest/r1/ADR-042.md)

Files affected

  • crates/khive-pack-brain/src/state.rs (319 sampled LOC)
  • crates/khive-pack-brain/src/fold.rs (197 sampled LOC)
  • crates/khive-pack-brain/src/lib.rs (424 sampled LOC)
  • crates/khive-pack-brain/Cargo.toml (27 sampled LOC)
  • crates/khive-pack-brain/src/event.rs (254 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-pack-brain passes.
  • cargo clippy --workspace -- -D warnings passes.
  • make ci passes.

Dependencies

  • Depends on: #[ADR-007] Namespace Token and Runtime API Migration
  • Depends on: #[ADR-017] Pack Verb Registry, Wire Names, and Introspection
  • Blocks: none

LOC estimate

~210 lines added/70 removed; 5 existing affected file(s) sampled at 1221 current LOC via wc -l, plus 0 new/planned path(s).

Risk notes

  • Same-file dependencies must merge first; dependency list includes the exact overlapping paths.
  • 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)

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions