<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mindattic.com/wiki/docs/index.php?action=history&amp;feed=atom&amp;title=Prose%2FARCHITECTURE</id>
	<title>Prose/ARCHITECTURE - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mindattic.com/wiki/docs/index.php?action=history&amp;feed=atom&amp;title=Prose%2FARCHITECTURE"/>
	<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Prose/ARCHITECTURE&amp;action=history"/>
	<updated>2026-12-05T17:48:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.3</generator>
	<entry>
		<id>https://mindattic.com/wiki/docs/index.php?title=Prose/ARCHITECTURE&amp;diff=753&amp;oldid=prev</id>
		<title>Docs Sync: md2wiki: sync from MindAttic.Docs</title>
		<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Prose/ARCHITECTURE&amp;diff=753&amp;oldid=prev"/>
		<updated>2026-11-29T20:31:05Z</updated>

		<summary type="html">&lt;p&gt;md2wiki: sync from MindAttic.Docs&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Prose — System Architecture =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;strong&amp;gt;Replaces the previous version of this file (superseded 2026-06-07, deleted content centered on &amp;lt;code&amp;gt;StoryDirectorService&amp;lt;/code&amp;gt; and a Blazor &amp;lt;code&amp;gt;Write.razor&amp;lt;/code&amp;gt; UI — both deleted 2026-08-13, commit &amp;lt;code&amp;gt;ed22bd4f6&amp;lt;/code&amp;gt;, &amp;quot;Command-line only&amp;quot;).&amp;lt;/strong&amp;gt; This describes the C# system as it actually exists as of 2026-10-07 (refreshed from the ~2026-08-23 version — see the Hub observability work order 01a1188f for what changed). For story-world canon (GLMZ facts, engine invariants), see &amp;lt;code&amp;gt;docs/BIBLE.md&amp;lt;/code&amp;gt;. For universal prose craft rules, see &amp;lt;code&amp;gt;docs/ENGINE.md&amp;lt;/code&amp;gt; (Tier 0) and &amp;lt;code&amp;gt;docs/CRAFT.md&amp;lt;/code&amp;gt; (Tier 1) — this file is about the &amp;lt;em&amp;gt;codebase&amp;lt;/em&amp;gt;, not the &amp;lt;em&amp;gt;canon&amp;lt;/em&amp;gt;.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 1. The project map ==&lt;br /&gt;
&lt;br /&gt;
Nine C# projects live under &amp;lt;code&amp;gt;src/&amp;lt;/code&amp;gt;. Four are the system; the rest are auxiliary tools or generated contract types.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Project&lt;br /&gt;
! Kind&lt;br /&gt;
! Role&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;strong&amp;gt;&amp;lt;code&amp;gt;Prose.Core&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt;&lt;br /&gt;
| Library&lt;br /&gt;
| Everything: &amp;lt;code&amp;gt;ProseDbContext&amp;lt;/code&amp;gt;, every service (enrichment chain, WriteGate, DCM, audits, generation), EF migrations. No entry point of its own — referenced by all three below.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;strong&amp;gt;&amp;lt;code&amp;gt;Prose.Hub&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt;&lt;br /&gt;
| ASP.NET Core app (&amp;lt;code&amp;gt;WebHost.UseUrls(&amp;quot;http&amp;amp;#58;//127.0.0.1:5900&amp;quot;)&amp;lt;/code&amp;gt;)&lt;br /&gt;
| &amp;lt;strong&amp;gt;The one resident, long-running process.&amp;lt;/strong&amp;gt; Owns the DI container every write and most reads actually execute inside. Hosts &amp;lt;code&amp;gt;CliDispatch&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;ToolDispatch&amp;lt;/code&amp;gt; (reflection-based command execution), the WriteGate hook, the resident Trinity (§3), and a small set of HTTP endpoints (&amp;lt;code&amp;gt;/api/health&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/api/dcm/status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/api/entities/active&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/api/edges&amp;lt;/code&amp;gt;). Runs with a visible console window that echoes every dispatched command in/out (&amp;lt;code&amp;gt;HubConsoleEcho&amp;lt;/code&amp;gt;, added 2026-08-21/22).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;strong&amp;gt;&amp;lt;code&amp;gt;Prose.Cli&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt;&lt;br /&gt;
| Console exe&lt;br /&gt;
| The &amp;lt;code&amp;gt;prose&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;Prose.Cli.exe&amp;lt;/code&amp;gt; command line. &amp;lt;strong&amp;gt;Almost entirely a forwarder&amp;lt;/strong&amp;gt;: 270 handler call sites in &amp;lt;code&amp;gt;Program.cs&amp;lt;/code&amp;gt; call &amp;lt;code&amp;gt;HubCliClient.ForwardAsync(...)&amp;lt;/code&amp;gt; (285 commands total per &amp;lt;code&amp;gt;docs/CLI_COMMANDS.md&amp;lt;/code&amp;gt;), which POSTs to the running Hub and streams its console output back — the actual &amp;lt;code&amp;gt;RunAsync&amp;lt;/code&amp;gt; handler classes under &amp;lt;code&amp;gt;Prose.Cli/Cli/*.cs&amp;lt;/code&amp;gt; (302 files) execute &amp;lt;em&amp;gt;inside the Hub process&amp;lt;/em&amp;gt;, not inside the &amp;lt;code&amp;gt;Prose.Cli.exe&amp;lt;/code&amp;gt; process that was invoked. A couple of commands (&amp;lt;code&amp;gt;WorkerModeCli&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;EstimateCostCli&amp;lt;/code&amp;gt;) run in-process instead — neither touches shared state.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;strong&amp;gt;&amp;lt;code&amp;gt;Prose.Mcp&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt;&lt;br /&gt;
| Library (loaded into Hub)&lt;br /&gt;
| MCP tool definitions (50 &amp;lt;code&amp;gt;Tools.*.cs&amp;lt;/code&amp;gt; files; &amp;lt;code&amp;gt;docs/MCP_TOOLS.md&amp;lt;/code&amp;gt; auto-generated, self-reports 289 tools across 52 families). &amp;lt;code&amp;gt;Prose.Hub&amp;lt;/code&amp;gt; loads this DLL directly — &amp;lt;code&amp;gt;ToolDispatch&amp;lt;/code&amp;gt; reflects into it the same way &amp;lt;code&amp;gt;CliDispatch&amp;lt;/code&amp;gt; reflects into &amp;lt;code&amp;gt;Prose.Cli&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Prose.Hub.Contracts&amp;lt;/code&amp;gt;&lt;br /&gt;
| Library&lt;br /&gt;
| Shared DTOs (&amp;lt;code&amp;gt;ObservabilityDtos.cs&amp;lt;/code&amp;gt;) between Hub and ObserverUi — kept separate so ObserverUi doesn&amp;#039;t need to reference all of Core.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Prose.ObserverUi&amp;lt;/code&amp;gt;&lt;br /&gt;
| Blazor (Razor) app&lt;br /&gt;
| A live observability dashboard over Hub&amp;#039;s own state (&amp;lt;code&amp;gt;HubApiClient&amp;lt;/code&amp;gt;) — part of the 2026-08-20 &amp;quot;Observability plan,&amp;quot; distinct from the deleted &amp;lt;code&amp;gt;Write.razor&amp;lt;/code&amp;gt; authoring UI. Watches, does not author.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Prose.KdpPublish&amp;lt;/code&amp;gt;&lt;br /&gt;
| WPF desktop app&lt;br /&gt;
| Separate tool for Amazon KDP publishing (WebView2-driven), documented in project memory, not part of the Cli/Core/Mcp/Hub write path.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Prose.LlmCli&amp;lt;/code&amp;gt;&lt;br /&gt;
| Console exe&lt;br /&gt;
| Standalone LLM-calling utility, independent of the Hub dispatch model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Prose.UnitTests&amp;lt;/code&amp;gt;&lt;br /&gt;
| Test project&lt;br /&gt;
| 3003 tests as of 2026-10-07 (2984 passed, 0 failed, 19 skipped — the 14 pre-existing failures this row used to note are gone; full &amp;lt;code&amp;gt;dotnet test&amp;lt;/code&amp;gt; run clean).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;The system that matters for &amp;quot;does a write get validated, does a read see fresh state&amp;quot; is Cli → Hub (→ Mcp) → Core.&amp;lt;/strong&amp;gt; Everything else is peripheral tooling.&lt;br /&gt;
&lt;br /&gt;
== 2. The dispatch model — reflection, not routing ==&lt;br /&gt;
&lt;br /&gt;
Neither &amp;lt;code&amp;gt;CliDispatch&amp;lt;/code&amp;gt; nor &amp;lt;code&amp;gt;ToolDispatch&amp;lt;/code&amp;gt; makes any decision about &amp;lt;em&amp;gt;which&amp;lt;/em&amp;gt; code to run beyond &amp;quot;resolve this exact string to a type/method and call it.&amp;quot; There is no request routing, inference, or fallback logic in either.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;&amp;lt;code&amp;gt;CliDispatch.ExecuteCoreInnerAsync&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt; (&amp;lt;code&amp;gt;src/Prose.Hub/CliDispatch.cs&amp;lt;/code&amp;gt;): resolves a handler &amp;lt;code&amp;gt;Type&amp;lt;/code&amp;gt; by exact name (&amp;lt;code&amp;gt;ResolveHandlerType&amp;lt;/code&amp;gt;, cached in a &amp;lt;code&amp;gt;ConcurrentDictionary&amp;lt;/code&amp;gt;), reflects its &amp;lt;code&amp;gt;RunAsync&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;Run&amp;lt;/code&amp;gt; method, redirects &amp;lt;code&amp;gt;Console.Out&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;Error&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;In&amp;lt;/code&amp;gt; and the working directory for the call&amp;#039;s duration (serialized through &amp;lt;code&amp;gt;ConsoleGate&amp;lt;/code&amp;gt;, a single global semaphore — one CLI command runs inside Hub at a time), invokes it, restores state, and writes a &amp;lt;code&amp;gt;CommandLedgerEntry&amp;lt;/code&amp;gt; row.&lt;br /&gt;
* &amp;lt;strong&amp;gt;&amp;lt;code&amp;gt;ToolDispatch.InvokeCoreAsync&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt; (&amp;lt;code&amp;gt;src/Prose.Hub/ToolDispatch.cs&amp;lt;/code&amp;gt;): identical shape for MCP — resolve &amp;lt;code&amp;gt;{ToolClass}&amp;lt;/code&amp;gt; type, resolve &amp;lt;code&amp;gt;{Method}Impl&amp;lt;/code&amp;gt;, JSON-deserialize args positionally by parameter name, invoke, log to the same ledger table.&lt;br /&gt;
&lt;br /&gt;
Both write a &amp;lt;code&amp;gt;CommandLedgerEntry&amp;lt;/code&amp;gt; for every invocation — this is the closest thing to a system audit trail, and doubles as a smoke test (confirm a ledger row + any expected findings-table row exist with correlated timestamps after running a command).&lt;br /&gt;
&lt;br /&gt;
== 3. The resident Trinity — Hub&amp;#039;s real, but narrow, memory ==&lt;br /&gt;
&lt;br /&gt;
Hub genuinely holds long-lived in-memory state across separate CLI/MCP invocations — this is not aspirational. Because the DI container these three are singletons in lives inside the one resident &amp;lt;code&amp;gt;Prose.Hub&amp;lt;/code&amp;gt; process, and because ~99% of CLI/MCP calls forward into that same process (§1), state set by one command really is still there for the next one:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Component&lt;br /&gt;
! What it holds&lt;br /&gt;
! Registration&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DocContextStack&amp;lt;/code&amp;gt;&lt;br /&gt;
| The DCM working set — a &amp;lt;code&amp;gt;ConcurrentDictionary&amp;amp;lt;Guid /*NodeId*/, ContextState&amp;gt;&amp;lt;/code&amp;gt; with its own action counter and LRU eviction (&amp;lt;code&amp;gt;EvictAfterActions&amp;lt;/code&amp;gt;)&lt;br /&gt;
| &amp;lt;code&amp;gt;AddSingleton&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ServiceCollectionExtensions.cs&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EntityContextStack&amp;lt;/code&amp;gt;&lt;br /&gt;
| Entity-level LRU (the &amp;quot;Lyra vs Vega&amp;quot; rule — see CLAUDE.md&amp;#039;s DCM section)&lt;br /&gt;
| &amp;lt;code&amp;gt;AddSingleton&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UniverseGraphService&amp;lt;/code&amp;gt;&lt;br /&gt;
| In-memory entity/edge graph, per-universe &amp;lt;code&amp;gt;GraphState&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;EnsureLoaded&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;EnsureFresh&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;AddSingleton&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Program.cs&amp;#039;s own comment calls these three &amp;quot;the resident Trinity.&amp;quot; Two HTTP endpoints expose them live: &amp;lt;code&amp;gt;/api/dcm/status&amp;lt;/code&amp;gt; (reads &amp;lt;code&amp;gt;docStack.GetActive(...)&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;/api/entities/active&amp;lt;/code&amp;gt; (reads &amp;lt;code&amp;gt;entityStack.GetActive(nodeId)&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;The important caveat&amp;lt;/strong&amp;gt;: this memory is real but &amp;lt;strong&amp;gt;narrow&amp;lt;/strong&amp;gt;. Only &amp;lt;code&amp;gt;DocContextService&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ProseWriterRouter&amp;lt;/code&amp;gt; (the beat-generation path, §4) ever read or write it. The other ~217 CLI/MCP commands — entity CRUD, audits, sweeps, exports — neither consult it nor invalidate it. A write from one of those commands can leave the resident Trinity holding stale state for a concurrent or later generation call, with nothing to catch it. Widening and hardening this is tracked as its own initiative (see the write-gate-successor plan referenced in project memory, &amp;lt;code&amp;gt;project_writegate_phase0_1_shipped_2026_08_22.md&amp;lt;/code&amp;gt; and its follow-on).&lt;br /&gt;
&lt;br /&gt;
The entity stack now has a relational fact pass at beat preparation time. It joins active EntityIds to canonical/confirmed &amp;lt;code&amp;gt;ContinuityClaims&amp;lt;/code&amp;gt;, scores predicate/object text against the beat goal and scene-so-far, collapses duplicate or historical rows per entity/predicate with deterministic tie-breakers, and injects only the highest-scoring facts into the DCM block. Scene-critical details belong here (for example, Kyle drawing Silence with his right hand or Pixel soldering left-handed); entity JSON blobs are not used as a fact store. The same pass is used regardless of whether the request arrived through CLI, MCP, or another LLM client because all adapters enter through the provider-neutral protocol.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;EntityContextStack&amp;lt;/code&amp;gt; (the table row above) is just the container; &amp;lt;strong&amp;gt;&amp;lt;code&amp;gt;EntityContextService&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt; (&amp;lt;code&amp;gt;src/Prose.Core/Services/EntityContextService.cs&amp;lt;/code&amp;gt;) is the engine that populates and reconciles it — three passes per beat: DETECT (scan beat goal + prior scene text for proper nouns, resolve to entity GUIDs), EXPAND (pull each detected entity&amp;#039;s semantic neighbors up to depth 2, from stored embedding vectors, not live re-embedding — fixed 2026-09-07, RFC 0012, after this loop was measured at 52 OpenAI round-trips per Bushido Coda beat), and RECONCILE (post-generation, non-blocking — scan generated prose for entity claims, detect conflicts against canon, file a &amp;lt;code&amp;gt;Finding&amp;lt;/code&amp;gt; for Legion to resolve as fix-prose/update-entity/ignore). This isn&amp;#039;t new from this pass — the engine predates this document — it was simply never named here before.&lt;br /&gt;
&lt;br /&gt;
There is &amp;lt;strong&amp;gt;no routing intelligence&amp;lt;/strong&amp;gt; anywhere in the system — Hub never decides which service or command to invoke; every dispatch is a caller (human via CLI flag, or an LLM via MCP tool name) naming the exact target.&lt;br /&gt;
&lt;br /&gt;
== 3a. The Verification Context Provider (RFC 0011 Brick 1) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;&amp;lt;code&amp;gt;VerificationContextService&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt; (&amp;lt;code&amp;gt;src/Prose.Core/Services/VerificationContextService.cs&amp;lt;/code&amp;gt;) closes the gap RFC 0011 named: a Finding-producing check used to judge a beat in isolation, with no way to ask &amp;quot;what do I already know about this beat/book/character that should change how I judge it?&amp;quot; — the root cause behind a 2026-08-10 session fixing four separately-discovered instances of the same bug (abstract-synopsis-vs-concrete-prose scoring, a POV character&amp;#039;s own established voice misread as a generic AI tic, etc.). It is a real, consulted dependency today, not just a design document: registered as a singleton (&amp;lt;code&amp;gt;ServiceCollectionExtensions.cs&amp;lt;/code&amp;gt;) and injected into &amp;lt;code&amp;gt;ProseWriterRouter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BarksExportService&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;Writer/BeatBriefBuilder&amp;lt;/code&amp;gt;, with test coverage in &amp;lt;code&amp;gt;BarksExportServiceTests&amp;lt;/code&amp;gt;. RFC 0011&amp;#039;s other two infrastructure bricks are also real, not proposals: &amp;lt;code&amp;gt;prose --findings-staleness&amp;lt;/code&amp;gt; (Brick 2 — CraftChecklist is deliberately absent from it, confirmed still correct: its LLM checklist was deleted under BIBLE ADR-10, and the category now holds only deterministic LINT rows hash-gated on beat text, which doesn&amp;#039;t need a rule-version concept) and &amp;lt;code&amp;gt;prose --provider-status&amp;lt;/code&amp;gt; plus a shared &amp;lt;code&amp;gt;ThrowingLlmService&amp;lt;/code&amp;gt; test fixture (Brick 3 — re-surveyed 2026-10-07: at least 51 services take &amp;lt;code&amp;gt;ILlmService&amp;lt;/code&amp;gt; as a constructor dependency; only 3 (&amp;lt;code&amp;gt;SceneContextAssemblerTests&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BeatAuditServiceTests&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SceneCollisionServiceTests&amp;lt;/code&amp;gt;) have the provider-down test. This is a much bigger gap than &amp;quot;a few services left&amp;quot; — closing it is its own bounded follow-up work order, not something to rush as a side effect of an unrelated pass). See &amp;lt;code&amp;gt;docs/rfc/0011-context-aware- verification-and-universal-engine-roadmap.md&amp;lt;/code&amp;gt; for the full brick-by-brick status.&lt;br /&gt;
&lt;br /&gt;
== 4. The prose-generation path — &amp;lt;code&amp;gt;ProseWriterRouter&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ProseWriterRouter.WriteAsync(context, beatId, beatIndex, totalBeats)&amp;lt;/code&amp;gt; is the one real entry point for beat generation (also &amp;lt;code&amp;gt;CombatSceneWriter&amp;lt;/code&amp;gt; for explicit multi-exchange combat). It coordinates ~25 enrichment services, each gated on its own precondition — the full, corrected table lives in &amp;lt;strong&amp;gt;CLAUDE.md&amp;#039;s &amp;quot;Context enrichment chain&amp;quot; section&amp;lt;/strong&amp;gt; (corrected 2026-08-23; do not duplicate that table here, it will drift — this file points to it as the source of truth for that specific mechanism).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;No generation bypass exists any more (corrected 2026-09-04; this section described one as live and &amp;quot;scheduled for deletion&amp;quot; for months after it was gone).&amp;lt;/strong&amp;gt; The last one, &amp;lt;code&amp;gt;SceneGenerationService&amp;lt;/code&amp;gt;, hand-rolled its own path around &amp;lt;code&amp;gt;BeatGeneratorService.GenerateBeatAsync&amp;lt;/code&amp;gt; and skipped the entire enrichment chain; it was &amp;lt;strong&amp;gt;deleted 2026-08-23&amp;lt;/strong&amp;gt; as confirmed dead code — verified again here: no such file, and the sole surviving reference is a historical note in &amp;lt;code&amp;gt;BeatExtractionService.cs&amp;lt;/code&amp;gt;&amp;#039;s header. &amp;lt;code&amp;gt;StoryDirectorService&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Write.razor&amp;lt;/code&amp;gt; went earlier, with the Blazor UI (&amp;lt;code&amp;gt;ed22bd4f6&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;ProseWriterRouter&amp;lt;/code&amp;gt; is the only live generation entry point.&lt;br /&gt;
&lt;br /&gt;
== 5. The WriteGate — the one chokepoint for writes ==&lt;br /&gt;
&lt;br /&gt;
Shipped 2026-08-22 (commits &amp;lt;code&amp;gt;06959f65a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;eac584be0&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;ProseDbContext.SaveChanges&amp;lt;/code&amp;gt;/ &amp;lt;code&amp;gt;SaveChangesAsync&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;src/Prose.Core/Data/ProseDbContext.cs&amp;lt;/code&amp;gt;) run two extra steps beyond the base EF save, for &amp;lt;strong&amp;gt;every&amp;lt;/strong&amp;gt; write on a &amp;lt;code&amp;gt;ProseDbContext&amp;lt;/code&amp;gt; regardless of caller:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Sync, pre-save, can reject&amp;lt;/strong&amp;gt;: walks &amp;lt;code&amp;gt;ChangeTracker.Entries()&amp;lt;/code&amp;gt; against every registered &amp;lt;code&amp;gt;IWriteGateSyncCheck&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;src/Prose.Core/Services/WriteGate/&amp;lt;/code&amp;gt;); a failing check throws &amp;lt;code&amp;gt;WriteGateRejectedException&amp;lt;/code&amp;gt; and aborts the save. Three checks are live: &amp;lt;code&amp;gt;SelfAliasSyncCheck&amp;lt;/code&amp;gt; (alias can&amp;#039;t equal its own entity&amp;#039;s name), &amp;lt;code&amp;gt;CrossUniverseOriginCheck&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;Entity.OriginNodeId&amp;lt;/code&amp;gt; must be in the entity&amp;#039;s own universe), &amp;lt;code&amp;gt;PreviousNodeCycleCheck&amp;lt;/code&amp;gt; (a book&amp;#039;s sequel chain can&amp;#039;t loop).&lt;br /&gt;
* &amp;lt;strong&amp;gt;Async, post-save, fire-and-forget&amp;lt;/strong&amp;gt;: dispatches changed entities to &amp;lt;code&amp;gt;IWriteAuditService&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;DefaultWriteAuditService&amp;lt;/code&amp;gt;) for slower judgment-based checks — currently near-duplicate-entity detection, filed as &amp;lt;code&amp;gt;Finding&amp;lt;/code&amp;gt; rows.&lt;br /&gt;
&lt;br /&gt;
Both lists are wired once at Hub startup by &amp;lt;code&amp;gt;WriteGateBootstrap&amp;lt;/code&amp;gt;, which &amp;lt;strong&amp;gt;must be eagerly resolved&amp;lt;/strong&amp;gt; in &amp;lt;code&amp;gt;Program.cs&amp;lt;/code&amp;gt; (a singleton nobody resolves never constructs — this is the same &amp;quot;a mechanism exists but nothing activates it&amp;quot; failure class the WriteGate initiative itself was built to close; see §6). &amp;lt;code&amp;gt;WriteGateScope&amp;lt;/code&amp;gt; is the ambient static gateway &amp;lt;code&amp;gt;ProseDbContext&amp;lt;/code&amp;gt; reads from, mirroring the existing &amp;lt;code&amp;gt;UniverseScope&amp;lt;/code&amp;gt; pattern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Known limitation, by design&amp;lt;/strong&amp;gt;: &amp;lt;code&amp;gt;ExecuteDeleteAsync&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;ExecuteUpdateAsync&amp;lt;/code&amp;gt;/raw SQL bypass &amp;lt;code&amp;gt;ChangeTracker&amp;lt;/code&amp;gt; and are invisible to this mechanism. The write-gate initiative audited all such call sites across the ~150 CLI/MCP surface and gave each an explicit disposition (rewired onto a sanctioned service method, or a documented accepted exception) — see project memory for the full per-file list.&lt;br /&gt;
&lt;br /&gt;
== 6. A recurring bug class worth naming ==&lt;br /&gt;
&lt;br /&gt;
Three times now (NodeWorkbenchService&amp;#039;s validator hooks, &amp;lt;code&amp;gt;DeleteNodeCli&amp;lt;/code&amp;gt; vs. &amp;lt;code&amp;gt;NodeWorkbenchService .DeleteNodeAsync&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CloneNodeCli&amp;lt;/code&amp;gt; vs. &amp;lt;code&amp;gt;DuplicateNodeAsync&amp;lt;/code&amp;gt;), the same shape of bug has appeared: &amp;lt;strong&amp;gt;a sanctioned/improved mechanism gets built, but the code it was meant to replace never gets rewired onto it&amp;lt;/strong&amp;gt; — so the old, buggier, or unvalidated path keeps running in production while the fix sits unused. When adding a new sanctioned method or service, the check that closes the loop is: &amp;lt;em&amp;gt;grep for every existing caller of the thing being replaced, and confirm each one was actually repointed&amp;lt;/em&amp;gt; — not just that the new method compiles and has a test.&lt;br /&gt;
&lt;br /&gt;
== 7. Canon documents are ALL database-backed — never hand-edit &amp;lt;code&amp;gt;docs/*.md&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Every canon &amp;lt;code&amp;gt;.md&amp;lt;/code&amp;gt; file under &amp;lt;code&amp;gt;docs/&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;BIBLE.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;WORLD.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;FRANCHISE.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CRAFT.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;GLMZ.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SCRY.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DELIGHT.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENGINE.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CHARACTER.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;universes/ENTOS.md&amp;lt;/code&amp;gt;) is a generated mirror of &amp;lt;code&amp;gt;CanonDocumentSections&amp;lt;/code&amp;gt; rows, keyed by &amp;lt;code&amp;gt;CanonDocumentType&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;WorldBible&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;WorldMaster&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Franchise&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;UniverseCanon&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CraftGuide&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;UniverseCraft&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DelightGuide&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;EngineGuide&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CharacterDoctrine&amp;lt;/code&amp;gt;). Confirmed live 2026-08-23 via &amp;lt;code&amp;gt;prose --generate-canon-md --all&amp;lt;/code&amp;gt;: every one of these files carries a &amp;lt;code&amp;gt;&amp;amp;lt;!-- GENERATED — do not hand-edit --&amp;gt;&amp;lt;/code&amp;gt; banner and a real, non-trivial section count. &amp;lt;strong&amp;gt;This file previously (in CLAUDE.md&amp;#039;s Codex table) told readers to hand-edit 5 of these files directly&amp;lt;/strong&amp;gt; — stale instructions from before they were migrated into &amp;lt;code&amp;gt;CanonDocumentSections&amp;lt;/code&amp;gt;; fixed 2026-08-23. The only sanctioned edit path for any of them is the &amp;lt;code&amp;gt;set_canon_section&amp;lt;/code&amp;gt; MCP tool, followed by &amp;lt;code&amp;gt;prose --generate-canon-md --type &amp;amp;lt;type&amp;gt;&amp;lt;/code&amp;gt; to re-materialize the &amp;lt;code&amp;gt;.md&amp;lt;/code&amp;gt; mirror.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Previously-flagged gap, confirmed fixed&amp;lt;/strong&amp;gt;: this section used to say &amp;lt;code&amp;gt;docs/ENGINE.md&amp;lt;/code&amp;gt; §SS-ENGINE-2 wrongly claimed &amp;lt;code&amp;gt;ArchivedBooks&amp;lt;/code&amp;gt; snapshots were the &amp;lt;em&amp;gt;only&amp;lt;/em&amp;gt; recovery mechanism, stale since the 2026-08-17 system-versioning re-enable, and that fixing it needed an MCP client this file&amp;#039;s author didn&amp;#039;t have at the time. Re-read 2026-10-07: the live &amp;lt;code&amp;gt;docs/ENGINE.md&amp;lt;/code&amp;gt; §SS-ENGINE-2 already states the corrected fact (&amp;lt;code&amp;gt;FOR SYSTEM_TIME AS OF&amp;lt;/code&amp;gt; rewind is real again, &amp;lt;code&amp;gt;ArchivedBooks&amp;lt;/code&amp;gt; is not the only path) and even narrates its own prior mistake — someone fixed it via &amp;lt;code&amp;gt;set_canon_section&amp;lt;/code&amp;gt; between 2026-08-23 and now. &amp;lt;code&amp;gt;set_canon_section&amp;lt;/code&amp;gt; itself still has no CLI equivalent (only an MCP tool), which remains worth knowing for a CLI-only session, but the specific ENGINE.md gap this section used to point at no longer exists.&lt;br /&gt;
&lt;br /&gt;
== 8. Documentation map (what&amp;#039;s real, what&amp;#039;s stale) ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Reference for&lt;br /&gt;
! Where&lt;br /&gt;
|-&lt;br /&gt;
| C# system architecture (this document)&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/ARCHITECTURE.md&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Story-world canon (GLMZ facts, engine invariants)&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/BIBLE.md&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universal prose craft — Tier 0 (loads above everything, every beat)&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/ENGINE.md&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universal prose craft — Tier 1&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/CRAFT.md&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Per-universe craft — Tier 2&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/GLMZ.md&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;docs/SCRY.md&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Character Doctrine (topic-tier craft law)&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/CHARACTER.md&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Logic-sweep / QA methodology&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/LOGIC.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;docs/READER-QA.md&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;docs/LEDGER.md&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Story Ledger — the record of what is true, and cross-predicate contradiction detection&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/LEDGER.md&amp;lt;/code&amp;gt; (added 2026-09-04, third peer of LOGIC/READER-QA)&lt;br /&gt;
|-&lt;br /&gt;
| MCP tool reference (auto-generated, current)&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/MCP_TOOLS.md&amp;lt;/code&amp;gt; (289 tools, 52 families)&lt;br /&gt;
|-&lt;br /&gt;
| CLI command reference (auto-generated, current)&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/CLI_COMMANDS.md&amp;lt;/code&amp;gt; (285 commands) — &amp;lt;strong&amp;gt;gap closed 2026-09-04.&amp;lt;/strong&amp;gt; &amp;lt;code&amp;gt;CommandDocGenerator&amp;lt;/code&amp;gt; parses the dispatch chain in &amp;lt;code&amp;gt;Program.cs&amp;lt;/code&amp;gt; rather than reflecting over attributes, because CLI handlers carry none; refresh with &amp;lt;code&amp;gt;dotnet run --project src/Prose.Cli -- --export-commands docs/CLI_COMMANDS.md&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Story/feature status&lt;br /&gt;
| &amp;lt;code&amp;gt;docs/USER_STORIES.md&amp;lt;/code&amp;gt; (stale ~1 week as of 2026-08-23 — missing this week&amp;#039;s write-gate/architecture work)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 9. Where data lives — SQL Server, and the two legacy SQLite files ==&lt;br /&gt;
&lt;br /&gt;
Owner ruling 2026-10-22: SQLite only for simple needs; corporate-grade data lives in the Prose SQL Server database. The two large SQLite files left in &amp;lt;code&amp;gt;engine/data/&amp;lt;/code&amp;gt; were ruled on 2026-10-27:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! Contents&lt;br /&gt;
! Ruling&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;continuity.db&amp;lt;/code&amp;gt; (10.5 MB)&lt;br /&gt;
| 12,875 continuity claims, 12,792 confirmations, 0 contradictions, 0 extraction runs; last write 2026-04-30&lt;br /&gt;
| &amp;lt;strong&amp;gt;Corporate-grade → SQL Server.&amp;lt;/strong&amp;gt; Canon facts about entities and chapters. &amp;lt;code&amp;gt;ContinuityService&amp;lt;/code&amp;gt; has read and written only the SQL Server tables (&amp;lt;code&amp;gt;ContinuityClaims&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ClaimConfirmations&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ClaimContradictions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ExtractionRuns&amp;lt;/code&amp;gt;) since the store was folded in. The one-shot &amp;lt;code&amp;gt;prose --migrate-sql --import-continuity-sqlite [--apply]&amp;lt;/code&amp;gt; copies any row SQL Server is missing (insert-only, SQL Server wins on conflict, imported claims graded &amp;lt;code&amp;gt;legacy-unknown&amp;lt;/code&amp;gt;) and opens the SQLite file read-only, so it stays readable as an audit artefact.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;embeddings.db&amp;lt;/code&amp;gt; (372 MB)&lt;br /&gt;
| 62,774 text chunks from 11,426 files with 1024-dim float32 vectors, indexed 2026-05-02/03&lt;br /&gt;
| &amp;lt;strong&amp;gt;Left on SQLite, not migrated.&amp;lt;/strong&amp;gt; It is a derived cache, not data: every one of its 11,426 source paths is under the retired &amp;lt;code&amp;gt;D:\Projects\MindAttic\StreetSamurai\&amp;lt;/code&amp;gt; file tree and none exists any more; no code opens the file; its 1024-dim vectors do not fit the SQL Server &amp;lt;code&amp;gt;VECTOR(1536)&amp;lt;/code&amp;gt; columns; and the live retrieval stores (&amp;lt;code&amp;gt;EntityEmbeddings&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ProseEmbeddings&amp;lt;/code&amp;gt;) are already in SQL Server, keyed by database ids and re-embedded from the database (&amp;lt;code&amp;gt;prose --reembed&amp;lt;/code&amp;gt;). Copying 372 MB of vectors for files that no longer exist would add nothing. The file is inert and can be deleted.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;md2wiki-crumb&amp;quot;&amp;gt;Part of [[Prose]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;md2wiki-source&amp;quot;&amp;gt;From [https://github.com/mindattic/Prose/blob/main/docs/ARCHITECTURE.md Prose/docs/ARCHITECTURE.md] via MindAttic.Docs; synced automatically, so edit the repo, not this page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Prose]]&lt;/div&gt;</summary>
		<author><name>Docs Sync</name></author>
	</entry>
</feed>