Build grounded world compiler flow

This commit is contained in:
Meta Vens 2026-08-16 20:12:53 +02:00
commit ab39d8cdac
25 changed files with 1350 additions and 225 deletions

View file

@ -33,9 +33,17 @@ per-campaign WorldKernel mailbox is the sole canonical writer. Ghostlight owns
the generalized Projector → Persona → Interpreter organ; Epiphany retains her
canonical Persona mind and will consume the shared organ through an adapter.
The immediate next action is to map Epiphany's existing projection machinery
into move/stay/split/delete ownership before continuing the Rust scaffold.
Existing Ghostlight fixtures remain regression evidence.
The Epiphany extraction map is complete. The active bounded organ is the world
compiler. Its Rust seam now retrieves hashed VoidBot witnesses, generates
distinct openings and roles, compiles approval-gated custom starts, rejects
invalid topology, and atomically admits campaign plus evidence only on
approval. The browser now exposes generated opening/role selection and custom
starts. A live DeepSeek plus VoidBot custom compilation passed with 30 witnessed
source chunks and remained an uncommitted approval preview. Next, prove browser
session/invite flow plus approval persistence against a disposable campaign
store, then add material-gap decisions, on-demand destination compilation, and
canon-candidate persistence. Existing Ghostlight fixtures remain regression
evidence.
## Prior research pipeline focus

View file

@ -203,6 +203,9 @@ paths as active state surfaces.
## Missing Or Incomplete Organs
- World compiler browser flow, selected-opening/role path, live provider
acceptance, material-gap approval, on-demand destination expansion, and
canon-candidate persistence
- Deterministic speaker-local input slicer
- Full prompt renderer
- Classifier/appraiser pipeline

171
notes/ghostlight-dungeon.md Normal file
View file

@ -0,0 +1,171 @@
# GhostlightDungeon MVP — Starfire-Hosted AI Dungeon Master
## Summary
Build `GhostlightDungeon` inside `GameCult/Ghostlight`: a persistent, Vault-grounded, single-player narrative simulation with a private web chat interface for two testers.
The runtime will be a Rust daemon on Starfire. It will own world compilation, typed CultCache state, d20 resolution, NPC Persona loops, offscreen simulation, narration, and Eve/CultUI publication. A thin TypeScript browser client will lower the Eve surface and submit typed commands.
Ghostlight’s existing v0 schemas and training fixtures remain evidence and regression material; they do not become runtime authorities.
## Authority and invariants
- The per-campaign `WorldKernel` is the sole owner of canonical state and revision numbers.
- Player commands, NPC actions, scheduled ticks, travel, waits, imports, and reloads all enter the same `WorldCommand → validate → atomic commit` path.
- Projectors, Personas, Interpreters, retrieval, initiative, narration, news generation, dice previews, and the browser may propose or project state; none may commit it.
- Scenes are derived from persistent occupancy, topology, perception, and current events. Leaving a location does not delete it.
- RAG evidence remains owned by the Vault provider. For Aetheria, Ghostlight consumes VoidBot’s canonical retrieval service and stores only exact evidence receipts used by each campaign—never a rival semantic index.
- Every campaign branches from canon at creation. Later historical records describe the baseline trajectory, not an outcome the player must be railroaded into.
- Improvised facts are explicitly branch-local. Broadly useful gaps become reviewable canon candidates, never silent Vault edits.
- Player text describes an attempt, not a completed fact. Impossible actions do not receive a roll.
- Model failures, malformed outputs, stale projections, or retrieval outages produce no partial world mutation.
## Implementation changes
### Runtime and persistence
- Add a Rust 2024 workspace using Tokio/Axum, the Rust CultCache/redb backend, CultMesh/CultNet publication, and a provider-neutral model port.
- Store service state under `F:\GameCult\GhostlightDungeon`:
- service/control and schema catalog `.cc`;
- one row-oriented `.cc` store per campaign;
- exact Vault evidence receipts;
- private model-stage records and commit receipts;
- exported campaign and canon-candidate bundles.
- Route all writers through an in-process campaign mailbox. Background ticks and HTTP commands cannot race or repair each other afterward.
- Publish the player surface, operator inspector, health, scheduler pressure, model receipts, and command results through CultMesh/Eve. HTTP health remains a probe of that state, not separate truth.
### Vault and world compiler
- Define a generic `VaultProvider` contract for source search, surrounding context, source witnesses, authority lanes, temporal scope, and exact-document retrieval.
- Implement the bundled Aetheria adapter against VoidBot’s streamable MCP endpoint at Starfire loopback.
- At campaign creation:
1. Retrieve broad Aetheria evidence and generate three distinct suggested openings across different eras, places, and pressures.
2. For the selected opening, generate three source-grounded player roles plus a custom-role path.
3. Alternatively compile a fully custom who/where/when/goal description.
4. Produce an approval preview containing the initial topology, cast, institutions, capabilities, clocks, evidence coverage, gaps, and branch-local assumptions.
5. Commit only after approval.
- Materialize a bounded playable region and surrounding institutional pressure graph, not the entire universe. New destinations compile on demand and attach to stable containment, route, distance, and travel-time records.
- Automatically improvise reversible local texture as provisional branch fact. Material gaps in geography, mechanics, institutions, or extraordinary abilities require approval before the world seed or action is admitted.
- Store useful gaps as `CanonCandidate` records with originating campaign, evidence, conflicts, proposed wording, and affected Vault sources. The lab can review and export Markdown plus `.cc` evidence; it cannot edit AetheriaLore or open PRs.
### Persona and world action loop
Ghostlight owns its own generalized projection machinery:
1. Projector converts the actor’s permitted typed slice, memories, perceived events, relationships, goals, and retrieved knowledge into a private lived narrative stream.
2. Persona receives only that narrative stream and responds naturally—no schemas, action DSL, or raw state.
3. Interpreter extracts typed private deltas, explicit speech, reaction priority, and `WorldActionProposal` candidates.
4. WorldKernel validates spatial reach, knowledge, custody, resources, capability, opposition, and state version before committing anything.
All affected scene participants appraise a committed event in parallel. Actor-private deltas commit against their own snapshot versions; initiative then chooses compatible reactions or actions for world resolution. This ensures present characters continue perceiving and reacting even when another character currently holds conversational focus.
Use DeepSeek’s current API directly:
- `deepseek-v4-flash`, non-thinking: Projectors, Interpreters, retrieval planning/reranking, verification, and offscreen actors.
- `deepseek-v4-pro`, non-thinking for live work: world compilation, action assessment, live Personas, and narration.
- Structured stages use JSON Output followed by local schema validation. Empty or malformed output receives one same-snapshot retry, then fails without mutation.
- Record provider, model, request hash, source receipts, latency, output hash, validation result, and state version. Never persist or display `reasoning_content`.
DeepSeek currently documents both V4 model IDs, streaming, and JSON output through its OpenAI-compatible Chat Completions API. [Models](https://api-docs.deepseek.com/quick_start/pricing), [Chat API](https://api-docs.deepseek.com/api/create-chat-completion), [JSON Output](https://api-docs.deepseek.com/guides/json_mode/).
### Fiction-first d20 resolution
- Provide separate `Assess` and `Attempt` commands. Assessment never becomes visible to NPCs or changes state.
- An assessment contains:
- normalized intent and intended effect;
- admissibility or the missing permission;
- DC on the 5/10/15/20/25/30 resistance scale;
- itemized contextual modifiers with state or evidence references;
- modifier total capped at ±10;
- effect ceiling;
- success, mixed-result, and failure stakes;
- campaign revision and expiring assessment digest.
- Contextual modifiers come from capabilities, knowledge, tools, access, assistance, leverage, position, opposition, injuries, and conditions. There are no base attributes.
- Confirmation checks the assessment revision, obtains a server-side OS-random d20, and atomically stores the roll receipt and world transition.
- Outcomes:
- total ≥ DC + 10: strong success;
- total ≥ DC: success;
- total within 5 below DC: mixed result;
- lower: failure with the previewed consequence.
- Natural 20/1 moves one outcome band, but cannot make an impossible action possible or exceed its effect ceiling.
- Stale assessments are recompiled rather than rebased.
- Overreach returns explicit sacrifices or bargains that could admit a new assessment.
- Speech and its intended effect are separated: the character may successfully say something while failing to persuade, deceive, or intimidate.
### Away-time world agency
- The daemon owns a five-minute scheduler pulse. Campaigns enter away simulation after fifteen minutes without player activity.
- Each real hour awards one strategic tick, capped at eight pending ticks per absence. The compiled campaign chooses the in-world tick duration; default is six hours.
- Background simulation affects remote actors, institutions, resources, movement, bargains, investigations, preparation, recruitment, obstruction, and clocks. The absent player is never puppeted or directly harmed.
- The scheduler and return-time catch-up invoke the same `AdvanceStrategicTick` command. Catch-up processes missed ticks before accepting the next player action.
- Live play has inference priority; background work stops launching new calls while a player turn is active.
- Offscreen events generate information-channel-aware news leads. On return, the player may receive newspapers, reports, messages, or rumors only when the character has access to them; the news layer cannot reveal omniscient state.
### Web laboratory and hosting
- Build the interface as a Ghostlight-owned `gamecult.eve.surface.v1` document and lower it with Eve’s pinned browser renderer.
- Provide:
- generated-opening and custom-start compiler;
- narrative transcript and composer;
- Assess, Attempt, confirm-roll, revise, and Wait controls;
- character ledger for capabilities, equipment, conditions, obligations, relationships, and known facts;
- location/time/pressure display;
- news and rumor drawer;
- named campaign creation, fork, reset, and `.cc` export;
- optional operator inspector for evidence, topology, state versions, model receipts, rejected proposals, and private spoiler traces.
- Do not expose model chain-of-thought or secrets.
- Serve the embedded web bundle on TCP `8831`. Firewall access is limited to Starfire’s private LAN and `10.77.0.0/24`; no public listener or Yggdrasil web gateway is added.
- Use two single-use invite links that establish separate HttpOnly sessions. Campaigns are single-player; simultaneous co-op is outside the MVP.
- Install `GhostlightDungeon` as an automatic Windows service under a dedicated virtual service identity. ACL the runtime root to administrators and the service identity.
- Read the DeepSeek key from stdin during setup, protect it with machine-scoped DPAPI plus file ACLs, and never place it in source, arguments, logs, or environment projections.
- Build immutable release directories from the exact Git commit, switch the active release atomically, record provenance in CultCache, and configure service restart recovery.
### Repository and operational documentation
- Implement on `codex/ghostlight-dungeon-mvp`, with coherent foundation, runtime, interface, and deployment commits pushed to GitHub.
- Add the authoritative GhostlightDungeon architecture/build document and update Ghostlight’s system map, implementation plan, handoff, state map, and evidence ledger.
- Keep Starfire service/firewall/tunnel ownership in `gamecult-ops`, with a deployment and rollback runbook.
- Before live VoidBot integration, resolve the current Yggdrasil inventory/DNS split and independently verify the offered SSH host fingerprint. Then repair the tunnel task’s stale `E:\Projects` path to `F:\Projects`, restore `127.0.0.1:17875/mcp`, and update ops truth. Never bypass host-key verification or revive Starfire’s retired VoidBot/Qdrant writers.
## Public contracts
- `ghostlight.vault_manifest.v1`, `vault_evidence_receipt.v1`, `world_compile_preview.v1`
- `campaign.v1`, `world_fact.v1`, `location.v1`, `actor_state.v1`, `institution_state.v1`, `relationship_state.v1`, `world_clock.v1`, `event.v1`
- `player_action_assessment.v1`, `roll_receipt.v1`, `world_commit_receipt.v1`
- `persona_stage_receipt.v1`, `actor_state_delta.v1`, `world_action_proposal.v1`
- `strategic_tick.v1`, `news_issue.v1`, `canon_candidate.v1`
- Existing `gamecult.eve.surface.v1` and `gamecult.eve.command.v1`
Publish JSON Schema only as the schema catalog. Runtime documents and exports use MessagePack-backed CultCache `.cc`; JSON exists only at browser, MCP, and model-provider boundaries.
## Test and acceptance plan
- Unit-test every schema, redb/CultCache round trip, optimistic commit, topology invariant, knowledge gate, DC/modifier rule, outcome band, roll receipt, branch fact, and scheduler budget.
- Use injected clocks, RNG, Vault provider, DeepSeek transport, and persistence ports.
- Prove malformed/empty DeepSeek JSON, timeout, retrieval loss, daemon restart, stale assessment, stale Persona output, and concurrent scheduler/player commands cannot partially mutate state.
- Run existing Pallas, Lucent, and Corvid fixtures as regression scenarios, even though hosted opening suggestions are generated.
- Acceptance scenarios:
- compile an obscure Aetheria time/place or return an honest evidence-gap preview;
- leave a location, advance the world, and return to the same geometry and inhabitants;
- show reactions from every affected present actor;
- prevent an NPC from acquiring unearned knowledge or expertise;
- reject impossible action claims and offer explicit bargains;
- preview and confirm a fully receipted d20 action;
- observe institutions exploiting, resisting, or redirecting the protagonist;
- produce material offscreen changes and accessible news after absence;
- reload/fork/export a campaign without losing continuity;
- verify two invite sessions and rejection of unauthenticated access.
- Performance targets under a healthy provider:
- first progress update within 300 ms;
- all actor stages execute in parallel waves;
- a four-actor live turn completes within 20 seconds;
- background inference yields immediately to live work.
- Final deployment smoke verifies service restart, LAN and WireGuard access, blocked public access, DeepSeek inference, VoidBot-grounded retrieval, scheduler continuation, state persistence, CultMesh/Eve publication, and exact deployed commit provenance.
## Assumptions and exclusions
- Aetheria is the only bundled Vault adapter, but no compiler logic is Aetheria-specific.
- Generated suggestions plus unrestricted custom compilation replace fixed featured openings.
- No D&D classes, spell slots, six-ability statistics, or 5e sheet are canonical in the MVP. The typed character ledger remains sufficient for later D&D-shaped projections.
- No arbitrary Vault upload/import UI, multiplayer campaign, voice, image generation, direct canon mutation, or public internet exposure.
- The live deployment requires a DeepSeek key and restoration of the trusted VoidBot retrieval crossing; fixture-backed development may proceed before those two setup gates.

View file

@ -8,12 +8,19 @@ architecture and ownership map is
pipeline and fixtures remain regression evidence; they do not become hosted
runtime authorities.
The first required cut is documentation and extraction mapping: inventory the
Projector → Persona → Interpreter machinery currently embedded in Epiphany,
classify move/stay/split/delete ownership, and only then continue runtime code.
The Epiphany Projector → Persona → Interpreter extraction map is complete.
Ghostlight owns the generalized projection organ. Epiphany keeps her canonical
Persona mind and consumes the shared organ through a narrow adapter.
The active implementation cut is the world compiler. The first Rust seam now
owns Vault witness conversion, distinct opening and role proposals,
approval-gated custom compilation, deterministic seed validation, atomic
campaign-plus-evidence admission, and the browser opening/role/custom flow. A
live DeepSeek plus VoidBot custom compilation passed without committing. Prove
invite/session plus approval persistence against a disposable campaign store,
then implement material-gap decisions, on-demand destination compilation, and
canon-candidate persistence before moving to the action/Persona loop.
## Prior research-program phase
Build a reliable data-generation loop for socially persistent Aetheria agents.