M4: sector-limited circle-segment ray test #64

Closed
opened 2026-11-20 22:31:44 +01:00 by SirStone · 1 comment
Owner

Part of #63

Goal

Each fan ray tests only the 64-gon segment in its own sector. Same polygon, fewer tests.

Acceptance criteria

  • Polygons byte-identical (geometry, vision, leak, doors, oneway, markers green unchanged)
  • A mutation that tests the wrong sector fails >= 1 test
  • Bench recorded in results/bench.log
  • Standing gate: full devbox run test green on a clean checkout, no test weakened or skipped, and the behaviour above proven at the seam(s) listed under "Proven at".

User stories covered

  • 66 — As the table, I want the vision result to stay identical while each ray tests less, so that the phone gate is not lost to server CPU.

Proven at

geometry + vision unit tests, bench, existing harnesses

Notes

  • Size: S (about one agent session, ~100K tokens). Lane: S (server, serial).
Part of #63 ## Goal Each fan ray tests only the 64-gon segment in its own sector. Same polygon, fewer tests. ## Acceptance criteria - [ ] Polygons byte-identical (geometry, vision, leak, doors, oneway, markers green unchanged) - [ ] A mutation that tests the wrong sector fails >= 1 test - [ ] Bench recorded in `results/bench.log` - [ ] Standing gate: full `devbox run test` green on a clean checkout, no test weakened or skipped, and the behaviour above proven at the seam(s) listed under "Proven at". ## User stories covered - 66 — As the table, I want the vision result to stay identical while each ray tests less, so that the phone gate is not lost to server CPU. ## Proven at geometry + vision unit tests, bench, existing harnesses ## Notes - Size: S (about one agent session, ~100K tokens). Lane: S (server, serial).
SirStone added the ready-for-agentenhancement labels 2026-11-20 22:31:44 +01:00
SirStone added a new dependency 2026-11-20 22:31:45 +01:00
SirStone added a new dependency 2026-11-20 22:31:46 +01:00
Author
Owner

Implemented and merged to main as d192381 (results 97f618c), rebased on 1dff520.

What changed — visibilityPolygon now tests only the 64-gon chord of each ray's angular sector, plus the neighbouring chord when the ray sits on a sector vertex (both chords meet there). Walls are still tested as before. The rayHit #26 collinear/radial branch from 414bb03 is untouched.

Byte-identical proof — tests/tgeometry.nim keeps the old all-segments fan as a test oracle (referencePolygon, exact float equality, not tolerance) and asserts visibilityPolygon == referencePolygon over:

  • all 336 prototype corpus polygons (door states replayed);
  • the seed scene, every token, closed/open doors, plus one-way (left/right) and window (sightBarrier:false) variants;
  • 5k sparse (16384) and 5k dense (4096) genScene layouts, same switch variants;
  • the #26 collinear/radial cases (k=0, k=16, 10 deg, grid-snapped), including one-way and window radial walls;
  • random walls with grid-snapped radial additions.

All existing geometry/vision/leak/doors/oneway/markers suites unchanged and green.

Mutation — new a2 in tools/mutation.sh: "a ray tests the next sector's chord" (sector + 1). Full devbox run mutation green; a2 fails 5 bit-identical tests.

Gates — devbox run test green on the rebased tree: Nim suite + 149 node tests, group evidence 16/16.

Bench (results/bench.log, same host, before -> after, 3-run medians):

scene before after
1 poly, prototype 0.028 ms 0.008 ms (3.5x)
1 poly + cells, prototype 0.036 ms 0.015 ms (2.4x)
6 polys, prototype 0.160 ms 0.049 ms (3.3x)
1 poly, 5k sparse 0.062 ms 0.033 ms (1.9x)
1 poly, 5k dense 1.085 ms 0.708 ms (1.5x)

Rebased-run log: 0.009 / 0.016 / 0.053 / 0.035 / 0.737 ms; targets PASS.

Implemented and merged to `main` as d192381 (results 97f618c), rebased on 1dff520. **What changed** — `visibilityPolygon` now tests only the 64-gon chord of each ray's angular sector, plus the neighbouring chord when the ray sits on a sector vertex (both chords meet there). Walls are still tested as before. The `rayHit` #26 collinear/radial branch from 414bb03 is untouched. **Byte-identical proof** — `tests/tgeometry.nim` keeps the old all-segments fan as a test oracle (`referencePolygon`, exact float equality, not tolerance) and asserts `visibilityPolygon == referencePolygon` over: - all 336 prototype corpus polygons (door states replayed); - the seed scene, every token, closed/open doors, plus one-way (left/right) and window (`sightBarrier:false`) variants; - 5k sparse (16384) and 5k dense (4096) `genScene` layouts, same switch variants; - the #26 collinear/radial cases (k=0, k=16, 10 deg, grid-snapped), including one-way and window radial walls; - random walls with grid-snapped radial additions. All existing geometry/vision/leak/doors/oneway/markers suites unchanged and green. **Mutation** — new `a2` in `tools/mutation.sh`: "a ray tests the next sector's chord" (`sector + 1`). Full `devbox run mutation` green; `a2` fails 5 bit-identical tests. **Gates** — `devbox run test` green on the rebased tree: Nim suite + 149 node tests, group evidence 16/16. **Bench** (`results/bench.log`, same host, before -> after, 3-run medians): | scene | before | after | |---|---|---| | 1 poly, prototype | 0.028 ms | 0.008 ms (3.5x) | | 1 poly + cells, prototype | 0.036 ms | 0.015 ms (2.4x) | | 6 polys, prototype | 0.160 ms | 0.049 ms (3.3x) | | 1 poly, 5k sparse | 0.062 ms | 0.033 ms (1.9x) | | 1 poly, 5k dense | 1.085 ms | 0.708 ms (1.5x) | Rebased-run log: 0.009 / 0.016 / 0.053 / 0.035 / 0.737 ms; targets PASS.
Sign in to join this conversation.