Aligns the inherited AI-DnD memory and context foundation with the history,
authority and state model M3-M5 established. Long stories now reach the narrator
through a bounded, lineage-safe, inspectable context rather than a growing
transcript.
This commit includes the corrective work that followed the independent review in
planning/reports/M6-IMPLEMENTATION-REPORT.md. The first implementation reported
E03 as passing and it was not; the report records that history rather than
hiding it.
What was already correct, and was kept rather than rebuilt
Memory lineage. Memories already carried (branch_id, depth) and retrieval
already filtered through the capped-path clause; the ten-step negative control
was measured passing against b7005e6 before any change here. M6 adds the
regression tests that pin it, plus provenance and authority on the result.
Summary lineage — both halves
A summary is a row carrying the coordinate of the last node it covers, and
eligibility is the same head-capped lineage clause memories use. That alone
was not enough: generation was seeded from adventures.story_summary, a
campaign-global column with no lineage, so after a divergence the summariser
was handed the abandoned line's prose and asked to update it. The row it
produced was correctly anchored and therefore looked safe while its sentences
described a story the reader had left.
Generation is now seeded from summaries.current — the same question the
context builder asks — so the input and the output are scoped by one rule.
adventures.story_summary remains a reader-facing mirror for the Plot panel and
the export bundle, kept in step when a summary is written and when the head
moves, and nothing authoritative reads it.
Retrieval redundancy
With a real embedding model, four near-identical memories crowded out the one
distinctive clue, which survived only because the default memory_top_k is 5.
Retrieval now drops a candidate that repeats one already chosen, never across
authority classes, at a threshold measured against the configured embedding
model. The clue is retrieved at top_k 5, 4 and 3. Ranking itself is unchanged;
the further factors CONTEXT-AND-MEMORY §20 contemplates remain unimplemented
and are recorded as such.
Memory authority, budgeting, observability
Memory.authority is accepted_story or heuristic, classified by the application
and marked in the prompt; retrieval never writes state. The reply is reserved
out of the context budget, and an impossible configuration fails clearly
instead of overflowing. Each derived pass records ok/idle/failed per campaign,
served by GET /adventures/{id}/derived and shown in Insights, so the M2
failure — a dead memory bank with a green suite — is visible if it recurs.
Provider-wiring tests mock no factory.
Also: two pre-existing test-suite leaks fixed; two fixtures that stored one
vector in every memory now use distinct ones, so lineage assertions stay
readable alongside redundancy suppression.
Planning: CONTEXT-AND-MEMORY, TECHNICAL-DESIGN, DATA-MODEL, V1-ACCEPTANCE-TESTS,
BUILD-MILESTONES, VERSION and planning/README updated to describe what exists,
including that a valid E03 test must regenerate a summary after diverging. The
M5 report was rotated to planning/archive/milestone-reports/. No new ADR — every
choice implements a decision the package had already settled.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWU4gTfLYY6Qq9U7aa9Qw2
Archive — historical material, not authoritative
Everything under planning/archive/ is evidence and history. None of it
governs current implementation. If an archived document and an active planning
document disagree, the active document is right and the archived one records
what was believed or measured at the time.
Do not consult this directory during ordinary milestone work unless an active document sends you here for a specific piece of historical evidence.
What is here
phase0/ — why AI-DnD was selected
Phase 0A static research and Phase 0B local validation, closed 2026-09-01.
| File | What it is |
|---|---|
RESEARCH-PLAN.md |
The question Phase 0 existed to answer, and its final dispositions. |
PRELIMINARY-RECOMMENDATION.md |
The Phase 0A conclusion, from static review alone. |
REUSE-MATRIX.md |
What each candidate offered against the required subsystems. |
AI-DND-ANALYSIS.md |
The selected base, analysed before the fork. |
AI-ADVENTURE-ANALYSIS.md |
The rejected finalist still cited as the implementation reference for typed state events. |
OPEN-DUNGEON-ANALYSIS.md |
The rejected finalist still cited as the UX/future-media reference. |
PHASE-0B-RECOMMENDATION.md |
The strongest single document. The measured Phase 0B findings and the fork decision. |
PHASE-0B-BASELINE.md |
Clean clones, builds and test runs for the three finalists. |
PHASE-0B-AI-DND-EXPERIMENT.md |
AI-DnD driven against a real local Ollama. |
PHASE-0B-AI-ADVENTURE-OLLAMA.md |
ai-adventure's Ollama and service-boundary behaviour. |
PHASE-0B-OPEN-DUNGEON-HISTORY.md |
Whether Open Dungeon could be retrofitted with history. |
PHASE-0B-OFFLINE-NETWORK.md |
What each candidate reached for with no route to the Internet. |
PHASE-0B-UNDO-SPIKE.md |
The disposable spike that proved non-destructive undo/redo, and became ADR 012's architecture. |
PHASE-0B-FOLLOWUP-CHECKS.md |
The world-state protocol, export/head, story-card lineage and Postgres checks. |
Phase 0A discovery and triage material (the candidate inventory, source index, reference-project list, licensing and static-privacy reviews, the Phase 0A status page) and the Phase 0B execution prompts were deleted in the 2026-09-03 documentation cleanup. They are intermediate working documents whose conclusions all reached the two recommendation reports above, and they remain in Git history.
milestone-reports/ — completed milestone evidence
M1-BASELINE-REPORT.md, M1-IMPLEMENTATION-REPORT.md,
M2-BASELINE-REPORT.md, M2-IMPLEMENTATION-REPORT.md,
M3-IMPLEMENTATION-REPORT.md.
M3's report is both its review and its primary evidence record; no separate M3 baseline report was produced. It arrived here when M4's report landed.
Every architectural conclusion these reports reached has already been applied to
the active planning documents and the ADRs — see planning/VERSION.md, which
lists the corrections each milestone produced. The reports are kept for their
measurements and their reasoning, not as instructions.
The current milestone's report stays in planning/reports/ while it is
still useful for reviewing the next milestone, and moves here when it is not.
decisions/ — superseded or completed ADRs
008-phase0-before-build-plan.md — a process gate ("do not start production
work before Phase 0 closes") that Phase 0 satisfied on 2026-09-01. It
constrains nothing now. ADR numbering continues from 012 in
planning/DECISIONS/; 008 is not reused.
A note on paths inside these files
Archived documents are kept verbatim. File paths written inside them refer to where those files lived when the document was written — before this archive existed, and in some cases before files were deleted. That is deliberate: an evidence record that has been quietly edited is no longer evidence. Resolve any such path against Git history, not against the current tree.