Repository navigation
engine: refuse negative indices instead of targeting element 0 - #1793
Merged
echelon merged 1 commit intoOct 15, 2026
Merged
Conversation
`version.*`, `pointColor.delete` and `redeye.catchlight`/`redeye.delete` parsed `index` with `f64_req(..)? as usize`. Rust's float-to-int cast saturates, so `index: -1` became 0 and the bounds checks never saw a negative: a caller sending `index: -1` silently deleted, restored or renamed version 0 (or the first point-colour sample / red-eye correction) and got `ok` back. `history.restore` already guards this and `spot_index` uses `as_u64`. New `index_req` helper in `cmd/mod.rs` (the same finite, non-negative guard) is used by the five sites. Behaviour for valid indices is unchanged. Regression test `negative_indices_are_refused` creates a version, then asserts `version.delete/restore/rename` with `index: -1` error and version 0 is untouched (before the fix the first one deletes it).
midasmatterhorn
force-pushed
the
fix/engine-negative-index
branch
from
October 14, 2026 20:13
c32a799 to
ea826b1
Compare
bogusyogi
added a commit
to Orthic-Labs/ember
that referenced
this pull request
Oct 15, 2026
…1793) Applied from storytold/lightcraft PR storytold#1793 (open upstream, not yet merged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thank you @midasmatterhorn! This landed on main in integration batch 36 (#1843). If you haven't already, please join our Discord: https://discord.gg/artcraft. We'd love to have you there. |
Contributor
Author
|
Appreciate it! |
This was referenced Oct 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
version.delete,version.restore,version.rename/version.update,pointColor.deleteandredeye.catchlight/redeye.deleteparseindexwithf64_req(..)? as usize; Rust's float-to-int cast saturates, soindex: -1becomes 0 and thei >= lenchecks never see a negative. A caller over the control channel, MCP or CLI sendingindex: -1silently deleted, restored or renamed version 0 (or the first point-colour sample / red-eye correction) and gotokback.history.restorealready guards withis_finite() && i >= 0.0andspot_indexusesas_u64; a newindex_reqhelper applies the same guard to the five sites, with behaviour for valid indices unchanged. Regression testnegative_indices_are_refusedcreates a version and asserts the threeversion.*commands withindex: -1return an error and version 0 is untouched — before the fix the first call deletes it.Partially addresses #1740 (finding 4, negative index). Targeted tests green locally;
cargo xtask cileft to the project runners.