Skip to content

Deterministic saves, replay apply, and macOS greybox golden - #381

Merged
lazyxeon merged 2 commits into
mainfrom
cursor/determinism-saves-b3de
Oct 18, 2026
Merged

lazyxeon merged 2 commits into
mainfrom
cursor/determinism-saves-b3de

Conversation

@lazyxeon

@lazyxeon lazyxeon commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Description

Saves and replays round-trip the sim state. Head 71e0ffc5.

#283 checkpoint fields

Each field is on Checkpoint in aravath_runtime/src/save.rs and is written into the save meta by save_checkpoint. Greybox::checkpoint fills them and Greybox::restore puts them back.

Field Where it is stored Round-trip proof
enemies Checkpoint.enemies: Vec<SavedEnemy> (enemies meta) restored_fight_hashes_like_the_source asserts one enemy at 17 health after restore, then state_hash matches the source
motor mode Checkpoint.motor_mode (motor meta) same test asserts MotorMode::Roll after restore
attack phase attack_time, attack_swinging, attack_hit (attack meta) same test asserts time 0.12, swinging, and hit landed after restore
lock Checkpoint.lock: Option<usize> (lock meta) same test asserts Some(0) after restore
tick Checkpoint.tick (tick meta and WorldState.tick) same test asserts tick 40 after restore
cover_broken Checkpoint.cover_broken (cover meta) same test asserts cover_broken after restore

The test is sim::tests::restored_fight_hashes_like_the_source in aravath_runtime/src/sim.rs. It saves, loads, restores into a fresh Greybox, checks those fields, and requires gameplay_hash and state_hash to match the source. greybox_checkpoint_replay_is_stable_and_written in aravath_runtime/tests/checkpoint_replay.rs checks the same fields on the loaded checkpoint (motor Roll, swinging attack, lock Some(0), one enemy, cover_broken, tick 30).

Inventory credits

PlayerInventory.credits is not its own state. The struct in persistence/aw-save/src/lib.rs is the example inventory slot on SaveBundleV2. No ECS component, resource, or greybox field stores a credit balance. CAmmo.rounds is ammunition. Quest rewards.currency is a reward figure, not a wallet. EchoCurrency lives in astraweave-weaving and is not this field. save_game writes credits: 0, which is what the greybox and veil saves already write. The earlier ammo sum was a stand-in and is removed. persistence_manager_save_has_credits locks that zero.

Already fixed on main

This branch does not re-fix those three.

Fixes #281
Fixes #283
Fixes #284

Supply-chain and Scorecard checks (#305–#311, #313) are left to the security agent.

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? No new dependencies.
  • 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? Save blobs store the sim tick and the replay log. PlayerInventory.credits stays 0. Scar loads still reject more than 4096 cells before insert.
  • Does this PR introduce new network communication or modify existing protocols?

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
Open in Web Open in Cursor 

Health replay events write CHealth, autosave stores the replay log, and the ECS blob records the sim tick. A greybox fight reload hashes like the source when the ground log is unchanged. The greybox golden now runs on macOS.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 18, 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: Repository: lazyxeon/AstraWeave/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 115f6530-d63e-411b-8439-bc92c29ba030
  • 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.

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

PlayerInventory.credits has no owning component, so save_game no longer copies CAmmo into it. The fight reload test checks tick, motor mode, attack phase, lock, cover, and the enemy after restore.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
@lazyxeon
lazyxeon marked this pull request as ready for review October 18, 2026 14:28
@lazyxeon
lazyxeon merged commit 5bde0d8 into main Oct 18, 2026
35 checks passed
@lazyxeon
lazyxeon deleted the cursor/determinism-saves-b3de branch October 18, 2026 14:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

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-18T14:45:04.729786Z 71e0ffc 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.

@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: 71e0ffc5b2

ℹ️ 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 on lines +539 to +540
if checkpoint.edits.is_empty() && checkpoint.demolition == self.ground.demolition_log() {
return Ok(Vec::new());

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 Rebuild terrain when restoring an empty checkpoint

When a pristine checkpoint is loaded into the already-running Greybox after place_sphere or another edit that does not change the demolition log, this condition is true even though self.ground.edits is nonempty. Returning here skips restore_dug and sync_dirty, so the loaded game retains the newer voxel edits, meshes, and collision bodies instead of restoring the saved terrain; only skip rebuilding after also confirming the current edit log is empty/equivalent. .github/copilot-instructions.mdL32-L32

Useful? React with 👍 / 👎.

.then_with(|| left.1.event_type.cmp(&right.1.event_type))
.then_with(|| left.1.data.cmp(&right.1.data))
});
rows.into_iter().map(|(_, event)| event).collect()

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 Preserve per-entity replay targets

When more than one entity owns a CReplayState, this conversion discards the entity ID after sorting, so the saved metadata cannot associate events with their original actors. start_replay then returns one flattened CReplayState, and apply_replay_event writes every due health event to whichever entity carries that state, causing multi-actor replays to produce incorrect health state; persist a target identifier and remap it during restoration instead of dropping it here. .github/copilot-instructions.mdL40-L40

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants