Branch Wrap Handoff (2026-02-08)¶
This file is the handoff for wrapping feat/rng and continuing differential
investigation in a fresh branch after merge.
Why wrap now¶
- Current branch contains useful verifier tooling, capture improvements, and concrete root-cause evidence.
- Remaining divergence work is now mostly math/precision parity and will be invasive; it is cleaner to continue from a new branch after merge.
Confirmed finding to carry forward¶
- First stable root cause is precision drift in creature movement math:
native x87 extended precision (
fsin/fcos/fpatan) plus float stores vs Pythonfloat64math. - That drift flips a borderline collision, which consumes different presentation RNG and permanently desynchronizes the single shared RNG stream.
- The later gameplay mismatch is a downstream consequence of earlier RNG drift, not an isolated reward bug.
Reference analysis:
- docs/frida/rng-divergence-root-cause.md
Non-negotiables for next branch¶
- Treat native math precision/rounding behavior as first-class parity scope.
- Keep one RNG stream for gameplay and presentation (native-like).
- Keep headless verification first-class while still executing RNG-consuming presentation command generation.
- Keep capture defaults full-detail and unlimited enough to avoid losing rare edge cases.
- Keep docs/session ledger updated on every recording-driven fix.
- Use Ghidra decompile as authoritative when behavior is ambiguous.
Target architecture direction¶
- Input stream -> deterministic simulation step -> presentation command stream.
- The same simulation step powers:
- interactive play (commands rendered + SFX played),
- replay playback (inputs from file),
- headless verification (commands discarded).
- Presentation command generation must stay in deterministic step order so RNG consumption matches native regardless of render mode.
Suggested next-branch execution plan¶
- Add precision-parity primitives for sim-critical math.
- Explicit float32 boundaries where native stores float fields.
- Controlled trig/atan path that mimics native rounding behavior as closely as practical.
- Apply parity primitives in creature movement/heading update paths first.
- Re-run divergence report on latest capture and confirm whether first shortfall tick moves or disappears.
- If still diverging, use focus trace to isolate next earliest RNG shortfall and patch in small behavior-accurate increments.
- Keep each fix and each capture-script change in separate commits.
Verifier/capture quality requirements¶
- Divergence report should keep producing:
- first mismatch,
- first pre-focus RNG shortfall,
- dominant native caller buckets,
- short run narrative (bonus/weapon/perk/level state highlights).
- Capture script defaults should avoid sample caps that can hide rare branches.
- Add focused telemetry only when needed, but do not reduce baseline capture detail.
Merge handoff checklist¶
- Merge
feat/rng. - Start new branch from updated
master. - Re-run baseline divergence command on current capture.
- Append a new entry in
docs/frida/differential-sessions.mdfor the first post-merge run. - Continue until either:
- full verification passes, or
- a concrete capture omission is proven and script updates are required.