Skip to content

fix: harden ray tracer against unphysical rays - #80

Merged
veillette merged 1 commit into
mainfrom
claude/codebase-review-j0q12h
Jul 27, 2026
Merged

fix: harden ray tracer against unphysical rays#80
veillette merged 1 commit into
mainfrom
claude/codebase-review-j0q12h

Conversation

@veillette

Copy link
Copy Markdown
Collaborator

Summary

  • Cull NaN-brightness and zero/non-finite direction rays in RayTracer (IEEE-754-safe brightness check).
  • Type fuzz env consts; add regression tests.

Test plan

  • npm test (415 passed)
  • npm run check

Made with Cursor

- 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
@veillette
veillette merged commit 3dddd66 into main Jul 27, 2026
@cursor

cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown

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.

@veillette
veillette deleted the claude/codebase-review-j0q12h branch July 27, 2026 19:07
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants