Repository navigation
docs: open-world AI orchestration archaeology (Phase 1, review before code) - #251
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Weaving (PR #252) is adding the fixed hazard tail you left as a review question. pub hazards: [WeaveHazard; 16],
pub hazard_count: u8,
|
492e20c to
ea8ec32
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe349aa01f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const MAX_RELINK: usize = 4096; | ||
| let limit = self.tris.len().min(MAX_RELINK); | ||
| let mut dirty_tri = [false; MAX_RELINK]; |
There was a problem hiding this comment.
Process dirty triangles beyond the relink cap
For any NavMesh with more than 4,096 baked triangles, an invalidated triangle at index 4,096 or later is never inspected or updated because every relinking loop stops at limit; partial_rebake nevertheless clears all dirty regions before returning. The mesh is therefore marked clean while still publishing stale geometry, so larger production navmeshes cannot reliably react to terrain edits.
Useful? React with 👍 / 👎.
| let n = src.normal_normalized(); | ||
| if n.length_squared() >= 1e-6 && n.dot(Vec3::Y) >= 0.0 { | ||
| self.tris[i].verts = [src.a, src.b, src.c]; | ||
| self.tris[i].center = src.center(); | ||
| self.tris[i].normal = n; | ||
| } |
There was a problem hiding this comment.
Reapply walkability filtering during partial rebakes
When an edit makes a formerly walkable triangle steeper than max_slope_deg, this condition still accepts and relinks it because it checks only for an upward-facing normal; if the replacement becomes degenerate or downward-facing, the old walkable vertices remain and are likewise relinked. The previous full rebake applied the slope filter and removed such faces, so dynamic terrain can now leave paths through walls, collapsed surfaces, or other non-walkable geometry.
Useful? React with 👍 / 👎.
| if chain_len as usize >= MAX_WAYPOINTS { | ||
| break; | ||
| } |
There was a problem hiding this comment.
Correctly truncate overlong waypoint chains
When a valid route contains more than MAX_WAYPOINTS nodes, this exits reconstruction before reaching start_n but then emits the requested start followed by the retained tail near the goal. That skips an arbitrary number of intermediate connected nodes—and can also fill the buffer before appending the goal—so callers receive a path whose first segment may cross blocked space. Return failure or retain the start-side prefix when the parent chain exceeds the output capacity.
Useful? React with 👍 / 👎.
| let mut far = scratch.waypoints[0]; | ||
| for point in scratch.waypoints.iter().take(scratch.waypoint_len as usize) { | ||
| if point.x.abs() > far.x.abs() { | ||
| far = *point; |
There was a problem hiding this comment.
Choose the movement target by path progress
For routes that move toward the origin on X, or primarily along Z while no waypoint has a larger absolute X than the start, far remains scratch.waypoints[0]; the resulting MoveTo sends the agent to its current cell and repeated replans never advance it. On other routes this can select an arbitrary lateral excursion rather than the next or final waypoint. Select by waypoint order or distance progressed along the path instead of absolute world X.
Useful? React with 👍 / 👎.
| let mut scratch = astraweave_nav::NavScratch::new(); | ||
| let sim_tick = tick.clock; | ||
| tick.clock = tick.clock.saturating_add(1); | ||
| crate::htn::tick_agents(tick, &mut scratch, sim_tick); |
There was a problem hiding this comment.
Apply spatial HTN plans to ECS agents
When AiPlanningPlugin runs with a SpatialTick—including the updated ecs_ai_demo—this call only stores plans in SpatialTick.agents; it neither writes CDesiredPos nor emits an action event, and a repository-wide search finds no non-test consumer of AgentPlan. Consequently the demo companion is still driven solely by the legacy planner and the new spatial HTN path never affects gameplay; translate these plans into ECS actions here or register a downstream consumer. .github/copilot-instructions.mdL193-L199
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved navigation invalidation, route generation, and scheduling defects undermine reliable rerouting, while validation misses key execution paths.
19 open findings
Commit queued navigation changes before ECS planning · New Invalidate plans when navigation changes · New Emit route waypoints in order and track progress · New Exclude sealed portals during route search · New Filter sealed breach cells before publishing POIs · New Hash complete navigation outputs and committed tile identities · New Process all triangles without dropping dirty work · New Rebuild dirty triangles with bake filters and remap adjacency · New Convert GeometryNotice bounds from voxel units to milli-units · New Prevent pending geometry changes from being silently discarded · New Publish accepted tiles with coherent derived connectivity · New Reject truncated path reconstruction instead of skipping nodes · New Rebuild dirty geometry instead of deleting overlapping triangles · New Preserve stable feature identities across source compaction · New Schedule deferred agents fairly within each band · New Enforce expansion budgets at every planning stage · New Ensure the benchmark actually triggers replanning · New Hash the exact vertex values consumed by the builder · New Synchronize spatial agents with the ECS movement consumer · New
What changed in this PR
Adds spatial AI planning and tiled navigation to AstraWeave, moving beyond the initial archaeology document toward bridge-collapse rerouting.
Changes:
- Adds bounded tile commits, destruction-notice adaptation, and step-height connectivity.
- Introduces HTN planning, spatial observations, scheduling, and demo registration.
- Adds replay coverage, allocation checks, benchmarks, and architecture updates.
| File | Description |
|---|---|
examples/ecs_ai_demo/src/main.rs |
Registers the spatial demo resource. |
docs/current/AI_ORCHESTRATION_ARCHAEOLOGY.md |
Records the survey, design, and implementation status. |
docs/architecture/nav.md |
Updates navigation behavior and status. |
docs/architecture/ai_pipeline.md |
Documents HTN and spatial planning. |
Cargo.lock |
Records navigation and destruction dependencies. |
astraweave-nav/src/tiles.rs |
Adds tiled navigation, queries, and geometry invalidation. |
astraweave-nav/src/lib.rs |
Exports tiles and changes connectivity and rebaking. |
astraweave-nav/Cargo.toml |
Adds the destruction dependency. |
astraweave-nav/benches/navmesh_benchmarks.rs |
Adds a tile-commit benchmark. |
astraweave-core/tests/replay_support/mod.rs |
Adds destruction-backed navigation replay data. |
astraweave-core/tests/replay_hash.rs |
Includes the navigation replay digest. |
astraweave-core/tests/perception_tests.rs |
Updates expectations for absent breach observations. |
astraweave-core/src/sim.rs |
Reserves navigation and HTN random-stream IDs. |
astraweave-core/src/perception.rs |
Adds spatial observation buffers and observed POIs. |
astraweave-core/Cargo.toml |
Adds replay test dependencies. |
astraweave-ai/tests/zero_alloc_tick.rs |
Adds allocation assertions for spatial work. |
astraweave-ai/tests/mutation_resistant_comprehensive_tests.rs |
Updates planner-mode assertions. |
astraweave-ai/src/veilweaver.rs |
Replaces GOAP search with priority-based action selection. |
astraweave-ai/src/orchestrator.rs |
Delegates utility planning to the HTN module. |
astraweave-ai/src/mutation_tests.rs |
Includes HTN in planner-mode tests. |
astraweave-ai/src/lib.rs |
Exports spatial planning interfaces. |
astraweave-ai/src/htn.rs |
Adds spatial plans, utility selection, and scheduling. |
astraweave-ai/src/ecs_ai_plugin.rs |
Registers the spatial planning system. |
astraweave-ai/src/core_loop.rs |
Adds HTN dispatch. |
astraweave-ai/Cargo.toml |
Enables allocation instrumentation and the HTN benchmark. |
astraweave-ai/benches/htn_budget.rs |
Benchmarks planning-budget consumption. |
.github/workflows/determinism-replay.yml |
Requires the navigation replay case. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let mut scratch = astraweave_nav::NavScratch::new(); | ||
| let sim_tick = tick.clock; | ||
| tick.clock = tick.clock.saturating_add(1); | ||
| crate::htn::tick_agents(tick, &mut scratch, sim_tick); |
| let band = band_of(agent.pos_milli, agent.player_milli); | ||
| agent.ticks_since_plan = agent.ticks_since_plan.saturating_add(1); | ||
| match band { | ||
| 0 if agent.ticks_since_plan >= REPLAN_TICKS || agent.plan.len == 0 => { |
| let mut far = scratch.waypoints[0]; | ||
| for point in scratch.waypoints.iter().take(scratch.waypoint_len as usize) { | ||
| if point.x.abs() > far.x.abs() { | ||
| far = *point; | ||
| } |
| if sealed(hooks, cell_x, cell_y) { | ||
| continue; |
| pois.push(Poi { | ||
| k: "breach".into(), |
| let b = agents[order[j] as usize]; | ||
| let band_a = band_of(a.pos_milli, a.player_milli); | ||
| let band_b = band_of(b.pos_milli, b.player_milli); | ||
| let out = band_a > band_b || (band_a == band_b && a.entity_id > b.entity_id); |
| *budget = budget.saturating_sub(1); | ||
| if let Some(portal) = best_breach(tiles, scratch, hooks) { |
| reset_allocs(); | ||
| tick_agents(&mut tick, &mut scratch, 9); | ||
| let tick_allocs = allocs(); |
| h = mix(h, milli(v.x) as u32 as u64); | ||
| h = mix(h, milli(v.y) as u32 as u64); | ||
| h = mix(h, milli(v.z) as u32 as u64); |
| app.world | ||
| .insert_resource(astraweave_ai::SpatialTick::demo_agent()); |
fe349aa to
d7f6555
Compare
Map planners, navmesh, and perception on main, and record the HTN-plus-utility upgrade that waits on review. No runtime code. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Tile rebuilds stop at four per tick and accept a worker buffer only when its input hash matches the synchronous build. A ledge taller than max_step no longer links, and partial_rebake leaves triangles outside the dirty AABB in place. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
The spatial tick scores breaches and destroyed cover with a fixed plan buffer, and perception no longer invents a breach cell. nav_reroute is a required three-OS replay case. UtilityOrchestrator and PlannerMode::Htn call this planner. AIArbiter and the advanced GOAP tree are deferred in issues 257 and 258. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
After warmup both paths record zero heap events under CountingAlloc. Collapse input is a GeometryNotice with the reason bytes drain_geometry_notices publishes; the destruction crate is still on its own branch. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
NavChangeKind is Explosion, Brush, Detach, and Weave. The replay drains GeometryNotice values from DestructionWorld instead of building a second notice type. The workflow still requires planner_pure, perception_world, gameplay_rng, fixed64, combat_resolve, and nav_reroute. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
build_snapshot no longer inserts a breach at a fixed cell. The comprehensive snapshot test still required one POI, which failed the Ubuntu and Windows jobs. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Main and the nav replay both added astraweave-destruction. The manifest keeps main's crate and the nav dev-dependency, once each. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
d7f6555 to
d6992b9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d6992b9885
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| [notice.x0, notice.y0, notice.z0], | ||
| [notice.x1, notice.y1, notice.z1], |
There was a problem hiding this comment.
Scale geometry notices before constructing nav changes
For real destruction events away from the origin, these bounds are in integer terrain/world cells: brush notices copy integer Brush::origin values and collapse notices use floor_whole/ceil_whole. source_hits later compares them with milli(vertex), so a brush spanning x=13..19 is tested against nav vertices near x=16000 and merely rebuilds unchanged geometry. Convert the producer bounds to milli-units here, or standardize the producer contract; the replay currently hides this mismatch by issuing a brush at coordinates such as 24,500.
Useful? React with 👍 / 👎.
| if source_hits( | ||
| &self.slots[slot].sources[i], | ||
| change.min_milli, | ||
| change.max_milli, | ||
| ) { | ||
| removed = true; |
There was a problem hiding this comment.
Rebuild brush edits instead of deleting every source
When a destruction brush uses BrushOp::Add or BrushOp::Smooth, the producer still emits reason 1 and this code maps it to NavChangeKind::Brush; drop_sources ignores the kind and permanently removes every intersecting source triangle. A terrain fill can therefore erase existing navigation instead of publishing the newly raised or smoothed surface, and there is no API here that supplies replacement geometry. Dirty tiles need to rebuild from the current terrain geometry rather than treating every notification as a subtraction.
Useful? React with 👍 / 👎.
| let id = portal_id( | ||
| self.slots[a].cx, | ||
| self.slots[a].cz, | ||
| ia as u16, | ||
| self.slots[b].cx, |
There was a problem hiding this comment.
Preserve stable identities across tile rebuilds
When an edit removes an early source triangle, drop_sources and build_slot compact the remaining triangles, so their local indices change. Deriving portal IDs from ia/ib (and cover IDs from the same local index later) makes unchanged geometry receive new identities after that rebuild: ordinary portals are then published as new breaches, while lost-cover matching can report a surviving cover as lost and miss the cover actually removed. Derive these IDs from stable source or edge identities instead of compacted array positions.
Useful? React with 👍 / 👎.
| 1 => { | ||
| plan_route( |
There was a problem hiding this comment.
Schedule deferred band-1 agents before repeat replans
With more band-1 agents than the expansion budget can serve, this unconditional replan combines with the fixed (band, entity_id) ordering to starve the same high-ID tail every tick. For example, after cover is lost each successful route consumes three budget units, so only about 22 of the 32 supported agents are processed; the first agents replan again next tick while the remaining agents are skipped indefinitely. Track deferral or otherwise rotate priority within the band before allowing already-served agents to consume the next tick's budget.
Useful? React with 👍 / 👎.
Freeze emits NavChangeKind::Weave on the nav tile record. The duplicate struct is gone. The perception case does not append an empty hazard tail, so that digest stays the one #251 published. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Freeze emits NavChangeKind::Weave on the nav tile record. The duplicate struct is gone. The perception case does not append an empty hazard tail, so that digest stays the one #251 published. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Freeze emits NavChangeKind::Weave on the nav tile record. The duplicate struct is gone. The perception case does not append an empty hazard tail, so that digest stays the one #251 published. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Freeze emits NavChangeKind::Weave on the nav tile record. The duplicate struct is gone. The perception case does not append an empty hazard tail, so that digest stays the one #251 published. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Freeze emits NavChangeKind::Weave on the nav tile record. The duplicate struct is gone. The perception case does not append an empty hazard tail, so that digest stays the one #251 published. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
* docs: map weaving surfaces and propose a data-driven framework Phase 1 only. Inventory of weave, ability, status, material, and physics paths on main, plus a review-gated modifier-graph design. No runtime code. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * feat(core): fixed weave hazard tail on WorldSnapshot Sixteen hazard slots, sorted by kind then cell, plus NavChange in milli-units for a later tile rebuild. Snapshot literals and the perception replay encoding include the tail. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * feat(weaving): data-driven casts into the local-sim field Evolve astraweave-weaving into the modifier graph. Templates stamp temperature, phase, density, flags, and gravity through SimField. TestSimField stands in until the local-sim crate exists. Legacy ops compile to those modifiers, freeze adds a walkable AABB and a NavChange, and the weaving replay case is required on the three-OS workflow. Echo dash and shield spend the single Echo ledger. Damage schools scale after defense, and chill, burn, and stun are read on the hit path. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix(weaving): emit FieldWrite and drop the private grid PR #253 owns the cells. Production weaving expands templates into FieldWrite stamps and hands them to SimField. NullField returns a zero digest until LocalSim shares this branch. TestSimField stays cfg(test) and records writes only. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix: close the snapshot literal before the hazard fields The slice runtime's world snapshot put the hazard tail outside the struct, which failed workspace checks. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * feat(weaving): match the mod queue_weave signature The public queue is the 64-slot WeaveScratch from the mods branch: queue_weave(scratch, start, until, seq, caster, template, origin), engine template ids 1 through 7 reserved, and parse_template_toml. The evaluator still turns those commands into FieldWrite stamps. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix: format hazard literals and drop them from the IPC bench struct The local WorldSnapshot in ipc_adversarial is not the engine snapshot, so the hazard tail does not belong on that type. rustfmt also wants the blank line before each real hazard literal removed. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix(gameplay): keep hit-stagger from blocking the next combo step is_stunned was matching every Stagger, so the stagger a hit already applies cancelled the rest of the chain. Stun is its own effect, from an item special tag. Shock school scale is 11000 basis points, so the echo weapon test expects 66 taken. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * docs(gameplay): stamp the stun-versus-stagger invariant Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix(weaving): reject origins outside the island and wide template ids queue_weave returns OutsideIsland for a cell outside ±2048 and leaves the queued command untouched. parse_template_toml checks the id as i64 before the u16 cast, so 65544 no longer aliases template 8. In-range replay origins are unchanged. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * docs(weaving): stamp the island-origin invariant Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix(weaving): match #214's template id range check Reject ids that do not fit u16 before the cast, with the same error string. Zero and ids 1 through 7 stay engine ids. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix: share the tile NavChange and keep the perception replay bytes Freeze emits NavChangeKind::Weave on the nav tile record. The duplicate struct is gone. The perception case does not append an empty hazard tail, so that digest stays the one #251 published. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix(ai): fill the hazard tail on decision-trace snapshots WorldSnapshot from #287 omitted the weave hazard fields, so the workspace check failed after the rebase. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * ci: retrigger after a Windows rustup timeout The code is unchanged. Partition 2/3 failed while downloading the 1.89.0 toolchain (os error 10060) before any test ran. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * docs: sync the workspace map after the #214 rebase Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> * fix(script): report an out-of-island weave origin queue_weave can return OutsideIsland. The mod host names that error instead of leaving the match incomplete. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>


Description
Phase 2 of the approved plan, still a draft. This branch does not merge.
Survey and the locked decisions remain in
docs/current/AI_ORCHESTRATION_ARCHAEOLOGY.md.What landed
astraweave-nav/src/tiles.rs.TILE_SIZE_Mis 32.TILE_COMMITS_PER_TICKis 4, lowest(cx, cz)first. A worker fillsTileSideBuffer.accept_side_buffercopies it only wheninput_hashmatches the sources the sim would build. Queries write intoNavScratch.max_stepis live. A shared XZ edge links only when the vertical gap is at mostmax_step. Coplanar pairs stay linked. The goldenmax_step_links_a_low_ledge_and_rejects_a_tall_onelocks a 0.3 m link and a 1.0 m reject.partial_rebakerelinks dirty triangles and leaves other vertices in place.GeometryNoticematches the fieldsdrain_geometry_noticespublishes on feat(destruction): replay, prefracture, and collapse bounds #243 (reason1 brush, 2 collapse, 3 weave).nav_change_from_geometry_noticemaps them.astraweave-destructionis not in this branch, so the replay builds the notice and does not calldrain_geometry_noticesyet.build_snapshotno longer emits a breach at a fixed cell.WeaveEffectHookandLocalHazardHookare fixed buffers. A non-zero kind on a cell seals that breach.astraweave-ai/src/htn.rs. Utility-scored breach and cover, LOD bands,[ActionSlot; 8], cap 64.ecs_ai_demorunsSpatialTick.cargo test -p astraweave-ai --features alloc-counter --test zero_alloc_tick -- --test-threads=1asserts the tile commit and the HTN tick allocate zero times after warmup.nav_rerouteis required in.github/workflows/determinism-replay.yml.Dormant systems
UtilityOrchestratorhtn::legacy_utility_plandispatch_plannerPlannerMode::Htnis always availableGoapPlanner::planand no wall clockAIArbiterGoapPlannerllm_dialogue.rsstays issue #225. The Aravath window scene is issue #261. A headlessBridgeAgentis being prepared oncursor/aravath-bridge-reroute-568b, stacked on #205.Type of change
Security Considerations
astraweave-core's replay test dev-depends onastraweave-nav.Checklist
Test plan
cargo test -p astraweave-nav --liband the nav integration testscargo test -p astraweave-ai --libcargo test -p astraweave-ai --features alloc-counter --test zero_alloc_tick -- --test-threads=1cargo test -p astraweave-core --test replay_hashis stable in one processcargo clippy -p astraweave-nav -p astraweave-core -p astraweave-ai --all-targets --features alloc-counter -- -D warningsdeterminism-replay / comparematchesnav_rerouteon Ubuntu, Windows, and macOS