Prompt Presets — Reusable, Shareable Prompt Snippets

What we are actually solving

Three unrelated-looking feature requests turn out to be the same shape:

  1. Custom Instructions is a single per-conversation free-text field today — mode-independent, appended near the end of the system prompt, before the response-pacing/target-words directives (PromptContextManager.AppendCustomInstructionsAsync, server/EchoOfDreams.Core/Pipeline/Providers/PromptContextManager.cs:278-311). There's no way to save more than one, name them, or reuse a favorite across conversations.
  2. Summarization is currently owned by Mode (prompt_mode_contents.summarize_messages_prompt / summarize_summaries_prompt) and — per Hybrid Pipeline §3 — is about to move to being owned by the beat mode specifically. The dev wants to go further: decouple it from Mode entirely so a user can author/select their own summarization behavior independent of whatever Mode they're chatting in.
  3. Model Profile Flavors (Document Mode Editor §Model-selected base prompts and flavor overlays, unbuilt) are already spec'd as "one optional, user-toggleable, profile-owned keyless System sub_prompt" with an explicit import-as-private-clone mechanism for pulling in accessible prompt text from elsewhere.

All three are the same underlying storage need: a named, reusable block of instruction text, selectable independent of the thing that's using it. But they split hard on one axis that matters a lot downstream — who writes the content:

Consumer Authored by Scope Distribution
Custom Instructions The end user controls it — always, no exceptions. (A package may seed the initial text — moderated at package publish, user-owned from creation on; see the decided item below) Private by default, personal preference Affects only that user's own conversations (unless explicitly shared peer-to-peer)
Summarization preset The end user, for themselves Private by default, personal preference Same — self-scoped
Flavor overlay The creator, as part of building their Model Profile Profile-owned, one of several toggleable style layers Ships to every reader of every Package/conversation that resolves that creator's Model Profile

Custom Instructions and Summarization are the same case as each other: a user writing a note to the model about themselves. (Custom Instructions here means standing rules for the whole RP — style, POV, limits. The steering use case that field also absorbs today — "plot direction for the next few messages" — is deliberately split out into its own sibling field, Author's Notes, which is not a preset consumer; the split purifies what a Custom Instructions preset is for.) Flavor is a different case wearing similar clothes: a creator writing style/tone instructions that ride along with their published work, at audience scale — much closer in kind to Mode or Character content than to a personal preset. The shared substrate below (sub_prompts) is still the right storage/reuse mechanism for all three, but the moderation weight and sharing model must not be unified across this line — see Moderation model below.

Decided (dev, this implementation): package-locked Custom Instructions are retired. Custom Instructions is purely user-controlled, always — a Package can still seed an initial value, but can no longer lock it. (An earlier draft overstated this as "a Package no longer supplies or locks one" — half wrong, and it contradicted the precedence rule this doc itself states later. Corrected on review, 2026-07-31.) The precise split:

So "user-driven" means control, not "no creator ever typed the first draft": the creator seeds, moderation screens the seed at package publish, and the user owns it from conversation creation onward. No locked-value path survives, which is the simplification that matters for this design.

Scope note — this retires the behavior, not necessarily the column. instructions_locked is one member of a package-wide lock-flag family (CharacterLocked/ModeLocked/LorebooksLocked/InstructionsLocked) threaded through 24 files — agent authoring tools, changelog triggers, browse listings, package CRUD — not narrowly scoped to this one check. What's in scope here is removing its enforcement effect on Custom Instructions; whether the column/API field itself gets cleaned up package-wide is a separate, larger concern this doc doesn't take on. See Legacy migration for what happens to conversations that currently have a locked value.

The core idea — reuse sub_prompts, don't invent a new prompt-content storage mechanism

sub_prompts already has almost the whole shape (database/v1/04_tables_prompts.sql:119-243):

What's missing is the ability for a sub_prompts row to be selected standalone — referenced directly by id from Custom Instructions settings — without being linked into a Mode's assembly at all. Today the only two ways a sub-prompt's content reaches the model are (a) via prompt_mode_sub_prompt_links into a Mode, or (b) — for Flavors, once built — a profile-owned private clone. Neither fits "pick one saved block of text and use it verbatim, standalone."

Correction: this framing only holds for Custom Instructions. Summarization needs a small new aggregate entity on top of this substrate, not a third standalone sub_prompts row — see What's new below for why, and Summarization needs its own research pass for the reasoning that forces it. The header above is scoped precisely: don't invent a new way to store prompt text (that part, sub_prompt_contents, gets reused everywhere); a small aggregate that owns two content rows plus a field schema is still new structure, just not new text storage.

What's new

  1. A purpose discriminator on sub_prompts, scoped to Custom Instructions only — a single 'custom_instructions' value, distinguishing it from the existing "mode-section" row (content that fills a {content} slot inside an assembled prompt, gated by provider_key; no purpose tag, unchanged). Forcing a standalone preset through provider_key semantics would be a category error — provider_key drives which content provider fills the slot; a standalone preset has no slot to fill. A typed discriminator (following the shape expansion_version already commits to) keeps the one table honest about the two contracts sharing it. Correction: this is Custom Instructions' shape only, not Summarization's — see item 2. An earlier draft of this doc gave Summarization its own 'summarize_messages'/'summarize_summaries' purpose values here, each independently selectable by id. That directly contradicts the "one versioned aggregate" decision in Summarization needs its own research pass — a single sub_prompts row can't own two prompts plus a field schema, and two independently-referenced rows let a user pick a mismatched pair. Fixed below; don't reintroduce the split purpose values. (Flavor still gets no purpose value at all, for the separate reason already covered: per Document Mode Editor §Model-selected base prompts and flavor overlays, "There is no is_bundle pseudo-type and no intrinsic sub_prompts.is_flavor: Flavor meaning/default/order belongs to its profile link" — Flavor identity lives on the profile-link row, never on sub_prompts.)
  2. Two different reference shapes for the two consumers, not one uniform pattern (both live FKs to a row the user owns — see Mutation semantics):
    • Custom Instructions gets a nullable custom_instructions_preset_id FK on the conversation, pointing at a purpose='custom_instructions' sub_prompts row the user owns. Set → the preset's text is live and edits propagate. NULL → the existing custom_instructions_id local-text row applies, exactly as today. Editing instructions inside a conversation clears the FK and detaches to local text. No mode link required — this is genuinely one block of text, the simple case.
    • Summarization gets its own small aggregate table (call it summarization_presets: id, uuid, created_by_user_id, name, is_public/published_at mirroring sub_prompts' sharing shape, plus two owned sub_prompt_contents rows — reusing that table purely as raw large-text storage, not as independently-addressable sub_prompts rows — for the messages-prompt and rollup-prompt bodies, and an owned field-schema definition, likely a child table mirroring Trackers' typed-field-definition shape). A consumer applies the aggregate as a unit, never a child content row on its own — that's what makes "both prompts agree on the schema" enforceable at all. This is the new-but-narrow piece: not new text storage (still sub_prompt_contents), but a new small entity that owns two of them plus a schema, because Summarization's two prompts can't be independently swapped without breaking the contract between them. Whether Summarization attaches live like Custom Instructions or pins its schema at attach time is deliberately left to slice 3 — see the Summarization lean; it has a schema-stability constraint Custom Instructions doesn't.
    • Flavor keeps its existing profile-owned clone mechanism per the Document Mode Editor design — the same "clone into your own scope, then own it" rule the import path uses, one layer over.
    • The invariant across all three: you only ever reference a row you own. Sharing works by cloning into your library at import, never by pointing at someone else's row — see Mutation semantics.
  3. A lightweight, non-blocking moderation trigger on publish, for user-authored presets only — see below. This is the piece that makes "let users share their own Custom Instructions/Summarization presets with each other" viable without building a second full review pipeline. It is not the moderation story for Flavor content — that's a separate, heavier problem (see below).
  4. A structured field-builder for Summarization presets, so a non-technical user names the fields they want preserved instead of hand-writing a JSON-format instruction. See Summarization needs its own research pass below — this is the biggest open unknown in the whole doc.
  5. A shared "pick a saved prompt" UI, reusable across the Custom Instructions picker, the Summarization preset picker, and — per the Flavor overlay's existing "import accessible prompt text" design — potentially the Flavor import picker too, so there's one place a user browses their private library and public shared presets, not three bespoke pickers. Correction: this belongs in slice 1, not deferred to a later "unify" slice. This doc names two consumers (Custom Instructions, Summarization) up front — the repo's own rule-of-two convention (root CLAUDE.md §On Reuse: "As soon as a block of markup gains a second consumer (or you can see it will gain one in this same change), extract it into a shared component. Do not copy-paste it 'for now'") says build the shared picker at first implementation, not bespoke-then-unify. An earlier draft of this doc deferred it to slice 4, which is exactly the pattern that rule exists to prevent.
  6. A user-level default preset for Custom Instructions, auto-applied to new conversations the same way a default persona already is — a column-for-column clone of the existing Persona.DefaultId mechanism (setting key, ownership-enforcing resolver, COALESCE in the same INSERTs), not a new pattern. Custom Instructions only; Summarization and Flavor get no default in this slice. See A user-level default preset.

Mutation semantics — decided: live FK to a row you own; import clones first

Decided (dev, 2026-07-25): a conversation references its preset by FK, live — edits propagate. The invariant that makes that safe is you only ever reference a row you own: importing someone else's public preset clones it into your own library first, and from then on it's your row. No version counter, no revision history — the only schema additions to sub_prompts are the purpose discriminator and is_deleted.

This mirrors the default-persona mechanism exactly (web_conversations.user_persona_id is a live FK to a row the same user owns), which is the working precedent for "the user's own reusable thing, attached to the user's own conversation." A preset is the same shape, so it gets the same treatment.

The three rules

  1. Attach a preset → live FK. Editing the preset updates every conversation still linked to it. That's the point of "my preset." Attaching over existing local text replaces it — the local row is cleared so the two columns are never both authoritative (the precedence section requires "both set" to be ruled out; this is where it's ruled out for the attach path).
  2. Edit the instructions inside a conversation → it detaches into that conversation's own local text (the existing conversation_custom_instructions row), and the preset FK is cleared. A local edit is never a silent edit of the preset — that would rewrite conversations the user wasn't looking at. This is why both columns coexist: custom_instructions_preset_id for the linked case, custom_instructions_id for ad-hoc typed text, and ad-hoc typed text stays a first-class case forever.
  3. Import someone else's preset → clone into your library first. You never hold an FK to a row you don't own, so a shared preset's author can never reach into your conversations, and unpublishing theirs can't break yours. This is already the mechanism Flavor specs (import-as-private-clone) — consistent, not novel.

What this costs, stated plainly

One real addition, and it's work slice 2 needs anyway:

The 5,000-character cap and the vector injection check must additionally run at preset save/edit — they do NOT leave conversation-save. They currently run on the text at conversation-save (ConversationsEndpoints.cs:915-927), and they stay there: the local/detached text path is first-class forever (rule 2) and still flows through it. But with a live FK the preset's text reaches the prompt without ever passing through that path, so both checks must also run where preset text is authored — at preset write — and re-run on every edit. That re-run requirement is not extra scope: it's the same moderation re-check-on-edit requirement slice 2 already carries, so the two share one transactional gateway rather than being two jobs.

Everything else is small or unchanged:

Concern Status under a live FK
Context Budget Two-line change — chase the preset instead of the local row. Structurally identical to the persona budget line that already ships (ConversationBrowseRepository.cs:419-425)
Legacy rows Unchanged. Existing rows have a NULL preset FK, so they're just the ad-hoc-typed case, which stays first-class. Still no migration
Branching One line — fn_branch_conversation copies the FK alongside the persona and text it already copies (the column is new, the behavior isn't)
Deletion is_deleted keeps the row, so linked conversations keep resolving; the preset just leaves the library
Mid-turn preset edit Same exposure persona already has today, self-inflicted and tiny. Not treated as a defect there; not one here

Where is_deleted still earns its place

Soft-delete on sub_prompts is the one schema addition, and it's purely additive — verified, not assumed: there is no DELETE FROM sub_prompts anywhere in the schema. Only link rows are ever deleted (fn_delete_mode_sub_prompt_links, 08_mode_migration_functions.sql:483); the sub_prompts row simply orphans. So is_deleted retrofits no existing delete path, and the ~10 existing readers (FROM sub_prompts / JOIN sub_prompts — mode assembly, content checks, entity stats) are unaffected as long as the new soft-delete path is scoped to standalone preset rows. It also matches the convention already set one function over: fn_delete_prompt_mode (08_mode_migration_functions.sql:495) is a soft delete. sub_prompts is currently the odd one out.

Soft-delete is also what makes the live FK safe on the delete path, and the contract is an asymmetry — state both halves so both get built: existing links keep resolving (the row survives; a linked conversation's instructions don't vanish, the preset just shows as removed from the library), while every forward-looking selection path rejects the row — the library list, the attach-time read-authz check, and the default resolver all filter NOT is_deleted. Miss the second half and a "deleted" preset silently keeps spreading to every new conversation through the user's default — precisely the surprise soft-delete exists to prevent. Hard-delete would have forced either a fan-out write or a dangling FK.

Lean for Summarization (slice 3, not decided here)

Summarization is the one place the copy argument may still be right, and for a reason that doesn't apply to Custom Instructions: the schema-drift-across-rollups problem wants a conversation's field schema to be stable for the conversation's whole life, which a live FK doesn't give. Pinning or copying the schema at attach time would. Noting the lean, not deciding it — Summarization has its own research pass and its own aggregate shape, and this doc shouldn't pre-empt it. The important part is that Custom Instructions and Summarization are allowed to differ here; they have genuinely different constraints.

A real authorization gap this surfaces, not a hypothetical one

Promoted to its own section: it was a subsection of Mutation semantics when both were open. Now that mutation is decided and this isn't, burying the one remaining hard blocker under a "decided" heading would hide it.

Checked the SQL function that actually mutates a sub_prompts row — fn_upsert_sub_prompt/08_mode_migration_functions.sql:131-149 — and it has no ownership check at all. The update branch (UPDATE sub_prompt_contents ... WHERE id = v_existing_content_id, then UPDATE sub_prompts SET ... WHERE id = p_sub_prompt_id) never compares created_by_user_id against the calling user, even though the function receives p_user_id as a parameter. This is safe today only because every current caller checks parent access first — CreatorModeEndpoints.cs:430-432 (RequireEntityAccess(context, "mode", modeId, a => a.can_edit, …)) gates the Mode before this function is ever reached, so the sub-prompt id is always reached indirectly through an already-authorized parent.

A standalone preset endpoint (Custom Instructions/Summarization, addressed directly by sub_prompts.id, no Mode in the loop) removes that indirection. If it calls the same SQL function directly, nothing in the function stops user A from editing user B's preset by guessing or discovering its id — the parent gate that made this safe simply isn't there anymore. Slice 1 needs its own explicit ownership check (created_by_user_id = p_user_id, or an app-layer check before calling in) — either added to fn_upsert_sub_prompt itself or as a new function/endpoint-level guard for the standalone path. This isn't optional hardening; the current function is unsafe to call directly without it.

This hole is independent of the mutation decision. It's about editing a preset row you don't own, an operation that exists however the preset's content later reaches a conversation. Still a slice-1 blocker, and the hardest-edged item on the list because it's a real hole rather than a design preference.

Existing Custom Instructions also has a full validation contract, and under a live FK it doesn't simply carry over — part of it has to move. Today: ownership checked before any compute happens (ConversationsEndpoints.cs:903-913, explicitly ordered this way — a non-owner 403s before triggering an embedding charge or learning package-lock state), a hard 5,000-character limit (:915-917), and a vector-similarity injection-pattern check against the text (:919-927).

Attaching a preset also needs its own read-authz check, separate from ownership-before-mutation:

Two things an earlier draft listed here are resolved by the import-clones-first rule rather than left open:

Substrate boundaries the discriminator alone doesn't enforce

Raised on external review (2026-07-31), and correct: purpose='custom_instructions' is a label, and nothing about a label stops a preset row from being linked into a Mode via prompt_mode_sub_prompt_links — the two contracts sharing the table need write-side enforcement, not just read-side purpose checks:

Legacy migration — no longer a question

There is no migration. An existing conversation_custom_instructions row is already exactly what the detached / ad-hoc case looks like — literal text in the instructions column, with a NULL preset FK. That's a valid post-feature state, not a legacy state needing conversion: it's simply a conversation whose instructions were typed rather than attached from a preset, which stays a first-class case forever (it's the same state a user lands in the moment they edit a preset-linked conversation locally). Every existing row keeps rendering, keeps being editable, and needs no backfill, no flag, and no dual-read path.

For the record, the three cases that exist in that bare table today (07_tables_conversations.sql:13-22 — id, instructions, created_at, updated_at; no owner, no source flag) and where each lands:

  1. Ordinary user-typed Custom Instructions → unchanged, indistinguishable from a post-feature hand-typed value.
  2. A package-authored instructions_locked value the reader never wrote → already handled by the package-lock retirement (shipped 2026-07-22, commit 4fff5326d): the value simply stopped being locked and became an ordinary editable starting value for the conversation's owner. Collapses into case 1.
  3. A branching snapshot (38_branch_conversation.sql:159-164 copies the text into a fresh row with no back-reference) → unchanged. A branch of a preset-linked conversation should carry the FK across the same way it carries persona and text, so the branch stays linked too — one line to add alongside the existing copy.

The one genuinely optional nicety, explicitly not required: offering a user a "save this as a preset" action on a conversation that already has text. That's an additive UI affordance whenever someone wants it, not a migration.

A user-level default preset — mirror the persona mechanism verbatim

Decided (dev, 2026-07-25): a user can mark one Custom Instructions preset as their default, applied to new conversations exactly the way a default persona already is. Custom Instructions only — Summarization and Flavor get no default in this slice.

This is deliberately not a new pattern. The default-persona mechanism already exists, is already applied server-side in both conversation-create paths, and already handles the stale/not-owned/malformed cases — so this is a clone of a working thing, not a design. Its four parts and their Custom Instructions counterparts:

Part Persona (existing) Custom Instructions (new)
Storage user_settings row, key Persona.DefaultId, value = id as a string (SettingsKeys.cs:1145). No schema change — user_settings is generic KV CustomInstructions.DefaultPresetId, same shape, pointing at a purpose='custom_instructions' sub_prompts row
Resolver fn_get_default_persona_id(user_id) — STABLE SQL, ownership enforced in the JOIN, returns NULL for unset / stale / not-owned / non-numeric (11_conversation_migration_functions.sql:216-227) fn_get_default_custom_instructions_preset_id(user_id) — same shape, same return kind (an id), joined against sub_prompts with purpose='custom_instructions' AND NOT is_deleted — a preset removed from the library must stop attaching to new conversations even while existing links keep resolving it (the soft-delete asymmetry, below)
Application COALESCE(p_persona_id, fn_get_default_persona_id(…)) in the INSERT (:387); package path calls it bare since package start has no persona pick (47_package_functions.sql:483) non-package path: the same COALESCE(explicit, default) on the new custom_instructions_preset_id column. Package path: guarded, not bare — the default resolver runs only when the package supplies no custom_instructions text; a bare COALESCE there would set both the package's local text and the default FK, the exact both-set state the precedence rule forbids
Surface GET/PUT/DELETE /api/personas/default (PersonasEndpoints.cs:363-498) + a per-row "set as default" action with the default pinned to the top of the list (PersonasTab.tsx:148) the same three routes and the same affordance on the preset library

It's a column-for-column clone (with one guard the persona version doesn't need)

Because the preset is a live FK like the persona is, the application step on the non-package path is literally the same expression on a different column — COALESCE(explicit, fn_get_default_…(p_user_id)) in the same INSERT that already resolves the persona default. No new insert, no new row, no text handling. The package path is the one divergence from a pure clone: there the default is wrapped in the package-text guard (apply only when the package supplies no custom_instructions — see the Application row above and Precedence), a condition the persona default never needed because packages don't seed personas.

That's a simplification over what an earlier draft of this section described. Under copy-on-apply the default had to materialize a conversation_custom_instructions row at creation, and the note here was that fn_create_conversation_from_package already had a template for exactly that (47_package_functions.sql:458-463 + :485). That template is no longer needed for the default path — but it remains the reference for how the package supplies its own instruction text, which is still how precedence gets resolved below.

It really is the same mechanism, all the way down

web_conversations.user_persona_id is a live FK to a row the same user owns; the preset FK is a live FK to a row the same user owns. So the resolver returns an id, not text, and the "set as default" affordance can behave identically in both places without teaching a wrong expectation — editing your default persona and editing your default preset both propagate to conversations still linked to them. (An earlier draft of this section had the resolver return text and warned about the resulting asymmetry; that asymmetry is gone along with copy-on-apply.)

One difference remains, and it's a UI concern rather than a mechanism one: a conversation can detach from its preset by editing the instructions locally (rule 2 above), which has no persona analogue. The default only ever applies at creation, so detaching later is unaffected by it — but the picker should make "linked to Terse prose" versus "edited locally" visible, or a user will wonder why their preset edit didn't reach a particular chat.

Precedence, the one actual design question

Only the package path has a conflict, because it already supplies its own custom_instructions as text when non-empty (47_package_functions.sql:459-463) while the user default supplies a preset FK — the two sit in different columns, so "both set" is representable and has to be ruled out deliberately rather than left to whichever runs last.

Decided: the package's text wins when it supplies one — the conversation starts in the detached/local state with the package's text and a NULL preset FK. The user's default preset applies only when the package supplies nothing. That mirrors COALESCE(explicit, default), and it's safe because the lock was retired: the package's value is now just a better starting point the reader can freely edit, wipe, or replace by attaching one of their own presets, not something they're stuck with.

Carve-out to copy deliberately: branching must not re-apply the default

fn_get_default_persona_id's own comment spells out why the branch path deliberately skips it: "a branch copies the parent's persona including NULL — a user who detached their persona must not get the default re-applied" (11_conversation_migration_functions.sql:206-208). The same must hold here. Branching already copies instruction text verbatim (38_branch_conversation.sql:169), so it holds for free today — record it as intentional so a later change doesn't "helpfully" add default resolution to the branch path.

Two registration points a naive implementation will miss

Both found by grepping the persona key rather than assumed, and both fail loudly rather than silently — but only if you know to look:

  1. 89_enforce_setting_write_scopes.sql:13 — a write-scope registry: ('Persona.DefaultId', ARRAY['user'], 'Fixed-key default-persona endpoint.'). The new key needs its own row or writes to it are rejected.
  2. SettingsSeedingTests.cs:35 — an explicit allowlist of keys that are deliberately not seeded into default_settings ("Persona.DefaultId", // per-user). The new key must be added there or that test fails. This is the enforced form of the "a key only lists if it has a default_settings row" rule; a per-user fixed-key setting is the sanctioned exception.

Moderation model — differs by who wrote it

The authorship split above is the reason this section can't be one policy. Traced the existing mechanism precisely rather than guessing:

User-authored (Custom Instructions, Summarization) — lightweight, report-style

The dev's proposed model: publish immediately, check runs, result is "report style," not a gate. This deliberately diverges from Character/Lorebook/Mode, which block public visibility behind a human-approved publish_requests row (Pending → Approved/Rejected). A user's own personal preset, self-scoped or shared peer-to-peer, is a much smaller attack surface than a full character or world — so the proposal is: flip is_public = TRUE immediately, run the same proven keyword check (fn_run_keyword_check(..., 2) — the "prompts" area, already used for mode sub-prompts) inline, synchronously, in the same transaction — no publish_requests row, no pg_notify, no background worker, no pending state. If it flags, the preset stays live but a report is left for admin visibility, matching the platform's existing "flag, don't block generation" posture rather than inventing a new blocking gate. The closest existing UX precedent for "runs a check, doesn't gate" is ContentPreCheckEndpoints (server/EchoOfDreams.ServerAPI/Api/Endpoints/ContentPreCheckEndpoints.cs:16-29) — though that one is creator-facing/advisory and persists nothing; this needs the inverse (persist a flag for admin visibility, say nothing alarming to the creator).

Correction — this is already confirmed, not an open question. moderation_check_results was already generalized for standalone entity checks: 12b_generalize_check_results.sql made publish_request_id nullable, added entity_type VARCHAR(30) + entity_id INTEGER, and added CHECK (publish_request_id IS NOT NULL OR (entity_type IS NOT NULL AND entity_id IS NOT NULL)). So the storage question is answered — no new table needed. What's actually still missing, now that the schema question is off the table:

  1. Prompt/sub_prompts needs to become an entity the check-writer can address via entity_type — today's EntityRegistry.cs:198-200 Prompt entry is a route/display alias for EntityType.Mode, not a distinct entity_type value the standalone-check columns could reference cleanly.
  2. An actionable admin queue — a flagged-content list, not just rows sitting in a table nobody looks at. The check landing in moderation_check_results doesn't by itself create visibility; something has to surface "these presets got flagged" to an admin.
  3. Dismiss/resolve state on a flagged report — today's schema generalization added where a standalone check result lives, not a resolution workflow for it.
  4. Re-checking on every edit while public, not just at the moment is_public flips true — otherwise a user publishes clean text, passes the check, then edits it to something else entirely and the report-style check never re-runs. The "check on publish" framing above needs to mean "check on every edit while live," not "check once."
  5. One transactional gateway, not policy prose. "Re-check on every edit" only holds if there's a single code path that publishing/editing public content is forced through — otherwise a different endpoint or a direct SQL caller (the same class of gap as the fn_upsert_sub_prompt ownership hole above) can mutate a public preset's content without ever touching the check. The edit, the check run, the result write, and invalidating any prior admin resolution belong in one transaction, not three separately-callable steps a future endpoint could skip.
  6. Dismissal needs to be tied to a content version/hash, not just a status flag. If an admin dismisses a flagged report and the preset is then edited, the dismissal must not silently cover the new text — a dismissal recorded against the content that was actually reviewed, invalidated the moment the content changes, so an edited-after-dismissal preset opens a fresh unresolved case rather than inheriting the old all-clear.

Creator-authored (Flavor) — a different, heavier problem, and currently an outright gap

Flavor content is not a candidate for the lightweight report-style model above. It's creator-written copy that ships to every reader of every Package resolving that creator's Model Profile — the same distribution shape as Mode content, which is why Mode content gets the full pre-approval pipeline. Treating Flavor like a personal Custom Instructions snippet would under-moderate creator-authored, audience-facing prose.

But today it's worse than under-moderated — it's unmoderated. Checked ModelProfile's existing publish-check coverage (database/v1/functions/32_run_content_checks.sql:607-613): when a Package goes through publish_requests, its linked (non-public) Model Profiles get swept in for check, but only name/description — there is no join through any linked prompt/Flavor content the way the Mode check block joins through prompt_mode_sub_prompt_links. So once Flavor overlays ship (per Document Mode Editor), their prompt text has no moderation coverage path at all unless one is deliberately added — this predates and is independent of this doc's user-authored-preset work, but belongs on the same punch list since it's the same substrate (sub_prompts) surfacing the same "is this content actually being checked" question. The fix is likely mechanical — extend the Package/Model-Profile check sweep to join through the Flavor's linking mechanism the same way the Mode check block already does for prompt_mode_sub_prompt_links — but it's a distinct, separate change from the lightweight trigger above, not a byproduct of it.

Summarization needs its own research pass

Correction — the premise in an earlier draft of this section was wrong, and worth recording so it doesn't get re-asserted. It claimed summarization is prose end-to-end with no JSON parsing, based on grepping only SummarizationStageBase (which has none). The actual JSON handling lives one layer down, in SummarizationLlmService.cs, which the earlier research pass didn't check:

So this isn't "prose today, JSON tomorrow" — it's a fixed two-field JSON contract today (summary, keywords, both hardcoded), and the dev's ask is extending that to a user-definable N-field contract where a non-technical user names what else they want captured. Real new work, correctly rescoped: the gap is the field-definition layer and the parser/validator that has to handle arbitrary user-chosen fields (today's parser only ever looks for exactly summary and keywords), not "add JSON parsing that doesn't exist."

The Trackers typed-value system (value_type: freeform/numeric/percentage/enum/list/datetime, TrackerValueFormatter in server/EchoOfDreams.Core/Services/Tracker/ turning a typed field definition into both the eval's [type: …] prompt instruction and the parse/validate/render logic) is still the strongest reuse lead — same "user names typed fields, backend builds the instruction and validates the output" shape, different consumer.

Decided, not left open: a Summarization preset is one atomic aggregate, not three independently selectable pieces. prompt_mode_contents already carries summarize_messages_prompt and summarize_summaries_prompt as a pair — the per-window summarize prompt and the rollup-merge prompt that combines summaries into a summary. A user-authored field schema has to be honored by both (a custom field defined for message summarization has to survive the rollup, or it silently disappears the first time two summaries merge). Modeling a Summarization preset as three independent, separately-selectable sub_prompts rows (message prompt, rollup prompt, and some detached notion of "the schema") would let someone pick an incompatible combination — the messages prompt asking for a mood field while the rollup prompt has no idea mood exists. An earlier draft of this doc left this as an open question even though its own reasoning already proves the answer — fixed: one versioned aggregate (both prompts + the field schema, edited/selected/versioned as a single unit, whether or not it's stored as literal sub_prompts rows underneath). A real design difference from Custom Instructions, which genuinely is just one block of text and doesn't need this.

A sharper problem this creates: schema drift across a conversation's own summary chain. Note that Custom Instructions' live-FK answer makes this worse, not better, which is why Summarization is allowed to diverge: a live FK means a preset edit reaches the next rollup immediately. Even the weaker guarantee — "editing a preset doesn't retroactively rewrite past summaries" — isn't sufficient by itself. Summaries roll up — a later summarization call merges older summaries into a new one — and if a user edits their preset's field schema between two rollups, the rollup call runs the new schema's prompt against old summaries that were produced under the old schema. The old summary's custom fields may not exist under the new schema, or the new schema may expect fields the old summary never populated. This needs an explicit answer, not silence: either (a) a conversation's summary chain pins the preset version/schema that produced it and rollups only ever combine same-schema summaries (falling back to treating older summaries as unstructured prose input when schemas don't match), or (b) editing a Summarization preset that has any existing summaries forces a new preset id rather than an in-place edit, so "which schema produced this" is always unambiguous from the reference alone. Not decided — needs to be before Summarization's slice, not discovered when a rollup silently drops a field.

Context Budget accounting — presets must feed it correctly, not bypass it

Flagged separately because it's easy to lose: whatever a user selects (a Custom Instructions preset, a Summarization preset, an enabled Flavor) has to show up correctly in Context Budget, not just work at generation time. Traced what "correctly" means against the real mechanism rather than assuming a token-budget allocator exists:

Decided (dev, 2026-07-25): display-only, like everything else. The Context Budget redesign and warn/truncate enforcement are explicitly out of scope — nothing in the codebase enforces a token budget for any section today, and presets don't become the first. "Calculated correctly" means exactly the display fixes above: the preset-FK branch on the Custom Instructions line, Flavor's first line item (when Flavor ships), and the public doc's stale chars/4.

Relationship to existing systems

Open questions

Decisions the dev already made in the conversation that produced this doc:

Still open, mine to research/decide before a slice starts:

Suggested slicing (leans, not committed)

  1. Substrate: one thing to settle first — the fn_upsert_sub_prompt ownership gap, which is a real hole rather than a design choice and must be closed before any standalone edit path can call that function. (Mutation semantics and legacy migration used to gate this slice too; both are now decided/dissolved.) Then build: is_deleted on sub_prompts, the purpose='custom_instructions' discriminator, a preset library (private-only, no sharing yet), the nullable custom_instructions_preset_id FK on the conversation, attach / detach-on-local-edit behavior, and the attach-time read-authz check. Resolve the FK everywhere the text is read — the core runtime change: the prompt build (PromptContextManager.AppendCustomInstructionsAsync, PromptContextManager.cs:278-311, which today only knows the local row) and the conversation read API that surfaces the text in the chat drawer, both branching FK-set → preset content, NULL → local row. Add the 5,000-char cap and the injection check at preset save/edit (required by the live FK — the preset's text never passes through the conversation-save path that runs them today; they stay on conversation-save for local text — two sites, not a move), and keep ownership-before-compute exactly where it is. Plus the shared "pick a saved prompt" UI (built here per rule-of-two, not deferred — see What's new #5), showing linked-vs-detached state so a user can tell why a preset edit did or didn't reach a given chat. Also in this slice: the user-level default preset — the CustomInstructions.DefaultPresetId setting, its resolver, and its application in both conversation-create paths: plain COALESCE(explicit, default) on the new FK column in fn_create_conversation, but guarded in fn_create_conversation_from_package — the default applies only when the package supplies no custom_instructions text, else a bare COALESCE would create the forbidden both-set state (package local text + default FK). Plus the three /default routes, the "set as default" affordance, and the two registration points (89_enforce_setting_write_scopes.sql, SettingsSeedingTests.cs). A column-for-column clone of the default-persona mechanism, so it rides along here rather than earning its own slice — see A user-level default preset. Smallest possible slice that proves the standalone (non-mode-linked) path works end to end for Custom Instructions specifically — Summarization's summarization_presets aggregate is deliberately slice 3's problem, not this one's, since it's a different shape. Already done, ahead of the slice: retiring the package-lock enforcement on Custom Instructions (shipped 2026-07-22, commit 4fff5326d — ConversationsEndpoints.cs, PackageLockDto, PackageRepository, WhoDrawer.tsx, changelog trigger, Echo Guide KB; verified live against a package with instructions_locked = TRUE still set). Small but don't forget: branch the Context Budget custom-instructions line on the preset FK (ConversationBrowseRepository.cs:385-393, modeled on the persona line at :419-425), carry the FK across in fn_branch_conversation, and fix the public Context Budget doc's stale chars/4 claim to match the code's chars*2/7 (see Context Budget accounting).
  2. Sharing + moderation: flip is_public live, build the import-as-clone action (the actual sharing mechanic under rule 3 — browsing another user's public preset clones it into your library; no cross-user FK ever exists), wire the inline keyword check, give Prompt a real entity_type the standalone-check columns can address, and build the admin flagged-content queue as one transactional gateway with dismiss/resolve state tied to a content version and re-check-on-edit (moderation_check_results already supports the storage side — see Moderation model).
  3. Summarization decoupling: its own research pass first (see Summarization needs its own research pass) — build the summarization_presets aggregate (owning two sub_prompt_contents rows + a field schema, per What's new #2), resolve the schema-drift-across-rollups provenance question and the stored-result design (structured storage for user-named fields + per-summary preset/schema provenance on web_summaries — see the open item above; the schema/result design lands before the UI), extend the fixed summary/keywords JSON contract to user-definable fields, and reuse the Tracker typed-field substrate where it fits. Reuses slice 1's shared picker (pointed at the aggregate, not a sub_prompts row), surfaced in the chat UI per the placement lean above (an "Options" surface near Context Budget / Memory in the How-drawer stack). Applies to both pipeline types per the decided item above — the beat mode supplies no summarization prompts. Does not touch Context Budget — Summarization prompts are correctly excluded from it (see the correction above); only the existing "summaries" line's character_count bookkeeping needs to keep working unchanged.
  4. Model Profiles hybrid-ready — committed scope, specced in the companion doc: Model Profiles — Hybrid-Ready, including its own slicing and the dependency ordering between its two pieces. What stays anchored here: the Flavor content-moderation gap from Moderation model, slice 1's shared picker being reused for Flavor import, and Flavor's first Context Budget line item — all three ride with the companion doc's Flavor half, since they need Flavor to exist.

This ordering isn't a commitment — slice 0 for whichever piece gets picked up first should answer most of the open questions above as a side effect, the same way any slice 0 does.


Slice 1 — as built (2026-08-04)

Slice 1 is implemented. This section records what shipped and, more importantly, where the build diverged from what this doc predicted — divergences only, so a later reader can tell design intent from implementation fact without re-deriving either.

Divergences from the plan above

  1. The fn_upsert_sub_prompt ownership check is scoped by row kind, NOT a blanket created_by_user_id = p_user_id. This doc proposed the blanket form. Building it that way would have been a regression: the mode-prompt PUT passes the caller's id, not the row owner's (CreatorModeEndpoints, gated by RequireEntityAccess(… a => a.can_edit …)), so a collaborator legitimately editing a shared mode's sub-prompt would have started failing. Mode sub-prompts are authorized by their parent Mode; only standalone presets are authorized by ownership. So the guard fires only for purpose IS NOT NULL rows — which is where the actual hole was, since those are the rows with no parent to gate them. A regression test pins the collaborator case so a future "tighten this" change can't silently break shared-mode editing.

  2. The FK is resolved once in conversation_view, not branched separately in two readers. This doc said PromptContextManager.AppendCustomInstructionsAsync and the conversation read API would each branch. Both already read through conversation_view (WebConversationRepository.GetCustomInstructionsForConversationAsync is the prompt hot path), so the branch became one COALESCE(preset content, local text) in the view. PromptContextManager is unchanged. One place means the prompt build and the API cannot drift into disagreeing about what a conversation's instructions are.

  3. "Both set" is unrepresentable at the table, not just avoided by writers. Added check_web_conversations_instructions_not_both. The doc treated this as a rule the attach path and the local-edit path each had to uphold; making it a CHECK means a future third writer cannot violate it. Same move for the substrate boundaries: purpose's vocabulary and preset ⇒ provider_key IS NULL are table CHECKs in addition to writer assertions.

  4. custom_instructions_preset_id carries no FK constraint, mirroring user_persona_id (which has none) rather than the custom_instructions_id column next to it (which does). Soft delete keeps the referent alive, so there is nothing for ON DELETE to do.

  5. fn_create_conversation gained a 13th parameter (p_custom_instructions_preset_id) so COALESCE(explicit, default) is real rather than default-only. It is not exposed on the REST create endpoint in slice 1 — attach-after-create is the UI flow — but the SQL contract supports it and is tested.

  6. fn_update_conversation_authorized's RETURNS TABLE had to be extended. It is a hand-maintained subset of conversation_view, so new view columns do not arrive for free; without the four preset columns (custom_instructions_preset_id, _uuid, _name, _is_deleted) every conversation PUT would have responded as though the conversation had just detached.

  7. Attach refuses a foreign conversation with 403, while every preset refusal is a uniform 404. The preset side is the enumeration-sensitive one and collapses all four failure modes (not yours / missing / wrong purpose / deleted) into one response. The conversation side matches its sibling UpdateCustomInstructions exactly rather than inventing a second convention; changing that pattern is a separate decision that should move both endpoints together.

  8. EntityRegistry's Prompt entry was deliberately left alone (DeletedColumn: null). Setting it to is_deleted would stop uuid→id resolution for soft-deleted presets, which would break the already-linked conversations that must keep resolving them. Liveness is filtered explicitly in the preset queries instead.

Also in this change, unrelated to presets

Not done in slice 1 (deliberately)

Sharing / is_public / import-as-clone, the admin flagged-content queue, and dismissal-tied-to-content-version are all slice 2 and are untouched. The write gateway (CustomInstructionsPresetGateway) is structured as the single path they will join.


Acceptance Criteria — Slice 1 only (private Custom Instructions presets)

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)

Behavior

Invariants that must stay true (carve-outs — the spec'd-free/baseline paths)

Edges