Skip to content

Fix brush restore, border digs, and cached sword damage - #343

Merged
lazyxeon merged 4 commits into
mainfrom
cursor/aravath-restore-brush-b844
Oct 16, 2026
Merged

lazyxeon merged 4 commits into
mainfrom
cursor/aravath-restore-brush-b844

Conversation

@lazyxeon

@lazyxeon lazyxeon commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Description

Review fixes from merged #329 and #275, rebased onto main 10757c81 (#330).

  • Brush history. restore_edits rebuilt voxels and left DestructionWorld on the live log. A dig after load used that stale history. Checkpoints now store persist_bytes under demolition. restore_dug replays that log, rebinds ColumnFns, and loads the brushed chunks before the next dig. An empty or pre-log save starts a fresh column world. dig_after_load_matches_the_continuous_run digs, saves, loads, digs, and matches the no-load state_hash.
  • Chunk border. apply_brush_now loaded only the centre chunk, so surface_y past the border ignored the brush. It now loads every chunk in (origin ± radius).div_euclid(CHUNK_EXTENT) before tick. brush_across_a_chunk_border_lowers_both_columns digs at x=31 with radius 3 and checks column 32.
  • Sword hit. run_aravath_slice built an ECS app, parsed the table, and ticked a destruction world on every connecting hit to read a constant sword_hp. Greybox::new and Greybox::open run it once. Each hit applies that remainder (40 - sword_hp, still 25) and the cached cover result.

The greybox golden stays b6a9d5a2c5da28a6 from #330. replay_matches_golden_hash passed on this rebase. Required replay cases are unchanged, including local_sim. The destruction replay case is unchanged: apply_brush_now is not on that path, and FlatColumnBase stays the unbound terrain. No new assets. No GPU sim.

Do not merge.

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?
  • Does this PR introduce new network communication or modify existing protocols? No.

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 

@coderabbitai

coderabbitai Bot commented Oct 16, 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: 28edcdfc-7170-45c9-a213-17a60c695e10
  • 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/aravath-restore-brush-b844 branch 2 times, most recently from 4c6ba64 to 50b92a1 Compare October 16, 2026 18:39
cursoragent and others added 4 commits October 16, 2026 19:41
A checkpoint now stores the demolition command log and replays it before the next dig. apply_brush_now loads every chunk in the brush radius. The greybox runs run_aravath_slice once at startup and reuses that sword remainder. The greybox golden and the destruction replay case stay put.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
The greybox golden stays b6a9d5a2c5da28a6. local_sim remains a required replay case.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/aravath-restore-brush-b844 branch from 50b92a1 to c929b78 Compare October 16, 2026 19:42
@lazyxeon
lazyxeon marked this pull request as ready for review October 16, 2026 20:55
@lazyxeon
lazyxeon merged commit fb1c8ec into main Oct 16, 2026
35 of 38 checks passed
@lazyxeon
lazyxeon deleted the cursor/aravath-restore-brush-b844 branch October 16, 2026 20:55
@cursor cursor Bot mentioned this pull request Oct 16, 2026
11 tasks done

@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: c929b78872

ℹ️ 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 +223 to +226
let count = self.log.len();
for index in 0..count {
if let CommandKind::Brush(brush) = self.log[index].kind {
self.load_brush_chunks(brush);

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 recent chunk histories while reloading brushes

When a save contains brushes in more than four distinct chunks, restore replay initially leaves the four most recent histories in Terrain's fixed slot array, but this oldest-to-newest loop then loads evicted older chunks and slot_mut overwrites slot zero. When the loop reaches the displaced recent chunk, load rebuilds an empty slot because it does not replay that chunk's commands. Consequently, loading a save and digging again in a recently edited chunk produces a different depth than uninterrupted play; reconstruct the loaded slots while replaying their brush commands rather than loading every logged span afterward.

Useful? React with 👍 / 👎.

Comment on lines 209 to 211
pub fn apply_brush_now(&mut self, brush: crate::command::Brush) -> Result<(), CommandError> {
let chunk = (
brush.origin[0].div_euclid(crate::octree::CHUNK_EXTENT),
brush.origin[2].div_euclid(crate::octree::CHUNK_EXTENT),
);
self.terrain.load(chunk);
self.load_brush_chunks(brush);
self.enqueue(DestructionCommand {

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 Validate brushes before traversing their chunk span

For a brush that enqueue will reject, this call still traverses and rebuilds its entire claimed span first. For example, a sphere with radius = u16::MAX is invalid under MAX_BRUSH_CELLS but causes roughly 16 million terrain.load calls before returning BrushTooLarge; LogFull similarly returns only after mutating the loaded-slot set. Validate the brush and command-log capacity before loading any chunks so rejected input cannot stall or alter the world.

Useful? React with 👍 / 👎.

Comment on lines +231 to +237
fn load_brush_chunks(&mut self, brush: crate::command::Brush) {
let extent = crate::octree::CHUNK_EXTENT;
let radius = i32::from(brush.radius);
let x0 = brush.origin[0].saturating_sub(radius).div_euclid(extent);
let x1 = brush.origin[0].saturating_add(radius).div_euclid(extent);
let z0 = brush.origin[2].saturating_sub(radius).div_euclid(extent);
let z1 = brush.origin[2].saturating_add(radius).div_euclid(extent);

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 Compute loaded bounds from the brush shape

Valid box brushes are bounded by half_extents, not radius, but this helper always derives both horizontal bounds from radius. For example, a box centered at x=29 with radius 1 and x half-extent 4 edits across x=32, while only chunk 0 is loaded; the brush is recorded in chunk 1 but surface_y ignores it because that slot remains unloaded. Use the relevant x/z half-extents for boxes and include them for the box portion of capsules.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T21:17:29.517352Z c929b78 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.

lazyxeon added a commit that referenced this pull request Oct 16, 2026
Status pages said every connecting hit calls run_aravath_slice. Greybox
startup runs it once, and each hit reuses that sword_hp. A checkpoint
stores the demolition command log, and the brush loads every chunk its
radius touches. The golden and the sixteen required cases are unchanged.

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