High-level overview of how Cougr is organized. For usage, see README.md.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ app::GameApp โ Default runtime surface
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโค
โ ECS โ Accounts โ Standards โ ZK Proofs
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ soroban-sdk 25.1.0 (no_std, WASM) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
GameApp (src/plugin/mod.rs) is the default onboarding layer. It owns a SimpleWorld,
the scheduler, plugin registration, and runtime resources in one place.
GameWorld (src/game_world.rs) remains available as a higher-level Beta integration
wrapper for combining ECS, auth, and proof submission, but it is not the primary
learning path for new users.
Two storage backends, same ComponentTrait interface:
| Backend | File | Strategy | Best for |
|---|---|---|---|
| SimpleWorld | src/simple_world/ |
Map<(EntityId, Symbol), Bytes> with dual Table/Sparse indexes |
General use, small entity counts |
| ArchetypeWorld | src/archetype_world/ |
Groups entities by component signature | Large entity counts, batch queries |
Both support typed access (get_typed<T>, set_typed<T>) and raw access (get_component, add_component).
Supporting systems:
- Query cache (
src/query/) โ version-tagged, invalidates on world mutation - Hooks (
src/hooks.rs) โ callbacks on component add/remove - Observers (
src/observers.rs) โ event-driven reactions - Commands (
src/commands.rs) โ deferred mutations during system execution - Scheduler (
src/scheduler/) โ stage-based, dependency-aware system ordering - Change tracker (
src/change_tracker.rs) โ per-component dirty flags - Plugins (
src/plugin/) โ modular game logic bundles - Incremental storage (
src/incremental/) โ only persist dirty entities
The impl_component! macro generates ComponentTrait (serialize/deserialize/type symbol) from a struct definition. Supported field types: i32, u32, i64, u64, i128, u128, u8, bool, bytes32.
All ZK operations use Stellar Protocol 25 (X-Ray) host functions โ the heavy crypto runs on the host, not in WASM.
- Groth16 (
groth16.rs) โ proof verification via BN254 pairing - BLS12-381 (
bls12_381.rs) โ G1 add/mul/MSM, pairing checks - Poseidon2 (
crypto.rs) โ ZK-friendly hashing, behindhazmat-cryptofeature - Merkle trees (
merkle/) โ SHA256 and Poseidon variants, sparse trees, on-chain proofs - Pedersen (
commitment.rs) โ commitment scheme for hidden state - Game circuits (
circuits.rs,traits.rs) โGameCircuittrait + pre-built circuits (Movement, Combat, Inventory, TurnSequence) +CustomCircuitBuilder - ECS integration (
components.rs,systems.rs) โCommitReveal,HiddenState,ProofSubmissioncomponents with verification systems
Account abstraction layer with pluggable implementations:
CougrAccount (trait)
โโโ ClassicAccount โ standard Stellar keypair
โโโ ContractAccount โ smart contract wallet
โโโ SessionStorage โ persistent session keys
โโโ RecoveryStorage โ guardian-based recovery
โโโ DeviceStorage โ multi-device key management
โโโ Secp256r1Storage โ WebAuthn/Passkey keys
Key traits: CougrAccount, SessionKeyProvider, RecoveryProvider, MultiDeviceProvider.
SessionBuilder provides a fluent API for constructing scoped session keys. authorize_with_fallback handles graceful degradation from session keys to direct authorization.
Reusable contract standards for integrations that need explicit operational controls:
OwnableandOwnable2Stepfor owner-managed authorityAccessControlfor role-based authorization with delegated adminsPausablefor emergency stopsExecutionGuardfor serialized critical sectionsRecoveryGuardfor blocking sensitive paths during recovery windowsBatchExecutorfor bounded multi-operation flowsDelayedExecutionPolicyfor time-delayed operation queues
Each standard instance is keyed by a caller-supplied Symbol, which keeps storage deterministic and avoids collisions when a contract composes multiple modules.
| Flag | Enables |
|---|---|
hazmat-crypto |
Poseidon2 hash, BN254 curve ops (via soroban-sdk/hazmat-crypto) |
testutils |
MockAccount, test helpers (via soroban-sdk/testutils) |
debug |
Runtime introspection, metrics, state snapshots (src/debug/) |
Release builds are configured with LTO, opt-level = "z", and overflow-checks = true to keep artifacts optimized for constrained execution environments.
Primary target: wasm32v1-none.