From cf81cbe034ce19855f054ecf0a780a052ef54322 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 22 Sep 2026 01:12:28 +0200 Subject: [PATCH] Map the play agent cut (plan step 16) Imagination's cut map for the play agent target. Probes compiled a scratch consumer against the library, and the agent's tool catalog was measured. The map answers target questions Q1-Q14. Q2, Q5, Q6, Q8 and Q9 are defaulted, Q4 and Q14 are findings, and Q11 is ruled by the operator. Q1, Q3, Q7, Q10, Q12 and Q13 await operator rulings. Ten cuts follow, subtraction in Dungeon first, then the local port, the kernel pieces (play authority, retirement, affordance grants), the Persona lane, the table vocabulary, the play table, and the Eve surface. Findings PA.f1-PA.f8; PA.f1 was already resolved at 5ff1d54. Co-Authored-By: Claude Opus 5 --- .../architecture/ghostlight-play-agent-cut.md | 1127 +++++++++++++++++ 1 file changed, 1127 insertions(+) create mode 100644 docs/architecture/ghostlight-play-agent-cut.md diff --git a/docs/architecture/ghostlight-play-agent-cut.md b/docs/architecture/ghostlight-play-agent-cut.md new file mode 100644 index 0000000..6f69d48 --- /dev/null +++ b/docs/architecture/ghostlight-play-agent-cut.md @@ -0,0 +1,1127 @@ +# Ghostlight Dungeon play agent — cut map (plan step 16) + +Ends are owned by `ghostlight-play-agent.md`; this document owns the means. +Written 2026-09-22 against Ghostlight `cb0b604` on +`codex/ghostlight-dungeon-mvp`, and re-read against `5ff1d54` (the target's Q1 +premise correction and the Q11 ruling). `cb0b604..5ff1d54` changes no file under +`crates/`, `sidecar/` or `web/`, so every line number below is against +`cb0b604` = `5ff1d54` source. Hands start at Cut 1 from the commit that lands +this file, once the open questions below carry rulings. + +## How status is read + +Status is derived from what this document records; nothing here is a +maintained header. + +- A **question** (`PA-Qn`) is open exactly when it has no `Ruling` field. + `Authority` is `operator`, `self-under-standing-go`, or `defaulted`. A + defaulted question is a conventional choice the map made and recorded; it + is open to the operator but blocks nothing. +- A **cut** is landed when its `Landed` field names commits, and closed when + every promise (`P.`) in its Verdicts table has a verdict + (`HOLDS | FALSIFIED | UNPROVEN`). The root agent fills `Landed` and the + Verdicts; Hands and Soul do not edit this file. +- A **mutation** (`M.`) names file, line, before and after; the commit + it ran against is filled at execution. Mutations run against committed code + and are restored with a reverse edit, never `git checkout`. +- A **finding** (`PA.f`) is something no cut owns; each carries + introduced-or-pre-existing, severity, and triage (`fix | operator | recorded`). +- The **ledger** carries an estimate per cut; the Actual column is computed + from the diff at landing and is empty until then. + +The pass is open until every cut is closed and every question has a ruling. + +Every build and test named here runs on the Windows workstation and proves +Windows only. The Linux release is Idunn's build on Yggdrasil +(`gamecult-ops/runbooks/ghostlight-dungeon-yggdrasil.md`); the Dungeon bin lists +four more tests there (`#[cfg(target_os = "linux")]`, see the stock-lenses map). + +## What the probes established + +- **Probe B, the public boundary (compile, external crate).** A scratch crate + outside the workspace (session scratchpad `probe-boundary`, path dependency on + `crates/ghostlight`, `cargo check --offline`, scratch target removed; repo + untouched) tried, from outside the library: + - build an `InferenceRequest`: **E0451**, fields `purpose` and `provider` are + private (`controllers.rs:115-118`); there is no public constructor + (`tool_request` is `pub(super)`, `controllers.rs:6061`); + - read `InferenceOutput.events`: **E0616** (`controllers.rs:148-151`, + `pub(super)`); + - read `PreparedInference.invocation`: **E0616** (`controllers.rs:132-135`). + So a port "a consumer implements outside this crate" (the doc comment at + `controllers.rs:376-380`) cannot read the request it must lower; + - read `SubjectSnapshot.position`: **E0616** (`lib.rs:978`); + - read `AffordanceSnapshot.entry.roles`: **E0616** (`patch.rs:889`). + + And these **compile** from outside: `ControllerPort::new(mailbox) + .submit_controller(id, &opportunity, invocation)` (`mailbox.rs:688-731`); + `WorldMailbox::submit_clock` (`mailbox.rs:356`); + `serde_json::from_str::` and `::` (both + derive `Deserialize` with `pub(crate)` fields). + + Consequence: Dungeon today can exercise for a Persona and submit a patch it + deserialized, but it cannot run an inference, read an inference's output, + read where anyone stands, or read what an affordance's roles are. Every + surface the play agent reads or writes is library-private. This is PA-Q12. +- **Catalog size (measured from the checked-in fixture).** + `sidecar/claude-sdk/test/schemas.json` is regenerated from `patch_tools()` + by `sdk_inference.rs:1874-1913`. The 39 patch tools total 54,810 characters + (parameters plus descriptions parsed from `patch.rs:5600-6128`). Dropping + `declare_affordance` (8,055 characters of parameters on its own), `record_gap` + and `submit` leaves 36 tools and 46,428 characters, about 13,300 tokens at + 3.5 characters per token. The largest are `create_commitment` (6,373), the + three pressure tools (about 2,950 each), `bind`/`release` (1,625). A 22-tool + core (relocate, transfer, consume, admit, bind, release, communicate, + witness, acquire_knowledge, forget, create/discharge_commitment, + advance/reduce_pressure, open/close_route, the five light declarations, + set_persona_material) is 31,609 characters, about 9,000 tokens. A granted + `speak` tool is 160 characters. Script: scratchpad `catalog_size.py`. +- **Source-verified facts the design rests on** (read, not probed): + - Rust drives every connector round: an inert port returns one round's calls + and the lane's evaluator re-derives the conversation from `completed` + (`evaluate_elaboration_loop`, `elaboration.rs:1127-1223`; + `evaluate_operational_loop`, `controllers.rs:5829`). The SDK port instead + runs the loop inside one sidecar query and asks a lent + `ToolResultOracle` (`sdk_inference.rs:417-498`); it holds one `gate` + mutex for a whole query (`:423`), and `ToolResultOracle::answer` is + synchronous (`controllers.rs:251-260`). + - Routing is a model-name prefix with two slots, connector and SDK + (`sdk_inference.rs:715-773`); `open_inference` refuses at open any + `ControllerModels` lane no slot claims (`controllers.rs:2336-2376`). + - The SDK sidecar is a private MessagePack child-process pipe + (`SidecarFrame`, `sdk_inference.rs:36-70`) that borrows + `codex_connector::CodexInputItem`; the connector port is the only user of + the connector's socket client (`controllers.rs:406-527`). The one shared + seam is the in-process `InferencePort` trait. This confirms the target's + corrected Q1 premise (`5ff1d54`). + - The Projector's typed context carries no knowledge + (`projector_context`, `controllers.rs:4144-4166`); its **visible stimulus** + is the subject's whole `knowledge`, each row rendered `said | seen_doing | + known` with the speaker's label, certainty and text + (`visible_stimulus`/`projector_knowledge`/`perceived_from`, + `controllers.rs:4604-4655`). Rows carry `minted_at` (`lib.rs:1044-1047`) + but nothing marks what arrived since the subject last acted. The kernel + records every exercise as a `DecisionEvent { revision, scope, .. }` in + `WorldState.events` (`lib.rs:774-793`, `:873`, pushed at `:4881`); + `last_opportunity_at` is fictional minutes, not a revision (`lib.rs:853`). + - Projector then Persona runs as two checkpointed stages of the narrative + lane (`run_narrative` `controllers.rs:2770-2840`, `run_projector` `:3530`, + `run_persona` `:3604`), followed by the Interpreter. `select_one` + (`:1261`) matches any mode the opportunity names, so the Projector can + run for a `Human`-mode opportunity; only `run_narrative`'s lane gate + (`:2776-2780`) restricts it. + - An exercise commits only if `exact_opportunity` finds the scope's current + digest (`lib.rs:4244-4270`) and the caller equals the assignment's + `expected_caller` (`lib.rs:738-752`, checked at `:1613` and `:1631` and + re-decided at `:4866` and `:4897`). A `NarrativePersona`'s expected caller is + `Controller(controller_id)`, which `ControllerPort::submit_controller` + mints from the kernel-issued opportunity (`mailbox.rs:316-332`); a forged + `controller_id` fails `ControllerMismatch`. A human's expected caller is + its `Principal`. + - Retry identity is caller plus body (`lib.rs:1466-1476`); an + `ExerciseDecision` body carries its opportunity (revision and digest), so a + retry rebuilt from a later snapshot is `CommandIdConflict`, not + `AlreadyApplied`. A retry must resubmit the persisted body. + - `require_system_capability` (`lib.rs:1703-1720`) and its twin + (`apply_effect`, `:4768-4780`) admit a system caller for exactly the + listed pairs. `require_answer` (`:1740-1764`) refuses every unanswered + Active patch that declares or carries evidence, from every caller, + including the owner. `require_patch_author` (`:4284-4315`) returns + unconfined only for the owner. + - `verify_state_shape` demands `controller_assignments.len() == + subjects.len()` (`journal.rs:488-495`); opportunities are minted for every + assignment whose `mode()` is `Some` (`lib.rs:4115-4156`). + - No operation grants or revokes an affordance: grants are written only by a + subject's declaration (`ComponentOp` variants `patch.rs:1014-1188`; + catalog "Draft-only", `lib.rs:868`). The genesis human subject is declared + with `kernel_speak_grant()` only, at the commons (`mailbox.rs:115-145`), + and `speak` has one precondition, `CanBroadcast { Colocated }` + (`patch.rs:2283-2297`). `Relocate` needs a route from the subject's + current place and cannot place an unplaced subject (`patch.rs:3613-3660`). + - `render_world_structure` (`elaboration.rs:2172-2280`) is an existing + whole-world renderer with bracketed ids, used by the seed lane only. + - `SourceSpan::locate` (`ghostlight-persona-projection/src/lib.rs:366-375`) + is the existing verbatim-quote locator. + - The seed lane's key hashes ancestry (`seed_command_id`, + `elaboration.rs:1545-1551`). Seeding runs as `sweep(1)` inside the + owner's request (`runtime.rs:1786-1826`), one session at a time. + +## Questions + +### PA-Q1 Where the local backend lives + +- **Asked:** 2026-09-22 (target Q1, premise corrected at `5ff1d54`). +- **Context:** the only shared seam is `InferencePort`. Every lane's request is + a `CodexProviderRequest` (instructions, input items, tools, tool choice, + parallel calls, effort, output cap); lowering that to OpenAI chat completions + is mechanical (instructions → system, `UserText` → user, `AssistantText` → + assistant, `ToolCall` → assistant `tool_calls`, `ToolResult` → tool message; + response text → `InferenceEvent::Text`, `tool_calls` → + `InferenceEvent::ToolCall`, inert). Probe B: an external port cannot read + `PreparedInference.invocation`, and routing is a private two-slot router. + Ghostlight never holds a credential; a local llama-server on loopback needs + none. +- **Options:** + - A: **a third port in the library**, `crates/ghostlight/src/local_inference.rs`, + beside `sdk_inference.rs`. Loopback-only endpoint (refused at open + otherwise), no credential header, inert tool calls, receipt digest over a + typed receipt (request id, model, response id, usage, finish reason). A + third routing slot claimed by a model prefix. Adds `reqwest` to the + library (already in the workspace lock for Dungeon). About 250 lines with + tests. + - B: **a port in Dungeon.** Needs a public accessor on `PreparedInference` + and a public routing seam that takes a foreign port. Two changes to the + library's inference boundary so the port can live outside it; the port + itself is the same code. + - C: **a CultNet connector daemon** (a new service speaking a new CultNet + contract, like CodexConnector). No invariant it protects exists here: a + local model server is already its own process, and no credential needs + isolating. It buys third-party credentialed endpoints, which the map says + are needed "before third parties use the deployment" — not for the gate. +- **Recommendation: A.** Smallest surface, one owner for routing, and the + loopback-and-no-credential rule keeps "Ghostlight never holds a credential" + true by construction. C remains the path for credentialed third-party + endpoints and is recorded as PA.f1. +- **Depends on it:** Cut 2. +- **Ruling:** — + +### PA-Q2 What a Persona perceived + +- **Asked:** 2026-09-22 (target Q2). +- **Finding:** partly yes. The visible stimulus already carries every row the + subject holds, with speaker and `said | seen_doing | known` + (`controllers.rs:4616-4638`), which is what speech heard and acts seen are + (`Told { by }`, `Seen { by }`). It carries all of it, in `minted_at` order, + with nothing marking what arrived since the subject last acted, so a Persona + cannot tell the player's line of this turn from one heard ten turns ago. +- **Smallest addition (default):** a derived, per-row marker. The snapshot + derives `last_acted_at: Option` for each subject as the greatest + `DecisionEvent.revision` whose scope is that subject (one pass over + `state.events`, no new state, no schema change), and `projector_knowledge` + adds `"new": minted_at > last_acted_at` to each row (a subject that never + acted sees every minted row as new). Nothing about who hears what changes; + the kernel's `knowledge` stays the sole perception owner. +- **Cost:** the Projector's stimulus bytes change for every lane that renders + one, including the offline narrative lane. Stored `NarrativeCheckpoint::Projector` + rows stay valid: their integrity check does not rebuild the stimulus + (`controllers.rs:788-822`). +- **Depends on it:** Cut 6. +- **Ruling:** default as above. +- **Authority:** defaulted. + +### PA-Q3 The callable Persona turn + +- **Asked:** 2026-09-22 (target Q3). +- **Context:** the stages exist; what binds them to `ControllerRunner` is the + checkpoint store, the Interpreter stage and the runner's five-model open. +- **Options:** + - A: **an unpersisted lane.** `pub struct PersonaLane` in + `controllers.rs`, built from a `ControllerPort`, an `Arc`, a projector model and a persona model. Two methods: + `pub async fn turn(&self, command_id, &DecisionOpportunity) -> + Result` (Projector then Persona, the + existing prompt builders, returns the existing receipt-bound + `PersonaTurn`), and `pub async fn narrate(&self, command_id, + &DecisionOpportunity) -> Result` (Projector only, + for the player; Q11). No work-store row. A restart mid-turn repeats the two + inferences; nothing was committed, and the returned turn is persisted by + its caller (Dungeon's turn record, Cut 8). + - B: **persisted.** Reuse the `Projector` and `Persona` checkpoints and end + at a new terminal stage (`Spoken { turn }`). Resumable, but it needs a new + stage, its integrity arm, its progression rule, and a `controller_work` + row bump, and it gives the turn two durable owners (the work store and + Dungeon's turn record). +- **Recommendation: A.** The prose is what is worth keeping and its caller keeps + it; in-flight inference on a local machine is the cheap thing to lose. One + owner for turn state. +- **Depends on it:** Cut 6. +- **Ruling:** — + +### PA-Q4 Exercising on an actor's behalf + +- **Asked:** 2026-09-22 (target Q4). +- **Finding: no kernel change.** Probe B compiled + `ControllerPort::submit_controller` from an external crate. A Persona's act + commits as that Persona's own `ExerciseDecision`, under the caller the + mailbox mints from the kernel-issued opportunity, and admission is unchanged: + `exact_opportunity` (scope digest), `expected_caller`, `require_granted`, + `action::exercise` (preconditions, ceilings, band draw). The player's act + commits through `submit_principal` with the player's own + `VerifiedPrincipalEvidence`, which Dungeon already holds for the request + (`runtime.rs:1571-1585`); the evidence's own expiry bounds it + (`mailbox.rs:227-233`). Sealed admission is not weakened because nothing new + is admitted. +- **What the kernel cannot check, Dungeon checks (Cut 8):** that the actor was + dispatched this turn (or is the player), and that speech and display are + literal spans of that actor's prose (invariant 4). Tool identity carries the + actor (`__`, the grouped lane's precedent, + `controllers.rs:73-75`), never a model-written argument. +- **Retry rule (Cut 8):** the exact `CommandBody` is persisted before it is + submitted, and a resumed call resubmits those bytes under the same command + id, so the kernel answers `AlreadyApplied` (`lib.rs:1466-1476`). +- **Ruling:** finding; nothing to rule. +- **Authority:** self-under-standing-go. + +### PA-Q5 The play authority's shape + +- **Asked:** 2026-09-22 (target Q5). +- **Default design:** `SystemCapability::Play` (`lib.rs:467-484`), unit-shaped. + Minted by exactly one public method on a narrowed port, + `pub struct PlayPort { mailbox }` in `mailbox.rs` with `snapshot()`, + `submit_patch(command_id, WorldPatch)` and `advance_time(command_id, + TickMinutes)`, both stamped (`submit_stamped`, `mailbox.rs:267`). The clock + precedent maps one-for-one: a system capability with no session evidence, + minted by one method, admitted for listed bodies only. Admission: + - `require_system_capability` and its `apply_effect` twin admit `(Play, + AdmitPatch)` and `(Play, AdvanceTime)` and nothing else; + - `require_patch_author` returns `Ok(None)` (unconfined) for `Play`; + - `require_answer` admits `(Active, None)` with declarations for `Play` and + for no other caller; `Play` is refused in Draft (`WrongPhase`) and refused + any patch carrying evidence (`Mismatch`, new variant + `PlayCarriesEvidence`), so it cannot mint quantity; + - `require_clock_caller` admits `Play`. +- **"Only one thing holds it":** the capability is compile-time narrowed like + every other port; exclusivity is Dungeon constructing one `PlayPort` in + `AppState`, pinned by a negative grep (Cut 3, Cut 8). +- **Option not taken:** binding `PlayPort` to the owner's verified evidence, + like `SeedPort`. It would end a long play session at the owner's session + expiry and buys nothing the journal's `System(Play)` attribution does not. +- **Depends on it:** Cut 3. +- **Ruling:** default as above; the name is the operator's to change. +- **Authority:** defaulted. + +### PA-Q6 Retirement's shape + +- **Asked:** 2026-09-22 (target Q6). +- **Finding and default:** retirement is a subject state written by a + component operation. + - State: `ControllerAssignment::Retired` (`lib.rs:700-722`). `id()` and + `mode()` return `None`, so `derive_opportunities` mints nothing for it + (`lib.rs:4125`) with no new filter, and `controller_assignments` stays the + sole answer to who may call (`lib.rs:836-838`). `expected_caller` + becomes `Option` and returns `None` for `Retired`; both call sites + compare `Some(caller)`. The shape check's `len ==` clause is unchanged. + - Operation: `ComponentOp::Retire { subject: Ref }` resolving to + `ResolvedOp::Retire { subject }`. Applied: the assignment becomes + `Retired`, the subject's `positions` entry and `affordance_grants` entry + are removed. `subjects`, `events`, `knowledge`, holdings, facts and the + journal keep everything, which is "stays in history". + - Refusals: retiring an already retired subject is `NoOperationEffect`; + retiring an `ExternallyControlled` mirror is refused (another world owns + it); a confined author (elaborator, consumer) is refused by + `confine_to_ground` (`OutsideJurisdiction`) whatever the subject's place. + Owner and `Play` may retire. + - What readers see: no opportunity, so no dispatch (Dungeon dispatches from + opportunities) and no act (`exact_opportunity` → `OpportunityMismatch`); no + position, so `audience` (`lib.rs:3053`) never reaches it and the + Projector's `present` omits it; `SubjectSnapshot` gains `pub retired: bool` + so the agent's view and the surface can say so. Preconditions read the + actor's own state and are never reached for a retired actor. + - Replay: `apply_effect` applies the resolved op like any other, so replay + reproduces it. + - A body that matters afterwards is the agent's `declare_resource` in the + same patch, as the target says. +- **Schema:** `ControllerAssignment`, `ComponentOp`, `SystemCapability` all + change shape, so `STATE_SCHEMA`/`COMMIT_SCHEMA` bump `consumer.v5 → v6` + (`lib.rs:172-173`, pinned at `consumer.rs` as for L1), in one cut with Q5. +- **Not done (recorded, PA.f4):** a retired subject's commitments, pressures + and dependency edges stay and the clock keeps deriving motion over them. +- **Depends on it:** Cut 4. +- **Ruling:** default as above. +- **Authority:** defaulted. + +### PA-Q7 The agent's catalog, and whether a small model plausibly handles it + +- **Asked:** 2026-09-22 (target Q7). +- **Measured:** above. The kernel side without `declare_affordance` is 36 tools, + ~13,300 tokens; a 22-tool core ~9,000 tokens. Dungeon adds `dispatch`, + `ask_player`, `end_turn` (small), plus one `__` tool per granted + entry per actor in the scene (160–1,500 characters each). With Cut 4 and + Cut 5, `retire` and `grant_affordance`/`revoke_affordance` join the kernel + side. +- **Plausibility:** nobody has measured Bonsai 2 on this. A 13k-token stable + tools prefix is reused from a llama.cpp slot's KV cache when the prefix is + byte-identical, so its cost is paid once per slot; the risk is selection + accuracy over ~40 tools, not tokens. Strict-schema grammar enforcement on + llama-server tool calls is a property of the server build and must be + checked on Raven's machine (PA.f2). +- **Options:** A: the whole kernel catalog minus `declare_affordance`. B: a + curated Dungeon list of `PATCH_TOOLS` names (Dungeon policy, pinned ⊆ + `PATCH_TOOLS` by test, the lens `leads_with` precedent), starting from the + 22-tool core plus `retire` and `grant_affordance`. +- **Recommendation: B**, measured at the gate against A on the same turn + script; the list is one constant and widening it is a one-line change. +- **Depends on it:** Cut 7 (the library takes a name list), Cut 8 (the list). +- **Ruling:** — + +### PA-Q8 The turn lifecycle, and what survives a restart + +- **Asked:** 2026-09-22 (target Q8). +- **Default design:** Dungeon owns one open turn at a time in its own CultCache + store, `service/play-turn-v1.cc`, on the `app_session.rs` pattern + (`OwnedRedbMessagePackBackingStore`, one row). The row, `PlayTurn`: + `turn_id` (the `world.play` idempotency key), `opening_prompt` (built once + from the snapshot and the player's text, then never rebuilt), `player_prose: + Vec` (the first text and each answer), `rounds: + Vec`, `calls: Vec` (per tool call: its call id, + the exact `CommandBody` or play patch persisted before submission, and its + result string once known), `persona_turns: Vec<(SubjectId, PersonaTurn)>`, + `question: Option`, `refusal: Option` (Q13), `narration: + Option`, `state: Running | AwaitingPlayer | Closed`. + - The agent's conversation is re-derived from `opening_prompt`, `rounds` and + the recorded results, the connector posture; nothing crosses from one turn + to the next except world state. When a turn closes, the next turn's + `opening_prompt` depends only on the snapshot and the new text, which is + invariant 1's test. + - Commands inside a turn carry ids derived from `(turn_id, round, + call_index)` (sha256 → UUID, `CommandId::parse_uuid`); a call whose body is + recorded and whose result is not is resubmitted with the recorded body. + - After a restart, a `Running` turn resumes on the player's next `world.play` + (the player's evidence rides that request; an empty text means + "continue"), and an `AwaitingPlayer` turn waits for the answer. Nothing + runs a player act without a live principal. +- **Depends on it:** Cut 8. +- **Ruling:** default as above. +- **Authority:** defaulted. + +### PA-Q9 The Eve play surface + +- **Asked:** 2026-09-22 (target Q9), narrowed by Q11's ruling. +- **Default design:** in Active, for the principal whose subject is + `human_controller`, the surface is: the latest `narration` (the Projector's + prose for the player; Q11) as a `text` card; the agent's `question` when one + is open; the refusal line (Q13) when present; the turn state; a + `control.input.textarea` bound to `text` and one `world.play` button + (`ghostlight.world_play.v0`, bindings `["text"]`). Place, co-presence, + perceived speech with speaker and displays arrive through the narration, + which renders them from committed state. The owner keeps `world.advance_time`. + The story card (`eve.rs:436-455`) is deleted from the play surface: it is the + whole-world operator log and shows the player speech it never perceived. +- **Depends on it:** Cut 9. +- **Ruling:** default as above. +- **Authority:** defaulted. + +### PA-Q10 The player's subject + +- **Asked:** 2026-09-22 (target Q10). +- **Finding:** the genesis human subject serves as the player's body, but not + as it stands. It holds `speak` only (`mailbox.rs:115-124`), and no + operation in any lane can grant it another verb; a physical act refused by a + precondition, and moving by the player's own act (invariant 3), both need + verbs it cannot get. Placement is fine: the agent, holding `Play`, declares + a route from the commons and relocates the subject as its own ruling. +- **Options:** + - A: **`ComponentOp::GrantAffordance { subject, affordance }` and + `RevokeAffordance`**, writing `affordance_grants` for an existing subject + and existing catalog entry. Owner, `Play`, and the seed lane (Draft, owner) + may use them; confined authors are refused (a grant is authority, not + structure). The seed can then grant the player the world's verbs in + Draft, and the agent can grant or take verbs in play (bound hands). + - B: rebind a seeded Person to the human principal. Binding a human is + genesis-only on purpose (`admits_human`, `lib.rs:1775-1778`), because a + human joins the required approvers. + - C: let the agent rule the player's physical acts as raw ops. Violates + invariant 3. +- **Recommendation: A.** +- **Depends on it:** Cut 5. +- **Ruling:** — + +### PA-Q11 The player's prose + +- **Ruling:** the player's perception is rendered by the same Projector a + Persona gets. "Render it with the Projector; we're paying for it on every + Persona already." The Projector is the player's narration; the play agent + writes none. Plan: one `PersonaLane::narrate` call for the player subject at + the end of every turn (Cut 8), after the last commit. Its serial cost is + measured and recorded at the gate beside seconds per turn, not decided here. +- **Authority:** operator. +- **Ruled:** 2026-09-22 (`4e61f58`). + +### PA-Q12 Where the agent's read and write vocabulary lives + +- **Asked:** 2026-09-22, from probe B. The target says the library gains three + pieces and Dungeon owns the agent's loop, prompt and catalog. The Body says + Dungeon cannot build or read an inference, cannot see positions, roles, + resources, routes or knowledge, and cannot decode a patch tool call, because + every one of those is `pub(crate)`. +- **Options:** + - A: **a consumer-neutral table module in the library** (`table.rs`), the + vocabulary any unconfined author running actors needs, and nothing about + turns: `pub fn table_view(&WorldSnapshot) -> String` (the whole-world + render with bracketed ids, grown from `render_world_structure`, which + moves here and the seed lane calls); `pub fn authoring_tools(names: + &[&str]) -> Result, TableError>` (a named subset + of `PATCH_TOOLS`, refusing unknown names); `pub fn decode_authoring_call(name, + arguments) -> Result` (the existing + `apply_tool_call` decode, one call to a one-item patch); `pub fn + actor_tools(prefix, &WorldSnapshot, SubjectId) -> Vec` + and `pub fn decode_actor_call(&WorldSnapshot, SubjectId, kind, arguments) + -> Result<(DecisionOpportunity, DecisionInvocation), String>` (the + existing `catalog_tools`/`decode_catalog_call`, plus an optional + `display`); `pub fn describe_refusal(&WorldSnapshot, &KernelError) -> + String`. Plus two inference seams: `pub fn InferenceRequest::play(..)` + (wraps `tool_request` under a new `InferencePurpose::Play`) and `pub fn + InferenceOutput::events(&self)`/`receipt_digest(&self)`. + - B: widen `pub(crate)` to `pub` on the types Dungeon would read and let + Dungeon render and decode. Two renderers and two decoders of one + vocabulary, one on each side of the boundary: split authority. + - C: move the loop into the library as a table runner with Dungeon + supplying prompt text and its own tools through a trait. Contradicts the + operator's ownership ruling. +- **Recommendation: A.** It keeps one owner per vocabulary, is consumer-neutral + (another consumer could run its own table on it), and leaves the loop, + prompt, Dungeon tools and turn lifecycle in Dungeon as ruled. It is a fourth + library piece the target did not list; the target's Ownership section + should name it when this is ruled. +- **Depends on it:** Cut 7, Cut 8. +- **Ruling:** — + +### PA-Q13 How the player sees why an act was refused + +- **Asked:** 2026-09-22, from Q11's ruling meeting gate item 3 ("does + something physical that a precondition refuses, and sees why"). A refused act + commits nothing, and the Projector renders committed state only, so the + narration cannot say why. The agent writes no narration. The play authority + cannot state a world truth as a canonical fact without an evidence receipt + (`FactStanding::Canonical { evidence }`), and Q5 refuses it evidence. +- **Options:** + - A: **the surface shows the kernel's refusal of the player's own attempt**, + rendered by `describe_refusal` (Q12) from the `ActionRejected` mismatch set + and the affordance's precondition list ("you are not at the cellar"). It + is the world's verdict on the player's own act, derived from state, not a + claim of world truth. Invariant 8's sentence "The agent's questions are the + one thing shown that is not derived from state" still holds; the target + should add that kernel refusals of the player's own act are shown. + - B: the agent asks the player a question that carries the reason. Puts the + agent's paraphrase of a kernel verdict in front of the player. + - C: a `Ruled` fact standing for play-authority facts, so the agent can + commit "the door is barred" and the Projector narrates it. New kernel + vocabulary for one gate item. +- **Recommendation: A.** +- **Depends on it:** Cut 7 (`describe_refusal`), Cut 8 (`refusal` on the turn), + Cut 9 (the line). +- **Ruling:** — + +### PA-Q14 L1.f13 and the gate + +- **Asked:** 2026-09-22 (target exception: in scope if it bites seeding on the + gate path). +- **Finding: it does not bite.** L1.f13 orphans a refused seed row only when an + owner Draft commit lands between the refused round and the retry + (`seed_command_id` hashes ancestry, `elaboration.rs:1545-1551`). The gate's + seeding is the owner pressing Seed, one `sweep(1)` per request + (`runtime.rs:1786-1826`); consecutive presses with no commit between them + find the same row. Its cost when it does bite is a repeated inference and an + orphan row, never a wrong commit. It stays deferred. +- **Ruling:** finding. +- **Authority:** self-under-standing-go. + +## Order, and why + +Subtraction first, then library, then Dungeon's table. The automatic cover +tick and the elaboration sweep are writers the play agent must not share the +world with: a cover tick makes Personas act outside any turn, and an Active +elaborator declares structure the agent did not rule. They are forbidden +writers under the target, so they go before the owner that replaces them exists +(Loud Rebuild: cut obsolete authorities first). `world.speak` and the story card +stay until Cut 9 replaces them, because between the cuts they are the only way +to use the world. + +| Cut | Kind | Repo | Depends on | +|---|---|---|---| +| 0 | captures | Ghostlight | rulings | +| 1 | subtraction | Dungeon | 0 | +| 2 | behaviour | library (inference) | PA-Q1 | +| 3 | behaviour | library (kernel: play authority, schema v6) | PA-Q5 | +| 4 | behaviour | library (kernel: retire) | 3, PA-Q6 | +| 5 | behaviour | library (kernel: grant/revoke affordance) | 4, PA-Q10 | +| 6 | behaviour | library (Persona lane, recency marker) | PA-Q2, PA-Q3 | +| 7 | behaviour | library (table vocabulary) | 2, 5, 6, PA-Q12, PA-Q13 | +| 8 | behaviour | Dungeon (play table and turn lifecycle) | 1, 7, PA-Q7, PA-Q8 | +| 9 | behaviour + subtraction | Dungeon (Eve play surface; speak and story deleted) | 8, PA-Q9 | + +Cuts 3–5 may land as one commit if Hands prefers one schema bump; the map +splits them so each has its own promises. Cut 2 and Cut 6 are independent of +3–5 and may land in either order. + +## Cut 0. Captures + +- **Repo/branch:** Ghostlight `codex/ghostlight-dungeon-mvp` at the map's + commit. No commit; output in the session scratchpad. +- **First:** `git status` clean. +- **Captures:** + - test census with `-- --list` for `-p ghostlight --lib`, `--doc`, `--test + external_admission`, `-p ghostlight-dungeon --bin ghostlight-dungeon`, + `--test build_provenance`, `-p ghostlight-persona-projection`; per-module + tally as the stock-lenses map did; + - `base-stimulus.txt`: from a temporary test beside the narrative lane's + leak tests, the rendered `visible_stimulus` for a subject with one `Told` + row, one `Seen` row and one held fact. Cut 6 pins that the new text equals + this plus exactly one `"new"` field per row; + - `base-catalog.txt`: `patch_tool_signatures()` and + `sha256(serde_json::to_vec(&patch_tools()))`. Cuts 4 and 5 change it by + exactly the added tools; + - distinct warnings from a forced rebuild of both crates; + - repo `target` size. + +## Cut 1. Delete the autonomous drivers and owner controls from Dungeon + +- **Repo/branch:** Ghostlight `codex/ghostlight-dungeon-mvp` from the map's + commit. One commit; builds alone. Library untouched. +- **Deletes first** (`crates/ghostlight-dungeon/src/runtime.rs` unless noted; + line counts approximate, measured at landing): + - the tick driver: `CoverSummary`, `InterruptedCell`, `cover_panel`, + `impl CoverSummary` (`:104-154`, ~50); `CLOCK_TICK_INTERVAL`, + `CLOCK_TICK_MINUTES`, `submit_clock_tick` (`:1747-1770`, ~24); + `configured_cover_budget`, `configured_tick_interval` (`:1864-1888`, + `:1908-1922`, ~40); `drive_cover_tick`, `drive_one_tick`, `run_cover_tick` + (`:1924-2125`, ~200); the spawn at `:408`; `AppState.cover`, + `AppState.cover_budget` (`:89-95`) and their construction; + - the Active elaborator: `ELABORATION_SWEEP_INTERVAL`, `elaborate_world`, + `run_elaboration_sweep` (`:1828-1862`, ~35); `configured_elaboration_ceiling` + (`:1900-1906`); `AppState.elaboration_permits` (`:84-86`); the spawn at + `:409`; + - the owner's "Let X act": `ControllerActPayload` (`:249-254`), + `dispatch_controller` (`:1048-1195`, ~148), `admit_controller_command` + (`:1197-1231`), `ControllerHttpResult` and `controller_narrative_result`, + `controller_operational_result`, `controller_pending_result`, + `controller_submission`, `controller_error_disposition` (`:1233-1427`, + ~195), the branch at `:1000-1002`; + - `crates/ghostlight-dungeon/src/eve.rs`: `CoverPanel`, `CoverPanelTick`, + `cover_card` (`:119-178`, ~60), the `cover` parameter of + `authenticated_surface` (`:242`), the owner's controller buttons and + descriptor (`:483-560`, ~78), `"world.controller.act"` in + `operation_schema` (`:633`); + - tests that pin only deleted behaviour: `a_clock_tick_submits_the_configured_span_and_nothing_measured` + (`:3106`), `the_tick_driver_never_exceeds_its_controller_permit_pool` + (`:3317`), `saturating_one_pool_never_delays_the_other` (`:3353`), + `a_speak_turn_and_a_sweep_draw_only_from_their_own_pools` (`:3522`), + `the_elaboration_driver_survives_a_panicking_sweep` (`:3666`), + `quarantine_raised_mid_tick_stops_the_sibling_cell_and_every_later_tick` + (`:3750`), `a_second_mid_turn_change_reaches_the_drivers_interrupted_arm` + (`:3914`), `drive_one_tick_runs_every_cell_before_the_clock_and_all_share_one_tick` + (`:4028`), the ignored `live_smoke_seeds_then_ticks_a_world_against_the_connector` + (`:4153`), and every fixture only they use (Hands lists them from the + compiler's dead-code warnings, not by name). `eve.rs` tests naming cover + are updated, not deleted. +- **Keeps:** `controller_permits` and `configured_controller_concurrency` + (`:1889-1898`): Cut 8 draws Persona dispatch from this pool. Between Cut 1 and + Cut 8 only `runtime_readiness` (`:1712-1716`) reads it; that interval is + stated here so no one reads it as a leftover. `ControllerRunner` stays for + seeding and `custody_probe`. `world.speak`, the story card and + `world.advance_time` stay until Cut 9. +- **Docs in the same commit:** `docs/architecture/ghostlight-dungeon-mvp.md:477-484` + drops the cover, tick-interval and elaboration-ceiling variables; + `docs/architecture/ghostlight-world-ontology.md:676-677` and the handoff line + 311 lose the elaboration pool. `gamecult-ops` sets none of these (grepped). +- **Authority map:** + - Owner: after this cut, nothing in Dungeon runs a Persona, an operational + agent or an elaborator on its own; the owner's world commands and seeding + remain. + - Forbidden writers (deleted): the wall-clock `AdvanceTime` loop, cover + cells, the Active elaboration sweep, owner-requested controller turns. + - Derived state: `CoverSummary` is gone with the driver it summarised. + - Deletion line: every path above. +- **Rules losing their only test** (Hands must list them in the report): pool + separation (both pool tests) and quarantine-on-tick go with the pools and + the tick they described; none survives in code. +- **Verification:** + - builds: `cargo check -p ghostlight-dungeon --bin ghostlight-dungeon`; + distinct warnings no larger than Cut 0's. + - tests: `cargo test -p ghostlight-dungeon --bin ghostlight-dungeon`; the + census drops by exactly the listed tests; `every_operation_the_panel_emits_has_a_schema` + (`:4558`) still passes with `world.controller.act` gone. + - negative: `rg -n 'derive_cover|drive_cover_tick|elaborate_world|run_elaboration_sweep|elaboration_permits|world\.controller\.act|submit_clock\(' crates/ghostlight-dungeon/src` + = 0 (`submit_clock\(` with the paren: the library method name must not + match a doc word); `rg -n 'GHOSTLIGHT_(COVER_|TICK_INTERVAL|ELABORATION_MAX)' crates docs/architecture/ghostlight-dungeon-mvp.md` + = 0. + - mutation: M1.1 re-add `"world.controller.act" => "ghostlight.world_controller_act.v0"` + to `operation_schema`: `removed_legacy_operation_is_denied_before_dispatch` + (`:3052`) must be extended in this cut to name `world.controller.act`, and + must then fail. +- **Promises:** + - P1.1 No Dungeon code path submits `AdvanceTime` except the owner's + `world.advance_time` command. + - P1.2 No Dungeon code path runs `run_cell`, `run_narrative`, + `run_operational` or `ElaborationRunner::sweep`. + - P1.3 `world.controller.act` is denied before dispatch. + - P1.4 The library diff is empty. +- **Landed:** — + +## Cut 2. The local inference port + +- **Repo/branch:** Ghostlight `codex/ghostlight-dungeon-mvp`. One commit. + Written for PA-Q1 A. +- **Deletes first:** none. +- **Adds:** + - `crates/ghostlight/Cargo.toml`: `reqwest.workspace = true`. + - `crates/ghostlight/src/local_inference.rs` (~180 lines plus tests): + `pub struct LocalBinding { pub endpoint: SocketAddr, pub model_prefix: + String, pub caller_runtime_id: String }`; `pub const + DEFAULT_LOCAL_MODEL_PREFIX: &str = "local/"`; `struct + LocalInferencePort { client, endpoint, prefix, caller_runtime_id }`. + `prepare` calls `PreparedInference::prepare` (the one builder). `infer` + refuses a foreign caller id and an expired invocation exactly as the SDK + port does (`sdk_inference.rs:680-690`), lowers the request to one `POST + /v1/chat/completions` (model = name with the prefix stripped, `messages` + from instructions and input, `tools` with `strict: true`, + `parallel_tool_calls`, `max_tokens`), and returns text and tool calls as + events, inert. It holds no mutex across a request (several slots). + Receipt: `sha256` over `rmp_serde::to_vec_named` of `LocalInferenceReceipt + { schema_id, request_id, conversation_id, caller_runtime_id, + native_request_sha256, provider_request_sha256, model, response_id, + finish_reason, prompt_tokens, completion_tokens }`, the SDK receipt's + shape. Faults: connection refused and 429/503 → `retryable`; 4xx other → + `recovery_required`; a response that is not the declared shape, a tool + call naming no offered tool, or an invalid call id → `integrity_violation`. + - Loopback rule: `open_inference` refuses a `LocalBinding` whose endpoint is + not loopback (`ControllerOpenError::LocalEndpointNotLoopback`). No header + other than content type is ever sent. +- **Per-file changes:** + - `sdk_inference.rs:715-773`: `RoutedInferencePort` gains a `local: + Option<(String, Arc)>` slot; `route` checks the local + prefix first, then the SDK prefix, then the connector. A prefix claimed by + two slots is refused at open. + - `controllers.rs:2336-2376`: `open_inference(connector, sdk, local: + Option, models: &[&str])`; `ControllerModels::each` + (`:2294`) becomes `pub` so callers pass `&models.each()` plus the play + model (Cut 8). + - `lib.rs:116`: `pub use local_inference::{DEFAULT_LOCAL_MODEL_PREFIX, + LocalBinding};` and `mod local_inference;`. + - `runtime.rs:440-478`: read `GHOSTLIGHT_LOCAL_ENDPOINT` and + `GHOSTLIGHT_LOCAL_MODEL_PREFIX`; no other Dungeon change in this cut. +- **Authority map:** + - Owner: `RoutedInferencePort` stays the one router; the model name still + carries the transport. + - Forbidden writers: no port reads a credential; no lane chooses a port. +- **Verification:** + - builds: `cargo check -p ghostlight`; `cargo check -p ghostlight-dungeon + --bin ghostlight-dungeon`. + - tests (`cargo test -p ghostlight --lib local_inference::`), against a + scripted HTTP responder on `127.0.0.1:0` (tokio listener in the test; no + new dev-dependency): + `a_scripted_backend_drives_an_elaboration_round_through_the_existing_evaluator` + pins invariant 7 (two rounds, calls inert, `evaluate_elaboration_loop` + re-derives the conversation, the second request carries the first round's + tool results); `the_request_lowers_every_input_item` pins the message + mapping item by item; `a_non_loopback_endpoint_is_refused_at_open`; + `a_call_to_an_unoffered_tool_is_an_integrity_violation`; + `routing_prefers_the_longest_claim_and_refuses_a_shared_prefix`; + `no_request_carries_an_authorization_header` (the responder asserts on the + raw header block). + - negative: `rg -n -i 'authorization|bearer|api[_-]?key' crates/ghostlight/src/local_inference.rs` + = 0 outside the test that asserts absence. + - mutations: M2.1 drop the loopback check: the open test fails. M2.2 + return `ToolCall` events only for the first call: the elaboration-round + test fails on the second call. M2.3 map a 4xx to `retryable`: the fault + test fails. +- **Promises:** + - P2.1 A scripted local backend carries a full tool round through the + existing evaluator with calls returned inert (invariant 7). + - P2.2 The port refuses non-loopback endpoints and sends no credential. + - P2.3 Each lane routes by its model name to exactly one port. +- **Landed:** — + +## Cut 3. The play authority (kernel), schema `consumer.v6` + +- **Repo/branch:** Ghostlight `codex/ghostlight-dungeon-mvp`. One commit. + Written for PA-Q5's default. +- **Deletes first:** none. +- **Per-file changes:** + - `lib.rs:467-484`: `SystemCapability::Play`, doc: "The play table. Admitted + for an unanswered, unconfined, evidence-free Active patch and for the + clock; minted only by `PlayPort`." + - `lib.rs:1703-1720` and `:4768-4780`: add `(Play, AdmitPatch)` / + `(Play, PatchAdmitted)` and `(Play, AdvanceTime)` / `(Play, TimeAdvanced)`. + - `lib.rs:1740-1764`: `require_answer(state, caller, answers, declares)`: + `(Active, None)` with `declares` is `Ok` when `caller == + System(Play)`; `Play` in Draft is `WrongPhase`. Both call sites + (`:1663`, `:4791`) pass the caller. + - `lib.rs` `AdmitPatch` arm (`:1655-1685`) and its twin: a `Play` patch with + nonempty `evidence` is `PatchRejected([Mismatch::PlayCarriesEvidence])`; + `Mismatch` gains the variant (`patch.rs`, beside `LensWeightsNeverDraw`). + - `lib.rs:4284-4315`: `CallerId::System(SystemCapability::Play) => + Ok(None)`. + - `lib.rs:1725-1731`: `require_clock_caller` admits `Play`. + - `mailbox.rs`: `pub struct PlayPort` with `new(WorldMailbox)`, `pub async fn + snapshot`, `pub async fn submit_patch(&self, CommandId, WorldPatch)`, + `pub async fn advance_time(&self, CommandId, TickMinutes)`, both through + `submit_stamped` with `CallerId::System(Play)`. `lib.rs:94`: export. + - `lib.rs:172-173`: `consumer.v5 → consumer.v6`; `consumer.rs` pins updated + as L1 did. +- **Authority map:** + - Owner: the kernel's admission functions; `PlayPort` is the only minter. + - Inputs: caller, phase, answer, patch. + - Outputs: an admitted patch or clock advance attributed `System(Play)`. + - Forbidden writers: every other caller still meets `AnswerRequired` for an + unanswered Active declaration; no other port mints `Play`. + - Deletion line: none; admission clauses only. +- **Verification:** + - builds: both crates. + - tests (library): `the_play_authority_declares_in_active_without_an_answer`; + `an_elaborator_declaration_in_active_without_an_answer_is_still_refused` + and `the_owner_still_cannot_declare_unanswered_in_active` (invariant 5, + both halves); `the_play_authority_is_unconfined` (a place outside every + jurisdiction); `the_play_authority_cannot_carry_evidence`; + `the_play_authority_advances_time`; `the_play_authority_cannot_approve_activate_or_exercise` + (each body refused `Unauthorized`); `the_play_authority_is_refused_in_draft`; + `apply_effect_re_decides_the_play_authority` (a forged `PatchAdmitted` + under `Clock` is refused, the `apply_effect_re_decides_elaborator_authority` + pattern, `lib.rs:15415`); replay of a `Play` commit reproduces the state + digest. + - external: `tests/external_admission.rs` gains + `play_port_is_the_only_play_minter` (compile-pass use of `PlayPort`) and + keeps its refusals. + - negative: `rg -n 'SystemCapability::Play' crates/ghostlight/src --glob '!*test*'` + lists only `lib.rs` admission sites and `mailbox.rs`'s one method. + - mutations: M3.1 in `require_answer`, admit any `System(_)` caller instead + of `Play`: the elaborator test fails. M3.2 drop the evidence refusal: its + test fails. M3.3 admit `(Play, ActivateWorld)`: the "cannot approve" test + fails. M3.4 drop `Play` from the `apply_effect` twin: the replay test fails. +- **Promises:** + - P3.1 `Play` declares in Active unanswered and unconfined; no other caller + does. + - P3.2 `Play` cannot carry evidence, act in Draft, approve, activate, + exercise or decline. + - P3.3 Replay re-decides `Play` admission. +- **Landed:** — + +## Cut 4. Retirement (kernel) + +- **Repo/branch:** Ghostlight `codex/ghostlight-dungeon-mvp` from Cut 3. One + commit (shares Cut 3's `v6`). Written for PA-Q6's default. +- **Per-file changes:** + - `lib.rs:700-760`: `ControllerAssignment::Retired`; `id`, `mode`, + `consumer`, `human_principal` return `None`; `expected_caller -> Option`, + `None` for `Retired` and `ExternallyControlled` keeps `Some(System(Consumer))`; + call sites `:1613`, `:1631`, `:4866`, `:4897` compare `Some(&caller)`. + - `patch.rs:1014`: `ComponentOp::Retire { subject: Ref }`; + `patch.rs:1689`: `ResolvedOp::Retire { subject: SubjectId }`; resolution + beside `Relocate` (`:3613`): subject resolves, is not retired + (`NoOperationEffect`), is not externally controlled + (`Mismatch::RetiresAMirror`); lowering at `:5093` region. + - `lib.rs:2115` `apply_operations`: set `Retired`, remove `positions` and + `affordance_grants` entries. + - `lib.rs:4411` `confine_to_ground`: every `Retire` under any confined author + is `OutsideJurisdiction`. + - `lib.rs:966-1015`: `SubjectSnapshot.retired: bool` (pub), set in + `snapshot`. + - `patch.rs:5600`: `PATCH_TOOLS` gains `retire` (`Operate { variant: + "retire" }`, one field `subject`); counts at `patch.rs` catalog test go to + `(7, 31, 40)`; the sidecar fixture is regenerated + (`GHOSTLIGHT_WRITE_SIDECAR_FIXTURES=1`). + - `controllers.rs:77-78`: `controller_work.v16 → v17`, because an in-flight + elaboration or seed row stores the old tool list and would otherwise be + refused at open with a less honest error (stock-lenses probe Q7). +- **Authority map:** + - Owner: `controller_assignments` stays the sole answer to who may call; + `Retired` is a value of it, not a second partition. + - Derived state: opportunities, audiences and presence are derived and read + the assignment and position; none stores "retired" apart from it. + - Forbidden writers: elaborators and consumers. +- **Verification:** + - tests: `a_retired_subject_holds_no_opportunity_across_a_replay` + (invariant 6: retire, reopen the journal, assert no opportunity and + `retired`); `a_retired_subject_cannot_act` (its last opportunity is + `OpportunityMismatch`); `a_retired_subject_hears_nothing` (speech in its + former place gives it no knowledge row); `a_retired_subject_keeps_its_history` + (events and knowledge unchanged); `retiring_twice_is_no_effect`; + `a_mirror_cannot_be_retired`; `an_elaborator_cannot_retire_inside_its_jurisdiction`; + `the_owner_and_the_play_authority_may_retire`; the state-shape check + accepts a world with a retired subject. + - mutations: M4.1 leave the position in place: the "hears nothing" test + fails. M4.2 make `mode()` return the old mode for `Retired`: the + opportunity test fails. M4.3 drop the confinement clause: the elaborator + test fails. +- **Promises:** + - P4.1 A retired subject gets no opportunity, cannot be an actor, and is + never an audience, and replay reproduces it (invariant 6). + - P4.2 Retirement erases no history. + - P4.3 Only the owner and `Play` retire. +- **Landed:** — + +## Cut 5. Granting and revoking affordances (kernel) + +- **Repo/branch:** from Cut 4. One commit. Written for PA-Q10 A; if B or C is + ruled, this cut is rewritten. +- **Per-file changes:** `ComponentOp::GrantAffordance { subject, affordance: + Ref }` and `RevokeAffordance`; resolution refuses a retired or + external subject, an unknown entry, a grant already held or a revoke not held + (`NoOperationEffect`), and a revoke that leaves a subject with no grant + (`derive_opportunities` requires one, `lib.rs:4142-4146`); apply writes + `affordance_grants`; `confine_to_ground` refuses both for every confined + author. `PATCH_TOOLS` gains `grant_affordance`, `revoke_affordance` + (`(7, 33, 42)`), fixture regenerated. Same `v6`/`v17` as Cuts 3–4 if landed + before either ships; otherwise its own bump. +- **Verification:** `the_seed_grants_the_player_a_verb_in_draft`; + `the_play_authority_grants_and_revokes_in_active` (the scope digest moves, the + old opportunity is `ScopeChanged`); `a_revoke_cannot_leave_a_subject_mute`; + `an_elaborator_cannot_grant`. Mutations: M5.1 allow the last revoke: its test + fails. M5.2 drop the confinement clause: the elaborator test fails. +- **Promises:** P5.1 Grants change only through owner, seed-in-Draft or + `Play`. P5.2 No subject with a controller is left with no grant. +- **Landed:** — + +## Cut 6. The Persona lane and the recency marker (library) + +- **Repo/branch:** Ghostlight `codex/ghostlight-dungeon-mvp`. One commit. + Written for PA-Q2's default and PA-Q3 A. +- **Deletes first:** none. (Moves: the Projector-then-Persona request + building in `run_narrative` `:2818-2840` and `run_projector` `:3530-3580` + becomes two private functions both paths call, so the prompts have one + builder.) +- **Adds:** + - `lib.rs:966`: `SubjectSnapshot.last_acted_at: Option` (`pub(crate)`), + filled in `snapshot` from one pass over `state.events`. + - `controllers.rs:4616-4638`: each row gains `"new": bool`. + - `controllers.rs`: `pub struct PersonaLane { mailbox: ControllerPort, + inference: Arc, projector_model: String, persona_model: + String }`, `pub fn new(..)` refusing non-canonical models; `pub async fn + turn(&self, command_id, &DecisionOpportunity) -> Result` (refuses any mode but `NarrativePersona`); `pub async fn + narrate(&self, command_id, &DecisionOpportunity) -> Result` (refuses any mode but `Human`). Requests are + `projector_request`/`persona_request` (`:5934`, `:5949`) under the given + command id. No work-store access; the type holds no `ControllerWorkStore`. + - `lib.rs:80-87`: export `PersonaLane`. +- **Authority map:** + - Owner: the library builds every Persona and Projector input from the + subject's own slice; `PersonaLane` has no parameter through which a caller + can pass text into either prompt. + - Forbidden writers: the caller (the play agent) of any Persona input. +- **Verification:** + - tests: `a_persona_turn_carries_no_structured_state` (the Persona request's + only input item is prose; none of the subject's ids, the scope digest, the + revision, or any key of the typed view appears; invariant 2); + `a_persona_turn_never_sees_a_secret_the_subject_does_not_hold` (a fact + another subject holds is absent from both requests); `the_marker_flags_rows_since_the_last_act` + (act, then hear two lines: those two are `new`, earlier rows are not); + `a_subject_that_never_acted_sees_every_row_new`; `narrate_refuses_a_persona_and_turn_refuses_a_human`; + the stimulus equals Cut 0's capture plus the marker; the existing + narrative-lane tests pass unchanged except where they pin stimulus bytes. + - negative: `rg -n 'ControllerWorkStore|persist' ` over the `PersonaLane` + impl block = 0. + - mutations: M6.1 pass `typed_view` into the Persona prompt: the + no-structured-state test fails. M6.2 compute `new` with `>=`: the marker + test fails on the subject's own spoken row. M6.3 take `last_acted_at` from + `last_opportunity_at` (minutes): the marker test fails. +- **Promises:** + - P6.1 A Persona's input is Projector prose; the Projector's input is the + subject's own slice (invariant 2). + - P6.2 The marker is derived from the journal's events and stores nothing. + - P6.3 The player's narration is the same Projector over the player's slice + (Q11). +- **Landed:** — + +## Cut 7. The table vocabulary and the inference seams (library) + +- **Repo/branch:** from Cuts 2, 5 and 6. One commit. Written for PA-Q12 A and + PA-Q13 A. +- **Keeps and moves:** `render_world_structure` and `id_text` + (`elaboration.rs:2164-2280`) move to `table.rs`; the seed prompt calls them + there. +- **Adds:** `crates/ghostlight/src/table.rs` with the functions named in + PA-Q12 A. `table_view` extends the moved renderer with each subject's place, + mode, `retired`, granted entry names, and the places' occupants, and ends + with the clock and the brief. `decode_authoring_call` is `apply_tool_call`'s + decode arm (`elaboration.rs:1339-1420`) called for one call, so there is + one decoder: `apply_tool_call` calls it. `decode_actor_call` is + `decode_catalog_call` (`controllers.rs:6279-6360`) plus a verbatim + optional `display`, and looks the subject's current opportunity up in the + snapshot. `describe_refusal` renders `ActionRejected` mismatches through the + entry's preconditions and every other `KernelError` by its `Display`. + `controllers.rs:99-112`: `InferencePurpose::Play`; `pub fn + InferenceRequest::play(command_id, round, model, instructions, input, tools, + max_output_tokens)` over `tool_request` with parallel calls on; + `InferenceOutput::events()` and `receipt_digest()`. +- **Authority map:** + - Owner: the library owns the only renderer and the only decoders of its + vocabulary; Dungeon composes them. + - Forbidden writers: Dungeon code building a `ComponentOp`, `Declaration` + or `DecisionInvocation` by hand. +- **Verification:** + - tests: `authoring_tools_refuse_an_unknown_name`; `every_authoring_tool_decodes_its_own_example` + (reuses `field_example`); `the_elaborator_and_the_table_share_one_decoder` + (the same arguments give the same operation through both); + `an_actor_tool_decodes_to_the_subjects_current_opportunity`; + `describe_refusal_names_the_failed_precondition`; `table_view_prints_every_id_the_tools_take`. + - negative: in `crates/ghostlight-dungeon/src`, `rg -n 'ComponentOp|Declaration|RoleBinding|ProposedEffect'` + = 0 after Cut 8. + - mutations: M7.1 give `decode_actor_call` the snapshot's first opportunity + instead of the subject's: its test fails. M7.2 let `authoring_tools` + skip unknown names: its test fails. +- **Promises:** P7.1 One renderer and one decoder per vocabulary. P7.2 Dungeon + can run an inference and read its output without widening any kernel type. +- **Landed:** — + +## Cut 8. The play table and the turn lifecycle (Dungeon) + +- **Repo/branch:** from Cuts 1 and 7. Two commits allowed: (a) the store and + the loop with scripted-port tests; (b) wiring into `AppState` and + `world.play`. Written for PA-Q7 B and PA-Q8's default. +- **Deletes first:** none beyond Cut 1. +- **Adds:** `crates/ghostlight-dungeon/src/play.rs` (~600 lines plus tests): + - `PlayTurnStore` over `service/play-turn-v1.cc`, the `app_session.rs:56-80` + pattern; one row, `PlayTurn` as in PA-Q8. + - `const PLAY_TOOLS: &[&str]` (PA-Q7 B), pinned ⊆ `PATCH_TOOLS`. + - `PlayTable { play: PlayPort, world: WorldMailbox, personas: PersonaLane, + inference, model, permits: Arc, store }` with `async fn + run(&self, principal: &VerifiedPrincipalEvidence, text: String)`. Per + round: re-derive the conversation, `InferenceRequest::play`, infer, + persist the output, then execute each call in order: + - an authoring tool → `decode_authoring_call` → persist → `PlayPort::submit_patch`; + - `__` → the handle must be the player or a subject + dispatched this turn, else refused; `decode_actor_call`; `text` and + `display` must `SourceSpan::locate` in that actor's prose (the + player's texts, or the Persona's turn), else refused; persist the body; + submit (`submit_principal` for the player, `ControllerPort::submit_controller` + for a Persona); on `ActionRejected` for the player, set `refusal` from + `describe_refusal`; + - `dispatch { subjects }` → for each subject with a `NarrativePersona` + opportunity, `PersonaLane::turn` concurrently under `permits`; + results are the prose, recorded; + - `advance_time { minutes }` → `PlayPort::advance_time`; + - `ask_player { question }` → `AwaitingPlayer`, loop stops; + - `end_turn` → loop stops. + Round budget 12; exhausting it ends the turn. On close, + `PersonaLane::narrate` for the player writes `narration`, and the turn is + `Closed`. + - The prompt (instructions) is a Dungeon constant stating the table rules: + speech and display are quotes; an actor acts only through its own tools; + rulings are authoring tools; ask when an outcome needs negotiating. +- **Per-file changes:** `runtime.rs:68-103` `AppState.play: Option>` + plus a `Mutex` guarding one running turn; `open_controller` (`:440-479`) + reads `GHOSTLIGHT_PLAY_MODEL` and passes it to `open_inference`'s model + list; `execute_world` (`:1439`) routes `world.play` to the table in a + spawned task and returns `accepted`; `eve.rs:622-636` adds + `"world.play" => "ghostlight.world_play.v0"`. +- **Authority map:** + - Owner: `PlayTable` owns the turn; the kernel owns every consequence. + - Inputs: world snapshot, the turn record, the player's text. + - Outputs: kernel commands (as the actor or as `Play`), the turn record. + - Derived state: the agent's conversation (from the record); `narration` + (from the Projector over committed state). + - Forbidden writers: nothing but `PlayTable` constructs `PlayPort`; no + transcript crosses turns; the agent never writes a Persona input. + - Shared paths: a first run, a resumed run after restart, and a run resumed + by the player's answer all execute the same round function over the same + record. + - Deletion line: none new. +- **Verification** (scripted `InferencePort` in tests, no model): + - `restart_equivalence_of_the_agent_input` (invariant 1: close a turn, drop + and reopen the store and the world, start the next turn; the first request + is byte-identical to the one built without the restart); + - `a_paraphrased_quote_is_refused` (invariant 4, for the player and a + Persona; the forgery differs by one word, same length); + - `an_act_for_an_undispatched_subject_is_refused` and + `a_raw_op_is_journaled_as_play_and_never_as_an_actor` (invariant 3: the + commit's caller is `System(Play)`); + - `a_resumed_call_resubmits_its_recorded_body` (kill after persist, before + result: `AlreadyApplied`, one commit); + - `a_question_holds_the_turn_open_across_a_restart`; + - `a_refused_player_act_sets_the_refusal_line`; + - `the_turn_closes_with_the_players_narration`; + - negative: `rg -n 'PlayPort::new' crates/ghostlight-dungeon/src` = 1. + - mutations: M8.1 skip the span check for Personas: the quote test fails. + M8.2 rebuild `opening_prompt` on resume: the question-across-restart test + fails on a moved snapshot. M8.3 rebuild the body from a fresh snapshot on + resume: the resume test fails (`CommandIdConflict`). +- **Promises:** P8.1–P8.4 invariants 1, 3, 4 and restart survival as pinned + above; P8.5 Persona dispatch draws only from `controller_permits`. +- **Landed:** — + +## Cut 9. The Eve play surface; `world.speak` and the story card deleted + +- **Repo/branch:** from Cut 8. One commit. Written for PA-Q9's default. +- **Deletes first:** `SpeakPayload` (`runtime.rs:225-231`), the `world.speak` + arm (`:1520-1538`), `eve.rs:436-455` (story card) and `:457-501` (speak + control), `"world.speak"` in `operation_schema` (`:632`), + `current_operator_view`'s log read for the surface (`runtime.rs:1630-1640`; + `operator_log` stays in the library), `speak_through` and tests that drive + speech through Eve (the HTTP journey test is rewritten to `world.play`). +- **Adds:** in `eve.rs` Active arm, the play card as PA-Q9 describes, read from + the store's row and the snapshot; `surface_version` also moves when the + turn row changes (the row's own counter), so the SSE path wakes the client. +- **Verification:** `the_play_surface_shows_only_the_projection` (no speech + the player did not perceive appears: a Persona speaks elsewhere, the surface + omits it); `every_operation_the_panel_emits_has_a_schema`; negative `rg -n + 'world\.speak|operator_log' crates/ghostlight-dungeon/src` = 0; mutation M9.1 + render the operator log into the card: the projection test fails. +- **Operator (the gate, on Raven's machine, local lanes only):** create; seed; + approve and activate; play the five items; restart mid-session; record + seconds per turn and the narration call's share of it. +- **Promises:** P9.1 Nothing shown is world truth unless committed, except the + question and the refusal of the player's own act (invariant 8 with Q13 A). +- **Landed:** — + +## Subtraction ledger + +Estimates; Actual is filled from each landing diff. + +| Cut | Removed (est.) | Added (est.) | Dependencies, formats, targets | Actual | +|---|---|---|---|---| +| 1 | Dungeon ~800 source, ~1,100 test, eve ~150 | ~10 | env vars −6 | | +| 2 | 0 | library ~250 | library +`reqwest`; routing slot +1 | | +| 3 | 0 | library ~120 + tests | `consumer.v5 → v6` | | +| 4 | 0 | library ~150 + tests | `PATCH_TOOLS` 39 → 40; `controller_work.v16 → v17`; fixture | | +| 5 | 0 | library ~120 + tests | `PATCH_TOOLS` → 42; fixture | | +| 6 | ~40 moved | library ~120 + tests | none | | +| 7 | ~120 moved | library ~300 + tests | `InferencePurpose` +1 | | +| 8 | 0 | Dungeon ~600 + tests | store `play-turn-v1.cc`; env +1 | | +| 9 | Dungeon ~150 | Dungeon ~120 | Eve op `world.speak` → `world.play` | | + +What Dungeon stops using, and whether it is deleted from Dungeon: + +| Surface | Other consumer in Dungeon | Fate | +|---|---|---| +| owner-only "Let X act", `world.controller.act` | none | deleted (Cut 1) | +| cover tick dispatch and the wall-clock tick | none | deleted (Cut 1) | +| Active elaboration sweep and its pool | none | deleted (Cut 1) | +| Interpreter pass | only through `run_narrative`/`run_cell`, both unreached | unreferenced after Cut 1; library keeps it | +| per-subject action catalogs (`run_operational`) | none | unreferenced after Cut 1; library exposes the catalog again through `table.rs` | +| `world.speak`, story card | none after Cut 9 | deleted (Cut 9) | +| `ControllerRunner` | seeding, readiness `custody_probe` | kept | +| `interpreter`/`operational_agent` model env | `ControllerRunner::open` requires all five | kept; follow-up PA.f5 | + +The library keeps cover, grouped cells, the controller runner, the +Interpreter, the elaborator sweep and lenses. + +## Findings + +- **PA.f1 (pre-existing, operator, recorded):** `state/map.yaml` says every + backend shares "one standardized CultNet connector API"; the Body has one + in-process trait and a private sidecar pipe. Resolved at `5ff1d54` (Self): + the target's premise and the map's sentence were both corrected there, and + the map now records the shared API as operator direction with what is true + today. A CultNet + connector for credentialed third-party endpoints remains the deployment + gate's item. +- **PA.f2 (new, medium, recorded):** strict tool-argument enforcement on + llama-server depends on its build and flags; an argument that fails decode + is a tool-result string, never a commit, but a model that loops on it burns + rounds. Measure on Raven's machine at the gate. +- **PA.f3 (new, medium, recorded):** the play lane on the SDK sidecar. The SDK + port runs a tool query inside the sidecar and asks a synchronous oracle, and + holds one mutex per query, so a play tool that commits or dispatches (async, + and a Persona dispatch is two more inferences through the same port) cannot + run inside it. A lent oracle with `remaining_rounds() = 1` answering a fixed + placeholder might make the SDK return one round inert; it is unproven and + off the gate's path (every play lane is local). Projector and Persona are + prose-only and need no oracle, so they fall back to the SDK as they are. +- **PA.f4 (introduced by design, low, recorded):** a retired subject's + commitments, pressures and dependency edges stay, and the clock keeps + deriving motion over them. +- **PA.f5 (pre-existing, low, recorded):** `ControllerRunner::open` requires + all five models, so Dungeon keeps configuring the Interpreter and + operational lanes it no longer runs. +- **PA.f6 (pre-existing, low, recorded):** the Projector's stimulus is every + row the subject has ever held; it grows without bound over a long session. + The recency marker does not bound it. +- **PA.f7 (pre-existing, low, recorded):** the play authority cannot create + quantity (no evidence) and cannot state a canonical fact; the agent rules + with structure and claimed facts only. Enough for the gate; a table that + hands out coin needs a ruling on quantity provenance. +- **PA.f8 (pre-existing, info):** `PreparedInference::prepare`'s doc says + consumers may implement ports outside the crate; probe B shows they cannot + read the request. Cut 2 removes the need for one; the comment is corrected + in Cut 2.