Tracker Transitions — Design Document
Status: ✅ shipped 2026-10-29 as chat events M1 (scene directions on chat., lines on every reading surface; 19adee20e / eea8d9b8a, live-checked 2026-10-29, pushed with origin/develop f25b4ad4b). Planned 2026-10-17. Mockup: docs-internal/mockups/TrackerTransition.dc.html.
"when tracker is updated, make offer to make it a transition instruction for the LLM. file in the ledger to plan and see how it would look" — owner, 2026-10-17
This page builds on Trackers (Phase 1 shipped; typed values; per-message snapshots), the chat. scene
editor (docs-internal/architecture/consoles/CHAT_STORY_SURFACE.md → Scene editor, Q1, B4), the
Author's Note current-turn slot, and the self-guarding feature pattern
(docs-internal/architecture/chat-engine/CLASSIC_PIPELINE_SIMPLIFICATION.md §7).
Overview
The reader can change the scene in chat.: open the scene editor, move Location from Tannery Row to Harbour market, raise Affection by 10, put a watch ledger in Kaelen's pack, and Save. Today that save is a correction: it rewrites the latest reply's snapshot, and the next reply reads the new state as if it were already true. The story never shows the move. The characters are suddenly at the harbour, and the prose either jumps there or ignores it.
A tracker transition is the other thing the reader often means: "make this happen in the story." When the reader changes trackers, the editor offers to turn the change into a scene direction for the next reply: "Location: from Tannery Row to Harbour market. Show it happening." If the reader takes the offer, the change is not written onto the past. The next reply is asked to play it out, and when that reply lands, its snapshot carries the values the reader set. The change shows under the reply that narrated it.
The reading, and what it corrects
The director read the ask as: after a tracker edit, offer a one-shot instruction for the next reply, built from the before and after values. That reading holds, with two corrections found in the code:
Only the Now view edits. After this reply is read-only (
SceneEditor.tsx,readOnly = showingPast || …;SCENE_COPY.pastIsReadOnly). The offer exists only where an edit exists: the Now view of the chat. scene editor, on the margin (desktop) and the sheet (phone).Accepting the offer can't also write the snapshot. A save writes onto the latest reply's snapshot (B4: "Save corrects the snapshot the next update reads"). Three readers treat that snapshot as what that reply's prose established:
- the stage direction under the reply, built from the two snapshots either side of it
(
sceneModel.tsbuildScene→snapshotChanges(prior, point.trackerJson)); - the summary timeline (
TrackerTimeline.Build), which folds the window's snapshots into Tannery Row → Harbour market; - the state block the next turn injects after that reply (
WebTrackerHistoryInjector), which would say Location: Harbour market (already there) beside a direction saying move there.
Write-then-direct makes all three lie: the previous reply's stage direction would read Location → Harbour market under prose set in Tannery Row. So an accepted offer stages the change: the snapshot stays, and the targets ride the direction onto the next reply.
- the stage direction under the reply, built from the two snapshots either side of it
(
Alternatives considered
| Shape | What it does | Why not |
|---|---|---|
| A. Write now, then direct (the director's literal reading) | Save corrects the latest snapshot; a separate one-shot note asks the next reply to narrate it | Misattributes the change to the previous reply (stage direction, summary timeline), and the state block contradicts the direction. Undoing it later means a compensating snapshot write racing the eval |
| B. Stage, then land (chosen) | The change becomes a pending direction with target values; the next reply is asked to play it out; its snapshot takes the targets | — |
| C. Put it in the Author's Note with a one-turn life | Reuses the note's field | One note per conversation (web_conversations.author_note): it would overwrite the reader's own note, and its countdown, pause and expiry notice mean something else |
| D. Append it to the reader's message as out-of-character text | No new storage | Pollutes the reader's words in the transcript and in the eval's input; Hybrid can't strip it from the prose leg, because it carries no marker |
| E. A creator-authored transition rule per tracker ("when Location changes, describe the journey") | Creator phrasing | The eval's own updates already come from prose, so they need no instruction. Only the reader's edits do. Kept as a later, optional phrasing override (Non-Goals) |
| F. Have a model write the proposal | Nicer sentences | A model call on every edit: cost, latency, a failure path in the editor, and nondeterministic words the reader must review anyway. The story model already turns a plain direction into prose; the proposal only has to be clear |
Design Goals
- A correction and a transition are different intents, and both stay one Save away. The reader chooses; Save commits either one.
- The record tells the truth. A snapshot only carries what its reply established. A directed change appears under the reply that played it out.
- Built from the values, never by a model. The proposal uses the stage direction's own vocabulary, per type, and the reader can edit it.
- One-shot, and replayable. It steers exactly one turn. A regenerate of that turn gets it again; later turns never see it.
- Reuse the channels that exist. The current-turn slot (
ICurrentTurnMessageInjector), its typed marker, the Hybrid director-only strip, the context-budget line, the scene save's validation and screens. - No trackers, no offer. The feature guards itself on the Trackers switch (§7).
Non-Goals
- The writing client.
clientConsolechat-v2's tracker bar edits any message's snapshot (carry-forward from that point). Those edits are corrections of the past, and they stay corrections. chat-v2 stays as it is (CHAT_STORY_SURFACE.md Non-goals). - Edits from After this reply. That view is read-only.
- Discord, the visual novel console. Web chat. only. The VN has its own scene engine (
SceneState/SceneMenusources). - Changing the tracker eval's prompt or adding an eval call. The eval runs as today; the targets are laid over its result for the directed keys (Landing).
- A creator-authored phrasing per tracker. The template is type-generic. A per-tracker phrasing override (on the definition, next to the eval hint) is a possible Phase 2, once the generic wording has met real stories.
- Directing changes the eval made. Only the reader's edits get an offer.
The design
When the offer appears
In the scene editor's Now view, as soon as the draft changes at least one tracker the reader can see, an offer card appears above the Cancel / Save pair. It is part of the form, not a second dialog (the form pattern: one pair per form). It reads:
Play it out in the next reply? Location: from Tannery Row to Harbour market. · Affection rises by 10, from 40 to 50. · Kaelen carries gains watch ledger. Skip · Use
- Use arms the transition. The card opens into an editable text field holding the proposal, under the line "The next reply shows these changes happening. The scene changes when it lands." Save's label reads Save for the next reply.
- Skip dismisses the card for this editing session. Save stays Save and corrects the scene, as today. A small Offer it again link brings the card back while the editor is open.
- While armed, the card's proposal follows the draft until the reader types in the text field. After that the text is the reader's: a further draft change appends the new clauses at the end. It never rewrites what the reader typed.
- Cancel discards the draft and the offer together.
- The card never appears when the draft only resets a tracker to its starting value (Reset). A reset is a correction by nature.
The proposal: one template per type
Built in one place, a shared TypeScript function beside changeText (shared/src/chat/trackers/, so the stage
direction and the proposal speak the same language). One line per changed tracker, in the creator's order, each a
plain clause. The tracker's name carries no meaning the template can use: Location is not known to be a place. So the
template is generic, and the editable text is what rescues it.
| Type | Before → after | Clause |
|---|---|---|
| Freeform | Tannery Row → Harbour market | Location: from Tannery Row to Harbour market. |
| Freeform, from unset | — → dry, cold wind | Weather: becomes dry, cold wind. |
| Freeform, cleared | dry, cold wind → — | Weather: no longer dry, cold wind. |
| Number | 40 → 50 | Affection rises by 10, from 40 to 50. (falls by …) |
| Percentage | 80% → 62% | Ward strength falls from 80% to 62%. |
| One of a set | neutral → wary | Ilsa’s stance: from neutral to wary. |
| List | + watch ledger, − 3 silver | Kaelen carries gains watch ledger and loses 3 silver. |
| List, emptied | → [] | On stage: now empty. |
| Date / time | 11:40 pm → 11:52 pm | Time: from 11:40 pm to 11:52 pm. |
Multiple changes in one save merge into one direction, one clause per line. The reader sees the clauses joined by line breaks in the field. A hand-typed value that isn't valid for its type (text in a number tracker) is refused on Save with the scene save's own message, before any direction exists.
The date/time row says no "moves on": a tracker's datetime is written in the creator's example format, and the template can't tell which of two values is later.
What the reader sees after Save
- The scene keeps today's values. Each directed tracker shows its target beside it: Tannery Row → Harbour market · next reply, in the stage direction's italic, tinted like a change.
- The composer carries a scene direction line above the field, like the Author's Note line: Scene direction · next reply with the text's first line, Edit (opens the scene editor with the targets as the draft and the card armed) and Remove (drops the direction; nothing else changes).
- After the next reply lands, the reader's turn carries one quiet line in the story's italic: — Directed: Location →
Harbour market · Affection 40 → 50 · Kaelen carries + watch ledger —. Pressing it shows the full text the model
received. The row stores targets only; the line's before-values come from the scene model the page already builds
(
buildScene'sbeforemap for the reply that follows), so no column is added for them. The reply's own stage direction then shows the same changes. They are now that reply's changes, because its snapshot carries them.
How it reaches the model
Storage — a pending direction on the conversation, consumed onto the turn.
web_conversations.scene_direction(JSONB, nullable):{ "text": "…", "targets": { "location": "Harbour market", "affection": "50", "kaelen_carries": "[\"copied tax roll\",\"watch ledger\"]" }, "edited": false }. One pending direction per conversation. A later Save for the next reply merges into it: targets by key (the later value wins; a key whose target now equals its current value drops out), and the text follows the rule above (regenerated whileeditedis false, new clauses appended once it's true).Written by one SQL function (
fn_set_conversation_scene_direction) behindPUT /api/conversations/{id}/scene-directionand removed byDELETE. The values are validated by the scene save's own validator (types, ranges, sets, list encoding), and the text passes the scene save's word screen plus the Author's Note'sinjection_detectioncheck, with the same ownership-first ordering and the publish edit lock its sibling conversation writes carry. Cap: 1,000 characters, as the note.Stamped on the turn, cleared by a reply. Two steps, so no retry path can lose it:
- When the turn writes the reader's message row, the pending direction is copied onto it
(
web_messages.scene_direction, JSONB, same shape withoutedited). Every regenerate or retry of that turn then replays it from the row. - The conversation's pending direction is cleared only in the transaction that stores a model-written reply. A
turn that ends before the model writes anything leaves it pending: a synthetic exit (the balance gate's
SyntheticReplyWriter, a refusal), a failed call, a turn stopped before its first token. The next new message stamps it again.
Where the reader's row is written relative to the balance gate's synthetic exit is checked at build time; the rule holds either way, because only a model-written reply clears.
- When the turn writes the reader's message row, the pending direction is copied onto it
(
Injection — the current-turn slot.
WebSceneDirectionInjector : ToggleableCurrentTurnInjector, a new base thatToggleableHistoryInjector.csalready anticipates ("One is added with its first toggleable implementer"). It belongs toFeatureId.Trackers: off, it answers nothing and never builds (§7, rule 1).It reads the direction with no I/O: on a new turn, from
WebChatContext.Conversation(the row the turn already loaded); on a regenerate, from the regenerated turn's user row (IPipelineContext.RegeneratedUserMessageId).It emits one user-role block tagged with a new
LlmMessageSource.SceneDirection, rendered by oneSceneDirectionBlock.Render(the injector and/context-budgetboth call it, asAuthorNoteBlockdoes):[Scene direction — the reader changed the story's state. In this reply, show these changes happening in the story, in the characters' voices; don't skip to them, don't list them, and never quote or mention this block.] Location: from Tannery Row to Harbour market. Affection rises by 10, from 40 to 50. Kaelen carries gains watch ledger.Placement: the
beforeCurrentUserslot, after the Author's Note, before the reader's message. The tracker state block before it still shows the true current state (Tannery Row), so the state and the direction agree: you are here; take them there.One-shot by construction. Current-turn blocks are never replayed in history (PROVIDER_PROMPT_CACHING.md §tail: "only this turn"). Later turns see the result, the narrated prose and the new snapshot, never the direction.
Landing — the targets win for their keys. After the reply, the tracker eval runs as today, with the previous snapshot as its prior. Its result is then laid under the targets: for each directed key, the snapshot stores the reader's value; every other key keeps the eval's answer. So the eval can't revert or drift a directed value (the reader said where the scene ends up), and nothing in the eval's prompt changes. If the eval fails, the reply's snapshot is the prior with the targets applied, so the reader never loses the change. This is a deliberate divergence: today a failed eval writes no snapshot (Failed, stats row kept). A directed turn writes one on that path, which also advances the eval's window past this reply.
Regenerate, versions, branch, delete
- Regenerate / swipe of the directed turn re-sends the direction (it lives on that turn's user row) and lands the targets on the new version too. Each version narrates the change its own way; each ends with the targets.
- Edit-and-resend of the reader's message keeps the direction on the row.
- A regenerate while a new direction is pending (made after that reply landed) replays the row's own direction (or none) and leaves the pending one for the next new message. (Open question 2.) A regenerate of a turn that died before its first token replays the direction stamped on its row, which is still the pending one.
- Branch from here: the branch's rows copy their
scene_directionlike every column of the row. The pending direction is not copied: it was made against the parent's latest scene, and a branch from an earlier point has another one. - Delete of the directed reply (the version shown, which takes every version): the direction goes with it, since the turn it directed is gone (owner, 2026-11-02; CHAT_EVENTS.md §5). The scene falls back to the previous snapshot, as any delete does. Deleting a version that isn't shown keeps the direction. Delete of the user row removes it.
Interactions
- Now vs After this reply. The offer only exists under Now. After this reply stays read-only.
- A correction while a direction is pending. A plain Save (offer skipped) still corrects the latest snapshot. A pending target on the same key keeps its value and lands on the next reply.
- Hybrid.
SceneDirectionjoinsHybridProseLeg.IsDirectorOnly, besideAuthorNoteandSceneMenu. The beat director sees the direction in the full context and plans the move. The prose leg gets the beat, not the raw direction, so the prose can't jump ahead of the beat (the Author's Note's reasoning, author-notes.md Mechanism). The targets land on the Hybrid reply's snapshot the same way. - Cost. The block adds tokens to one turn: its header (about 45 tokens) and one line per tracker, usually under 120
tokens in all.
/context-budgetgainssceneDirectionTokens(fromSceneDirectionBlock.Render, priced likeauthorNoteTokens) while a direction is pending, so the context ring and the Echo chip's estimate include it. The turn's reservation andTurnCostQuotecount it. It sits in the volatile tail, after the cache breakpoints, so it changes nothing in what is cached. A regenerate pays for it again, because it's in that turn's prompt. - SFW (all-ages stories). The block is reader-authored text, like the reader's message. The lane treats it the way it treats the reader's own message (CHAT_SFW_MODE.md owns that). No new gate. Its words pass the same screens as a scene save at write time.
- Trackers off. No offer, no card, no composer line. A direction pending when trackers are switched off for the story stays stored but inert. Nothing is injected and no targets land; the composer line reads Scene direction · paused while trackers are off with Remove. (Open question 3.)
- A tracker unbound or hidden meanwhile. A target whose tracker is no longer bound, or no longer Visible to the user, is dropped at landing. The direction's text still goes to the model as the reader approved it — the server never rewords it — and a direction whose every target was dropped is not sent at all (it stays staged, inert, until removed). (Decided 2026-10-29, overnight director.)
- The scene moved on (409). Targets are absolute values, so a newer snapshot doesn't invalidate them. The text was
approved by the reader and is sent as approved: the template lives in one place (the client), and the server never
rewords it. Its
fromhalf can be stale in that case; the state block before it shows the true current state, and the targets are what land.
Implementation Plan (Sliced)
One push unit: the slices below are only honest together (a stored direction nothing injects is a dead control).
| Slice | What |
|---|---|
| S1 — SQL | web_conversations.scene_direction, web_messages.scene_direction, fn_set_conversation_scene_direction, the stamp onto the reader's row and the clear in the reply's storage transaction, branch column copy, idempotent through v1_run_all.sql |
| S2 — Server | PUT / DELETE /api/conversations/{id}/scene-direction (reusing the scene save's validator and screens), SceneDirectionBlock, ToggleableCurrentTurnInjector + WebSceneDirectionInjector, LlmMessageSource.SceneDirection + Hybrid strip, the targets-over-eval landing in the tracker eval's write, /context-budget sceneDirectionTokens, the conversation read and the turn's terminal frame carrying the pending direction |
| S3 — chat. | The proposal template (shared, beside changeText), the offer card in SceneEditor (both densities), the scene's pending marks, the composer's scene direction line, the reader's-turn Directed line |
Open Questions
Owner, 2026-10-28: in chat, tracker changes should be events in the story — and the same model will carry dice roll animations, skill application and inventory application, so it is designed as a whole, not per feature. These defaults are on hold until that design exists; research draft:
docs-internal/architecture/chat-engine/CHAT_EVENTS_RESEARCH.md. The build doesn't take them as written.Decided 2026-10-28:
docs-internal/architecture/chat-engine/CHAT_EVENTS.md§1. Defaults 1–4 and 6 stand; default 5 changes — the direction is one merged event line where the reply's stage direction sits, not a reader-turn line. The storage below (scene_directioncolumns) is replaced by the genericstaged_events/turn_events(CHAT_EVENTS.md §3); S1–S3 are built as that doc's M1. Where this page disagrees with CHAT_EVENTS.md, that doc wins — in particular:
- Stamp and clear are one step. The turn's storage transaction stores the reader row, the reply and the consumed direction together; there is no separate stamp at the reader insert.
- A turn that dies before its first token has no reader row on the standard lane, so there is nothing to regenerate; the direction stays staged and the next send carries it (replaces the edge and the Regenerate bullet that say "a regenerate of that turn sends the direction").
- The slot's emptying reaches the client through the conversation read after
done, not the terminal frame (S2).- The failure-path write (Landing) is the general rule for every event with effects (CHAT_EVENTS.md §6).
Each has a recommended default; the build takes the default unless the owner says otherwise.
- Who wins on the next reply, the reader's target or the eval? Default: the target, for the directed keys only. The alternative (the eval wins whenever it set a value) lets a reply that walks past the harbour end at "the fishmonger's stall", which may be truer to the prose but drops the reader's word.
- A regenerate while a new direction is pending. Default: the regenerate replays only its own turn's direction; the pending one waits for the next new message. The alternative sends the pending one on the regenerate, which makes "edit the scene, then regenerate" a way to redo the last reply with the move in it.
- Trackers switched off with a direction pending. Default: kept and inert, as a paused Author's Note. The alternative drops it.
- Is the offer collapsed or armed by default? Default: collapsed (Skip / Use). The owner's word is "offer". A reader who always wants transitions could get a per-story preference later.
- Show the Directed line on the reader's turn? Default: yes, one italic line, pressable for the full text. It is the only record of why the reply moved the scene. When the eval agrees, it reads the same as the reply's own stage direction one screen below (see the mockup). The alternative folds it into that stage direction as a prefix (— Directed · Location → Harbour market … —) and drops the reader-turn line.
- A per-tracker creator phrasing (Phase 2). Default: not now.
Acceptance Criteria
The feature is not done until every box below is verified ✅ against the running product.
User use cases — satisfiable + accessible (verify by driving the UI, not the code):
- UC-1. As a reader in a chat. story, I can change Location in the scene editor and have the next reply walk the characters there, reachable from the scene margin's Edit (desktop) or the scene pill's sheet (phone), with no knowledge beyond the editor itself.
- UC-2. As a reader, I can change several trackers at once (a location, a number, a list) and send them as one direction.
- UC-3. As a reader, I can reword the proposed direction before saving.
- UC-4. As a reader, I can skip the offer and correct the scene exactly as today.
- UC-5. As a reader, I can see that a direction is waiting (composer line, pending marks in the scene), change it (Edit) or drop it (Remove) before I send.
- UC-6. As a reader, I can see after the reply which direction it was given (the Directed line) and read the full text.
- UC-7. On a phone at 390 px, UC-1 to UC-5 complete in the sheet at the app's phone control size (touch-target sizing is off by the owner's 2026-10-25 decision; controls are 36 px).
Behavior:
- The offer card appears in the Now view as soon as the draft changes a visible tracker, and disappears when the draft is clean again.
- The proposal is built from the before and after values by the per-type templates above, with no model call (no request leaves the browser while the reader edits).
- With the offer armed, Save writes the pending direction and leaves the latest reply's snapshot unchanged
(its
tracker_jsonbyte-identical before and after). - With the offer skipped, Save corrects the latest snapshot exactly as today (B4, 409 rebase included).
- The next turn's prompt carries one
SceneDirectionblock in thebeforeCurrentUserslot, after the Author's Note and before the reader's message, with the fixed header (verified with the mock LLM's prompt capture). - The directed reply's snapshot holds the target value for every directed key, and the eval's value for every other key, including when the eval answered a different value for a directed key.
- The directed reply's stage direction lists the directed changes; the previous reply's stage direction is unchanged.
- The turn after the directed one carries no
SceneDirectionblock. - Regenerating the directed reply re-sends the same block and lands the same targets on the new version.
- Two Saves for the next reply before sending merge into one direction: one target per key, the later value winning, and a key moved back to its current value dropped.
- A reader-edited text is never rewritten by a later draft change; new clauses are appended.
- In Hybrid, the beat call's prompt carries the block and the prose call's prompt doesn't.
-
/context-budgetreportssceneDirectionTokensabove 0 while a direction is pending and 0 once it's consumed or removed, and the context ring moves with it.
Invariants that must stay true (carve-outs):
- With trackers off for the story, the editor shows no offer, the composer's direction line reads paused with only
Remove (no Edit), and no turn carries a
SceneDirectionblock, even with a direction stored. - After this reply stays read-only and never shows the offer.
- A story where the reader never accepts an offer sends byte-identical prompts to today's (no block, no extra tokens, no eval change).
- The Author's Note is untouched: its text, countdown, pause and expiry behave exactly as before, with or without a direction pending.
- The writing client's tracker bar edits stay corrections (no offer, no direction).
- Classic and Hybrid prompts alternate roles at the provider boundary with both the note and the direction present
(
NormalizeForProvider), Hybrid's prose leg included after the strip. - The tracker eval makes the same number of calls per turn as today.
Edges:
- A turn answered by the balance gate's synthetic reply leaves the direction pending; the next real turn uses it.
- A turn that fails, or is stopped before its first token, leaves the direction pending; regenerating that turn sends the direction, and its reply lands the targets and clears it.
- If the tracker eval fails on a directed turn, the reply's snapshot is the prior with the targets applied.
- In a story with no reply yet (the greeting's snapshot only), the offer appears and the first reply lands the targets.
- A turn stopped mid-reply (text stored) consumes it, and its snapshot carries the targets.
- A target whose tracker was unbound or hidden meanwhile is dropped from the landing; the text goes as approved; a direction with no target left is not sent and stays staged.
- A value that doesn't fit its type is refused on Save, named under its field; no direction is stored. A number outside its tracker's range is clamped to the nearest bound, the same rule the scene save applies (decided 2026-10-29).
- Words the scene save refuses, or text failing the injection check, are refused with the scene save's message.
- A text over 1,000 characters is refused with a friendly message, not a 500.
- A direction made when the latest snapshot later moved on (another tab's turn) still lands its targets, and is sent with the text the reader approved.
- A branch from an earlier reply doesn't inherit the parent's pending direction; its copied rows keep theirs.
- Remove drops the direction and changes nothing else in the scene.
- A reader without edit rights on the story (
scene.canEditfalse) sees no offer and gets 404 from the endpoint (never 403: someone else's conversation answers as an unknown one, F92b / F92f).