Author's Notes — steering for the next few messages
The request, and why it's right
"…two separate fields — one for custom instructions (the ones that apply to the entire RP) and another for what is usually called Author's Notes — a field where you can specify plot directions for the current messages. That field should be closer to the top and easily accessible."
The two fields differ on the axis that actually matters mechanically: injection position. Recency is
influence. Custom Instructions lands at the end of the system prompt
(PromptContextManager.AppendCustomInstructionsAsync, PromptContextManager.cs:278-311) — far from the
newest messages, which is correct for standing rules (style, POV, limits) and weak for steering. "The
ambush happens tonight" belongs next to the latest turns, where model attention is. One field can't
occupy both positions, so today users abuse Custom Instructions for steering — and then forget to remove
the note, leaving "shift the tone to melancholy" applied for the next 200 messages. This isn't a
second feature bolted on; it's one field doing two jobs badly, separated:
| Custom Instructions | Author's Note | |
|---|---|---|
| Scope | The entire RP — standing rules | The next few messages — current plot direction |
| Injection | End of system prompt (existing) | Adjacent to the newest messages (new) |
| Lifetime | Until changed | Expires visibly (decided — see below) |
| Reuse | Preset library (Prompt Presets) | None — ephemeral by nature |
| UI home | Who drawer (existing) | Beside the message box, "closer to the top" (new) |
Not a preset consumer — and that's the point
Author's Notes deliberately gets no preset library, no sharing, no default, no FK. It's ephemeral per-conversation steering text; a saved-notes library would be absurd. This sharpens the Prompt Presets scope rather than complicating it: Custom Instructions becomes cleanly "standing rules worth saving and reusing" (where presets make sense), and the steering use case that never fit the preset model gets its own home. None of the preset design — mutation semantics, moderation, defaults — applies here or needs to change.
Mechanism — second consumer of the tracker injection substrate
The hard part already exists. Trackers built exactly this: IHistoryMessageInjector
(Core/Pipeline/Interfaces/) → ContextBuildingStageBase's per-message injector loop →
MergeConsecutiveRoles folds the injected user-role OOC block into the adjacent user turn.
WebTrackerHistoryInjector is today's only implementation; a WebAuthorNoteInjector is the second
consumer (rule of two, satisfied on arrival), placing one OOC block immediately before the newest user
message. Fixed depth in v1 — a configurable-depth knob is a later addition if real usage asks for it,
not part of the first slice.
Three contract points the external review (2026-07-31) correctly forced, checked against the code:
- The "before the current user message" position needs one new slot. The injector interface keys
blocks by history index and inserts after them (
IHistoryMessageInjector.cs:23-35); injecting after the last history message lands before the new user message — but the current user message is appended after the loop (ContextBuildingStageBase.cs:163), so on an empty history (note set before the first message) there is no index to hang the block on. Fix: a first-classbeforeCurrentUserslot in the stage (durable — trackers' "current state right before the new message" block is a natural second consumer of the same slot), rather than a v1 "note requires at least one message" restriction. - Failure posture is a decision, not an inheritance. The injector loop deliberately logs a Warning
and skips a failing injector so a tracker hiccup never breaks a turn
(
ContextBuildingStageBase.cs:110-136). For explicit user steering, silently not applying the note is worse than for tracker state — but failing the whole turn is worse still, against the platform's never-block-generation posture. Decided lean: keep never-break-the-turn, and note that the author-note injector reads conversation state already loaded for the turn (no extra I/O), so its real failure surface is minimal; the composer row reflects stored note state, and the turn-level injection result is not surfaced in v1. - In hybrid, the note feeds the Beat leg only — and that requires an explicit strip, not just a
placement choice. (An earlier draft said the prose model "receives it via the beat, same as every
other story-state input" — checked, and that's not how the pipeline works: the beat flattens the
full assembled context (
BeatDirectionStage.cs:82-84), and the prose rebuild then keeps every non-System turn from the original prompt (:270-271) — so a user-role injected block reaches both legs by default. Today's tracker OOC blocks already do.) Plot direction is a director concern: raw steering fed straight to the prose model bypasses the director and can make the prose jump ahead of the beat. So the decided lean is Beat-only, implemented as stage-scoped removal — and "identifiable" is a typed contract to build, not an assumption that holds today (raised on external review, correct): the injector API returns bare strings (IHistoryMessageInjector.cs:31-34), the builder turns them into untagged user messages, and the role-merge pass then folds them into neighboring user turns — by the time the prose rebuild sees the prompt, the note's boundaries are gone. ThebeforeCurrentUserslot therefore emits a message carrying a typed source marker (an optional source/kind on the message record) that survives assembly, and the merge pass must not fold across differing markers (equivalently: the tagged note stays a standalone message). The prose reconstruction filters by the marker. Substring removal is explicitly banned — matching on text risks deleting user-authored content that happens to contain the same words. The prose leg still receives the director's response to the note via the direction block, which is the intended path. Classic feeds the primary call, no strip needed.
As built (slice 0) — the three contract points, and what "identifiable" actually cost
All three held. The third one cost more machinery than the sketch implies, and that machinery is now shared, so it's worth stating exactly:
- The slot is a sibling interface, not an extension of the existing one.
ICurrentTurnMessageInjector(Core/Pipeline/Interfaces/) sits besideIHistoryMessageInjectorand returns a single block for thebeforeCurrentUserposition;ContextBuildingStageBasecollects it after the per-index loop. Two positions were kept apart rather than overloading the index map with a sentinel key. On a regeneration the block is inserted before the existing last user turn rather than appended, so a regenerate assembles the same shape as the original turn.WebTrackerHistoryInjectorwas not migrated — it stays on the per-index path (which yields the same placement whenever history is non-empty); the slot is there for it whenever that's worth doing. - "Identifiable" is a typed marker on the message, and it needed three cooperating pieces.
LlmMessagegained an optionalSource(LlmMessageSource.AuthorNote);MergeConsecutiveRolesbecame marker-aware so it won't fold a marked block into the user's own turn (folding destroys the very handle the marker exists to provide); andRequestPrompt.NormalizeForProvider()runs at the twoChatPipelinefinal-request sites, guaranteeing that what reaches a provider alternates and carries no markers. The strip itself (HybridProseLeg.CarriedTurns) is then one predicate, applied in both prose-rebuild paths (hardcoded fallback and mode-driven). Nothing anywhere matches on the note's text.
The bug this design nearly shipped — and why the boundary pass guarantees alternation
Worth recording, because the first cut was wrong in a way that only appears in composition and that a whole green test suite missed.
NormalizeForProvider was originally CollapseMarkedRuns: scoped to marked adjacencies, with a fast
path that returned early when no message carried a marker. That reads as obviously safe — "no markers,
nothing to undo" — and it is wrong, because a stage that deletes a marked message removes the last
marker along with it. With trackers on (the default), assembly produces:
… assistant, tracker-OOC(User), author-note(User/AuthorNote), current-turn(User)
The marker-aware merge correctly refuses both folds. The Hybrid prose rebuild then drops the note — and
the prompt that remains has no markers at all, so the fast path returned it untouched with
tracker-OOC(User) sitting directly against current-turn(User). Anthropic-family models routed
through Bedrock/Vertex reject that outright ("roles must alternate… found multiple user roles in a
row"), so it would have surfaced as "Hybrid is broken for some users on some models."
Two things generalise out of it:
- The invariant a pipeline boundary owes the provider is alternation, not bookkeeping. Any stage
that removes a message can re-open an adjacency, so the last pass must assert the property itself
rather than trust a proxy for "did anyone defer a merge".
NormalizeForProvidernow collapses every non-System same-role adjacency (System is excluded — the leading system run is load-bearing forGetMessagesForInlineSystemApiand for prompt caching's static-prefix breakpoint). - Every test had built the note into the one shape that cannot fail — sandwiched between an
Assistantand the currentUser, where deleting it leaves alternation intact. The regression tests now pin the composition explicitly (BeatDirectionStageTests.ProcessAsync_TrackerBlockInFrontOfTheNote_ProseStillAlternatesForTheProvider, both prose paths;CurrentTurnInjectionTests.NormalizeForProvider_UnmarkedButNonAlternating_IsStillFixed), and both were confirmed to fail against the old implementation before the fix landed.
- Never-break-the-turn held cheaply, as predicted.
WebAuthorNoteInjectorreadsWebChatContext.Conversation— the row the turn already loaded — so it performs no I/O and has almost no failure surface; the stage still logs a Warning and drops the block on any throw.
Known residual (not handled, deliberately). The regeneration insert uses
FindLastIndex(m => m.Role == User). That is exact for every history shape reachable today: tracker
blocks attach only to assistant indices, enhance-prompt interlacing inserts before its message, and
enhanceAtEnd runs after the insert. It would place the note slightly late — after the current user
turn rather than before it — only if history could end with two consecutive assistant rows (the
regeneration path strips just one, leaving a tracker block as the trailing user-role message). No such
path was found, and the outcome would be a suboptimal position rather than a broken prompt, since
alternation is guaranteed at the boundary regardless. Left unhandled rather than speculatively coded
around; if a "continue" feature ever appends a second assistant row, revisit this line.
One rule the build added that the spec didn't name: a single canonical liveness rule,
WebConversation.AuthorNoteIsActive (text present, no expiry anchor, countdown not spent). The injector
consults it directly; the Context Budget row and the DTO mapper carry documented, textually-identical
mirrors of the same expression (their row types are query-shaped projections that can't reach the domain
property — each mirror's comment names the canonical source, so a future edit knows to move all three).
The prompt and the UI therefore cannot disagree about whether steering is being applied. Both
conditions are load-bearing and neither is redundant — a branch inherits a spent countdown without an
anchor, and an anchor can be stamped while the count reads zero.
V1 shape
| Aspect | Lean | As built |
|---|---|---|
| Storage | Nullable columns on the conversation: note text, optional short label (falls back to a truncated excerpt), TTL, the set-time anchor, and the expiry anchor once it fires (see anchor mechanics below). No history table — one active note per conversation | As-built, inline on web_conversations (07c_web_conversations_author_note.sql). One refinement: TTL is two columns — author_note_ttl_turns (what the user picked, retained after expiry so a renew preselects the same quick-pick) and author_note_turns_remaining (the live countdown). Inline rather than a conversation_custom_instructions-style side table because the 1,000-char cap makes the row cheap, and it keeps the branch copy a column-list addition and the budget read a plain LENGTH() |
| Cap | ~1,000 chars — it sits in the highest-attention zone; short is a feature, not a limit | As-built, 1,000, enforced at the endpoint (friendly 400), in fn_set_conversation_author_note, and as a DB CHECK |
| Safety | The same vector injection-pattern check Custom Instructions runs at save (ConversationsEndpoints.cs:919-927 shape) — this text lands in the prompt |
As-built — same injection_detection check, same ownership-before-compute ordering, plus the publish-review edit lock its sibling conversation writes carry |
| Injection | Existing injector loop, one OOC block before the newest user message | Diverged (as the doc's own contract points predicted): a new first-class slot, not the existing loop. See Mechanism |
| Expiry | TTL in turns (assistant replies), not raw messages — a normal turn appends two messages (NewChatPage.tsx:816-823, messageCount += 2), so "15 messages" would silently mean 7½ exchanges. Quick-picks in the editor (e.g. 5 / 15 / 30 turns / until cleared). Default is a slice-0 call — lean 15 |
As-built shipped quick-picks 5 / 15 / 30 / until cleared, default 15 (the lean, taken). Revised 2026-08-05 (dev request): the picker is now two modes — "for a number of turns" (free entry, 1–99) or "until cleared" — default still 15 |
| Context Budget | Its own small display line (display-only, per the decided Context Budget scope in Prompt Presets) | As-built — authorNoteTokens, chars * 2 / 7 like every sibling line, in its own rose segment next to Custom instructions. Reports 0 once the note stops injecting, so the budget and the prompt can't disagree |
| UI | Collapsible row beside the message box — the structural precedent is ComposerEchoesBar.tsx (chat-v2 already has a composer-attached bar). Custom Instructions stays in the Who drawer |
As-built as AuthorNoteBar in ChatInput's topContent. Note: ComposerEchoesBar was the structural precedent only — it lives in the swipe footer and so exists on touch alone, whereas the note row must render in both layouts |
| Pause | (Not in the original shape — added 2026-08-19 on user request.) An on/off switch on the note itself, so it can be taken out of play without being thrown away | As-built, author_note_enabled on the conversation row + a surgical fn_set_conversation_author_note_enabled. See Pause |
| Live countdown | (Not in the original shape — the countdown was only ever refreshed by a conversation load.) | As-built 2026-08-19: the turn's terminal SSE frame carries the post-tick note state, so the composer chip and the expiry notice update in place. Closes the follow-up logged in the slice-0 verification record |
| Branching | The branch copies the parent's note state (text, label, remaining TTL) like it copies persona and instructions — and there's no default to re-apply, so the persona carve-out has no analogue to violate | As-built. The anchors are deliberately not copied — they are parent message ids, and the branch's messages are fresh rows, so a carried anchor would pin the notice to a slot that isn't in the branch |
Expiry — decided: visible, and the chat says so
Decided (dev, 2026-07-31): expiry is visible, user-friendly, and surfaces in the chat itself — an inline notice at the expiry point, e.g. "Author's note expired: prolog", clickable.
The forget-to-clear problem doesn't vanish with the field split — it gets a shorter blast radius and, with this, a visible home:
- While active: the composer row shows the note's label and remaining life ("prolog — 6 turns left"), so the note's mortality is visible before it dies, not only after.
- On expiry: the note stops injecting, and the transcript renders an inline notice at the point where it lapsed — "Author's note expired: prolog" — clickable, reopening the editor pre-filled with the expired note to renew, extend, rewrite, or dismiss.
- The notice is a virtual row, not a stored message. It's derived at render time from the
conversation's note state — nothing is written to
web_messages, so the transcript data stays clean and the notice disappears naturally once a new note is set or the old one is dismissed. No inline-notice component exists in chat-v2 yet (checked —MessageBubbleand style files only), so this is a small new piece; build it as a shared component, since retention warnings and future system notices are obvious next consumers.
Anchor mechanics — decided: count-based countdown, id-based anchor, resolved via version group
Decided (dev, 2026-07-31). The two halves use different currencies, on purpose:
- The countdown ticks on completed turns — new assistant version groups — counted, not
positioned. In turn currency (see the Expiry row above: a turn appends two messages, so raw
messageCountis the wrong unit). Verified against the actual persistence path: a regenerate inserts a new row into an existing version group rather than deleting anything (WebMessagePersistence.cs:62-99— the old message is flaggedselected=false, the replacement gets a fresh id andversionNumber=2), so a regenerate adds a version, not a turn, and the count of version groups never decreases. A turn-based TTL is therefore monotonic — regenerates and swipes don't tick it, and can't rewind it. One more non-ticking case, found at build time: a turn blocked by the Echo balance gate writes its synthetic assistant row straight through the repository and skips the LLM, so a blocked turn never spends note life either — only genuinely completed turns tick. - The expiry point is captured as a message id at the moment the countdown hits zero — the id of the append that consumed the last tick — not precomputed as "position N." Ids don't drift under edits the way indexes do.
- The one wrinkle, and its resolution: an id anchor must resolve through the version group. If the
anchor message is later regenerated, its id leaves the visible transcript (
selected=false) while its version group stays in place. The notice renders after the anchor's version group's currently selected member — same transcript slot, whichever version is showing. A naked id lookup would silently drop the notice the first time someone regenerates the message it points at.
Pause — decided: a third state, not a clear
Requested by a user (Raven, 2026-08-19), confirmed in the same thread: "it would be nice if the 'until cleared' option was 'until expired', and you could manually expire it. That way it's still there but inactive in case you want to use it again or need a reminder" → "just some way to disable it without clearing it completely is fine."
Built as an on/off switch on the note, not as a manual-expire. The literal ask — "let me expire it by hand" — would have overloaded expiry, which is a one-way, countdown-owned state with a transcript anchor and its own inline notice. Manually firing it would mean stamping an expiry anchor at a message that didn't consume anything, and un-firing it would mean deciding what the countdown resets to. A separate boolean keeps both states honest, and matches what the follow-up actually asked for ("some way to disable it").
The rules that make pause different from clear:
- A paused note neither injects nor ticks. The countdown is frozen, not spent — park a
15-turn note for ten turns and you get a 15-turn note back. A pause that kept metering would quietly
expire the note while it sat unused, which is the "it's gone" outcome pausing exists to prevent.
(
AuthorNoteIsActivegains the flag;fn_tick_conversation_author_notegainsAND author_note_enabled.) - Pause and expiry are orthogonal. A note can be both. Resuming does not un-expire — renewing is the editor's Save, which is the one place that resets a countdown. So the toggle can never become a back-door renew.
- The switch belongs to the note, not the conversation. Clearing the note resets it to on, so the next note never inherits a pause set on text that no longer exists. Branching does carry it: a branch of a conversation whose note the author had parked must not silently start steering with it.
- Toggling is its own endpoint (
PUT /api/conversations/{id}/author-note/enabled), not a field on the save. The save is a full replace that resets the countdown — pausing through it would hand the note a fresh TTL, i.e. exactly the thing pause is supposed to preserve. The editor's Save does carry the flag, because there it is part of the one committed value ("rewrite this, and leave it off"). - The composer button carries its own state — icon and the word On/Off — and a paused row mutes
itself and says
paused · 6 turns left. A bare power icon is ambiguous (is that the current state or what clicking does?), and the remaining count has to stay visible precisely because pausing is what protects it.
The countdown had to become live first
The same report carried a second half: "there is some weird behavior with the turns option if you set it after the fact. Both if you change from 'until cleared', or if it expires and you set a new number of turns. It no longer advances turns."
The countdown was advancing correctly server-side the whole time — pinned now by
Tick_AfterSwitchingAnUntilClearedNoteToATurnCount_ResumesCountingDown and
Tick_AfterRenewingAnExpiredNoteWithANewTurnCount_CountsDownAgain. What never advanced was the
display: conversation.authorNote was only ever written by the conversation load and by the note's
own save/clear, so the composer chip froze at whatever the last save returned and only caught up on
the next page load. Setting a TTL mid-session is exactly when a user stares at that chip, which is why
the symptom read as "only when you set it after the fact" — it was the slice-0 follow-up
("the expiry notice appears after a reload") seen from the other end.
Fixed by carrying the post-tick note state on the turn's terminal SSE frame (done / stopped), read
on the pump side after the tick and patched onto the conversation by the client's shared terminal
handler. Best-effort, like the tick itself — a failed read logs a Warning and leaves the client's
current state alone rather than failing a stream over a chip.
Relationship to sibling docs
- Prompt Presets — the sibling field's design. Author's Notes deliberately stays out of its substrate; the split purifies Custom Instructions' scope ("standing rules worth saving") and removes the steering misuse case from it.
- Trackers — owns the injection substrate this reuses (
IHistoryMessageInjector, the OOC-block convention,MergeConsecutiveRolesfolding).
Open questions
-
Default TTL— 15, shipped in slice 0. Still the value to revisit from real usage feel; it's one constant (AUTHOR_NOTE_DEFAULT_TTL), not a structural choice. -
Is the label required or optional-with-excerpt-fallback?— optional, shipped. Blank collapses to NULL in SQL and the UI falls back to a 40-char excerpt (authorNoteDisplayName). The label is capped at 80 characters (VARCHAR(80)+LEFT(v_label, 80)in the SQL function). Forcing a naming step on an ephemeral note fought the "easily accessible" requirement, as expected. -
Where exactly the expired notice anchors under edits/regenerates— decided 2026-07-31: count-based countdown (regenerates can't lower the visible count — verified, they insert version-group rows), id-based expiry anchor captured when the countdown fires, resolved through the version group at render. See Anchor mechanics. - Whether "until cleared" notes get a gentle age indicator anyway ("set 40 messages ago") — lean
yes, same visibility principle without an expiry. Not built in slice 0 — the composer row shows
"until cleared" with no age. The data is already there (
author_note_set_message_idis written on every set), so this is a display-only follow-up, not a schema change.
Suggested slicing
One small slice, independent of Prompt Presets — could ship before or after preset slice 1. Storage columns + injector + save endpoint with cap/injection-check + composer row + expiry state + the virtual notice row + Context Budget line. The only shared-component work is the inline chat notice, extracted as shared from day one per the rule of two (retention warnings are the visible second consumer).
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):
- As a writer mid-scene, I can set a plot direction for the next few messages — reachable from the composer-adjacent Author's Note row in chat, without opening the Who drawer or any settings page.
- As a writer, I can see at a glance that a note is active and how much life it has left (label + "N turns left") without opening the editor.
- As a writer, I can pick how long the note lasts at set time (any number of turns, 1–99, or until cleared), with 15 prefilled. (Originally shipped as 5/15/30 quick-picks; revised to free number entry 2026-08-05 on dev request.)
- As a writer, I can give the note an optional short label; leaving it blank still produces a readable name (truncated excerpt of the note text).
- As a writer whose note has expired, I see an inline notice in the transcript at the point it lapsed, and clicking it reopens the editor pre-filled with the expired note so I can renew, extend, rewrite, or dismiss it. (The notice currently appears after a reload — see the known follow-up in the verification record.)
- As a writer, I can clear an active note from the same row, and the row returns to its empty "add a note" affordance.
- As a writer, I can switch a note off without losing it — one click on the composer row's
On/Off button — and switch it back on later with its text, name and remaining turns intact.
(Browser pass:
prolog · 3 turns left · On→ click →prolog · paused · 3 turns left · Off→ click →prolog · 3 turns left · On. Nothing else moved.) - As a writer, I can tell at a glance from the composer row whether the note is currently steering the story, without opening the editor or hovering anything. (The row mutes to grey, the chip reads "paused · N turns left", and the button carries icon + word — ⚡ On / ⚡̸ Off.)
- As a writer, I can save a note straight into the off state from the editor (write it now, arm it
later). (Browser pass: new note + switch off + Save → row rendered
Armed later: the informant lies. · paused · 15 turns left · Offimmediately.) - As a writer watching the turns count down, the number on the composer row updates as I play, not only after a reload — and the expiry notice appears in the transcript the moment it lapses. (Browser pass, three real turns, no reload at any point: "3 turns left" → "2 turns left" → "1 turn left" → "expired", and "Author's note expired: prolog" appeared inline at the lapsing turn. Clicking that notice reopened the editor pre-filled.)
Behavior:
- A saved note is injected as a user-role OOC block immediately before the current user message —
including on an empty history (note set before the first message ever sent).
(
CurrentTurnInjectionTests.ProcessAsync_EmptyHistory_PlacesBlockImmediatelyBeforeCurrentUserMessage+_WithHistory_+_OnRegeneration_;WebAuthorNoteInjectorTests.) - The note applies for exactly the next N completed turns and stops injecting from turn N+1 onward.
(SQL half —
AuthorNoteFunctionTests.Tick_AppliesForExactlyTheChosenNumberOfTurnsThenExpires, green in the serial run. C# half — that a spent/expired note stops injecting — viaWebAuthorNoteInjectorTests.) - The countdown ticks once per completed turn (a new assistant version group). A regenerate /
swipe does not tick it — remaining TTL after a regenerate equals remaining TTL before it.
(
WebMessagePersistenceAuthorNoteTests— new turn ticks, single and repeated regenerations don't, user messages don't.) - When the countdown reaches zero, the id of the assistant message that consumed the last tick is
stored as the expiry anchor; the inline notice renders at that anchor's slot in the transcript.
(Anchor-stamping —
AuthorNoteFunctionTests, green in the serial run. Render half observed in the browser pass — the notice appeared at the expiry slot.) - The expiry notice resolves through the anchor's version group — regenerating the anchor
message keeps the notice in the same transcript slot rather than dropping it.
(View projection —
AuthorNoteFunctionTests.ConversationView_ResolvesTheExpiryAnchorToItsVersionGroup, green in the serial run; the client resolves version-group-first and the notice rendered through that path in the browser pass.) - Save rejects note text over 1,000 characters with a 400. (SQL guard —
AuthorNoteFunctionTests.SetAuthorNote_OverLengthCap_IsRejected, green. The 400 itself exercised 2026-08-05: a 1,001-char PUT returned 400 with the friendly message.) - Save runs the same
injection_detectionvector check Custom Instructions runs and rejects a matching note with a 400 explaining the rejection. (Exercised 2026-08-05 against the live embedding path: an "ignore all previous instructions…" note returned 400 with the redirect-to-storytelling copy.) - In the Hybrid pipeline the note reaches the Beat leg only: the flattened beat context
contains the note block, and the rebuilt prose prompt contains no trace of it.
(
BeatDirectionStageTests.ProcessAsync_HardcodedProsePath_…and_ModeDrivenProsePath_…— both rebuild paths; plus_StripsOnlyTheMarkedMessage_OtherUserTurnsSurvive.) - In the Classic pipeline the note reaches the single primary call.
(
CurrentTurnInjectionTests.NormalizeForProvider_FoldsTheBlockIntoTheUserTurnAndClearsTheMarker— Classic has no strip, and the block reaches the provider folded into the user turn.) - The injected note message carries a typed source marker that survives prompt assembly; the note
is identified by that marker, never by matching its text.
(
CurrentTurnInjectionTests.ProcessAsync_BlockIsNotFoldedIntoTheUserTurnDespiteBothBeingUserRole;WebAuthorNoteInjectorTests.Source_IsAuthorNote.) -
fn_branch_conversationcopies the parent's note state (text, label, remaining TTL) to the branch. (AuthorNoteFunctionTests.BranchConversation_CopiesNoteTextLabelAndRemainingTtl— green in the 2026-08-04 serial Database.Tests run, 116/116.) - A paused note is not injected — in Classic and in Hybrid's beat leg — and reports 0 tokens on the
Context Budget line, so the budget and the prompt still agree.
(
WebAuthorNoteInjectorTests.BuildAsync_PausedNote_ContributesNothing+_PausedUntilClearedNote_; budget via the sharedAuthorNoteIsActivepredicate, which the pause flag is part of. Confirmed on a live turn: the OOC block was absent from the captured prompt andauthorNoteTokensread 0.) - A paused note does not tick: N completed turns while paused leave
turnsRemainingunchanged. (AuthorNoteFunctionTests.Tick_WhilePaused_FreezesTheCountdownRatherThanSpendingIt; a live paused turn left the count at 3.) - The terminal SSE frame of a completed turn carries the note state as of after that turn's
tick, and the client patches it onto the conversation. (Read off a real
doneframe: the note arrived withturnsRemainingalready decremented, in camelCase after the fix above.) - Context Budget shows the Author's Note as its own display line with a
chars * 2 / 7token estimate, consistent with its sibling lines. (Repo + endpoint + hook + segment colour all wired; segment confirmed rendering in the 2026-08-04 browser pass.)
Invariants that must stay true (carve-outs — the spec'd-free/exempt paths):
- Author's Notes is free for every tier — no subscription, Echo, or feature-commitment gate on setting, saving, injecting, or expiring a note. (No tier/Echo/commitment call exists on any path: the endpoint checks ownership + edit-lock + cap + injection only; the injector reads a column.)
- Custom Instructions is unchanged: still injected at the end of the system prompt, still 5,000
chars, still in the Who drawer. Setting a note does not alter it. (No file on the Custom
Instructions path was touched;
ServerAPI.Testsincl.UpdateCustomInstructionsAuthTestsgreen.) - The note is not a preset consumer — no library, no sharing, no default, no FK. Branching
copies state; nothing re-applies a default (there is none). (No FK on any
author_note_*column, no preset table reference, no seed row.) - Never breaks the turn. An author-note injection failure logs a Warning and the turn proceeds
without the note — it never surfaces as a generation error.
(
CurrentTurnInjectionTests.ProcessAsync_ThrowingInjector_StillProducesAUsablePromptWithoutTheBlock; tick failure covered byWebMessagePersistenceAuthorNoteTests.StoreAssistantMessageAsync_TickFailure_DoesNotFailTheTurn.) - Nothing is written to
web_messagesfor the expiry notice — it is derived at render time from conversation state, and the transcript export/PDF paths are unaffected. (No write path exists — the notice is computed inChatPanelfromconversation.authorNote; no export/PDF file touched.) - Clearing or deleting the note stops injection on the very next turn, with no lingering block.
(Clear wipes text + anchors —
AuthorNoteFunctionTests.SetAuthorNote_BlankText_ClearsEverythingIncludingAnchors, green in the 2026-08-04 serial Database.Tests run — andWebAuthorNoteInjectorTests✅ proves a cleared/blank note injects nothing.) - Pausing changes nothing else about the note: text, label, TTL, remaining turns and both
anchors survive a pause/resume round trip byte-for-byte.
(
AuthorNoteFunctionTests.SetEnabled_PausesWithoutTouchingTextLabelTtlOrCountdown+SetEnabled_ResumingGivesBackTheTurnsThePauseProtected; also observed over HTTP — the pause and resume responses differ from the pre-pause response in theenabledfield alone.) - Resuming a note that expired while paused does not revive it — expiry is still only undone by
a save. (
AuthorNoteFunctionTests.SetEnabled_OnAnExpiredNote_DoesNotReviveIt.) - The pause switch is free for every tier, like the rest of the feature — no tier, Echo, or
commitment check on the toggle endpoint. (
SetAuthorNoteEnabledcalls ownership + edit-lock + the SQL setter, and nothing else — same gate list as its sibling save.) - A failed note-state read on the terminal frame never fails the turn and never clears a live
note: the stream completes, the message is persisted, and the frame falls back to the pre-turn
state (so the countdown may read one turn high until the next load). Structural, not
fault-injected — the read sits in its own try/catch that logs a Warning and leaves the field at
its seeded pre-turn value, and
ChatSseAuthorNoteFrameTests.TerminalFrame_WithNoNote_EmitsAnExplicitNull_NotAnAbsentKeypins the wire shape that makes the seed necessary. Forcing the read itself to throw needs fault injection; flagged rather than silently ticked. - Existing conversations with no note behave exactly as before — no injected block, no composer
row content, no Context Budget line. (
WebAuthorNoteInjectorTests.BuildAsync_NoNoteSet_InjectsNothing;BeatDirectionStageTests.ProcessAsync_WithNoAuthorNote_ProsePromptIsUnchanged;RequestPrompt.NormalizeForProviderreturns the same instance for unmarked prompts; budget segment is suppressed at 0 tokens. Full Core/WebChat/ServerAPI suites green — 4,331 tests.)
Edges:
- Empty / whitespace-only note text is treated as "no note" — save clears rather than storing blank.
(
WebAuthorNoteInjectorTests.BuildAsync_BlankNote_InjectsNothing; SQL half inAuthorNoteFunctionTests.SetAuthorNote_BlankText_ClearsEverythingIncludingAnchors.) - Note set on a conversation with zero messages injects correctly on the first turn (the
beforeCurrentUserslot has no history index to hang on). (CurrentTurnInjectionTests.ProcessAsync_EmptyHistory_…— the case that motivated the new slot.) - "Until cleared" (no TTL) never expires, never renders an expiry notice, and shows no
"N turns left" countdown. (Injection half —
WebAuthorNoteInjectorTests.BuildAsync_UntilClearedNote_Injects; never-expires —AuthorNoteFunctionTests.Tick_UntilClearedNote_NeverExpiresAndKeepsInjecting, green in the serial run; the "until cleared" copy rendered in the browser pass.) - A non-owner calling the save endpoint gets the uniform not-found/forbidden shape — no existence
or content leak. (SQL guard —
AuthorNoteFunctionTests.SetAuthorNote_ByANonOwner_IsRejectedAndChangesNothing, green. Endpoint exercised 2026-08-05: non-owner → 403, nonexistent id → 404, both empty-bodied — the exactUpdateCustomInstructionssibling shape.) - Saving on a conversation locked for publish review is rejected by the same edit-lock as sibling
conversation writes. (Exercised 2026-08-05: with a pending
publish_requestsrow staged, the PUT returned 409entity_in_reviewwith the withdraw guidance; unlocked afterwards.) - Toggling on a conversation with no note is a no-op that returns null, not an error.
(
AuthorNoteFunctionTests.SetEnabled_WithNoNoteSet_IsANoOpRatherThanAnError.) - A non-owner calling the toggle endpoint gets the same uniform not-found/forbidden shape as the
save endpoint, and the note is unchanged.
(SQL guard —
AuthorNoteFunctionTests.SetEnabled_ByANonOwner_IsRejectedAndChangesNothing; the endpoint's own ownership check is the same code asUpdateAuthorNote's, ahead of any state read.) - Toggling a conversation locked for publish review is rejected by the same edit-lock as the save.
(Exercised 2026-08-19: with a pending
publish_requestsrow staged, the toggle returned 409entity_in_reviewwith the withdraw guidance — byte-identical to the save endpoint's response under the same lock; 200 again once the row was removed.) - The On/Off button is not offered for an expired note — renewing is the action there.
(Browser pass: at expiry the row rendered
⏳ prolog · expired · ✕with no On/Off control.) - Clearing a paused note and setting a new one starts the new note on.
(
AuthorNoteFunctionTests.SetAuthorNote_ClearThenSetAgain_StartsLiveEvenIfTheOldNoteWasPaused.) - A branch of a conversation whose note was paused inherits the pause.
(
AuthorNoteFunctionTests.BranchConversation_CarriesThePauseSwitch.) - A note whose expiry anchor message was deleted degrades gracefully — the notice is dropped, not
rendered at the wrong slot, and no error surfaces. (The renderer resolves the anchor by
find(...) ?? nullover the loaded messages; no match simply draws nothing — seeChatPanelnoticeAfterMessageId. Also covers an anchor older than the loaded page.) - Setting a new note while an expiry notice is showing replaces the state and the stale notice
disappears. (SQL half —
AuthorNoteFunctionTests.SetAuthorNote_OnAnExpiredNote_RevivesItAndClearsTheExpiryAnchor, green in the serial run; the renew flow was driven in the browser pass — saving from the pre-filled editor cleared the notice.)
Additional invariant discovered during slice 0 (not in the original list, pinned because a bug was caught here):
- The prompt sent to the provider never contains two consecutive same-role non-System messages as a
result of note injection — in Classic and Hybrid, and with trackers on or off.
(The marker deferral creates exactly that shape mid-assembly. Two separate bugs were caught here
before shipping: an early
CollapseMarkedRunscleared the marker on insert, ending the run early; and the marker-scoped fast path let the Hybrid strip re-open an adjacency it could no longer see. Pinned byBeatDirectionStageTests.ProcessAsync_TrackerBlockInFrontOfTheNote_ProseStillAlternatesForTheProvider(both prose paths) andCurrentTurnInjectionTests.NormalizeForProvider_*. See the bug this design nearly shipped.) - Normalization does not disturb the leading System run (prompt caching's static-prefix breakpoint).
(
CurrentTurnInjectionTests.NormalizeForProvider_DoesNotMergeTheLeadingSystemRun.)