10-day Week 5 Memory workflow implementation plan.

The goal is not “search old claims.” The goal is:

ClaimFlow observes past workflow outcomes
→ writes useful memory
→ retrieves relevant memory for a future claim
→ uses memory safely in agent routing
→ updates memory after the future outcome
→ generalizes repeated patterns
→ evaluates the full loop

This fits your original Week 5 goal: use past corrections, claimant history, policy history, vendor history, rejection reasons, and recurring error patterns as workflow memory, not generic chat memory.

Your current repo already has the raw ingredients: review decisions store corrected JSON and reviewer notes, and the agent context already loads current run state, review task, coverage question, events, and previous agent actions.


Final Week 5 architecture

Existing ClaimFlow state
= short-term memory

WorkflowMemory rows
= long-term episodic memory

Repeated pattern memories
= semantic memory

Prompt + guardrails
= procedural memory

MemoryHit rows
= memory retrieval/use audit

MemoryUpdate rows
= memory learning/update trail

New flow:

Upload / extract / validate / RAG
→ write or retrieve workflow memories
→ add top relevant memories to agent context
→ agent routes safely
→ guardrails block unsafe memory use
→ human review confirms or contradicts
→ memory is strengthened, weakened, retired, or generalized

Day 1 — Add memory taxonomy + DB architecture

New architecture added

Add the core memory tables:

WorkflowMemory
MemoryHit
MemoryUpdate

Meaning:

WorkflowMemory = what ClaimFlow remembers
MemoryHit = when a memory was retrieved for a claim
MemoryUpdate = how future outcomes changed that memory

Add memory kinds:

HUMAN_CORRECTION
PRIOR_REJECTION
PRIOR_REVIEW_DECISION
CLAIMANT_PATTERN
VENDOR_PATTERN
POLICY_HISTORY
RECURRING_ERROR_PATTERN

Add memory statuses: