feat(memory): replace legacy file-based memory system with native MuninnDB integration#218
Closed
Aperrix wants to merge 16 commits into
Closed
feat(memory): replace legacy file-based memory system with native MuninnDB integration#218Aperrix wants to merge 16 commits into
Aperrix wants to merge 16 commits into
Conversation
Aperrix
force-pushed
the
feat/muninndb-integration
branch
5 times, most recently
from
March 7, 2026 13:56
80ec0c3 to
53c7cd9
Compare
MuninnDB replaces the file-based rolling summary as the cross-phase memory system. Remove all traces: - Delete compile-rolling-summary.sh and its tests - Remove rolling_summary config flag from defaults and rollout stages - Clean compile-context.sh: remove ROLLING_CONTEXT injection and Activity Log blocks from all 6 role templates - Clean cache-context.sh: remove rolling context fingerprint from cache key computation - Clean bootstrap-state.sh and persist-state-after-ship.sh: remove Activity Log generation and extraction - Clean templates/STATE.md: remove Activity Log section - Clean vibe.md: remove deprecated rolling summary compilation step - Clean execute-protocol.md: replace REQ-03 rolling summary block with MuninnDB consolidation reference - Clean compaction-instructions.sh and post-compact.sh: replace rolling context re-read instructions with MuninnDB recall - Remove rolling_summary references from all test files
Add MuninnDB as native memory infrastructure for VBW: - Add muninn-setup.sh: vault creation with REST API retry (3x with backoff), MCP config detection, API token resolution - Extend init.md Step 0.6: vault setup with muninn_guide call, hard failure on REST API or vault creation errors - Add doctor.md check swt-labs#16: MuninnDB binary, health, and vault verification - Add status.md MuninnDB section: vault name and health indicator - Add session-start.sh warning when MuninnDB is not running - Add muninndb_vault to config.md settings reference and README - Add muninndb_vault to bootstrap-claude.sh env export
MuninnDB is now native infrastructure, not an optional addon. Remove
all conditional language ("if muninn_activate is available") and add
explicit failure handling per role:
- Lead/Architect: STOP on MuninnDB failure (planning depends on
prior decisions)
- Dev: send blocker_report to Lead on failure
- QA: report "⚠ unavailable" in verification output
- Scout/Docs/Debugger: report "⚠" in output section
Also:
- Add muninn_guide call to compile-context.sh cross-phase memory hint
- Make muninn_consolidate MANDATORY at phase end in execute-protocol
- Keep V2 envelope reference in execute-protocol message send section
New test files: - muninn-setup.bats: 10 tests covering vault creation, REST API retry logic, MCP config detection, error handling - muninn-integration.bats: 18 tests verifying MuninnDB is referenced unconditionally across all agents, compile-context, init, and session-start Updated tests: - role-isolation.bats: verify V2 Role Isolation heading in all agents, lease in V2 gate sequence reference - Rename muninn-v2-integration.bats → muninn-integration.bats - Minor test description updates for consistency
Aperrix
force-pushed
the
feat/muninndb-integration
branch
from
March 7, 2026 14:13
53c7cd9 to
57a3c7b
Compare
- Fix duplicate/misplaced comment block in compile-context.sh: the codebase mapping hint helper comment was stranded above emit_muninn_memory_hint() instead of above emit_codebase_mapping_hint() where it belongs - Fix missing blank line before ## Output Format heading in doctor.md
- Make agent MuninnDB reference tests fail explicitly per-agent instead of silently skipping missing files (muninn-integration.bats) - Remove no-op assertion in muninn-setup --check test: `|| true` made the exit status check always pass regardless of actual result
- Remove stale "Activity Log" reference from vibe.md archive step: Activity Log was removed from STATE.md in this PR but the description still listed it as a milestone-specific section - Add "Memory" to the list of project-level sections preserved across milestones
Phase-aware warnings when muninn_activate returns 0 results in Phase 2+ (expected in Phase 1, suspicious later). Standardize explicit results handling across all 6 agents. Add memory_recalled field to SUMMARY.md template for audit trail. Instruct Dev/Docs to populate it and QA to verify it.
P0-1: Debugger now stores bug resolutions and patterns back to MuninnDB via muninn_remember after diagnosing/fixing. P0-2: All 7 compaction instruction roles and post-compact.sh now include muninn_guide call before muninn_activate, matching agent file requirements. Also adds missing codebase re-read for docs agent compaction. P0-3: All 7 agents and compile-context.sh now guard against empty muninndb_vault — report warning and continue without memory instead of passing empty string to MuninnDB calls.
SubagentStart hook (muninn-vault-gate.sh) blocks Lead/Architect spawn when vault is unconfigured. PostToolUse hook (validate-summary.sh) checks memory_recalled field in SUMMARY.md frontmatter.
P1-3: QA agent now stores contradictions, useful verification patterns, and pre-existing failure classifications to MuninnDB after verification. P1-4: Added docs role to compile-context.sh — Docs agents now receive the same phase context (goal, criteria, conventions, MuninnDB hint, codebase mapping) as all other roles. P1-7: Created references/muninn-types.md documenting canonical engram types (Issue, Observation, Decision, Task) and their usage by each agent.
P1-2: Phase-end consolidation now collects engram IDs via muninn_activate before calling muninn_consolidate, matching the ship-time pattern. Prevents unscoped vault-wide consolidation. P1-5: Discussion engine now recalls prior decisions via muninn_activate before generating gray areas, and stores decisions via muninn_decide after capture.
Tests for: vault gate with no project dir, missing config, missing vault key, compile-context with empty/missing config, validate-summary edge cases, agent failure behavior specs, session-start health check.
Added muninndb_port_mcp and muninndb_port_rest to defaults.json. Updated session-start.sh and muninn-setup.sh to read ports from config instead of hardcoding. Expanded references/muninn-types.md into a full MuninnDB reference documenting all config parameters, recall limits (10 for planning agents, 5 for task agents), and score thresholds.
…ngrams P2-1: Lead and Architect now call muninn_contradictions pre-planning to catch conflicting prior decisions before decomposing, preventing rework discovered during QA. P2-7: compile-context.sh emits role-specific memory hints — QA gets contradictions reminder, Debugger gets bug-focused context guidance, Scout gets prior research check, Lead/Architect get contradictions. P2-8: Compaction wildcard fallback now includes MuninnDB recovery instructions for inline orchestrator sessions. P2-9: Phase-level outcome engram stored before consolidation at phase end, ensuring downstream phases can recall what was delivered even after individual task engrams are consolidated.
P2-2: Memory observability metrics (muninn_recall/store/unavailable events) P2-3: memory_recalled enrichment with scores, extend to PLAN.md and VERIFICATION.md P2-4: Engram lifecycle management — archived tagging at milestone ship P2-5: Scout post-research consolidation in Lead agent P2-6: Session-start hardening — REST API check, vault existence verification P2-10: MuninnDB recall/storage in /vbw:verify P2-11: Tests for consolidation calls across protocol/vibe/lead P2-12: Tests for session-start dual-port health check P2-13: Tests for doctor check 16 config-driven ports P2-14: Session-start health check latency reduced (2s → 1s) P2-15: README MuninnDB section with setup, usage, and guardrails P2-16: Troubleshooting guide at docs/muninndb-troubleshooting.md P2-17: Vault isolation with multi-project collision detection
Member
|
Closing as Muninn's license isn't permissible in an MIT project so it wouldn't be compatible with VBW. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Fixes #219
What
Remove the legacy file-based memory system and make MuninnDB the native, unconditional memory infrastructure for all VBW agents. This eliminates dual code paths, removes silent bypass risks, and establishes a single contract: agents always use MuninnDB, and every failure is explicitly reported.
Why
VBW's cross-phase memory was historically handled by
compile-rolling-summary.sh, which concatenated allSUMMARY.mdfiles into a singleROLLING-CONTEXT.mdfile, then injected its content verbatim into agent context at compile time. This approach has structural limitations:MuninnDB replaces this with
muninn_activate(vault, context), which performs semantic search and returns only relevant memories ranked by similarity score. The agent gets what it needs, at the moment it needs it, without reading a growing file.The integration up to now was hybrid: MuninnDB was added alongside the old system with feature flags (
muninndb: true,rolling_summary: false), conditional guards (if muninn_activate is in your available tools), and silent fallbacks (if the tool call fails: proceed normally). This created three concrete problems:compile-rolling-summary.shand MuninnDB memory calls had to be kept in sync. Changes to cross-phase memory required updates in two systems.rolling_summary,muninndb) existed to gate the same capability. The brownfield migration system had to handle both, adding complexity tomigrate-config.sh.How
Architecture change: compile-time injection → runtime retrieval
The fundamental shift is when and how agents access cross-phase memory.
Before:
compile-context.shreadROLLING-CONTEXT.mdand injected its content into.context-{role}.mdfiles for each of the 6 compiled roles (lead, dev, qa, scout, debugger, architect). Each agent received the full concatenated history as a static text block in its context window.After:
compile-context.shemits a "### Cross-Phase Memory" hint via a newemit_muninn_memory_hint()function, instructing the agent to callmuninn_guide(vault)thenmuninn_activate(vault, context)at runtime. The agent performs the retrieval itself, scoped to its current task, and receives only semantically relevant results.This moves memory access from a static compile-time operation to a dynamic runtime operation, which is both more relevant and more token-efficient.
Agent contract: unconditional calls with role-specific failure severity
All conditional MuninnDB language has been removed from the 7 agent files. There is no
if available, noif NOT available: skip, noproceed normallyfallback. Agents call MuninnDB tools unconditionally.Each role has an explicit, differentiated failure behavior:
blocker_reportto LeadThe severity distinction is intentional: Lead and Architect produce planning artifacts that downstream agents depend on — memory gaps here propagate. Dev, QA, Scout, Docs, and Debugger produce task-level output where a memory gap is visible but not structurally propagating.
Recall guardrails
Semantic retrieval is probabilistic — if the
contextstring doesn't match well, critical prior decisions can be silently omitted. Multiple guardrails address this:1. Phase-aware 0-result warning. All 6 agents that call
muninn_activatenow have standardized handling:[concept] — [how it informs approach]⚠ Memory recall returned 0 results despite prior phases — verify context parameter or check vault healthMemory: no prior context (first phase)The context compiler (
compile-context.sh) also emits a phase-aware warning viaemit_muninn_memory_hint($PHASE, $ROLE)when phase > 1, with role-specific guidance (QA→contradictions, Debugger→bug context, Scout→prior research, Lead/Architect→contradictions).2. Memory audit trail. A
memory_recalledfrontmatter field with concept names and relevance scores records what was consulted:"concept-name (score: 0.8)"["none"]. If MuninnDB unavailable:["unavailable"]["none"]in Phase 2+ as a warning3. Deterministic hook enforcement. Two hooks provide deterministic (not prose-based) guardrails:
muninn-vault-gate.sh(SubagentStart): Blocks Lead and Architect from spawning when vault is unconfigured (exit 2). Advisory warning for other roles.validate-summary.sh(PostToolUse): Warns when SUMMARY.md is missing thememory_recalledfrontmatter field.4. Contradiction detection. Lead (Phase 2+) and Architect (non-first milestone) call
muninn_contradictions(vault)before decomposing/scoping to catch conflicting prior decisions pre-planning.muninn_guideas mandatory first callAll 7 agents now call
muninn_guide(vault)before any other MuninnDB tool. This retrieves vault-specific instructions, ensuring agents use the correct vault interface. The call is integrated at three levels:emit_muninn_memory_hint()output.muninn_guidein compaction instructions.Engram lifecycle management
Storage: Agents store engrams after work:
muninn_decide), bugs (Issue), patterns (Observation)Task), decisionsObservation)Issue), verification patterns (Observation), pre-existing failuresDecision)Issue)Phase-end: Orchestrator stores a phase-level outcome engram (
muninn_rememberwithtype: Decision, tags:[phase:{N}, outcome]) before consolidation, ensuring downstream phases can recall what was delivered.Consolidation: Phase-end and milestone-ship consolidation via
muninn_consolidatewith scopedmuninn_activate(score > 0.3) to collect relevant engram IDs.Archival: At milestone ship, engrams are tagged
[milestone:{SLUG}, archived]via a milestone-level bookmark engram.Session-start health check
Session start checks both MCP (port from
muninndb_port_mcp, default 8750) and REST API (port frommuninndb_port_rest, default 8475) with--max-time 1. When vault is configured, it verifies the vault exists on the server. Status messages:MuninnDB: active (vault: {name})— both ports healthy, vault exists⚠ vault '{name}' not found— server running but vault missingMuninnDB: MCP active (vault: {name}, REST API not responding)— partial⚠ MuninnDB: NOT RUNNING— both ports unreachableMulti-project vault isolation
muninn-setup.shdetects vault name collisions when two projects share a MuninnDB instance. If a vault with the derived name already exists and belongs to a different working directory, a hash-based disambiguator is appended to prevent cross-project memory pollution.Memory observability
collect-metrics.shsupports MuninnDB-specific events:muninn_recall,muninn_recall_empty,muninn_store,muninn_unavailable,muninn_consolidate,muninn_contradictions. These enable answering "Is MuninnDB actually being used effectively?" via/vbw:status --metrics.MuninnDB in
/vbw:verifyStandalone verification mode now:
muninn_activatebefore generating test scenariosMuninnDB in
/vbw:discussDiscussion mode now:
muninn_activate(Step 1.5) before Orient phasemuninn_decidein Step 4 CaptureDocumentation
docs/muninndb-troubleshooting.md: Common failure scenarios and fixes (server not running, vault missing, 0 results, port conflicts, multi-project collision)references/muninn-types.md: Engram type documentation (Issue, Observation, Decision, Task) and full configuration parameter table/vbw:doctorcheck 16: Updated to read ports from config, check both MCP and RESTTest coverage
79 tests in
tests/muninn-integration.batscovering:muninn_guide,muninntools, empty vault guard, and failure behaviormemory_recalled, passes when present, ignores non-SUMMARY filesCross-reference: agent MuninnDB call matrix
Commits
0709482b1e7ce58d6728c346114329f8dda9cb799a5ca20ba5ae923fb50a7c0Files changed
vbw-dev.md,vbw-lead.md,vbw-qa.md,vbw-scout.md,vbw-debugger.md,vbw-architect.md,vbw-docs.mdverify.md,vibe.md,doctor.mdcompile-context.sh,session-start.sh,compaction-instructions.sh,muninn-setup.sh,collect-metrics.sh,muninn-vault-gate.sh(new),validate-summary.shexecute-protocol.md,discussion-engine.md,muninn-types.md(new)defaults.json,hooks.jsonSUMMARY.mdmuninn-integration.bats(79 tests),test_helper.bashREADME.md,docs/muninndb-troubleshooting.md(new)Notes
muninn_contradictionsin QA is non-blocking by design (supplementary check), but explicitly reports failure instead of silently skipping.two-phase-completion.bats(artifact-registry: register creates entry) is unrelated to this PR.