Repository navigation
engine-size-cap: fix ENGINE-11 size cap bypass - #36
Merged
Merged
Conversation
kridaydave
force-pushed
the
fix/pr-14-engine-size-cap
branch
from
November 8, 2026 18:22
0a7da67 to
d2df1ca
Compare
kridaydave
force-pushed
the
fix/pr-14-engine-size-cap
branch
from
November 8, 2026 18:51
d2df1ca to
eead4c5
Compare
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.
Bugs
What was wrong
MAX_AST_PARSE_SIZE_BYTES was only checked in parse_source (src/engine/mod.rs:867), while the 2-way and 3-way top-level checks called squash_ws(without_defs(...)) unconditionally. without_defs allocates vec![false; bytes.len()], a kept byte copy, and squash_ws another string, so oversize files still incurred O(n) multi-copy allocations despite the DoS guard.
Fix
Added top_level_changed() helper: under the cap it keeps the existing blanked, whitespace-insensitive comparison; if either side exceeds MAX_AST_PARSE_SIZE_BYTES it falls back to a plain byte comparison with no new allocations. Both diff paths now call it. Regression test test_top_level_changed_oversize_uses_byte_comparison covers identical oversize files (silent), changed oversize files (reported), and the whitespace-only fallback (reported, where the old squash path was silent).
Verification
CI green (fmt, clippy, tests, release build, adjudication) + the regression test added