Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project Overview

AstraWeave is a **scientific proof of concept**: an AI-native game engine built **iteratively by AI with zero human-written code**. It uses a deterministic ECS architecture where AI agents are first-class citizens. The player-facing game name is Aravath. The workspace contains 141 crates (`cargo metadata --no-deps` at `a10780f4`, 2026-10-16; 58 names start with `astraweave-`, 60 example manifests). #215 did not add a member. #316 caps image decode and confines CLI glTF imports; Ollama constructors stay on loopback unless `allowing_remote` is used. #318 keeps physics and nav proxies off the gameplay script tick. #252 puts the data-driven weaving framework on main. #205 puts the windowed Aravath greybox on main (`aravath_greybox`). #244 puts the 60 Hz traversal sim on main. #215 puts integer forest columns and `ColumnStream` on main. #217 puts the CI burndown on main: `libudev-dev` on the editor-test and sanitizer jobs, per-process audio fixtures, and a finite SPH step in `fluid.wgsl`. `openssl` is gone from the lockfile and stays banned. #327 keeps `net` off the workspace `tokio` dependency. #275 runs `run_aravath_slice` once at greybox startup. Each sword hit reuses that `sword_hp`, and the window shows `Cover broke` once when the cover bond breaks. #343 stores the demolition command log in the checkpoint and loads every chunk a brush radius touches. #329 calls `BridgeAgent::step` from `Greybox::step`, digs with a sphere `Subtract` brush on `ColumnFns`, and sets the greybox golden to `0a576578512f25d2`. #331 keeps `AIArbiter`, `GoapPlanner`, and `GravityManager` off the deterministic tick. `recorded_line` is a pure helper intended as the dialogue boundary. It does not draw, and it has no non-test caller yet. #382 keeps `AIArbiter`, `GoapPlanner`, and advanced GOAP off the tick. With `ai-goap` on, `PlannerMode::GOAP` reads `CAiController.gather`. The default build returns an error instead. #257, #258, and #335 are closed. #334 and #383 stay open. #336 is closed. The July 2026 note of 133 members is older. Rust toolchain is pinned at 1.89.0. #330 puts `astraweave-localsim` on main. Required replay cases are nineteen. `local_sim` is the sixteenth. `greybox_checkpoint`, `quest_ticks`, and `persist_replay` are the seventeenth through nineteenth (#332). `gravity.rs` is deleted and #336 is closed. The greybox golden is `b6a9d5a2c5da28a6`. Determinism replay requires nineteen cross-OS cases (`planner_pure`, `perception_world`, `gameplay_rng`, `fixed64`, `combat_resolve`, `destruction`, `gameplay_qa_aravath_slice`, `nav_reroute`, `causal_bridge`, `scripted_system`, `weaving`, `traversal`, `traversal_deformed`, `worldgen_columns`, `deformed_chunk`, `local_sim`, `greybox_checkpoint`, `quest_ticks`, `persist_replay`). #216 is on main (`92727109`). The heavy-scene GPU frame on a GTX 1660 Ti Max-Q is 3.688 ms, `budget_11ms=pass`, and the amortized cloud shadow is 0.323 ms. #371 and #372 stay open. #253 is closed.
AstraWeave is a **scientific proof of concept**: an AI-native game engine built **iteratively by AI with zero human-written code**. It uses a deterministic ECS architecture where AI agents are first-class citizens. The player-facing game name is Aravath. The workspace contains 141 crates (`cargo metadata --no-deps` at `a10780f4`, 2026-10-16; 58 names start with `astraweave-`, 60 example manifests). #215 did not add a member. #316 caps image decode and confines CLI glTF imports; Ollama constructors stay on loopback unless `allowing_remote` is used. #318 keeps physics and nav proxies off the gameplay script tick. #252 puts the data-driven weaving framework on main. #388 (`43b1b48f`) closed #295: `queue_weave` returns `OutsideIsland` outside ±2048 cells and does not saturate, and `meters_to_cell` returns `None` before the cast when the metre value is non-finite or the millimetre value is outside the `i32` range. The `weaving` replay case still hashes `NullField`. #397 (`49d289eb`) closed #260. GitHub linked it. The mod host rejects an origin outside ±2048 before the cast is stored, and a failed `run_one` drops that call's casts. An earlier script for the same agent that already returned `Ok` stays applied. #394 (`a9663b82`) changes the intro companion line to thread-binder. The Gate job runs `scripts/ci/player_facing_names.sh`. #389 is the Hi-Z skip: `draw_into` records the pyramid only when `hiz_depth_load` and `sample_hiz` are both set. #269 is closed. The fix is #389. GitHub cross-referenced that pull. The close was not attributed. #393 is the wiring inventory. `gpu_frame_budget` rejects an enabled gated flag before the scene. #403 and #400 stay open. #205 puts the windowed Aravath greybox on main (`aravath_greybox`). #244 puts the 60 Hz traversal sim on main. #215 puts integer forest columns and `ColumnStream` on main. #217 puts the CI burndown on main: `libudev-dev` on the editor-test and sanitizer jobs, per-process audio fixtures, and a finite SPH step in `fluid.wgsl`. `openssl` is gone from the lockfile and stays banned. #327 keeps `net` off the workspace `tokio` dependency. #275 runs `run_aravath_slice` once at greybox startup. Each sword hit reuses that `sword_hp`, and the window shows `Cover broke` once when the cover bond breaks. #343 stores the demolition command log in the checkpoint and loads every chunk a brush radius touches. #329 calls `BridgeAgent::step` from `Greybox::step`, digs with a sphere `Subtract` brush on `ColumnFns`, and sets the greybox golden to `0a576578512f25d2`. #331 keeps `AIArbiter`, `GoapPlanner`, and `GravityManager` off the deterministic tick. `recorded_line` is a pure helper intended as the dialogue boundary. It does not draw, and it has no non-test caller yet. #382 keeps `AIArbiter`, `GoapPlanner`, and advanced GOAP off the tick. With `ai-goap` on, `PlannerMode::GOAP` reads `CAiController.gather`. The default build returns an error instead. #257, #258, and #335 are closed. #334 and #383 stay open. #336 is closed. The July 2026 note of 133 members is older. Rust toolchain is pinned at 1.89.0. #330 puts `astraweave-localsim` on main. Required replay cases are nineteen. `local_sim` is the sixteenth. `greybox_checkpoint`, `quest_ticks`, and `persist_replay` are the seventeenth through nineteenth (#332). `gravity.rs` is deleted and #336 is closed. The greybox golden is `b6a9d5a2c5da28a6`. Determinism replay requires nineteen cross-OS cases (`planner_pure`, `perception_world`, `gameplay_rng`, `fixed64`, `combat_resolve`, `destruction`, `gameplay_qa_aravath_slice`, `nav_reroute`, `causal_bridge`, `scripted_system`, `weaving`, `traversal`, `traversal_deformed`, `worldgen_columns`, `deformed_chunk`, `local_sim`, `greybox_checkpoint`, `quest_ticks`, `persist_replay`). #216 is on main (`92727109`). The heavy-scene GPU frame on a GTX 1660 Ti Max-Q is 3.688 ms, `budget_11ms=pass`, and the amortized cloud shadow is 0.323 ms. #371 and #372 stay open. #253 is closed.

### Mandate

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AstraWeave is an AI-native game engine with a deterministic ECS. AI agents are f

## Current status

Main is `98335926` (#392). #390 is merged as `5a52b039`. The rows below were checked at `556a305c` except the CI badge row.
Main is `49d289eb` (#397). #390 is merged as `5a52b039`. The older rows were checked at `556a305c` except the CI badge row. The weave, name, Hi-Z, and wiring rows were checked at `49d289eb`.

| Topic | State |
| --- | --- |
Expand All @@ -17,6 +17,10 @@ Main is `98335926` (#392). #390 is merged as `5a52b039`. The rows below were che
| Frame budget | 3.688 ms GPU frame, 11 ms target, GTX 1660 Ti. #371 and #372 stay open |
| Supply chain | Postcard is alloc-only. `rustls-webpki` is 0.103.16. `webpki-roots` is 1.0.10. Ignored leftovers are #305, #306, #308–#310, and #321–#323 |
| CI badges | #390 is merged. It dropped the Clippy unwrap-prevention badge. That workflow was deleted in #223. `astraweave-ai` mutants run as 8 round-robin shards. The 70% gate is caught / (caught + missed). Timeouts are not caught. `cargo-mutants` is 27.1.0 |
| Weave origins | #388 closed #295. `queue_weave` returns `OutsideIsland` outside ±2048 cells and does not saturate. #397 rejects that origin in the mod host before the cast is stored. A failed `run_one` drops that call's casts. An earlier script for the same agent that already returned `Ok` stays applied. #260 is closed. GitHub linked it to #397. The `weaving` case still hashes `NullField` |
| Player-facing name | #394. The intro companion line says thread-binder. The Gate script scans dialogue, quests, echoes, voices, npc lines, and cinematics. The dialogue test uses dialogue, quests, echoes, and voices, then one directory level of npc and cinematics. `assets/cells` is outside both scans |
| Hi-Z | #269 is closed. The fix is #389. GitHub cross-referenced that pull. The close was not attributed. `draw_into` records the forward Hi-Z pyramid only when `hiz_depth_load` and `sample_hiz` are both set. The default of `sample_hiz` is off. The 0.275 ms figure is the capture at `939a21bb` |
| Wiring | #393. [WIRING_CAMPAIGN.md](docs/current/WIRING_CAMPAIGN.md) is the inventory. `gpu_frame_budget` rejects an enabled `--atmosphere`, `--ssgi`, `--taa`, `--upscale`, `--dof`, or `--clouds` before the scene. #403 is open |

The nineteen cases are `planner_pure`, `perception_world`, `gameplay_rng`, `fixed64`, `combat_resolve`, `destruction`, `gameplay_qa_aravath_slice`, `nav_reroute`, `causal_bridge`, `scripted_system`, `weaving`, `traversal`, `traversal_deformed`, `worldgen_columns`, `deformed_chunk`, `local_sim`, `greybox_checkpoint`, `quest_ticks`, and `persist_replay`.

Expand Down
57 changes: 57 additions & 0 deletions astraweave-scripting/src/sim_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,63 @@ scripts = ["scripts/tick.rhai"]
}
}

#[test]
fn failed_script_keeps_an_earlier_ok_for_the_same_agent() {
fn once() -> (Vec<(u16, [i32; 3])>, Vec<String>) {
let mut app = App::new().add_plugin(ModScriptPlugin);
app.world.insert_resource(ModClock::new(0xA11C));
app.world.insert_resource(ModPrograms {
scripts: vec![
ModScriptSource::new(
"demo.mod",
"scripts/a.rhai",
"weaves.queue_weave(1, 0, 0, 0);",
),
ModScriptSource::new(
"demo.mod",
"scripts/b.rhai",
"weaves.queue_weave(1, 3000, 0, 0);",
),
ModScriptSource::new(
"demo.mod",
"scripts/c.rhai",
"weaves.queue_weave(1, 2, 0, 0);",
),
],
});
let entity = app.world.spawn();
app.world.insert(entity, CModAgent { x: 0, y: 0 });
mod_script_system(&mut app.world);
let scratch = app.world.get_resource::<WeaveScratch>().unwrap();
let queued = (0..scratch.command_count())
.map(|index| {
let command = scratch.command(index).unwrap();
(command.template, command.origin)
})
.collect();
let errors = app
.world
.get_resource::<ModScriptErrors>()
.unwrap()
.messages
.clone();
(queued, errors)
}

let first = once();
let second = once();
assert_eq!(first.0, second.0);
assert_eq!(first.1, second.1);
assert_eq!(first.0, vec![(1, [0, 0, 0]), (1, [2, 0, 0])]);
assert!(
first.1.iter().any(|message| {
message.contains("scripts/b.rhai:") && message.contains("outside the island")
}),
"{:?}",
first.1
);
}

#[test]
fn queue_weave_through_build_app_replays_identically() {
use astraweave_core::ecs_adapter::build_app;
Expand Down
14 changes: 8 additions & 6 deletions docs/architecture/scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ lifecycle_status: active
integration_status: wired
summary: "Gameplay and mod scripts run on the security sandbox. script_system does not inject PhysicsProxy or NavMeshProxy. The scripting examples no longer call them."
owns: [astraweave-scripting, astraweave-author]
doc_version: "1.5"
last_verified_commit: a9837f2f
doc_version: "1.7"
last_verified_commit: 79122e78
runtime_edges:
- to: astraweave-security
note: "ScriptEngineResource and mod_script_system call sandbox::SandboxEngine / execute_deterministic"
Expand All @@ -28,8 +28,8 @@ runtime_edges:
|---|---|
| **System name** | Scripting and mod API |
| **Primary crates** | `astraweave-scripting`, `astraweave-author` |
| **Document version** | 1.5 |
| **Last verified against commit** | `a9837f2f` |
| **Document version** | 1.7 |
| **Last verified against commit** | `79122e78` |
| **Last verified date** | 2026-10-21 |
| **Status** | Active for the sandboxed Rhai path. `register_mod_runtime` plus `build_app` is how the editor, `veilweaver_slice_runtime`, and `hello_companion` run mods. `script_system` does not inject physics or nav proxies (#318). The editor does not feed `CScript` entities. |
| **Owner notes** | WS-MOD. One sandbox implementation lives in `astraweave-security::sandbox`. This trace is the caller side. |
Expand Down Expand Up @@ -186,7 +186,7 @@ Mods need a single sandboxed command set whose results are sim inputs. A second
| 5 | `scripted_system` SHA-256 is `362e4c6d3085d2a95d1219b988326beb4cbe898408de4a91e5b2abe3c3294d78` for seed `0xA11CE5E0`, 32 ticks, three agents, and the checked-in script. | Yes | `tests/script_replay_hash.rs` |
| 6 | A script swap recorded as `(tick, path, content hash, source)` and replayed from `ScriptReplayLog` matches the live digest. | Yes | `reload_mid_run_replays_to_the_identical_hash` |
| 8 | `build_app` installs `ModScriptPlugin` after `register_mod_runtime`. A mod loaded onto that app, including a mid-run swap in `ScriptReplayLog`, replays to the same digest. Manifest script map keys are the relative manifest paths. | Yes | `mod_loaded_through_build_app_replays_identically`, `load_mod_dir_keys_are_manifest_paths` |
| 9 | `queue_weave` is capability `Weave` at command API 2. The script passes a template id and an origin. The host fills tick, seq, and caster and calls `astraweave_weaving::queue_weave`. Ids 1 through 7 are engine ids. Ids outside `u16`, and cells outside ±2048, are rejected in the script call before a cast is stored. A script error applies none of that script's casts. `max_weaves` defaults to 64 and does not spend `terrain_edits`. Two runs enqueue the same commands. | Yes | `queue_weave_is_a_weave_command_and_weaves_do_not_spend_terrain`, `queue_weave_through_build_app_replays_identically`, `queue_weave_edges_fail_closed` |
| 9 | `queue_weave` is capability `Weave` at command API 2. The script passes a template id and an origin. The host fills tick, seq, and caster and calls `astraweave_weaving::queue_weave`. Ids 1 through 7 are engine ids. Ids outside `u16`, and cells outside ±2048, are rejected in the script call before a cast is stored. A failed `run_one` drops that call's casts. The tick walks sources, then entities (`sim_mod.rs:367-396`). `apply_weave_casts` runs only on `Ok`. An earlier script for the same agent that already returned `Ok` stays applied. `max_weaves` defaults to 64 and does not spend `terrain_edits`. Two runs enqueue the same commands. | Yes | `queue_weave_is_a_weave_command_and_weaves_do_not_spend_terrain`, `queue_weave_through_build_app_replays_identically`, `queue_weave_edges_fail_closed`, `failed_script_keeps_an_earlier_ok_for_the_same_agent` |
| 10 | The mod tick does not register `PhysicsProxy` or `NavMeshProxy`. The sim sandbox keeps the operation budget and `timeout_ms = 0`. `advertised_memory_bytes` is the structural product of the string, array, and map caps, not a process limit. | Yes | `mod_tick_rejects_physics_and_nav_proxies`, `sim_sandbox_keeps_the_op_budget_and_no_wall_clock` |
| 11 | Gameplay `script_system` does not inject `PhysicsProxy` or `NavMeshProxy`, even when `PhysicsWorld` and `NavMesh` resources are present. The event-callback scope is built the same way. | Yes | `script_system_rejects_physics_and_nav_proxies` |
| 7 | Author `configure` output that exceeds the director ceilings is an error. Hints cannot contain floats. | Yes | `sandboxed_configure_is_deterministic_and_capped` |
Expand All @@ -209,7 +209,7 @@ Each mod script is compiled on the tick it runs. The replay case is 32 ticks of
- `cargo test -p astraweave-scripting --test script_replay_hash`
- `cargo test -p astraweave-scripting --lib mod_loaded_through_build_app_replays_identically`
- `cargo test -p aw_editor --lib -- file_watcher:: rhai_reload::`
- CI: `.github/workflows/determinism-replay.yml` requires `scripted_system` as one of the fifteen cross-OS cases. `target-cpu=native` is not set. Apple Silicon uses the default aarch64 baseline.
- CI: `.github/workflows/determinism-replay.yml` requires `scripted_system` as one of the nineteen cross-OS cases. `target-cpu=native` is not set. Apple Silicon uses the default aarch64 baseline.

---

Expand All @@ -231,6 +231,8 @@ Each mod script is compiled on the tick it runs. The replay case is 32 ticks of

| Version | Date | Notes |
|---|---|---|
| 1.7 | 2026-10-21 | A failed `run_one` drops that call only. An earlier script for the same agent stays applied, and a later success still lands. `failed_script_keeps_an_earlier_ok_for_the_same_agent` queues `a`, then a failing `b`, then `c`, and compares two runs. Section 10 says nineteen replay cases. |
| 1.6 | 2026-10-21 | Withdrawn in 1.7. It said a failed run drops only that agent's casts and marked that wording verified at `49d289eb`. The host does not roll back an earlier `Ok` for the same agent. |
| 1.5 | 2026-10-21 | Script `queue_weave` rejects an origin outside ±2048 before storing the cast. `queue_weave_edges_fail_closed` covers ids, the island, the 64 cap, and replay equality. |
| 1.0 | 2026-10-14 | WS-MOD. Sandbox, mod loader, tick-boundary reload, `scripted_system` hash. |
| 1.1 | 2026-10-14 | `build_app` installs `ModScriptPlugin` via `register_mod_runtime`. Editor, game runtime, and `hello_companion` call it. |
Expand Down
Loading
Loading