Skip to content

engine-size-cap: fix ENGINE-11 size cap bypass - #36

Merged
kridaydave merged 1 commit into
mainfrom
fix/pr-14-engine-size-cap
Nov 8, 2026
Merged

kridaydave merged 1 commit into
mainfrom
fix/pr-14-engine-size-cap

Conversation

@kridaydave

Copy link
Copy Markdown
Contributor

Bugs

  • ENGINE-11: without_defs allocated full-size copies for oversize files, bypassing the AST size cap

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

@kridaydave kridaydave added the purging Batch purge: bug-fix swarm PRs label Nov 8, 2026
@kridaydave
kridaydave force-pushed the fix/pr-14-engine-size-cap branch from 0a7da67 to d2df1ca Compare November 8, 2026 18:22
@kridaydave
kridaydave force-pushed the fix/pr-14-engine-size-cap branch from d2df1ca to eead4c5 Compare November 8, 2026 18:51
@kridaydave
kridaydave merged commit 5fb9f29 into main Nov 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

purging Batch purge: bug-fix swarm PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant