No description
  • C# 42.6%
  • TypeScript 13.9%
  • Rust 13.1%
  • HTML 10.7%
  • Python 10.6%
  • Other 9.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Meta Vens b090ca97f9 CultNet selection cut1, commit 3: the Rust runtime
docs/cultnet-selection-cut.md section 6/7: packages/cultnet-rs/src/selection.rs
(new) - the Rust spelling of the vocabulary at wire parity with the corrected
C# reference (e5348d3), matching D7: no cultcache-rs knowledge, the row owner
supplies declared values and edges through two traits.

- Wire types: Selection, FieldPredicate, Citation, Incoming, RecordRef, Edge,
  RawDocumentHeader, SelectionDocumentRecord (the v1 full-shape record, distinct
  from v0's CultNetRawDocumentRecord, which lacks schemaName/schemaVersion/
  schemaContentHash - a pre-existing v0 gap this cut does not touch).
  SelectionOperator mirrors CultNetSelectionOperator for evaluator ergonomics;
  FieldPredicate.op stays a raw wire string, never a serde-tagged union.
- canonical_number module (Q-J, section 2 "Numbers"): is_canonical (a
  hand-rolled digit-grammar parser, no regex dependency added),
  canonicalize_decimal_digits, expand_scientific_notation, compare (sign, then
  integer length, then digits, then padded fraction - no f64 anywhere), and
  render_i64/render_u64/render_f64/render_f32 for a Row implementer's own
  rendering. probe_f64_display_never_uses_exponent_notation empirically
  verifies the map's claim about Rust's f64 Display (confirmed true) rather
  than trusting it.
- Row/RowSet traits (D7): schema_id, record_key, ordinal, values, number
  (canonical string, never f64), references for Row; all_schema_ids,
  declared_indexes, declared_roles, is_numeric, target_leaves for RowSet.
  A blanket `impl<T: Row> Row for &T` lets sorted/filtered slices of
  references satisfy generic bounds without an extra copy.
- validate (S1 door refusals), matches (D6 single-row fast path, hop-bearing
  selections assert via debug_assert since Rust has no exception type to
  mirror C#'s InvalidOperationException), select (order/hop/cursor/paging,
  D9's reference_outside_target refusal, S23's per-row match - never through
  a unique-index map, because there is none here to begin with).
- Cursor: mint/parse/digest is this runtime's own internal algorithm (a
  cursor is opaque and never crosses runtimes - each server answers its own
  pages), not a byte-for-byte port of the reference's; what must match is the
  *rule* (asOf + last position + a digest bound to the selection), which it
  does, pinned by RS-CursorStale-Revert/Loosening and RS-CursorDigest-Revert.
- contracts.rs: three v1 CultNetMessage variants (SnapshotRequestV1,
  DatabaseSubscribeV1, SnapshotResponseRawV1) matching the C# messages'
  field-for-field shape. SnapshotResponseRawV1 carries binary payloads
  (documents[].payload, edges[].payload), so it is routed through the
  existing raw JSON-bypass path (parse_raw_cultnet_schema_message/
  encode_raw_cultnet_schema_message) alongside v0's DocumentPutRaw/
  SnapshotResponseRaw, with its own require_*/encode_* helpers for
  SelectionDocumentRecord, RawDocumentHeader, Edge and RecordRef.
  SnapshotRequestV1/DatabaseSubscribeV1 carry no binary and use the
  ordinary serde_json-intermediate path. No message-layer selection
  semantics validation here, matching the reference
  (CultNetSchemaMessageSerialization.cs only deserializes; a server calls
  selection::validate against its own RowSet before evaluating).
- snapshot_query.rs (D3/D4): serve_read_only_raw_snapshot's two hand-rolled
  allowlist filters collapse into one call to selection::matches over a
  lowered v0 Selection, through a minimal RawSnapshotRow wrapper whose
  ordinal/values/number/references are unreachable (the lowered selection
  never sets fields/cites/cited, so matches_schema_keys_fields never calls
  them) - documented, not hidden.

Ruling (Self, 2026-09-22, docs/cultnet-selection-cut.md commit 2 fix batch,
mirrored here per the coordinator's mid-task instruction rather than C#'s
pre-fix spelling as it stood at e5348d3):
- validate refuses an empty-but-present schemas/keys list (already had this)
  and now also refuses any individual entry that is empty or whitespace
  (fields[i]-style names: schemas[i]/keys[i]).
- The evaluator never sees []; matches_schema_keys_fields does not special-case
  an empty list as "no filter" (it never did here - that C# fallback,
  CultNetSelectionEvaluator.cs:84 pre-fix, was never mirrored into Rust).
- snapshot_query.rs's v0 lowering gets its own cleaning, owned by the
  lowering and not the evaluator: lower_v0_list turns an empty or
  all-blank v0 schemaIds/recordKeys list into None before it ever reaches
  validate or select.

Tests: cultnet-rs 173 passed, 0 failed (was 111 baseline #[test]s pre-cut;
+62 across lib unit tests, tests/selection.rs and tests/cultnet.rs).
cultcache-rs unmodified, 64 passed, 0 failed (untouched by this commit -
confirmed unaffected). GameCult.Networking.Tests (the new
SelectionParityVectorTests.cs file, compiled but not yet fully exercised -
see below) builds clean.

Mutation harness (tools/eureka-mutations.ps1, scripts/mutate-cultnet-
selection-rust.entries.ps1): 22 entries against src/selection.rs and
src/snapshot_query.rs, all KILLED, M0 green. Covers: S1's empty-list and
new blank-entry refusals (schemas and keys, revert x4), order/descending
(revert), cursor staleness (revert + loosening) and digest (revert), S7's
incoming negation (revert + loosening), S16's le/ge boundaries (revert x2),
S18's reference_outside_target (revert), Q-J's door regex and -0 exclusion
(revert x2), Q-J's comparator integer-length and sign (revert x2), Q-J's
integer-through-float64 renderer, decimal trailing-zero stripping and
exponent expansion (revert x3, the last two pinned via direct
canonical_number unit tests since render_f64 itself cannot reach exponent
notation given Rust's Display contract - verified, not assumed), and the
new v0-lowering rule (revert).

Negative grep: `rg -n "untagged" packages/cultnet-rs/src packages/cultcache-rs/src`
empty.

Not included here, landing as commit 4 once ready: the committed parity
vector files (contracts/cultnet/interop/selection-vectors.{cs,rs}-written.json).
Both directions already work for six evaluated selections and the []
door-refusal case; the blank-key-entry refusal vector cannot be generated
from the C# side yet because the parallel C# fix batch implementing that
door check (docs/cultnet-selection-cut.md, "Self's rulings...for the commit
2 fix batch") has not landed on this branch as of this commit. Rust's own
tests (validation_refuses_a_blank_entry_in_schemas_or_keys,
serve_read_only_raw_snapshot_lowers_an_empty_or_blank_v0_schema_list_to_no_filter)
already pin both new rules independently of C#.

Structural delta: packages/cultnet-rs/src/selection.rs +1407 (new),
contracts.rs +616/-21, snapshot_query.rs +76/-21 (net +55, collapsing the
fifth selector engine into one call), lib.rs +2, tests/cultnet.rs +67 (new
v0-lowering test), tests/selection.rs +900 (new, evaluator tests + vector
machinery), scripts/mutate-cultnet-selection-rust.entries.ps1 +233 (new),
tests/GameCult.Networking.Tests/SelectionParityVectorTests.cs +296 (new).
Against section 14's ~430-line estimate for selection.rs+contracts.rs: the
two together land at ~2000 lines added, well over estimate - the map's own
§14 correction already flagged commits 0/1 running roughly 2x estimate for
the same reason (the hop's incoming index, the cursor, and per-field door
messages cost more than the prose assumed), and the v1 raw-message handling
(SelectionDocumentRecord/RawDocumentHeader/Edge require_*/encode_* helpers,
~400 lines) was not separately budgeted at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 05:31:19 +02:00
.github/workflows Write and enforce the semver policy, per operator ruling on 1.0.60 2026-09-17 22:03:22 +02:00
.voidbot REC-102: cut stale generated mirrors and a dead maintenance receipt 2026-09-13 14:10:10 +02:00
.vscode Initial commit 2026-04-18 06:04:39 +01:00
contracts CultNet selection cut1, commit 2f: the Q-J fix (canonical decimal numbers) 2026-09-22 04:18:22 +02:00
docs Record Soul's sixth pass: the wait's predicate is pinned by nothing 2026-09-22 00:50:29 +02:00
native/GameCult.Mesh.Quic.Native Tell an existing Windows clone how to get its build script back to LF 2026-09-22 01:03:51 +02:00
notes Specify canonical CultCache persistence format 2026-05-08 00:16:55 +01:00
packages CultNet selection cut1, commit 3: the Rust runtime 2026-09-22 05:31:19 +02:00
research/cultnet-distributed-database Add CultNet simulation observation server 2026-05-19 18:48:53 +01:00
samples Give the counter sample integer MessagePack keys 2026-09-14 00:27:19 +02:00
scripts CultNet selection cut1, commit 3: the Rust runtime 2026-09-22 05:31:19 +02:00
src CultNet selection cut1, commit 2f: the Q-J fix (canonical decimal numbers) 2026-09-22 04:18:22 +02:00
tests CultNet selection cut1, commit 3: the Rust runtime 2026-09-22 05:31:19 +02:00
tools Authenticate CultMesh authority routes and replay operations 2026-08-18 19:02:46 +02:00
unity/org.gamecult.cultlib Say the OpenSSL bridge ships with this release, and pack the changelog 2026-09-17 20:40:12 +02:00
.gitattributes Tell an existing Windows clone how to get its build script back to LF 2026-09-22 01:03:51 +02:00
.gitignore Ignore Python package build output 2026-09-10 13:55:46 +02:00
AGENTS.md JSON backing store, I/O fixes, Networking Security 2026-04-18 13:01:24 +01:00
CLAUDE.md Wire AGENTS.md into Claude Code memory 2026-09-04 00:33:01 +02:00
CultLib.sln Delete the CultCache MessagePack source generator 2026-09-13 23:38:08 +02:00
Directory.Build.props Ship authenticated remote transports in Unity package 2026-08-18 20:23:27 +02:00
LICENSE Initial commit 2026-04-18 06:04:39 +01:00
package-lock.json Give every cultcache-ts document type one home store 2026-09-14 00:37:31 +02:00
package.json Add real browser CultMesh transport proof 2026-08-18 00:05:57 +02:00
README.md Delete the CultCache MessagePack source generator 2026-09-13 23:38:08 +02:00

CultLib

CultLib is GameCult's shared state, transport, and runtime substrate. It started as reusable C# game infrastructure, but the useful thing now is larger: typed .cc persistence, schema-stable wire formats, ergonomic reliable-UDP networking, distributed database sync, simulation witness consensus, streaming surfaces, and UI/runtime affordances that can be used from C#, TypeScript, Rust, Python, and Kotlin without each runtime inventing its own local folklore.

The stack is less a single product than a set of capabilities:

  • logging primitives and implementations
  • CultCache typed documents, .cc persistence, and SoA memory access
  • CultNet schema-v0 messages over TCP and LiteNetLib adapters, a bounded ASP.NET Core WebSocket host adapter, and CultLib's native cross-runtime RUDP pipe
  • CultMesh distributed realtime database, Verse discovery, authority leases, shard replication, and witness-authoritative simulation consensus
  • typed geometry domain/chunk documents for distributed CSG and LOD streaming
  • low-latency stream catalogs and frame-handle negotiation for media, tensors, and runtime-native buffers
  • Eve/CultUI daemon-published surfaces that lower into GUI, TUI, web, native, overlay, or agent-facing clients
  • declarative Unity UI composition and reflective runtime inspector tooling

The practical pitch: a runtime can persist typed state, exchange it with peers, discover compatible schemas, join a Verse, publish observations, reconcile canonical state, and expose an operator surface without translating through a bespoke JSON bridge at every boundary. A frontend is just another CultMesh client: the daemon publishes a typed Eve/CultUI surface, and any compatible runtime can lower that surface where it needs to live.

Which Package Do I Want?

If the job is shared game state, start here before inventing a fourth drawer and pretending the label makes it furniture.

Job Start With Owns Use When Do Not Use It For
Local typed state GameCult.Caching / CultCache Document identity, schema compatibility, record keys, indexes, globals, and local persistence You need a typed cache, file-compatible save data, local reactive reads, or a stable domain document model Peer discovery, transport security, shard routing, or mesh consensus
Portable math GameCult.Math / CultMath Shader-shaped numeric primitives, deterministic random, noise, and CPU/GPU parity helpers Shared simulation and geometry code must not depend on an engine's math or RNG types Domain-specific geometry, rendering, or world authority
Procedural geometry GameCult.Geometry / CultGeometry Isosurface extraction plus CultCache-native domains, LOD requests, selected cuts, and mesh artifacts C#, Rust, Godot, or remote workers need shared geometry algorithms and typed results Transport policy, peer discovery, or gameplay authority
Network transport and database plumbing GameCult.Networking / CultNet Native RUDP sessions, LiteNetLib/TCP adapters, an authenticated WebSocket host adapter, schema-v0 wire contracts, shard authority, raw document replication, snapshots, and subscriptions You need a client/server pipe, login/session flow, schema discovery, reliable UDP, or a low-level distributed CultCache lane Gameplay-facing mesh ergonomics, Verse policy, mod branches, or simulation consensus composition
Distributed realtime gameplay state GameCult.Mesh / CultMesh Public mesh entrypoints, Verse discovery, peer exchange, shard replication defaults, authority leases, client prediction, and witness consensus You want the game to treat clients and servers as one reactive database for persistent state, input state, and simulation facts A tiny local-only tool, a bare transport client, or a storage format contract
Realtime media/frame streams GameCult.Mesh / CultMesh streaming mode Stream identity, authority, clock metadata, body transport negotiation, frame cursors, and backpressure state Audio/video/tensor frames need to move between runtimes through shared memory, GPU handles, platform buffers, or CultCache page refs Durable document mutation, mesh consensus facts, or pretending inline bytes are zero-copy
Daemon-published UI Eve / CultUI Typed operator and user-facing surfaces over CultMesh state A daemon should expose controls, inspection, or workflow UI that can lower into GUI, TUI, web, native, overlay, or agent clients One-off vendor dashboards, untyped debug panels, or runtime-local UI that cannot travel with the daemon

Quick rule:

  • Choose CultCache when the problem is "how do I model and persist typed state?"
  • Choose GameCult.Math when the problem is "which portable numeric and random semantics do these runtimes share?"
  • Choose GameCult.Geometry when the problem is "how do geometry workers build and share engine-neutral geometry?"
  • Choose CultNet when the problem is "how do peers exchange authenticated, schema-aware database messages?"
  • Choose CultMesh when the problem is "how does a game join a Verse and share realtime state across a mesh?"
  • Choose CultMesh streaming mode when the problem is "how do these runtimes move audio/video frames while the mesh owns identity, clocks, cursors, and pressure?"
  • Choose Eve/CultUI when the problem is "how does this daemon publish its own operable surface instead of waiting for a hosted admin console?"

CultMesh sits on CultNet, and CultNet distributes CultCache documents. That is the stack. If a design needs another peer-to-peer category, first check whether it is really Verse policy, peer exchange, or shard authority wearing a fake mustache.

If you want to build an application rather than tour the component drawer, start with the maintained CultMesh And Eve Getting Started series. Its first executable package-consumer checkpoint is samples/eve-two-runtime. The real-process browser continuation is samples/eve-browser-network. One documented command runs both layers:

pwsh -File ./scripts/verify-eve-getting-started.ps1

The implemented browser client boundary and remaining deployed-infrastructure gates are mapped explicitly in browser-verse-transport.md.

If you want only the smallest durable "open node -> put typed doc -> get typed doc" path, use src/GameCult.Mesh/docs/durable-node-quickstart.md. If you want the lower-level "typed local document -> raw wire document -> mesh/runtime watch surface" handoff, follow it with src/GameCult.Mesh/docs/typed-document-path.md.

Repository Scope

The solution includes:

  • GameCult.Logging: common logging abstraction plus console and file implementations
  • GameCult.Caching: DatabaseEntry-based cache, indexes, global entries, and backing-store abstractions
  • GameCult.Caching.MessagePack: MessagePack-backed persistence for the cache
  • GameCult.Caching.NewtonsoftJson: Newtonsoft.Json-backed persistence for the cache
  • GameCult.Math / CultMath: portable numeric primitives, deterministic random, noise, and shader-parity helpers
  • GameCult.Geometry / CultGeometry: engine-neutral geometry algorithms plus CultCache-native domain, selected-cut, and mesh artifact documents
  • GameCult.Networking: encrypted login/register/verify flows, schema-v0 contracts, transport adapters, and native RUDP sessions
  • GameCult.Networking.WebSockets: bounded ASP.NET Core binary WebSocket host adapter for browser CultMesh clients
  • GameCult.Mesh: CultMesh package home for distributed realtime database, shard replication, client prediction, Verse discovery, and mesh witness consensus
  • GameCult.Caching.Tests: NUnit tests for cache and backing-store behavior
  • GameCult.Networking.Tests: NUnit tests for networking behavior
  • GameCult.Unity: CultUI, a Unity runtime UI composition framework with reflective inspector generation, prefab-backed field resolvers, reusable controls, and a demo project packaged for UPM-style consumption
  • packages/cultcache-ts: TypeScript CultCache with MessagePack persistence and inspector tooling
  • packages/cultnet-ts: TypeScript CultNet schema-v0 contracts, framing, discovery, raw document replication, and interop tests
  • packages/cultmesh-ts: TypeScript CultMesh local node and mesh catalog surface for local runtimes such as VoidBot
  • packages/cultmesh-browser: browser-safe, read-only CultMesh document leases and typed operations over an Odin-resolved WebSocket route
  • packages/cultcache-py: Python CultCache with CultCache v1 wire parity
  • packages/cultnet-py: Python CultNet contracts, framing, RUDP transport, replication, and interop peer
  • packages/cultmesh-py: Python CultMesh local node, discovery, sessions, local server, and daemon
  • packages/cultcache-rs: Rust CultCache and derive macro
  • packages/cultnet-rs: Rust CultNet contracts, framing, discovery, and interop peer
  • packages/cultmesh-kotlin: Kotlin/JVM CultMesh and CultNet surface for Android-adjacent runtimes

Repository Layout

package.json
src/
  GameCult.Logging/
  GameCult.Caching/
  GameCult.Caching.MessagePack/
  GameCult.Caching.NewtonsoftJson/
  GameCult.Geometry/
  GameCult.Networking/
  GameCult.Networking.WebSockets/
  GameCult.Mesh/
  GameCult.Unity/
tests/
  GameCult.Caching.Tests/
  GameCult.Geometry.Tests/
  GameCult.Networking.Tests/
packages/
  cultmath/
  cultcache-ts/
  cultnet-ts/
  cultmesh-ts/
  cultmesh-browser/
  cultmesh-kotlin/
  cultcache-py/
  cultnet-py/
  cultmesh-py/
  cultcache-rs/
  cultnet-rs/

Build

dotnet build CultLib.sln

Test

dotnet test CultLib.sln

TypeScript package tests:

npm test --workspace packages/cultcache-ts
npm test --workspace packages/cultnet-ts
npm run test:interop --workspace packages/cultnet-ts
npm test --workspace packages/cultmesh-ts
npm test --workspace packages/cultmesh-browser

Measured reactive, retained-session, and shared-memory hot-body gates:

pwsh -File ./scripts/measure-reactive-document-performance.ps1 -Quick
pwsh -File ./scripts/verify-eve-getting-started.ps1

The first command measures the same 16 KiB document workload in C#, TypeScript, and Python and includes a mapped hot-body probe with explicit copy telemetry on Windows named maps and Unix file-backed maps. The second includes 10,000 real WebSocket operations on one retained identity-owned C# session after provider route replacement.

Rust package tests:

cargo test --manifest-path packages/cultcache-rs/Cargo.toml
cargo test --manifest-path packages/cultnet-rs/Cargo.toml

Kotlin package build:

.\packages\cultmesh-kotlin\build.ps1

Common Concepts

DatabaseEntry

The cache-centric libraries revolve around DatabaseEntry. Every entry has a stable Guid identifier and can optionally:

  • expose a human-readable name through INamedEntry
  • participate in generic indexes registered at runtime
  • be treated as a global singleton entry through GlobalSettingsAttribute

Typical entry shape:

using GameCult.Caching;

public class ItemData : DatabaseEntry, INamedEntry
{
    public string Name = string.Empty;
    public int Value;

    public string EntryName
    {
        get => Name;
        set => Name = value;
    }
}

CultCache and Backing Stores

CultCache is an in-memory index over DatabaseEntry objects. It can operate entirely in memory, or it can be attached to one or more backing stores for persistence and synchronization.

  • the cache is the query surface
  • backing stores are persistence adapters
  • indexes and name maps are maintained inside the cache, not inside the store

Multiple Backing Stores

Every document type has exactly one home store. There are no mirrors.

cache.AddBackingStore(catalogStore, typeof(ItemData), typeof(Faction));
cache.AddBackingStore(runStore, typeof(SavedGame));
  • the home is chosen by the document's runtime type: the most derived routed type wins, otherwise the untyped store
  • at most one untyped store; a type claimed by two stores is an error
  • a write with no home is an error once any store is attached
  • attaching a store reads it; attach routed stores first and the untyped store (if any) last, because a record's home cannot move after it is loaded
  • loading never writes: opening and flushing without a mutation leaves every file byte-identical
  • a read-only store refuses writes and is skipped by flush

The contract is src/GameCult.Caching/Contracts/cultcache-store-composition.md. Until the C# cache implements it, AddBackingStore takes no home types and every attached store receives every record; attach one store per cache.

Example: Cache + Networking

using GameCult.Caching;
using GameCult.Logging;
using GameCult.Networking;

var cache = new CultCache
{
    Logger = new ConsoleLogger()
};

var server = new Server(cache)
{
    Logger = new ConsoleLogger()
};

server.Start();

Secrets and Runtime Configuration

GameCult.Networking uses two pieces of deployment configuration:

  • GAMECULT_CONNECTION_KEY
  • GAMECULT_SESSION_SIGNING_SECRET

Production guidance:

  • set both values before starting the server
  • treat GAMECULT_CONNECTION_KEY as shared client/server protocol configuration
  • treat GAMECULT_SESSION_SIGNING_SECRET as a server-only secret
  • generate high-entropy random values and store the server-side value in your platform's secret store
  • do not rely on local-development defaults in production
  • partial configuration is rejected at startup

Recommended value format:

  • at least 32 random bytes per value
  • encode as Base64 or Base64Url if you want a portable text representation

Example secret generation in PowerShell:

[Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Maximum 256 }))

Typical production setup patterns:

  • inject GAMECULT_SESSION_SIGNING_SECRET and the server copy of GAMECULT_CONNECTION_KEY as environment variables from Docker secrets, Kubernetes secrets, systemd environment files, or your cloud secret manager
  • ship the matching GAMECULT_CONNECTION_KEY to the client through a build-generated config asset, code-generated constants, or another explicit client configuration mechanism
  • scope them per environment so development, staging, and production do not share values
  • rotate GAMECULT_SESSION_SIGNING_SECRET operationally
  • treat GAMECULT_CONNECTION_KEY as versioned protocol config; changing it requires a coordinated client/server rollout

Example server startup with strict environment validation:

using GameCult.Caching;
using GameCult.Networking;

var cache = new CultCache();
var security = ServerSecurityOptions.FromEnvironment();
var server = new Server(cache, security);

Example local-development server startup:

using GameCult.Caching;
using GameCult.Networking;

var cache = new CultCache();
var security = ServerSecurityOptions.Development();
var server = new Server(cache, security);

Example shipped-client startup with explicit client configuration:

using GameCult.Networking;

var security = new ClientSecurityOptions("<matching-connection-key>");
var client = new Client(security);

Project Docs

Each subproject has a local README with package-specific detail: