Skip to content

spec(context): add Context-Adaptive Memory specification (CAM)#4546

Merged
bug-ops merged 1 commit into
mainfrom
context-adaptive-memory
May 28, 2026
Merged

spec(context): add Context-Adaptive Memory specification (CAM)#4546
bug-ops merged 1 commit into
mainfrom
context-adaptive-memory

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 28, 2026

Summary

Formal specification package for the Context-Adaptive Memory (CAM) subsystem, covering three research issues:

The three approaches are unified into a single coherent subsystem. Spec produced via the spec-driven team-develop workflow (architect → critic → SDD → reviewer), with architect plan revised after SIGNIFICANT critic findings (S1-S4: index invalidation race, CompactionState underspec, LLM API contract violation, weight normalization).

Spec package

specs/062-context-adaptive-memory/:

  • spec.md — 12 invariants (INV-01..12), full data flow, scoring rules, fidelity application rules, 12 ACs
  • brd.md — problem statement, 40–60% token reduction target, stakeholders
  • srs.md — 35 FRs (EARS notation), 10 measurable NFRs
  • plan.md — Phase 1 MVP + Phase 2 deferred + risk register
  • tasks.md — 10 granular developer tasks (T-01..T-10)

MVP scope (Phase 1, v0.21)

  • ContextFidelity { Full, Compressed, Placeholder } enum in zeph-common
  • Heuristic FidelityScorer in zeph-context (temporal decay + role importance + keyword overlap + plan relevance)
  • Proactive regrade trigger at configurable budget threshold (regraded_this_turn re-entry guard)
  • PlannedToolHint type in ContextBuildRequest
  • Fidelity application in assembler.rs (AFTER apply_prepared_context())

Deferred (Phase 2)

  • RL training pipeline (AgeMem full GRPO)
  • Orchestration DAG wiring for PAACE lookahead
  • Embedding-based semantic scoring
  • Fidelity persistence across sessions

Critical invariants

  • INV-01: Fidelity scoring only after apply_prepared_context() returns (index invalidation prevention)
  • INV-02: Placeholder messages excluded from hard compaction summarizer input
  • INV-03: Tool-use/tool-result pairs downgrade atomically
  • INV-04: No consecutive same-role Placeholder messages in final window
  • INV-05: Fidelity scores normalized by sum of active weights
  • INV-06: regraded_this_turn guard prevents double-regrade

Test plan

  • Spec files build without broken links
  • Follow-up implementation issue created with spec reference
  • Playbook added at .local/testing/playbooks/context-adaptive-memory.md
  • Coverage-status rows added (5 new Untested rows)

Closes #4016
Closes #4017
Closes #4018

@github-actions github-actions Bot added documentation Improvements or additions to documentation size/XL Extra large PR (500+ lines) labels May 28, 2026
Formal spec package for the Context-Adaptive Memory subsystem covering
GitHub issues #4016 (AgeMem proactive summarization), #4017 (Adaptive
Focus Memory three-level fidelity), and #4018 (PAACE plan-aware context
engineering).

Spec includes BRD, SRS (35 FRs, 10 NFRs), main spec with 12 invariants,
implementation plan, and 10 granular developer tasks. MVP scope (v0.21):
ContextFidelity enum in zeph-common, heuristic FidelityScorer, proactive
regrade trigger, PlannedToolHint in ContextBuildRequest. RL training and
orchestration wiring deferred to Phase 2.

Closes #4016
Closes #4017
Closes #4018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/XL Extra large PR (500+ lines)

Projects

None yet

1 participant