fix: harden ray tracer against unphysical rays - #80
Merged
Conversation
- RayTracer.processRayEntry: cull rays with non-finite brightness. The brightness cutoff now uses `!(b >= min)` so a NaN brightness (which a degenerate element could produce) is dropped too — `NaN < min` is false in IEEE-754, so the previous `<` check let a NaN ray propagate uncapped to maxRayDepth. Non-finite brightness contributes 0 to the truncation total so it cannot poison the accumulator. - RayTracer.processRayEntry: cull rays with a zero-length or non-finite direction at the tracer boundary. normalize() returns the zero vector for a zero input, so a degenerate element (e.g. a SegmentMirror with p1 === p2) could feed a zero direction into the tracer and emit a zero-length or NaN segment. Centralizes the guard the normalize() contract previously left to every caller. - tests/review-regressions.test.ts: add coverage for both guards via a minimal stub source, plus a control that a normal ray still traces. - tests/fuzz/fuzz.spec.ts: add explicit string types to FUZZ_SEED/RATE/ POINTERS env consts, clearing the biome useExplicitType warnings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PoybPnXW2tmUCtDfksrXJg
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Summary
RayTracer(IEEE-754-safe brightness check).Test plan
npm test(415 passed)npm run checkMade with Cursor