[MEMPALACE][MP-2] Enforce retrieval-order — palace first, generation last #369
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of epic #367 | Depends on #368
Why
This is the single most important behavioral change for elegant memory. Right now, agents faced with a recall-style question ("what did we do yesterday?", "what's the status of issue #X?") generate from vibes instead of checking their palace drawers first. The result is hallucination dressed up as memory.
The fix is a retrieval-order enforcer: a middleware that intercepts recall-style prompts and routes them through a defined lookup chain before allowing free generation.
Retrieval Order
Implementation
1. Recall Detector (
scripts/skills/recall_detector.py)Heuristic classifier that detects recall-style prompts:
Returns a confidence score and suggested retrieval layers.
2. Retrieval Chain (
scripts/skills/retrieval_chain.py)Given a recall-classified prompt:
3. Honest Fallback
When the palace has no relevant data, the agent says so:
Not:
Acceptance Criteria
docs/MEMORY_ARCHITECTURE.mdMP-2: Retrieval Order Enforcer — Complete
Created
hermes-sovereign/mempalace/retrieval_enforcer.py:Layers:
~/.mempalace/identity.txt, capped at 200 tokens)Features:
is_recall_query()regex detection for 16 recall patternsenforce_retrieval_order()with skip_if_not_recall gatelayers_checkedtracking in result dict17 tests — all pass.
PR: #374