Document canonical CultMesh access rules

This commit is contained in:
Meta Vens 2026-06-29 00:28:12 +01:00
commit 8a76e4f9fb
9 changed files with 317 additions and 89 deletions

View file

@ -32,6 +32,28 @@ compiles down to the fastest safe path the runtime can prove.
6. Native views expose zero-copy or near-zero-copy slices when safe, with the same state semantics as remote query/subscription fallbacks.
7. Schema evolution is part of the developer experience. Bindings and migration manifests come from one source instead of hand-maintained slot maps.
## Canonical State Before Projection
CultMesh should make one canonical typed document feel native everywhere. If a
feature's game state is `AetheriaRuntimeFooDocument`, the daemon, Unity,
Electron, browser, tools, and future Rust clients should all hold managed
handles to that document type. Authority, prediction, debouncing,
reconciliation, quorum, locality, and transport are handle/runtime behavior,
not reasons for each application to create a private "truth" object and then a
client projection copy.
A projection is a different state shape, not the normal visibility mechanism.
Use projected documents or query surfaces for hidden-information filtering,
derived aggregation, viewport/windowing, SoA/native memory layout, lossy UI
summaries, Eve/CultUI surfaces, or temporary compatibility bridges. Do not
project merely because a client needs to read daemon-owned state.
This rule is cross-runtime. C#, Rust, TypeScript, Unity, browser/WASM, and tool
hosts should all express the same intent: grab a typed document/collection/query
handle, read it for display, or mutate/submit through it when authority policy
allows. CultMesh supplies the managed access conventions and generated handles
that make that simple.
## Ownership Boundary
| Belongs in CultMesh/CultLib | Belongs in Aetheria |

View file

@ -103,6 +103,16 @@ The project already has the first layer of primitive sugar:
The remaining problem is that the sugar is not yet the only obvious path. There are still public or semi-public seams where clients can fall back into raw envelopes, record keys, ad hoc frame projection, manual state resolution, locality-specific wiring, and renderer-side facade adaptation.
The architectural correction is simple and strict: a normal gameplay feature has
one canonical typed document. The daemon may be the authority for that document,
but daemon authority is not a second state model. The shared runtime assembly
defines the document, the daemon mutates/publishes it, and every runtime grabs a
managed handle to that same type for display, input, prediction, or testing.
Projection documents exist only when the state shape is intentionally different:
hidden-information filtering, expensive aggregation, viewport/windowing,
SoA/native layout, lossy UI summaries, Eve/CultUI surfaces, or compatibility
bridges with a removal stage.
The worst current pattern is not one bad helper. It is a repeated protocol walk:
1. read one projected document;
@ -114,6 +124,12 @@ The worst current pattern is not one bad helper. It is a repeated protocol walk:
That entire stack must collapse behind one typed CultMesh document, collection, query, or operation handle. If a client wants current docking, current inventory, current target, current stats, zone contacts, station refit state, or visible render objects, the caller should make one semantic CultMesh call and receive a typed reactive value. CultMesh owns cache hydration, routing, sync, invalidation, watch lifetimes, schema binding, derived-state execution, and locality choice.
The facade/projector/adapter/surface-builder chain is no longer an acceptable
style. A single adapter at a real boundary can be honest; a chain of translation
objects to recover one domain value is heretek architecture. Replace it with a
canonical document handle, a generated typed query/operation handle, a state
pointer, or a native view descriptor.
## Migration Rules
1. Repeated Aetheria-specific glue becomes a generated Aetheria facade.
@ -125,6 +141,9 @@ That entire stack must collapse behind one typed CultMesh document, collection,
7. The browser/RTS client and Unity client must use the same semantic Verse facade, even when their locality/runtime routes differ.
8. Client code must not manually compose state access from multiple protocol layers. A semantic state read is one CultMesh call from the caller's point of view.
9. Renderer-local object facades are presentation caches. They are not the API for game state, inventory, docking, targeting, or station services.
10. Do not split "daemon truth" from "CultMesh typed state" for ordinary gameplay. Use one canonical document, then let authority policy decide who can mutate, predict, or only observe it.
11. Add projections only for a distinct derived/filter/window/native/UI shape. "A client needs to read it" is not a projection justification.
12. Do not add facade/projector/adapter/surface-builder chains. One real boundary adapter is allowed; stacked translation layers are a missing CultMesh primitive.
## Stage 0: Freeze The Vocabulary
@ -153,6 +172,11 @@ Gates:
- No new public API may introduce `Apply(command, payload)` style call sites.
- No new client API may require a caller to know transport record keys or raw schema slots.
- No new client API may require a caller to join projected documents, frame rows, record keys, and renderer-local facades to obtain one domain value.
- No new feature guide, example, or verifier rule may describe separate daemon
truth and client typed state when one canonical document would work.
- No verifier may require a facade/projector/adapter/surface-builder chain as
proof of correctness. It should require the semantic typed handle and reject
the translation chain.
- All new examples in docs must use the North Star shape.
## Stage 1: Harden Shared CultMesh Primitives
@ -235,7 +259,11 @@ npm run check:rts-bindings
Status: partially started; local projection still leaks.
Goal: clients ask the daemon for typed projections. They do not reconstruct world truth from frames unless they are inside a generated/internal query executor.
Goal: clients ask CultMesh for typed query surfaces or projected documents when
the requested shape is derived, filtered, windowed, or native-layout-specific.
They do not reconstruct world truth from frames unless they are inside a
generated/internal query executor, and they do not add projections for canonical
state that a typed document handle can expose directly.
Targets:

View file

@ -143,9 +143,10 @@ Completed and usable:
daemon delegates the temporary RUDP compatibility hook to it.
- `AetheriaRuntimeStarbridgeProjection` owns the first S0 session-summary
projection, and `AetheriaClient.StarbridgeSessionSummaryAsync` exposes it as
a named facade read without routing through map viewport state. Scenario and
session facts now have latest-record keys in local Verse, so clients can ask
the facade for the active Starbridge summary without passing documents around.
a semantic managed read without routing through map viewport state. Scenario
and session facts now have latest-record keys in local Verse, so clients can
ask the client state surface for the active Starbridge summary without passing
documents around.
- The daemon boot path seeds the first Starbridge scenario/session facts from
daemon-owned local state. A fresh once-mode daemon publishes `Frontier
Fabricator Defense` as typed scenario/session documents, and the authority
@ -1147,7 +1148,7 @@ allowed to become Electron/RTS features.
| 1 | Sector topology | `SectorMap`, `SectorRenderer`, and main-menu observed-game boot consume `SectorMapAsync`, `CurrentZoneAsync`, daemon zone contents, catalog, and player settings through explicit clients. `SectorMapAsync` carries tutorial mode, generation seed, and faction relationships so Unity can lower the temporary observed galaxy without a whole daemon frame. | `SectorMap` no longer reads `ActionGameManager.TryGetObservedGalaxy`, passes `GalaxyZone`, or owns a legacy faction graph. `MainMenu` may not call `LatestAuthoritativeRunFrameAsync` for observed-game boot. | `verify-stage7d-unity-parity.ps1`; scoped search for `TryGetObservedGalaxy`, `GalaxyZone`, `Dictionary<Faction` in sector menu files, and `LatestAuthoritativeRunFrameAsync` in `MainMenu` returns no forbidden hits. |
| 2 | Zone render feed | Split `ActionGameManager` frame lowering into `gamecult.aetheria.zone_render.v1`, currently a typed transitional feed over explicit render facts, entity facade rows, orbit rows, and body rows. It no longer exposes the whole current-zone snapshot. Body poses, asteroid-belt poses, asteroid-instance poses, dropped pickups, entity facades, orbits, and bodies are render-feed facts, not per-frame Unity recomputations over the snapshot. Target, compass, and visibility rows come from `gamecult.aetheria.zone_contacts.v1`; viewport-scoped presentation loading comes from `ObjectsViewportAsync(...)`; visible body discovery and gravity terrain sampling facts come from `GravityViewportAsync(...)`. | `ZoneRenderer.LoadDaemonZoneView` remains only as a listed Stage 8 shim; it may not gain new state ownership. Raw run restoration in `ActionGameManager`, whole-zone exposure in `zone_render`, run/zone snapshot storage in `ZoneRenderer`, and `ZoneRenderer` calls to body/belt/asteroid-instance/target/compass/visibility/presentation/gravity-terrain daemon queries are forbidden. | Unity compile plus verifier checks for `ZoneRenderAsync`, `ProjectZoneRender`, no `TryRestoreEntityGraphFromDaemonRun`, no `render.Run`, no `render?.Zone`, no zone snapshot property on `AetheriaRuntimeZoneRenderDocument`, no `_daemonRunSnapshot`, no `_daemonZoneSnapshot`, no body/belt/asteroid-instance pose recomputation, no `QueryBodyViews`, no `EvaluateGravityTerrainHeight`, no `QueryGravityTerrainBand`, no `TryQueryEntityTarget`, no `QueryCompassMarkers`, no `QueryVisibleEntityIndices`, and no `QueryPresentationEntityIndices` in `ZoneRenderer`. |
| 3 | Current entity/status feed | Replace `ActionGameManager` entity facade reads needed by HUD, docking camera, local menu, click selection, inventory, and station/refit affordances with typed current-subject projections. `gamecult.aetheria.current_entity.v1` owns current entity identity/status/inventory/equipment/cargo, shutdown threshold, and player HUD status facts. `gamecult.aetheria.current_docking.v1` owns the current entity's docked state, dock parent identity, and docking bay index. | Unity facade objects may remain only as presentation adapters after their daemon keys are validated against `CurrentEntityAsync` or `CurrentDockingAsync`. Direct `TryGetObservedCurrentEntity` and `TryGetObservedDockingBay` calls are forbidden in newly migrated menu logic. Manager methods that only resolve daemon identity become private shims or move to state projection code. Target/enemy schematic rows remain a Stage 8 presentation shim until a target-entity projection exists. | HUD/menu surfaces read through `AetheriaClient`; no public manager read API returns Unity facade objects for portable state. Verifier requires `CurrentEntityAsync`, `CurrentDockingAsync`, `ProjectCurrentEntity`, `ProjectCurrentDocking`, typed-key validation in `InventoryMenu`, and typed HUD status consumption in `SchematicDisplay`. |
| 4 | Docking/refit projection split | Promote station stock, docked ships, loadout slots, cargo, and refit eligibility from menu-local facade graph reads into named typed projections that match Starbridge S2. Keep pricing through `aetheria.trade_value_policy.v1`. | `InventoryPanel`, `InventoryMenu`, and `TradeMenu` may adapt Unity UI controls, but stock/refit truth cannot come from manager-global observed cargo, docked ship, or trade collections. Broad available-entity reads are deleted; any remaining facade-object bridge must be key-scoped and listed as a Stage 8 shim with the typed projection that will replace it. | Unity and Electron can inspect the same selected station/pawn inventory and submit the same typed refit operation through `AetheriaClient`; verifier searches reject new manager-global inventory/stock reads. |
| 4 | Docking/refit state split | Promote station stock, docked ships, loadout slots, cargo, and refit eligibility from menu-local facade graph reads into canonical typed documents or derived projections as appropriate. Keep pricing through `aetheria.trade_value_policy.v1`. | `InventoryPanel`, `InventoryMenu`, and `TradeMenu` may adapt Unity UI controls, but stock/refit truth cannot come from manager-global observed cargo, docked ship, or trade collections. Broad available-entity reads are deleted; any remaining facade-object bridge must be key-scoped and listed as a Stage 8 shim with the typed document/projection that will replace it. | Unity and Electron can inspect the same selected station/pawn inventory and submit the same typed refit operation through `AetheriaClient`; verifier searches reject new manager-global inventory/stock reads. |
| 5 | Gravity/object viewport parity | Finish using `ObjectsViewportAsync` and `GravityViewportAsync` wherever Unity currently asks for whole-zone data to draw map or tactical views. | Whole-zone daemon frame reads are kept only for renderer compatibility until 7D.5. | Electron and Unity use equivalent projection calls for XY map bounds. |
| 6 | Policy/editor surfaces | Extend the same typed Eve/CultUI authoring shape to Starbridge station/wave data after station/refit read parity is complete. | No return to Unity `GameSettings` as gameplay truth. | New policy surfaces must define typed bodies, command lowering, daemon bridge persistence, and verifier coverage before UI work depends on them. |

View file

@ -1370,7 +1370,7 @@ Current staged work order:
| Order | Build now | Code surface | Verifier | Demolition rule |
| --- | --- | --- | --- | --- |
| 1 | Finish S2 station/refit read parity. `current_entity`, `current_docking`, inventory rows, source slot identity, and loadout templates are already moving; split remaining station stock, docked ship, cargo, equipment, pricing, and refit eligibility reads into named projections. | `AetheriaRuntimeRtsProjection`, `AetheriaRuntimeRtsViewportDocuments`, `AetheriaClient`, Unity inventory/trade menus, generated TS bindings. | `verify-stage7d-unity-parity.ps1`, `Aetheria.State.Verify`, `AuthoritySmoke`, `npm run check:rts-bindings`, Unity compile. | Menu logic may adapt Unity controls, but station/refit truth may not come from manager-global observed cargo, docked ship, catalog, pricing, or loadout caches. |
| 1 | Finish S2 station/refit read parity. `current_entity`, `current_docking`, inventory rows, source slot identity, and loadout templates are already moving; split remaining station stock, docked ship, cargo, equipment, pricing, and refit eligibility reads into canonical typed documents or derived projections as appropriate. | `AetheriaRuntimeRtsProjection`, `AetheriaRuntimeRtsViewportDocuments`, `AetheriaClient`, Unity inventory/trade menus, generated TS bindings. | `verify-stage7d-unity-parity.ps1`, `Aetheria.State.Verify`, `AuthoritySmoke`, `npm run check:rts-bindings`, Unity compile. | Menu logic may adapt Unity controls, but station/refit truth may not come from manager-global observed cargo, docked ship, catalog, pricing, or loadout caches. |
| 2 | Add S2 typed refit operation parity. Dock, undock, select docked ship, equip, store, transfer, restore loadout, and purchase/refit become named operations with typed receipts. | `AetheriaRuntimeDaemonOperationClient`, `AetheriaRuntimeVerseClient`, generated TS operation bindings, Unity/Electron facade methods, daemon operation validation. | Cross-client operation smoke: one runtime issues an allowed refit operation, the other observes the committed result through local Verse state. | Delete or quarantine any public client path that mutates inventory/loadout through operation strings, raw item bags, UI-local rules, or Unity checkpoint rewrites. |
| 3 | Contract Unity to a render/input shell for S2. Inventory/trade UI can remain Unity UI, but every gameplay read/write goes through typed state. | `InventoryMenu`, `InventoryPanel`, `TradeMenu`, `ActionGameManager`, `ZoneRenderer` shims. | Stage 7D verifier rejects direct manager-global refit reads, public manager gameplay reads, new command buses, and Unity-only command paths. | Remaining facade-object bridges must validate daemon keys against typed projections and name the Stage 8 projection/native slab that deletes them. |
| 4 | Prove 7E.1 two-client local Verse parity. Raven Unity and Starfire Electron are peers with separate local Verse nodes, not one runtime viewing another runtime's projection. | launch harness, scoped peer sync, committed facts, session/refit/authority projections, diagnostics. | Raven/Starfire smoke: both clients see the same session, station/refit state, controlled entities, policy id, and fact receipts through local Verse state. | No test may prove co-op by reading a remote viewport or one daemon's debug projection as gameplay state. |
@ -1406,11 +1406,19 @@ Implementation discipline:
- Treat every Starbridge feature as either `state`, `projection`, `operation`,
`policy`, or `presentation`. If it does not fit one of those boxes, stop and
define the missing typed primitive first.
- Start with one canonical shared typed document for gameplay state wherever
possible. Daemon authority mutates/publishes that document; clients receive
the same document type from the shared assembly and read or write it through a
managed CultMesh handle according to authority policy.
- Add a projection only when the shape is intentionally different: hidden-info
filtering, aggregation, viewport/windowing, SoA/native layout, UI summaries,
Eve/CultUI surfaces, or a named compatibility bridge.
- Build vertical proof slices, not horizontal subsystems. A slice is better
when it proves one designer-visible verb end to end than when it creates ten
unused abstractions.
- Prefer small daemon-owned facts plus local projections over broad documents
that become the next viewport-shaped dumping ground.
- Prefer small canonical facts over broad documents that become the next
viewport-shaped dumping ground. Use local projections for derived views, not
merely to make canonical state visible to clients.
- Every UI feature must name the typed state it reads and the typed operation it
submits. A button without that contract is not ready to implement.
- Every temporary Unity facade bridge must validate daemon keys against a typed
@ -1745,7 +1753,10 @@ Progress:
status, station stock, wave forecast, and runtime roles from daemon frame plus
optional scenario/session documents without going through an RTS viewport.
- `AetheriaClient.StarbridgeSessionSummaryAsync` exposes that projection as a
named facade read for Unity, Electron, and future clients.
semantic managed read for Unity, Electron, and future clients. New canonical
state should prefer generic typed document handles; named reads are justified
when they carry derived/query identity rather than single-document wrapper
convenience.
- `AetheriaRuntimeVerseClient` now owns latest Starbridge scenario/session
record keys plus typed put/read/watch helpers; the facade resolves those local
Verse records automatically when callers ask for a session summary.

View file

@ -6,7 +6,18 @@ Aetheria should follow the Odin/VoidBot daemon shape instead of growing a privat
Odin is the all-seer, not the owner. It discovers Aetheria's provider advertisement and interface bindings, indexes the schema/catalog surface, and gives agents a registry overview. Idunn keeps the daemon alive from daemon-published health and command-boundary records. Bifrost hosts the MCP crossing for Codex and other xeno agents. Eve/CultUI defines presentation shape. The Aetheria daemon remains the side-effect owner.
The daemon owns Aetheria simulation state, typed command application, health publication, command boundaries, provider advertisement, and provider-owned Eve GUI/TUI surfaces. Unity is a renderer and input lowerer. A browser, a terminal, Blender, or another runtime should see the same daemon-owned Verse through the same typed publications.
The daemon owns authority over Aetheria simulation state, typed command
application, health publication, command boundaries, provider advertisement,
and provider-owned Eve GUI/TUI surfaces. Authority does not imply a private
daemon truth plus a separate client state copy. Wherever possible, the daemon
mutates and publishes the canonical shared typed document, and Unity, a browser,
a terminal, Blender, or another runtime grabs a managed handle to that same
document type through CultMesh.
Projection documents are for different shapes: hidden-information filtering,
derived aggregation, viewport/windowing, SoA/native render layout, lossy UI
summaries, Eve/CultUI surfaces, and named compatibility bridges. A projection is
not required merely because a non-daemon runtime needs to read state.
Witness-authoritative networking sharpens this rule. Unity should not be a dumb terminal; it may hold local projection caches, prediction state, render-native SoA views, and eventually immutable witness observations for facts it could actually observe under the active Verse rules. Those local records are admissible testimony, not committed truth. Observation, prediction, consensus candidates, and committed facts are separate stages. Unity can lower input documents, predict local presentation, and publish typed witness documents through CultMesh, but it must not mutate canonical Aetheria state or promote a local projection cache into authority.