Repository navigation
feat(ai): zero-cost decision ring and headless inspector - #287
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 |
d89ffec to
4319694
Compare
d7f6555 to
d6992b9
Compare
decision-trace stays off by default, so the record sites compile out and the six required replay cases are unchanged. With the feature on, a preallocated ring records the plan and a null sink hashes to the same plan bytes. aw_decision prints one Aravath bridge tick and a sealed-cell counterfactual. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
The replay harness calls plan_route with eight arguments. A feature-only extra parameter made that test fail to compile when decision-trace was unified on, so the sink now lives in thread-local storage. perception_world stays 6e52e721 with the feature off and on. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
The required replay set is the eight cases on main. The allocation test reads the ring after the trace guard returns it. Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
4319694 to
b0fa24d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0fa24de6e
ℹ️ 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".
| pub struct TraceGuard { | ||
| trace: *mut crate::decision_trace::DecisionTrace, |
There was a problem hiding this comment.
Tie the guard lifetime to the trace borrow
TraceGuard stores a raw pointer but carries no lifetime, so safe code can call attach_trace(&mut trace, ...), move or drop trace, and then drop the guard. Its Drop implementation will dereference the pointer to the moved/dropped value, potentially causing use-after-free or a double free. Encode the mutable borrow in TraceGuard<'a> (or avoid the raw pointer) and add the required Miri/Kani coverage for this unsafe path. .github/copilot-instructions.mdL248-L252
Useful? React with 👍 / 👎.
| TRACE_HOLDER.with(|cell| { | ||
| if let Some(trace) = cell.borrow_mut().as_mut() { | ||
| let _ = trace.push(record); | ||
| } |
There was a problem hiding this comment.
Bind each spatial agent before emitting its record
When sys_spatial_tick is given a freshly inserted DecisionTrace, it attaches the trace with entity 0 and tick_agents only changes TRACE_ENTITY; no spatial agent is ever bound. Because DecisionTrace::push rejects unknown entity IDs, this call silently drops every HTN record unless the caller independently pre-bound all agents, so inserting the advertised ECS resource alone produces an empty spatial trace. Bind the current entity before pushing, as the grid tracing path already does.
Useful? React with 👍 / 👎.
| #[cfg(feature = "decision-trace")] | ||
| fn ecs_entity_key(entity: ecs::Entity) -> u64 { | ||
| (u64::from(entity.generation()) << 32) | u64::from(entity.id()) | ||
| } |
There was a problem hiding this comment.
Reserve a nonzero trace key for ECS entity zero
For the first ECS entity, the allocator produces (id=0, generation=0), so this encoding returns 0. DecisionTrace::bind explicitly refuses entity ID 0, meaning an ECS companion spawned first can never produce a grid decision record. Encode valid ECS handles into a nonzero namespace or allow zero as a bound ID.
Useful? React with 👍 / 👎.
| #[cfg(feature = "decision-trace")] | ||
| { | ||
| let perceived = perceived_for_route(tiles, pos_milli); |
There was a problem hiding this comment.
Emit a record for the no-path wait branch
When query_path returns fewer than two waypoints, plan_route writes a 500 ms Wait action and returns before reaching this newly added emission block. Tracing therefore reports no decision for no-path or already-at-goal ticks instead of recording the actual wait plan. Route all plan exits through the emitter or emit the wait record before that return.
Useful? React with 👍 / 👎.
| out.extend_from_slice(&alt.b.to_le_bytes()); | ||
| } | ||
| out |
There was a problem hiding this comment.
Serialize the full decision record in dumps
record_bytes returns immediately after serializing the alternatives, omitting the entire PerceivedView and BeliefView portions of DecisionRecord. Consequently, --dump loses the perception and belief layers that show exposes and cannot be decoded back into the promised complete decision record by a later panel or other consumer. Append every remaining field to the versioned format, or define and document an explicitly partial dump schema.
Useful? React with 👍 / 👎.
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. |
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>
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>
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>
* 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
Implements the approved decision-debugger plan, rebased onto PR #251 at
fe349aa0. Draft. Do not merge.perception_worldis6e52e721ceb8a96413a7ae0ba1ad3f88adaeb37c56ba520c3a3cb9f6f0bf7ebbon that head and on this branch, withdecision-traceoff and on. Main'sad6f87b69a97ed5c86fec18a5028b2750648fe330f7c8dc9e7d074830eedaa80is the older digest. The change is #251 commit4172ed01:build_snapshotno longer inserts abreach_doorPOI at(15, 8).fe349aa0only updates the comprehensive snapshot test to expect an empty POI list. Tracing does not write that hash.decision-traceis off by default.plan_routekeeps eight arguments in both builds; the sink is thread-local only while the feature is on. The null-sink and ring plan SHA-256 match.tools/aw_decisionis the headless inspector. Scene text says Aravath. The editor panel is not in this PR.Type of change
Security Considerations
No new third-party crate.
sha2is a dev-dependency already in the workspace. The CLI parses a tick, an entity id, and anx,ycell.Checklist
Test plan
perception_worldonfe349aa0, and on this branch with the feature off and on, is6e52e721ceb8a96413a7ae0ba1ad3f88adaeb37c56ba520c3a3cb9f6f0bf7ebbcargo test -p astraweave-ai --features decision-trace --test decision_trace_hashdeterminism-replay / compareond89ffecapassed on Ubuntu, Windows, and macOS with that same digest (run 38765134289)4319694b