Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
docs: scripting demos no longer call physics or nav
advanced_ai.rhai now uses distance for sight and an empty patrol path.
scripting_playground keeps trigger damage and drops the player raycast.
The hosts still insert the resources.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
  • Loading branch information
cursoragent and lazyxeon committed Oct 16, 2026
commit 4c5ee77c9791de9e67d22d9d03ce7a7871aebacc
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Checked against `main` at `3971cbe1`. Numbers that were not re-measured in this
- **Security caps (#312, #316).** #312 bounds model text, imports, admin auth, and socket frames, on top of the Rhai sandbox ceilings (operation budget, string/array/map sizes, mod counts). `default_allowed_llm_domains` is localhost only. #316 caps image decode at a 4096-pixel edge and 64 MiB (`open_limited_image` / `decode_limited_image`). Render, the editor, blend import, and `aw_asset_cli` call that decoder. `astraweave-asset-pipeline` doc comments still show an uncapped open; that crate is the dormant cook path, not a live caller. `aw_asset_cli` rejects glTF buffer and image file URIs that fail `safe_under` before import. `OllamaClient::new` keeps only loopback URLs unless `allowing_remote` is used.
- **AI decision debugger (#287).** Zero-cost decision ring plus the headless `aw_decision` inspector (`show` / `diff`). Tracing is off unless the caller records.
- **Causal consequence engine (#286).** `CausalWorld::tick` admits recorded inputs and fires a baked rule table. It does not call a model. Replay case `causal_bridge`. Editor play does not call it. The causality crate does not read a geometry notice; `BridgeAgent` drains the collapse into the cut.
- **Rhai mod sandbox and loader (#214, #318).** Gameplay and mod scripts run on the security sandbox. `build_app` installs `ModScriptPlugin` after `register_mod_runtime`. Replay case `scripted_system`. Gameplay `script_system` does not inject `PhysicsProxy` or `NavMeshProxy` (#318).
- **Rhai mod sandbox and loader (#214, #318).** Gameplay and mod scripts run on the security sandbox. `build_app` installs `ModScriptPlugin` after `register_mod_runtime`. Replay case `scripted_system`. Gameplay `script_system` does not inject `PhysicsProxy` or `NavMeshProxy` (#318). The host still uses `PhysicsWorld` for collision events and spawned bodies. `scripting_advanced_demo` still inserts physics and nav resources, and `advanced_ai.rhai` no longer calls them: sight is distance under 20, and a finished patrol point clears `path`. `scripting_playground` still runs triggers and `apply_damage`, and the player script no longer raycasts.
- **Destruction (#243).** Command log, support graph, fracture, terrain deltas, and debris. Sim state is `Fixed64`. Display meshes are outside the hash. Replay case `destruction`.
- **Gameplay QA (#277, replay #280).** Headless Aravath-slice scenario hashed as `gameplay_qa_aravath_slice`. The #277 document is the plan; the required replay case is what landed.

Expand Down Expand Up @@ -132,7 +132,7 @@ The 12,700-agent figure is a CPU capacity estimate for a mid-complexity AI loop
| **Navigation** | Navmesh plus tile routes. `nav_reroute` is a required replay case. |
| **Destruction** | `astraweave-destruction`, `Fixed64` sim, required replay case. |
| **Causality** | `astraweave-causality`, baked rules, required replay case. Headless Aravath caller only. |
| **Scripting** | Sandboxed Rhai, mod loader, tick-boundary reload. Required replay case `scripted_system`. Gameplay scripts do not receive physics or nav proxies (#318). |
| **Scripting** | Sandboxed Rhai, mod loader, tick-boundary reload. Required replay case `scripted_system`. Gameplay scripts do not receive physics or nav proxies (#318). See [scripting.md](docs/architecture/scripting.md). |
| **Security** | Path checks, the deterministic Rhai sandbox, the #312 bounds, and the #316 image, glTF, and Ollama caps are wired. Anticheat, signatures, and the secrets crate stay dormant. See [security.md](docs/architecture/security.md). |
| **Decision inspector** | `tools/aw_decision`. |
| **Aravath bridge** | `aravath_runtime::BridgeAgent`. No window in that crate. |
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/nav.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ It provides the navigability check + path query that the AI tool-validation laye
- Test/bench-only siblings: `astraweave-nav/src/{mutation_tests,stress_tests,edge_case_tests}.rs`, `astraweave-nav/tests/*.rs`, `astraweave-nav/benches/navmesh_benchmarks.rs`.

**Status note:**
The crate itself is Active and is a declared workspace member. However, of its non-test consumers, the most "real" runtime wiring is the **scripting** `NavMeshProxy` (reads `NavMesh` as an ECS resource) and the **editor** Bake button. The AI tool-sandbox nav check (`astraweave-ai/src/tool_sandbox.rs:400-410`) is present but its enabling path (`ValidationContext::with_nav`) has **zero non-test callers** — see §6. The `astraweave-gameplay::weaving` consumer bakes a navmesh and immediately discards it (`let _nav = …`). A second on-disk directory, [`crates/astraweave-nav/`](../../crates/astraweave-nav), is an **orphan** containing only one benchmark file and no crate manifest — see §6.
The crate itself is Active and is a declared workspace member. Gameplay scripts do not read it (#318). `NavMeshProxy` remains a type in `astraweave-scripting` and is not injected. Of the non-test consumers, the editor Bake button is the live path query. `examples/scripting_advanced_demo` still inserts a `NavMesh` resource, and `advanced_ai.rhai` does not call `nav.find_path`. The AI tool-sandbox nav check (`astraweave-ai/src/tool_sandbox.rs:400-410`) is present but its enabling path (`ValidationContext::with_nav`) has **zero non-test callers** — see §6. The `astraweave-gameplay::weaving` consumer bakes a navmesh and immediately discards it (`let _nav = …`). A second on-disk directory, [`crates/astraweave-nav/`](../../crates/astraweave-nav), is an **orphan** containing only one benchmark file and no crate manifest — see §6.

---

Expand Down
25 changes: 14 additions & 11 deletions docs/architecture/scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ primary_crate: astraweave-scripting
domain: gameplay
lifecycle_status: active
integration_status: wired
summary: "Gameplay and mod scripts run on the security sandbox. build_app installs ModScriptPlugin after register_mod_runtime, so the editor and game tick mods on the logged sandbox path. Native plugin template is not a runtime."
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.3"
last_verified_commit: d6b07fc8
doc_version: "1.4"
last_verified_commit: 3971cbe1
runtime_edges:
- to: astraweave-security
note: "ScriptEngineResource and mod_script_system call sandbox::SandboxEngine / execute_deterministic"
Expand All @@ -28,10 +28,10 @@ runtime_edges:
|---|---|
| **System name** | Scripting and mod API |
| **Primary crates** | `astraweave-scripting`, `astraweave-author` |
| **Document version** | 1.3 |
| **Last verified against commit** | `d6b07fc8` |
| **Last verified date** | 2026-10-15 |
| **Status** | Active for the sandboxed Rhai path. `register_mod_runtime` plus `build_app` is how the editor, Veilweaver runtime, and `hello_companion` run mods. Examples still exercise `ScriptingPlugin`. The editor does not feed `CScript` entities. |
| **Document version** | 1.4 |
| **Last verified against commit** | `3971cbe1` |
| **Last verified date** | 2026-10-16 |
| **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 All @@ -52,7 +52,7 @@ Mods need a single sandboxed command set whose results are sim inputs. A second
- `tools/aw_editor/src/rhai_reload.rs` — editor hot reload

**Status note:**
`script_system` no longer stats files during the tick. Reloads come from `ScriptReloadQueue::take_boundary` at the start of the system. `mod_script_system` uses a separate `ModReloadQueue` so the two systems do not steal each other's bytes. Neither tick places `PhysicsProxy` or `NavMeshProxy` in the script scope.
`script_system` no longer stats files during the tick. Reloads come from `ScriptReloadQueue::take_boundary` at the start of the system. `mod_script_system` uses a separate `ModReloadQueue` so the two systems do not steal each other's bytes. Neither tick places `PhysicsProxy` or `NavMeshProxy` in the script scope. The host still reads `PhysicsWorld` for collision events and for bodies spawned by script commands. A gameplay script that names `physics` or `nav` errors. `script_system_rejects_physics_and_nav_proxies` checks that: the script runs (`saw` becomes 1) and the assignment after the proxy call does not (`result` stays 0), even when both resources are in the world.

---

Expand Down Expand Up @@ -128,6 +128,8 @@ Mods need a single sandboxed command set whose results are sim inputs. A second
| `astraweave-author/src/lib.rs` | `configure` | Active | Floats in hints are rejected. |
| `tools/aw_editor/src/rhai_reload.rs` | Editor boundary | Active | |
| `tools/aw_plugin_template/` | Scaffold | Non-runtime | README says so. |
| `examples/scripting_advanced_demo/` | `ScriptingPlugin` demo | Example | Host still inserts `PhysicsWorld` and `NavMesh`. `assets/advanced_ai.rhai` does not call them. Sight is `dist_to_player < 20.0`. A finished patrol point sets `path = []`. |
| `examples/scripting_playground/` | `ScriptingPlugin` demo | Example | Host still owns `PhysicsWorld`, dynamic boxes, and a sensor. The player script handles `on_trigger_enter` and `commands.apply_damage`. It does not raycast. |

---

Expand Down Expand Up @@ -162,7 +164,7 @@ Mods need a single sandboxed command set whose results are sim inputs. A second
- **Status:** Accepted
- **Context:** No shipped gameplay script called `PhysicsProxy` or `NavMeshProxy`. The only callers were `examples/scripting_advanced_demo`, `examples/scripting_playground`, and the unit tests that exercised the injection. The proxies held raw pointers into the live world.
- **Decision:** `script_system` does not inject them, on the main body or on event callbacks. Issue #317.
- **Consequences:** A script that names `physics` or `nav` errors and does not advance its result. The types remain registered for the mutation tests.
- **Consequences:** A script that names `physics` or `nav` errors and does not advance its result. The types remain registered for the mutation tests. #318 (`3971cbe1`) also changed the two demos that used to call the proxies. `advanced_ai.rhai` no longer calls `physics.raycast` or `nav.find_path`. `scripting_playground`'s player script no longer raycasts. The hosts still insert the resources.

### Decision: Hot reload is data staged for the next tick
- **Date:** 2026-10-14
Expand Down Expand Up @@ -207,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` along with `planner_pure` and `perception_world`. `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 ten cross-OS cases. `target-cpu=native` is not set. Apple Silicon uses the default aarch64 baseline.

---

Expand All @@ -231,5 +233,6 @@ Each mod script is compiled on the tick it runs. The replay case is 32 ticks of
|---|---|---|
| 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. |
| 1.3 | 2026-10-15 | Gameplay `script_system` does not inject `PhysicsProxy` or `NavMeshProxy`. #317. |
| 1.3 | 2026-10-15 | Gameplay `script_system` does not inject `PhysicsProxy` or `NavMeshProxy`. #317, merged as #318. |
| 1.4 | 2026-10-16 | Demo follow-through. `advanced_ai.rhai` uses distance for sight and an empty patrol path. `scripting_playground` keeps trigger damage and drops the player raycast. Hosts still insert the physics and nav resources. |
| 1.2 | 2026-10-15 | `queue_weave` on capability `Weave`. Command API 2. Weave casts are a fixed buffer. |
2 changes: 1 addition & 1 deletion docs/guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Developer guides and tutorials for AstraWeave.

| Guide | Description |
|-------|-------------|
| [ai-scripting.md](ai-scripting.md) | Rhai scripting for AI |
| [ai-scripting.md](ai-scripting.md) | Gameplay Rhai scripts. No physics or nav proxies (#318). |
| [behavior_and_quests.md](behavior_and_quests.md) | Behavior trees and quests |
| [hierarchical_goals_designer_guide.md](hierarchical_goals_designer_guide.md) | Goal-oriented AI |
| [persona-packs.md](persona-packs.md) | Persona pack system |
Expand Down
16 changes: 8 additions & 8 deletions docs/guides/ai-scripting.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# AI Scripting (Rhai)

The engine calls into Rhai for:
- **Encounter budgets** (fortify/collapse/spawn)
- **Boss phase logic** (HP/time driven)
- **Persona profile distillation**
Checked against `main` at `3971cbe1` (#318).

Contract:
- Input: world snapshot (read-only) + limited op budget
- Output: allowed verbs only; engine validates/corrects
Gameplay scripts run on `script_system` (`astraweave-scripting`). They emit `ScriptCommands`. They do not receive `PhysicsProxy` or `NavMeshProxy`. A script that names `physics` or `nav` errors, and the statement after that call does not run. The host can still read `PhysicsWorld` for collision events and for bodies a command spawned. The trace is [scripting.md](../architecture/scripting.md).

See: `content/encounters/*.rhai` in your repo.
Two examples changed with that tick:

- `examples/scripting_advanced_demo` still inserts `PhysicsWorld` and `NavMesh`. `assets/advanced_ai.rhai` does not call them. Sight is distance under 20. A finished patrol point sets `path` to an empty array.
- `examples/scripting_playground` still builds a physics world, a dynamic box, and a sensor. The player script handles `on_trigger_enter` and `commands.apply_damage`. It does not raycast.

Encounter, boss, and persona scripts, where they exist, are a different surface: a read-only snapshot in, allowed verbs out, and the deterministic sim validates the result. Do not treat `docs/src/game-dev/scripting.md` as this API. That page describes callbacks and a `raycast` function the gameplay tick does not provide.
4 changes: 3 additions & 1 deletion docs/src/game-dev/scripting.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Scripting with Rhai

> **Not the live gameplay API.** This page describes callbacks, a `ScriptEngine` config, and a `raycast` function that `script_system` does not provide. As of #318 (`3971cbe1`), gameplay scripts do not receive `physics` or `nav`. The live contract is [docs/architecture/scripting.md](../../architecture/scripting.md) and [docs/guides/ai-scripting.md](../../guides/ai-scripting.md).

> **Crates**: `astraweave-scripting`, `astraweave-author`
> **Status**: Production Ready (Sandboxed)
> **Status**: Historical sketch. The sandboxed tick is real. The snippets below are not.

AstraWeave provides secure Rhai scripting for modding, behavior authoring, and runtime customization with full sandboxing.

Expand Down