Model Profiles — Hybrid-Ready

What this is

Two pieces of unfinished substrate, both surfaced by Hybrid Pipeline's Model routing §as-built note, that together "finish what role-tagged Model Profiles were built for":

  1. The hybrid runtime doesn't consume role-tagged entries. ✅ Shipped 2026-08-04 — see As built. (Stated below as it stood before the build, because the contract paragraph that follows is what was implemented and is still the reference.) model_profile_entries.role (0=Primary / 1=Beat / 2=Prose) already shipped end to end through repo/API/Workbench — but nothing in the hybrid runtime consumes a role-tagged entry yet. The hybrid legs run on flat HybridPipelineLlm.* settings with hardcoded beat/prose prompts, and no "Authentic over Comfort" Profile pairs the two roles. The column is a promise the runtime doesn't keep yet.

    The contract, stated with the arrow pointing the right way (an earlier draft had it backwards — "resolve Beat/Prose models from role-tagged entries" — corrected on review): an Entry is model_identifier → Mode + optional param overrides (23_tables_model_profiles.sql:54-84). It carries no provider, preset, endpoint, or credential — a public Profile must stay credential-free, so an entry can never supply a model, only match one. Concrete execution always comes from the user/settings side (today the flat HybridPipelineLlm.* family — Provider / Endpoint / ApiKey / Model plus the Prose* variants, SettingsKeys.cs:434-452; durably, an accessible concrete preset selected per role). Consuming role-tagged entries means: given the Beat leg's concrete model, match it against the Profile's same-role entries by model_identifier — the winning entry supplies that leg's Mode. Its stored parameter values are opt-in recommendations, not automatic overrides — Document Mode Editor is explicit that Entry parameters never auto-apply during resolution (the "Apply recommendations" flow is the only path they land through), and hybrid roles are not an exception (an earlier draft of this contract said "Mode and param overrides" — corrected on review; the schema comment's word "overrides" describes the column's intent, GME's recommendations rule governs its application). Effective params come from the leg's preset/user Generation settings, exactly as in classic. Then freeze the tuple — (profile, role, entry, mode, preset/provider/model, effective params) per leg — for the turn; the minimum meaning of "freeze" in this slice is resolve-once-per-accepted-turn carried on the pipeline context, deliberately independent of the Document Mode Editor plan-freeze. No same-role match → that leg keeps its selected model and today's behavior — which is not hardcoded prompts (a stale claim in an earlier draft): the legs already run the settings-bound seed Modes via the HybridPipelineLlm.BeatModeId / .ProseModeId interim bridge, with the hardcoded HybridPipelinePrompts constants only as the last-resort fallback when those settings are unset or unresolvable (Hybrid Pipeline §4's as-built note). Entry consumption replaces the interim settings bridge, not the constants — a Profile that predates roles changes nothing.

    Pair-winner, tie-break, and provenance — the minimum contract piece 1 must pin (raised on external review, correct that it was unstated; implemented as specified — see As built):

    • One Profile owns the pair. Packages bind multiple ordered Profiles, and the existing resolver is one flat query across all bindings (47_package_functions.sql:294-316 — match tier → identifier length → binding order → entry order). Running that same per-role query independently for Beat and Prose could produce Beat from Profile A and Prose from Profile B — legal SQL, incoherent product: the language everywhere is "one Profile describes both halves." Decided: walk bound Profiles in binding order; the first Profile carrying any role-tagged (Beat/Prose) entry is the conversation's hybrid pair-owner, and both legs resolve strictly within it. A leg with no same-role match inside the pair-owner keeps seed-mode behavior — it does not fall through to the next bound Profile (pair coherence beats match rate; revisit only with evidence).
    • Frozen ≠ Guided's execution plan. This slice stays independent of the Document Mode Editor plan-freeze: the minimum freeze here is resolve once per accepted turn and carry the result on the pipeline context (exactly how the beat call's telemetry already rides the context today) — no mid-turn re-read of settings or entries. Folding into the full execution-plan machinery is the end-state when that ships, not a dependency of this slice.
    • Per-leg provenance is persisted, not inferred. web_message_stats carries mode_id/provider/model but no Profile or Entry identity, and reverse-inferring the Entry from mode_id is exactly the trap Document Mode Editor already names (two Profiles may point at the same mode). Each hybrid stats row (stage='hybrid-beat'/'hybrid-prose') gains the winning entry id — nullable, no FK, may dangle — mirroring the web_conversations.model_profile_entry_id convention.
  2. Flavor's target_stage is hardcoded to classic_primary. Per Document Mode Editor §Flavor validity and ownership, V1 Flavor runtime is deliberately Web + Classic only — Direct/Discord/Hybrid assemble the Base unchanged and report the Flavor layer unsupported ("Style & rules are available in Classic chats"). Extending target_stage to beat_direction / prose is what lets a Flavor apply in a hybrid turn.

They're one committed feature rather than two coincidental fixes because they end in the same place: a Model Profile that fully describes how a creator's work runs in a hybrid conversation — which models take the Beat and Prose legs, and which style overlays apply to which stage.

Dependency ordering — the two pieces are not symmetric

What already exists (verified against code, not assumed)

Relationship to sibling specs

Doc Relationship
Prompt Presets The implementation this scope is committed to. Owns the shared sub_prompts substrate, the picker, and the Flavor moderation-gap analysis.
Document Mode Editor Owns Flavor's design — validity rules, ownership, target_stage, import-as-clone. Piece 2 extends what it defines.
Hybrid Pipeline Owns the runtime the role-tagged entries must feed. Its Model routing as-built note is the origin of piece 1. Its § Package start makes piece 1's role entries reader-visible: whether a package carries beat/prose entries becomes the readiness signal in the package start modal — copy only, never a gate, because a leg with no match degrades to the settings-bound seed mode.

Suggested slicing (leans, not committed)

  1. Role-tagged entry consumption — ✅ SHIPPED 2026-08-04 (As built). Per the contract above — each hybrid leg's concrete model (settings/preset-side) is matched against the effective Profile's same-role entries; a match supplies that leg's Mode + param overrides, no match keeps the settings-bound seed-mode behavior. Includes the per-leg execution-plan freeze. Ship with at least one real paired Profile ("Authentic over Comfort") to prove it.
  2. target_stage extension (after Flavor ships): extend past classic_primary to beat_direction / prose, plus the three riders above (moderation-coverage join, picker reuse, Context Budget line).

Open questions

Open follow-ups (knowledge review, 2026-09-29)

As built — piece 1

Shipped 2026-08-04. The consumption contract above was implemented as written; this section records only what the code adds to it and where it diverged.

Where it lives

Concern Code
Pair-owner walk + per-role tiered match database/v1/functions/47d_hybrid_role_mode_functions.sql — fn_resolve_hybrid_role_modes, fn_match_model_profile_role_entry
Per-turn resolution + freeze HybridLegPlanner.ResolveRoleModesAsync, run once by HybridContextBuildingStage (the hybrid_context stage, Order 100, before compute allocation) → IPipelineContext.HybridLegPlan + .HybridRoleModes (Core/Services/Hybrid/HybridLegPlan.cs, HybridRoleModeResolution.cs)
Per-leg mode precedence HybridLegPlanner.ResolveLegModeAsync — entry → settings binding → constants
Repository seam IModelProfileRepository.ResolveHybridRoleModesAsync behind IHybridRoleModeSource
Provenance web_message_stats.model_profile_entry_id (27_tables_message_stats.sql), threaded via WebMessageStatsStage
Seeded pair database/v1/92_seed_hybrid_model_profile.sql — "Authentic over Comfort"

Divergences from the spec text (deliberate, each with its reason)

  1. Param overrides are NOT applied. The contract paragraph above says a winning entry supplies "Mode and param overrides"; piece 1 supplies the Mode only. This was the brief's explicit call, and it is load-bearing rather than a shortcut: fn_resolve_hybrid_role_modes does not even return the parameter columns, so no caller can start applying them by accident. The entry keeps holding them as recommendations for a future opt-in surface.
  2. The plan-freeze does NOT ride the Document Mode Editor's execution-plan machinery. The spec's §1 pointed at that plan-freeze as the model; the brief scoped it out, and the implementation freezes a single small record on the pipeline context instead — the same carrier BeatTelemetry already uses. What is frozen is narrower than the spec's tuple: (profile, per-leg entry, per-leg mode), not (… preset/provider/model, effective params), because the model side never moved off the settings path and params are not applied.
  3. The beat leg is matched against the beat call's whole fallback chain, not HybridPipelineLlm.Model alone. BeatLlmService.TryResolveModel (the resolver the beat call itself uses: HybridPipelineLlm.Model → Llm.Model since 2026-11-22, Relay eod-421; before that the helper stages TrackerEvalLlm.Model → JournalEvalLlm.Model → SummarizationLlm.Model came between) is shared with the matcher. Reading the first key alone would match against a blank while a fallback supplied the model that actually ran. Same move on the prose side via ProseSettingsOverride.ResolveProseModel (ProseModel → Llm.Model).
  4. A winning entry whose Mode can't serve degrades to the settings-bound Mode, not to the constants. The spec only says an unmatched leg keeps today's behavior. A matched entry pointing at an unusable Mode (zero declared sections) is a third case; dropping only what the entry added stays closer to the creator's intent than falling to a compile-time prompt.
  5. Pair ownership requires a role-tagged entry with a LIVE Mode. A Profile whose only role-tagged entries point at soft-deleted Modes cannot serve either leg, so letting it own the pair would starve both legs and shadow a later Profile that could serve them.
  6. is_default on package_model_profiles is not consulted — ownership is pure binding order, matching what the classic resolver does.
  7. Unplanned prerequisite: package-start could not be Hybrid. fn_create_conversation_from_package never set pipeline_type, and ConversationsEndpoints documented "Package-start stays Classic" — so no conversation could be both package-bound and Hybrid, and this feature (which resolves through the package) was unreachable. p_pipeline_type was added to the function and the endpoint now honours IsHybrid on the package path. UI reachability (added 2026-08-05, dev decision): the chat gear menu's "New conversation" re-pick is now package-aware — on a package conversation it creates a new package conversation honoring the pipeline pick, making package+Hybrid reachable without insider knowledge. The package-page start still shows no picker (always Classic), deferred to the persona-templates new-chat redesign as before.

Open questions this settles

Acceptance Criteria — piece 1 (role-tagged entry consumption)

Scoped to piece 1 only. Piece 2 (target_stage) waits on Flavor existing and has no criteria here. 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):

Edges: