Skip to content

feat(ai): zero-cost decision ring and headless inspector - #287

Merged
lazyxeon merged 3 commits into
mainfrom
cursor/decision-trace-impl-def8
Oct 15, 2026
Merged

lazyxeon merged 3 commits into
mainfrom
cursor/decision-trace-impl-def8

Conversation

@lazyxeon

@lazyxeon lazyxeon commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Description

Implements the approved decision-debugger plan, rebased onto PR #251 at fe349aa0. Draft. Do not merge.

perception_world is 6e52e721ceb8a96413a7ae0ba1ad3f88adaeb37c56ba520c3a3cb9f6f0bf7ebb on that head and on this branch, with decision-trace off and on. Main's ad6f87b69a97ed5c86fec18a5028b2750648fe330f7c8dc9e7d074830eedaa80 is the older digest. The change is #251 commit 4172ed01: build_snapshot no longer inserts a breach_door POI at (15, 8). fe349aa0 only updates the comprehensive snapshot test to expect an empty POI list. Tracing does not write that hash.

decision-trace is off by default. plan_route keeps 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_decision is the headless inspector. Scene text says Aravath. The editor panel is not in this PR.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Security enhancement

Security Considerations

  • Does this PR introduce new dependencies? If yes, have they been vetted for security issues?
  • Does this PR modify how user input is handled? If yes, has it been validated/sanitized?
  • Does this PR change authentication or authorization mechanisms?
  • Does this PR access sensitive data or modify how it's stored?
  • Does this PR introduce new network communication or modify existing protocols?

No new third-party crate. sha2 is a dev-dependency already in the workspace. The CLI parses a tick, an entity id, and an x,y cell.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • I have run security checks (cargo audit, cargo deny) locally

Test plan

  • perception_world on fe349aa0, and on this branch with the feature off and on, is 6e52e721ceb8a96413a7ae0ba1ad3f88adaeb37c56ba520c3a3cb9f6f0bf7ebb
  • cargo test -p astraweave-ai --features decision-trace --test decision_trace_hash
  • determinism-replay / compare on d89ffeca passed on Ubuntu, Windows, and macOS with that same digest (run 38765134289)
  • Compare on the rebased head 4319694b
Open in Web Open in Cursor 

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 23c7b8fc-7916-4563-aa6f-3249a1ac0d8a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor
cursor Bot force-pushed the cursor/decision-trace-impl-def8 branch from d89ffec to 4319694 Compare October 15, 2026 16:16
@cursor
cursor Bot force-pushed the feat/ai-orchestration branch 2 times, most recently from d7f6555 to d6992b9 Compare October 15, 2026 18:42
Base automatically changed from feat/ai-orchestration to main October 15, 2026 19:42
cursoragent and others added 3 commits October 15, 2026 20:43
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>
@cursor
cursor Bot force-pushed the cursor/decision-trace-impl-def8 branch from 4319694 to b0fa24d Compare October 15, 2026 20:48
@lazyxeon
lazyxeon marked this pull request as ready for review October 15, 2026 21:56
@lazyxeon
lazyxeon merged commit ab8ed4b into main Oct 15, 2026
26 checks passed
@lazyxeon
lazyxeon deleted the cursor/decision-trace-impl-def8 branch October 15, 2026 21:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread astraweave-ai/src/htn.rs
Comment on lines +229 to +230
pub struct TraceGuard {
trace: *mut crate::decision_trace::DecisionTrace,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread astraweave-ai/src/htn.rs
Comment on lines +289 to +292
TRACE_HOLDER.with(|cell| {
if let Some(trace) = cell.borrow_mut().as_mut() {
let _ = trace.push(record);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +277 to +280
#[cfg(feature = "decision-trace")]
fn ecs_entity_key(entity: ecs::Entity) -> u64 {
(u64::from(entity.generation()) << 32) | u64::from(entity.id())
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread astraweave-ai/src/htn.rs
Comment on lines +508 to +510
#[cfg(feature = "decision-trace")]
{
let perceived = perceived_for_route(tiles, pos_milli);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +99 to +101
out.extend_from_slice(&alt.b.to_le_bytes());
}
out

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T22:09:13.803622Z b0fa24d Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

cursor Bot pushed a commit that referenced this pull request Oct 15, 2026
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>
cursor Bot pushed a commit that referenced this pull request Oct 16, 2026
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>
cursor Bot pushed a commit that referenced this pull request Oct 16, 2026
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>
lazyxeon added a commit that referenced this pull request Oct 16, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants