参伍引擎 Canwu Engine
Website: canwu.org
Canwu is a headless historical simulation engine written in Rust. It simulates a historical world, advances time in a repeatable way, accepts validated commands, and records events and their causes. It can also represent what each person knows instead of giving every actor access to the true world state.
Canwu does not render graphics, play audio, or provide a production user interface. Games, research tools, Python programs, web clients, and AI agents use Canwu through its public APIs.
Canwu is built for simulations that need more than a mutable game-state object. It provides deterministic time, validated authority-aware commands, atomic settlement, actor-relative knowledge, typed extension points, causal evidence, save/load validation, exact replay, and explicit live evidence sealing. The engine remains domain-neutral: applications define their own rules and content through public contracts rather than adding application-specific types to the kernel.
The project is under active development. The public examples are small on purpose: they make the engine's guarantees easy to inspect, test, and reuse in larger games, research environments, and agent-driven simulations.
Use Canwu as a dependency
Rust applications should depend on the supported public facade rather than the implementation crates:
[]
= "0.4.0"
Applications that persist Canwu snapshots should pin the exact engine release and upgrade only alongside an explicit save migration:
= "=0.4.0"
The other canwu-* crates are published so Cargo can resolve the facade's
dependency graph. They are not separate compatibility surfaces for application
code.
Quick start
Install Rust 1.88 or newer, then run the headless movement example:
cargo run -p canwu-api --example move_army
For a phased, API-only plugin example:
cargo run -p canwu-api --example phased_boundary
How the repository fits together
canwu-core: stable IDs, repeatable random numbers, and schema metadatacanwu-time: historical time that is independent of rendering speedcanwu-event: stored events and links between causes and effectscanwu-world: historical entities and read-only world snapshotscanwu-knowledge: what each actor knows and when they learned itcanwu-sim: private simulation state, commands, scheduling, and pluginscanwu-api: public APIs for programs, agents, explanations, and debuggingcanwu-debug: a small reference client built only on the public API
The documentation index links the architectural contracts,
community guidance, and legal notices. agent-interface contains skills for
engine users and repository maintainers; these are tooling, not runtime
simulation plugins. The website and assets directories contain the
community site and project media.
Read the architecture and end-state design before changing boundaries.
Development
Contributions, bug reports, examples, documentation improvements, and careful architecture discussions are welcome. See CONTRIBUTING.md for local setup and contribution terms. Coding agents must also follow AGENTS.md and any nearer instructions.
-
Read
AGENTS.md,docs/architecture.md,docs/end-state.md, and any nearer repository instructions for the area being changed. -
Inspect
git status. Preserve existing work and use a worktree for unrelated parallel changes. -
State the invariant, identify every affected surface, and make the smallest coherent implementation. Keep semantic changes separate from large file moves or generated-file refreshes.
-
Treat tests as durable evidence. Commit a test only when it is necessary, reusable, very likely to fail under a plausible future change, and non-trivial: it must exercise a multi-step invariant, public contract, persistence/replay boundary, or failure-recovery path beyond format, lint, compile, or a simple accessor assertion. Run narrower one-off verification inline. Canwu uses no TDD requirement, test quota, or coverage target. Then run:
cargo fmt --all -- --check cargo clippy --workspace --all-targets -- -D warnings cargo test --workspace cargo check -p canwu-debug -
Run affected public examples and
cargo doc --workspace --no-depswhen APIs or documentation change. -
Obtain independent review for architectural, persistence, replay, authority, determinism, or performance work. Commit only coherent, passing milestones.
The detailed project hierarchy and change-surface map live in AGENTS.md.
Agent skills
Agent-facing integrations live under agent-interface.
External users can invoke
$canwu-engine-docs
to find and explain official tutorials and design documents, then use
$canwu-engine-usage
for implementation guidance. Contributors and maintainers use skills under
canwu-developer; the release
workflow is
canwu-developer-release.
The human-readable package and registry procedure is documented in
docs/releasing.md.
Minimal API example
use ;
let mut canwu = demo?;
let ids = demo_ids;
canwu.submit?;
let events = canwu.advance?;
# Ok::
See crates/canwu-api/examples/phased_boundary.rs for an API-only plugin that
offers and claims a conserved resource, consumes its declared allocation, and
commits attributable boundary evidence.
License
Canwu is open-source software licensed under the Apache License 2.0. You may use, modify, and distribute Canwu in open-source or proprietary products without royalties or revenue reporting. Distributed copies must comply with the Apache License and preserve applicable license and NOTICE material. The Apache License does not require a Canwu logo or public acknowledgement; the branding guide explains optional, non-endorsing use of the project marks. Third-party dependencies remain under their own licenses; see the third-party license inventory.
Supported platforms
The supported operating systems are Windows, macOS, and Linux. The simulation
crates are headless and platform-neutral; the reference debug client uses
OpenGL through eframe, with Wayland and X11 enabled on Linux. The CI matrix
checks all three operating systems. The workspace and published crates require
Rust 1.88 or newer.