Skip to content

Hoist magic numbers and file-local constants to OpticsLabConstants - #76

Merged
veillette merged 2 commits into
mainfrom
cursor/hoist-constants-f33a
Jul 23, 2026
Merged

veillette merged 2 commits into
mainfrom
cursor/hoist-constants-f33a

Conversation

@veillette

@veillette veillette commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Continues the OpticsLab constants-hoisting work by moving remaining semantic magic numbers and duplicated file-local constants into OpticsLabConstants.ts (and wiring model-layer aliases in OpticsConstants.ts).

Already-defined constants now used at call sites

  • Glass defaults: DEFAULT_REFRACTIVE_INDEX / DEFAULT_CAUCHY_B (Glass, SlabGlass, HalfPlaneGlass)
  • Light-source / splitter ctor defaults: beam/arc/single-ray/point brightness, beam-splitter transmission
  • PIXELS_PER_METER in RayTracer convergence math (was bare / 100)
  • APERTURED_MIRROR_MAX_APERTURE_FRACTION in apertured-mirror view
  • FALLBACK_RAY_WAVELENGTH_NM for canvas/SVG wavelength fallbacks (was 550)
  • Query params: grid spacing, max ray depth startup default, ray-stub length bounds
  • Font / stroke: FONT_11PX, HANDLE_LINE_WIDTH

Newly centralized constants

  • Slider ranges/deltas for prisms, dimensional glass, gratings, fiber core fraction, beam splitter, element angle, brightness, refractive index
  • Observer / selection / image-marker / track / spatial-index / detector / fiber spline parameters
  • LENGTH_DEGENERATE_M, MAX_HISTORY_SIZE, DETECTOR_MAX_HITS, QUERY_DEFAULT_MAX_RAY_DEPTH, grating duty-cycle default
  • Wavelength aliases: GREEN_WAVELENGTH → beam/grating defaults; CONT_SPECTRUM_DEFAULT_WL_MIN_NMWAVELENGTH_MIN_NM
  • OpticsConstants aliases PIXELS_PER_METER / BRIGHTNESS_MAX / DEFAULT_RAY_DENSITY

Cleanup

  • Removed unused RayStubsProperty.ts (superseded by per-screen ViewOptionsModel)
  • Point-source ctor default aligned to DEFAULT_POINT_SOURCE_BRIGHTNESS (0.6), matching the factory
  • Exclude CI audit.json from Biome (and gitignore it) so npm run lint matches the GitHub workflow order: security-audit → lint → check

Verification (same as Baton CI)

  • npm audit … > audit.json then npm run lint — pass
  • npm run check — pass
  • npm test — 413 tests pass
Open in Web Open in Cursor 

Wire constructors, query params, edit-panel ranges, and views to the
central constant registry; alias wavelength/scale duplicates; remove
the unused RayStubsProperty singleton leftover.
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

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

Scanned Files

None

Baton's security-audit step writes audit.json before npm run lint;
Biome was failing on that ephemeral artifact's formatting.
@veillette
veillette marked this pull request as ready for review July 23, 2026 19:13
@cursor

cursor Bot commented Jul 23, 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 merged commit 479f1fb into main Jul 23, 2026
8 checks passed
@veillette
veillette deleted the cursor/hoist-constants-f33a branch July 23, 2026 19:13
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