Files

4.3 KiB

Review — feature/sun

Adversarial self-review (CLAUDE.md §5.3). Analysis: features/sun.md. Reviewed 2026-11-01 on Node 22.11.0, Windows 10. There is no PR: the only remote is Gitea.

Gates — counts, not exit codes

Gate Result
pnpm lint exit 0, the engine purity rule included: src/sun/ reads no clock, no network, no device
pnpm typecheck exit 0, scripts/fetch-sun-golden.ts included
pnpm test 236 passed: schema 15, content 47, art-prep 56, engine 102 (+50 sun), ui 16
pnpm test:e2e / test:offline 7 passed / 1 passed. The app is unchanged: nothing imports the sun yet

Golden. 26 published days in 6 cities match the U.S. Naval Observatory's tables within 2 minutes on the city's own clock, for sunrise, solar noon and sunset. Two more days, Tromsø's polar day and night, match the table's no event. The table's clock offset agrees with the IANA zone database on all 28 days.

Stable. The property tests ran three times with fresh seeds, 50 of 50 each time.

Bug drills — each put back once, in src/sun/sun.ts

Put back Result
No refraction: the horizon at 90° instead of 90.833° CAUGHT: 27 failures, every golden day
No equation of time CAUGHT: 25 failures
Polar day and polar night swapped CAUGHT: 8 failures
No local-day correction of solar noon CAUGHT: 2 failures (Kiritimati, D8)
The UTC date derived back from the noon instant (finding 2's bug) CAUGHT: 3 failures (properties near 180°)

Findings

# Area Finding Resolution
1 Correctness The published table for Reykjavík on 21 June lists a sunset at 00:04. That is the previous evening's sunset. A naive "events within the calendar day" design would tell a player in Reykjavík that tonight's sunset was 00:04 this morning. By design (D2): today's sunset is the one after today's solar noon. Tested: it falls on 22 June, local.
2 Correctness The first draft derived the UTC date back from the noon instant. Near 180° the noon falls on the next UTC date, which would move sunrise and sunset by a whole day. Spotted on re-reading, before any test ran. Fixed: the date is passed in. Drill 5 shows the property tests now catch it.
3 Correctness fast-check found a day with no solar noon: at 179.9° W on UTC, noon crosses midnight in late December. Defined (D8) and pinned by a unit test. No real zone is twelve hours off the sun, so the properties use zones that follow longitude.
4 Correctness Near the edge of polar day or night the hour angle can leave its range during refinement. Clamped (D5). Accuracy on those few days is not measured: no golden day sits at the edge. Said here and in not verified.
5 Soul Where the sun never sets or never rises, "every day at sunset" would leave a person with no invitation for months. Fixed (D4): the lowest light in polar day, noon twilight in polar night. The author confirmed the second on 2026-11-01 (Q10).
6 Soul A DST change could make the game look as if the sunset "moved" because of the player, or move the rose's sentence to another day. The engine works in instants (D3); the day comes only from localDay. Tested on all six DST days in the fixture.
7 Privacy The golden script calls a US government API with coordinates. Only by hand, only for six public city centres, never in a test or the app. The tests read the recorded file.
8 Privacy A sunset time narrows down where someone is. It never leaves the device: the module has no I/O and the purity rule forbids any. Phase 4 must never send it (CLAUDE.md §4).
9 Test honesty The DST tests read the clock with Intl in the test, which is also what localDay uses. A bug in the platform's zone data would hide in both. Cross-checked: the USNO table states each day's offset independently, and a test asserts the zone database agrees on all 28 days.

What was not verified

  • Accuracy on the days right at the edge of polar day or night (finding 4).
  • Latitudes above 72° on ordinary days, other than Tromsø's 69.6°.
  • Years far from 2026. The method holds for centuries, but only 2026 is tested.
  • The app: choosing a city, the time-zone guess, and showing the time are later in Phase 1 (G1.2).