Repository navigation
Cap rule combinations before their count can overflow - #1216
Merged
WaylandYang merged 1 commit intoOct 13, 2026
Merged
Conversation
Signed-off-by: Floating-Y <118035379+Floating-Y@users.noreply.github.com>
WaylandYang
approved these changes
Oct 13, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Thank you for the report and the fix together.
The guard is right: the count is checked as it grows, so it stops at the cap before the product can overflow, and exactly 64 still passes. I ran the new test: it passes on the branch, and with the unchecked product put back it panics with attempt to multiply with overflow, as described.
Merging. Thanks again.
4 tasks done
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.
Why
Both rule evaluators multiplied all candidate counts before checking the 64-combination cap. With two candidates in each of 64 conditions, the unchecked
usizeproduct panics in Debug. The default Release profile can wrap that count and bypass the cap; resource exhaustion in the unpatched Release evaluator remains a source-level inference, not a measured result.Closes #1214.
What changes
checked_mulguard in the ordinary and joined paths, stopping when the count overflows or exceeds 64 before building the Cartesian product.cappedreporting, and evaluation of other eligible OR groups. Candidate nonempty checks stay ahead of the cap check.How it was checked
Checked the final source tree now committed as
6dd0d64d95be44b053fc2e2e2d632a668d16c0fc, based ondevat259931ac702623351c2ed4e6487474790e57a6b0, on Windows x86_64 with Rust/Cargo 1.98.1 and Node 22.20.0.attempt to multiply with overflow.cargo fmt --all --checkandgit diff --check: passed.cargo clippy --locked --workspace --all-targets -- -D warnings: passed.pgvector/pgvector:pg16database,cargo test --locked --workspace --no-fail-fastwithRUST_TEST_THREADS=4,UTOPIA_TEST_REQUIRE_DB=1,UTOPIA_TEST_REQUIRE_PDFTOTEXT=1, and the test database configured: 1,515 passed, 0 failed, 6 existing ignored tests. The ignored tests require live services or opt-in process/delivery experiments. The disposable database was removed afterward.cargo test --locked --release -p utopia-reason --quiet: 108 passed, 0 failed, 0 ignored.web/,pnpm install --frozen-lockfileandpnpm build: passed, including the style guard and TypeScript check.The first workspace run at the machine's default 22 test threads had two server test failures:
failed_document_chunks_do_not_become_a_successful_empty_documentreturned Windows directory cleanup error 145, andthe_embedding_gate_is_never_held_beyond_its_ceilingexceeded its elapsed-time bound. Both passed unchanged in isolated reruns, and the complete four-thread run above passed. Neither test, assertion, nor threshold was changed. Linux CI is still required.Before review
git commit -s).