sots-engine/src/shim
alex 496a5124c9 Z: measure the strategic RNG, do not assume it
The turn's RNG cost has never been measured end to end. combat-done-tail.md
found two draw sites in OnAllCombatDone_Tail that nothing models and that both
run before the autosave, so a reimplementation that reproduces both ProcessTurn
functions exactly still diverges the first turn a node line expires.

RngLedger recovers an ABSOLUTE WORD POSITION from (mt[624], left) alone, by
indexing the forward-only chain of blocks the twist generates. Word deltas
between any two observations are then exact -- across twists, across NextInt
rejection loops, and across draws nobody hooked. That last point is not
theoretical: the image has four draw entry points, one of which (NextUInt
0x004f7670) appears in no previous lane's primitive set, plus inlined draws in
twelve functions. A primitive-counting hook would have undercounted silently.

Six nested trace hooks bracket one End Turn between the two autosaves and
attribute the words: the two turn drivers, the two tail phases that can draw,
and ProcessNodeSpaceTravel because it runs twice a turn. NodeLineDecay carries
a real model -- one word per expired node line under NodePath::RemainingLife --
so compare mode checks the count rather than reporting it.

Corrections from the instruction stream, both load-bearing:
  * StrategyHost::Autosave is ret 8, not ret 4, and returns the std::string* in
    EAX. A void-returning hook would have dropped it at both call sites.
  * node-line decay's 0x20000-fleet skip runs AFTER the Chance(0.5f) call, not
    before, so it cannot change the draw count -- combat-done-tail.md reads as
    if it gated the roll.

fpu.sample_turn releases StrategyServer::ProcessTurn, which the fpu sampler and
this ledger both want and MinHook grants to one of them. Default on: no
existing run changes behaviour.

Host ctest 37/37; shim cross-built on CT111; clean-room check OK.
2026-09-08 09:16:24 -04:00
..
hooks Z: measure the strategic RNG, do not assume it 2026-09-08 09:16:24 -04:00
trace harness: compile-time Coverage on every descriptor, guard regions, replace-mode records; audit of 23 undeclared side effects 2026-09-08 01:28:35 -04:00
binkw32.def m0: binkw32 proxy shim, minhook, trace hook on Application::Initialize; build/deploy tooling 2026-09-07 17:22:15 -04:00
fpu_force.cpp Z: measure the strategic RNG, do not assume it 2026-09-08 09:16:24 -04:00
fpu_force.h shim: force and verify the x87 control word around the turn gate 2026-09-08 05:09:16 -04:00
main.cpp Z: measure the strategic RNG, do not assume it 2026-09-08 09:16:24 -04:00
shim.cfg b3: research hook + RNG-snapshot compare design; fix draw mapping to y/(2^32-1), NextInt inclusive, float32 odds, spend floor, decay constants 2026-09-07 23:14:08 -04:00
shim.cfg.b4compare b4: colony + movement hooks; 22 formula corrections (growth curve has no capacity term, range margin +0.05f, ties-to-even rounding); 3 verified signatures 2026-09-08 00:57:55 -04:00
shim.cfg.b4scout b4: colony + movement hooks; 22 formula corrections (growth curve has no capacity term, range margin +0.05f, ties-to-even rounding); 3 verified signatures 2026-09-08 00:57:55 -04:00
shim.cfg.b4trace b4: colony + movement hooks; 22 formula corrections (growth curve has no capacity term, range margin +0.05f, ties-to-even rounding); 3 verified signatures 2026-09-08 00:57:55 -04:00
shim.cfg.fpu1a7f shim: force and verify the x87 control word around the turn gate 2026-09-08 05:09:16 -04:00
shim.cfg.fpu007f shim: force and verify the x87 control word around the turn gate 2026-09-08 05:09:16 -04:00
shim.cfg.fpu027f shim: force and verify the x87 control word around the turn gate 2026-09-08 05:09:16 -04:00
shim.cfg.fpu127f shim: force and verify the x87 control word around the turn gate 2026-09-08 05:09:16 -04:00
shim.cfg.fpu137f shim: force and verify the x87 control word around the turn gate 2026-09-08 05:09:16 -04:00
shim.cfg.fpuoff shim: force and verify the x87 control word around the turn gate 2026-09-08 05:09:16 -04:00
shim.cfg.recapb1 recapture: golden traces with guards on the live game 2026-09-08 03:04:34 -04:00
shim.cfg.recapb3 recapture: golden traces with guards on the live game 2026-09-08 03:04:34 -04:00
shim.cfg.recapmisc recapture: golden traces with guards on the live game 2026-09-08 03:04:34 -04:00
shim.cfg.recaptrace recapture: golden traces with guards on the live game 2026-09-08 03:04:34 -04:00
shim.cfg.tturn T: hook for Game::ServerPlayer::ProcessTurn, with the prediction committed first 2026-09-08 08:08:47 -04:00
shim.cfg.tturncmp T: hook for Game::ServerPlayer::ProcessTurn, with the prediction committed first 2026-09-08 08:08:47 -04:00
shim.cfg.zledger Z: measure the strategic RNG, do not assume it 2026-09-08 09:16:24 -04:00