M10: the seam for media, and no media
CI / Backend tests (push) Canceled after 0s
CI / Frontend lint + build (push) Canceled after 0s
CI / Docker image builds (push) Canceled after 0s

The media extension contract asks for a scene snapshot a future image or video
provider could be handed: location, who is present, what they hold, what must
stay true, and where in the story it sits. Building one was the milestone's
obvious first task, and it was the wrong one. That snapshot has existed since
M5. `narrative_state["scene"]` holds the summary, the location, the cast and the
coordinate it was written at; a validated `set_scene` event writes it, every
position snapshots it, and every head move restores it. It survives Undo, Redo,
Retry, divergence, Save Point restore and a process restart because it is the
authoritative state rather than a copy of it.

So there is no scenes table here. A second scene store would have been a second
answer to "where is the story now", with its own lineage rules to get wrong —
and the lineage rules are the expensive part, which is the argument for reusing
the ones that already work rather than against it. The Scene Packet is derived
on read, and its identity is computed from the campaign and the position rather
than allocated: the same position yields the same id in another process, after a
restart, and after the packet is thrown away and rebuilt, with no row to keep in
step. That is the part of a future media_assets table that would be expensive to
retrofit, so it is fixed now even though the table is not built.

One table, then: visual_profiles, the only thing the contract's scene list asks
for that nothing already stored. Campaign-scoped and not per-position, because a
character does not change appearance when the story forks — a reader who
diverged would otherwise lose their cast, and the same descriptors would land in
every per-position snapshot, measured at 245 copies of 367 bytes in a 120-turn
campaign to say something that never varies. Keyed by the M5 entity key rather
than a new identity namespace, and one table for characters, locations and items
alike, because a location is an entity with a type and splitting them would
reintroduce the genre shape M5 spent a milestone removing.

What the packet leaves out is the more interesting half. Not the transcript, and
not imported knowledge — none of it, not merely the sources marked hidden. The
rule is what the story established at this position, not everything the narrator
was told, and drawing it by class is what makes it hold for a secret nobody
thought to mark. A hidden Canon source proves it, with a positive control
showing the narrator did receive the sentinel the packet does not carry. Once a
validated event puts the observer in the room, the observer is in the packet:
that is no longer narrator-only knowledge, and a packet that hid it would be
hiding the story from itself.

The providers are contracts and nothing else. Protocols for image, video, audio,
speech and transcription, an empty registry, no adapter, no dependency, no
socket, and no media setting to point anywhere — a setting that exists can be
pointed at a cloud by mistake. A future provider endpoint must be loopback,
stricter than narration's trusted-LAN allowance, because a picture of a scene
carries the scene with it. Transcription returns an editable draft with no
commit method, so STT structurally cannot bypass the authoritative path.

Nothing here can write the story. Not by convention: no module under media/
imports the code that writes state, no media event type exists in the state
vocabulary, and every test in the authority suite compares the authoritative
document byte for byte either side of a media operation — including one where a
provider insists Alice is in a red coat in a corridor, and the campaign goes on
disagreeing.

One defect, found by the milestone's own tests. M10 first added a migration
creating an index that create_all already builds from the column, so an upgraded
database ended up with two indexes and a fresh install with one. Comparing the
two schemas is what caught it; neither database examined alone would have. The
migration is gone rather than renamed, and the right number of migrations for a
new table whose indexes are declared on its columns is zero.

Backend 1,191 passed / 14 skipped / 0 failed, 89 of them M10's. Frontend 145
passed. Lint, production build and Docker build clean. No frontend file changed:
M10 adds no reader-facing surface, and ordinary play — turns, state, memory,
knowledge, Undo, Redo, Retry, Save Point restore, restart — runs with no media
configuration, no warning, no connection attempt and no media row written.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qyn3oRd4D6pi72nKBG725B
This commit is contained in:
JesseMarkowitz
2026-09-07 03:41:04 -04:00
co-authored by Claude Opus 5
parent 44edece67e
commit 1013c94eb1
27 changed files with 5235 additions and 23 deletions
+58
View File
@@ -1098,6 +1098,64 @@ microphone/audio -> local STT -> editable draft -> normal user submission
STT never bypasses the ordinary authoritative story commit path.
### 15.1 As implemented (M10)
The boundary above is built. What follows is what it turned out to be.
**The scene snapshot was already there.** §15 says "persist or derive", and the
answer is *derive*, because M5 had persisted it three milestones earlier:
`narrative_state["scene"]` holds `summary`, `location`, `present[]` and the
`at: {branch_id, depth}` coordinate, written by the validated `set_scene` event
and snapshotted per position. It already restores correctly through Undo, Redo,
Retry, Save Point restore and divergence, because the head move restores the
whole state document and the scene is part of it. A second scene store would
have had to reimplement all of that, and would have been a second answer to
"where is the story now".
So the seam is three modules under `app/media/`, and only one of them has a
table:
```text
app/media/packet.py the normalized scene packet §15 names, built on read
app/media/profiles.py visual character/location profiles — the one field in
§15's list that nothing already stored
app/media/providers.py the contracts a future coordinator implements
```
`GET /api/adventures/{id}/scene-packet` returns the packet; the four
`visual-profiles` endpoints read and write profiles. Nothing else in the
application calls either — no turn, no prompt, no context section.
**What the packet contains, and the rule behind it.** Location, characters
present with their profiles, significant objects, an action summary, continuity
constraints, ambience, the source turn range and the lineage coordinate. What it
deliberately excludes is the more interesting half: the raw transcript, all
imported knowledge, memories and summaries. The rule is *what the story
established at this position*, not *everything the narrator was told* — which is
what keeps a hidden Canon source out of a depiction without needing a filter
that someone has to remember to apply to each new secret.
**Story engine functional with media disabled** is the milestone's central
acceptance condition rather than a footnote, and it is tested as one
(`backend/tests/test_m10_no_media.py`): a whole campaign — turns, state
extraction, memory and summary activity, knowledge retrieval, Undo, Redo, Retry,
Save Point restore, restart — with an empty provider registry, no media setting
in existence, and no media row written. Media readiness is inert until something
uses it, and nothing does yet.
**STT asymmetry.** The `TranscriptionProvider` contract returns a
`DraftTranscription` with `editable: bool = True` and no commit method, so the
diagram above is enforced by the shape of the interface: a transcriber can
produce a draft and cannot submit one. The ordinary authoritative commit path is
the only way in.
**Endpoint policy.** A future media provider endpoint is checked by
`providers.endpoint_rejection_reason`, which reuses the local-only policy in
`app/endpoints.py` and then requires loopback in addition — stricter than
narrator inference, which permits a trusted LAN host. A GPU that renders a
reader's campaign is a machine that reader is sitting at. No provider
configuration setting exists to point anywhere, because none is needed yet.
## 16. Database Direction
SQLite remains the selected v1 authoritative store.