Skip to content

[ADR-021] Memory Recall and Rerank Pipeline #328

@ohdearquant

Description

@ohdearquant

Summary

Rework memory remember/recall semantics around explicit memory types, strict validation, composed objectives, reranker configuration, embed boundary, and migration fallback behavior.

Source ADRs

  • F107 ADR-021 (CRIT): remember starts with empty props and only writes properties.memory_type when the caller supplies one (from audit-platform/e4/ADR-021.md)
  • F108 ADR-021 (CRIT): importance and decay_factor are clamped rather than rejected, and decay_factor is capped at 1.0 (from audit-platform/e4/ADR-021.md)
  • F109 ADR-021 (CRIT): source_id is parsed with if let Ok(...); invalid UUID strings are ignored and memory creation continues without an annotates edge. (from audit-platform/e4/ADR-021.md)
  • F110 ADR-021 (CRIT): Default DecayModel::Exponential ignores the note's decay_factor and uses temporal_half_life_days (from audit-platform/e4/ADR-021.md)
  • F111 ADR-021 (CRIT): Text recall candidates are filtered only by namespace, vector candidates are filtered only to SubstrateKind::Note, and memory scoping happens after fetching notes by checking... (from audit-platform/e4/ADR-021.md)
  • F112 ADR-021 (MAJ): MemoryPack owns a single KhiveRuntime; remember always writes through self.runtime.create_note_with_decay, and there is no instance parameter or primary_write_instance routing in... (from audit-platform/e4/ADR-021.md)
  • F174 ADR-031 (MAJ): Memory recall checks one embedding_model, calls runtime.embed(query), and searches one vector store (from audit-rest/r1/ADR-031.md)
  • F175 ADR-031 (MAJ): Memory registers remember, recall, and dotted debug verbs recall.embed, recall.candidates, recall.fuse, recall.score (from audit-rest/r1/ADR-031.md)
  • F184 ADR-033 (CRIT): handle_recall ignores its VerbRegistry, builds config from active_config() plus per-call overrides, and runs candidates/fuse/score directly (from audit-rest/r2/ADR-033.md)
  • F185 ADR-033 (MAJ): The memory pack registers remember, recall, recall.embed, recall.candidates, recall.fuse, and recall.score (from audit-rest/r2/ADR-033.md)
  • F186 ADR-033 (MAJ): RecallConfig includes base weights, temporal settings, candidate multiplier/limit, fuse_strategy, min filters, and include_breakdown, but has no reranker_weights, reranker_params... (from audit-rest/r2/ADR-033.md)
  • F187 ADR-033 (MAJ): handle_recall_embed returns one {embedding, dimensions} generated by runtime.embed(). (from audit-rest/r2/ADR-033.md)
  • F188 ADR-033 (MAJ): Final scoring is still an inline compute_score function (from audit-rest/r2/ADR-033.md)
  • F189 ADR-033 (MAJ): Runtime has RrfFusionObjective, but exact searches found no DecayAwareImportanceObjective, TemporalRecencyObjective, RerankerObjective, ComposePipeline, or candidate rerank_scores... (from audit-rest/r2/ADR-033.md)
  • F190 ADR-033 (MIN): memory.recall returns the result array directly (from audit-rest/r2/ADR-033.md)
  • F222 ADR-042 (CRIT): Memory pack registers no recall.rerank / recall_rerank verb, and dispatch has no rerank branch (from audit-rest/r1/ADR-042.md)
  • F223 ADR-042 (MAJ): RecallConfig has relevance/importance/temporal weights and retrieval knobs only (from audit-rest/r1/ADR-042.md)
  • F230 ADR-043 (MAJ): RecallConfig has scoring and candidate fields only; there is no fallback_during_migration. (from audit-rest/r5/ADR-043.md)

Files affected

  • crates/khive-pack-memory/src/handlers.rs (678 sampled LOC)
  • crates/khive-pack-memory/src/config.rs (500 sampled LOC)
  • crates/khive-pack-memory/src/lib.rs (140 sampled LOC)
  • crates/khive-runtime/src/objectives.rs (335 sampled LOC)
  • crates/khive-fold/src/objective/compose.rs (422 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-memory -p khive-runtime -p khive-fold 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

~520 lines added/170 removed; 5 existing affected file(s) sampled at 2075 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)platformPlatform layer (ADR-016..030)

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions