8.1 KiB
Ghostlight Implementation Plan
Objective
Rebuild Ghostlight Dungeon as one legible world machine: one lifecycle, one typed ontology, one command ingress, one authority derivation path, and one atomic persistence owner. Preserve narrative roleplay where it matters and use direct operational cognition where it is a better fit, without granting either mode additional authority.
Current mechanism
The repository still contains the pre-rebuild runtime: separate Session Zero and campaign kernels, aggregate Campaign and component representations, multiple mutation ingresses, semantic verifier and reconciliation stages, model-owned scheduling decisions, and persisted recovery/checkpoint paths. These mechanisms are teardown evidence, not foundations that must survive.
The target map is adopted. The first subtraction removed seven pipeline-smoke
binaries and two live-fire scripts. The projection crate now exposes explicit
NarrativePersona and OperationalAgent modes plus a total Interpreter report.
The replacement world ontology is the active bounded implementation move.
Authority map
- Owner: one per-world
WorldKerneland its private aggregate journal. - Inputs: authenticated
CommandEnvelopes, currentWorldState, internally derived authority, deterministic time/randomness inputs, and typed proposals from humans or autonomous controllers. - Outputs: one accepted or rejected command receipt; accepted commands produce one new digest-chained revision and derived notifications.
- Derived state: projections, schedulers, news, transcripts, model receipts, checkpoints, coverage counts, and evaluations. None may write world truth.
- Forbidden writers: the old Session Zero publication path, aggregate Campaign writer, legacy transition projection, alternate elaboration and mutation inputs, verifier/reconciliation agents, model-owned schedulers, recovery repair loops, and external consumer callbacks.
- Shared paths: draft creation, approval, activation, player action, autonomous action, time, travel, imports, reload, and administration use the same submit/derive/reduce/commit primitive.
- Deletion line: obsolete writers are deleted or reduced to read-only evidence before their replacement path is called complete.
SessionZeroKernel is no longer a target owner; Draft is a WorldState phase.
Aggregate Campaign state is no longer an owner; aggregate views are derived
from typed components. A checkpoint is no longer a repair authority; it is a
projection of committed history.
Invariants
- Every world mutation passes through one deterministic reducer and one atomic compare-and-swap commit.
- Authority is derived inside the kernel from canonical membership, governance, custody, jurisdiction, and controller scope.
- Each autonomous decision scope has exactly one controller. Cognition mode changes representation only; there is no fallback or double action.
- Narrative interpretation is total. Persona prose is preserved; faithful typed proposals and exact translation gaps account for the turn. The Interpreter does not accept, reject, or commit world state.
- Structural invalidity is rejected deterministically before persistence and without a model verifier. A failed batch changes nothing.
- Private knowledge remains scoped until an explicit communication command changes it.
- External consumers retain sovereignty. Ghostlight views, proposals, and acknowledgements cannot mutate external-owned state.
- Sparse causal sufficiency controls elaboration. Counts and qualitative review remain evaluation evidence only.
- Restart reconstructs the exact committed world and idempotency history; a recovery loop cannot repair or reinterpret it.
Implementation sequence
1. Typed world foundation — in progress
Define opaque runtime-issued IDs, lifecycle phases, subjects, places, routes, relations, governance, knowledge, resources, custody, jurisdiction, external ownership, controller scopes, events, commands, structural validation, and the pure reducer. Prove referential integrity, atomic rejection, disjoint controller scope, privacy, sparse activation, and lifecycle legality with focused tests.
2. Private aggregate journal
Expose only create/open/snapshot/submit. Keep the CultCache writer in a private child module. Persist digest-chained commits and snapshots atomically with expected revision and idempotency key. Prove stale revision rejection, replay idempotency, corruption detection, and byte-for-byte restart recovery.
3. One vertical slice
Route Draft creation and activation, one player action, and one autonomous action through the aggregate. Derive a subject-private projection and one decision opportunity. Exercise both cognition modes without allowing either to write directly.
For NarrativePersona, the Projector emits prose context, the Persona returns
prose only, and the Interpreter returns a completed report containing preserved
speech, zero or more typed proposals, and zero or more translation gaps. Model
timeouts leave the source pending for retry; they do not become semantic
interpretation failures.
For OperationalAgent, the controller receives only its permissioned typed
view and tools. Its proposals enter the same command path as narrative
proposals. It does not bypass projection privacy, authority derivation, or the
reducer.
4. Migrate and cut
Move Session Zero, turn handling, resolution, elaboration, scheduling, persistence, transcript/news projection, and external publication onto the vertical slice. At each move, delete or neuter the old writer first. Retain model transport, Vault retrieval, Heimdall identity, Eve/CultMesh projection, Idunn health, and external adapters only where their ownership remains clean.
5. Contract verification
Required black-box proofs:
- Draft → Active → player action → autonomous action → restart preserves the exact digest and commit history.
- Invalid ontology patches are atomic and model-free; a typed causal boundary can activate sparse new state.
- Models, scheduler, projection, and recovery are inert without an explicit aggregate submission.
- Private knowledge stays private until explicit communication.
- External proposals and acknowledgements cannot mutate consumer-owned state; only a fresh owner snapshot can update the local observation.
- Narrative and operational controllers have exact disjoint scopes, never fall through, and never consume one opportunity twice.
- Interpretation always completes semantically and preserves unlowered material as translation gaps.
A 1,200-actor synthetic fixture may measure load after these pass. It cannot serve as an ontology or completeness gate. No live Delvehold acceptance run is admitted before the focused suite passes and the old writers are structurally unable to override the aggregate.
Subtraction budget
Prefer deletion, collapse, or reuse before adding surfaces. The replacement buys explicit capabilities: one lifecycle owner, one structural reducer, one persistence writer, disjoint cognition controllers, total interpretation, and restart proof. It must retire more writer and stage liability than it adds. Review each completed pass for modules, binaries, schemas, dependencies, processes, and tests added or removed.
Build budget
- Package:
ghostlight-dungeon, plus the pinnedghostlight-persona-projectioncrate when its contract changes. - Profile/target: Windows MSVC debug test/check, default features only.
- Focused checks: library checks, named module tests, the rebuild contract test, and the daemon binary check after cutover.
- No workspace-wide, all-target, release, cross-platform, or clean build during surgery.
- Existing
targetfootprint is roughly 30 GiB; stop before 33 GiB and inspect artifact fan-out before continuing.
Deferred research lanes
The 36-case agency corpus, separate-account multiplayer proof, visual/Ink fixtures, newspaper variation, and direct-tool Persona comparison remain useful research lanes. They do not steer the authority rebuild and cannot reopen a retired writer. Historical plans and results remain recoverable through Git, the evidence ledger, and the frozen pre-rebuild system map.