CLAUDE, 14 Sep 2026 (later)
THE HARNESS NOW REACHES GAMEPLAY WITHOUT A HUMAN. SIX RANKED GAPS ARE CLOSED.
THE THING THAT COST THE MOST TIME WAS A STALE ARTIFACT, AND THE AUDIO
"REGRESSION" I SPENT AN HOUR ON WAS THE MAC'S AUDIO DAEMON.

Supersedes CLAUDE_HANDOVER_2026-09-14_THE_RENDERER_IS_FINE_AND_THE_HARNESS_IS_NOT.txt.
Read sections 1, 4 and 5. Section 5 is the one that will save you time.


0. STATE OF PLAY
================
Tree dirty, nothing committed by me beyond what is described here.
ctest 24/26 -- the 2 failures are the same deliberate pair as before (05e0465).
Was 21/23; three tests added, all passing.

The title was REGENERATED and REBUILT this session. That matters (section 2).

    diagnostics/jsrf_first_fault/pad/gameplay.pad     skates, jumps, sprays
    diagnostics/jsrf_first_fault/play_scripted.sh     light runner + 3 verdicts
    diagnostics/jsrf_first_fault/test_pad_schedule.py pad lint, in ctest


1. WHAT GOT DONE, AGAINST THE OLD RANKED LIST
==============================================
All of ACCURACY_GAPS.md's "suggested order" items 1, 2 and 4, plus §8:

  * BUILD FLAGS (§4). -fwrapv on the title; -fno-strict-aliasing TREE-WIDE, not
    just on generated code -- kernel_bridge.c, xbox_memory_layout.c and the two
    nv2a pushbuffer files reach guest memory through the same MEM8/16/32/MEMF
    macros. -w replaced by -Wall minus four generator-inherent classes, NOT
    dropped: dropping it outright is 11318 unused-label and 742 unused-variable,
    which nobody reads. Measured yield of the chosen set over the whole gen
    tree: 440 -Wuninitialized and 11 -Wmacro-redefined, and nothing else.
  * KeSynchronizeExecution (§6) and NtProtectVirtualMemory (§7) bridged.
    CONFIRMED LIVE by a run first -- both appear as "[KERNEL] WARNING: no bridge
    for ordinal N" in a real gameplay log, so neither was a static reading.
  * fistp -> RECOMP_F2I_* (§5), with new 16- and 64-bit helpers.
  * Signed conditions vs OF (§8).

Three of those sections were WRONG in ways worth knowing; see ACCURACY_GAPS.md,
which now records each correction inline. Briefly: §5's "172 callers" is 432
calls across 129 functions and there are only SIX fist/fistp sites in the whole
image; §8's claim was true of `add` only, because `sub` already went through a
reconstruction that is SF!=OF at 32 bits; §6's "returns STATUS_SUCCESS" is a
BOOLEAN export, so the guest got a fabricated FALSE, not a success.


2. THE MOST EXPENSIVE BUG WAS NOT A BUG, IT WAS A STALE ARTIFACT
=================================================================
Dropping -w surfaced 440 `PUSH32(esp, ebp)` reading an indeterminate `ebp`.
Real: at -O2 that is poison the compiler may propagate, not stack residue.

But translator.py ALREADY FIXED IT, in b1f0531, at 18:44 on 13 Sep. The gen
tree in build-macos was generated at 16:59 the same day -- one hour and
forty-five minutes earlier. So the fix existed, and every binary measured since
carried all 440 anyway, because nobody regenerated.

REGENERATING CLEARED THEM: 496 declarations now `uint32_t ebp = 0;`, zero
uninitialised, zero -Wuninitialized from the generated title in the build log.

THE LESSON IS THE PROCESS ONE. A translator fix does nothing until the title is
regenerated, and nothing in the build tells you the gen tree is older than the
tool that produced it. If you change tools/recomp, regenerate, or you are
testing yesterday.


3. THE HARNESS NOW REACHES GAMEPLAY
====================================
gameplay.pad + play_scripted.sh. MEASURED: 1408 NtOpenFile, i.e. New Game, with
nobody at the machine. Previously only a human had ever got there.

play_scripted.sh exists because neither existing script could measure gameplay:
play.sh is light but has no schedule; run_scripted.sh has a schedule but turns
on four heavy probes at once, and heavy probes provoke the input-poll stall, so
the measurement measures the probes. This is the first with both.

It prints THREE verdicts, deliberately separate, because conflating them is how
the first version of this lied to me:

    AUDIO   did the host audio device even open      (section 5)
    SCENE   1342 opens = title plateau, 1408 = New Game
    PLAYED  [APU-VOICE] off=, which must be well clear of 0

FIRST VERSION FAILED INSTRUCTIVELY, and this is the part to keep. It ran the
full 250 s, fired 186 of 193 events, retired one voice -- and never left the
attract screen. off=1 read as "it played" until the open count was checked. The
cause: it copied moving.pad's boot prefix, which stops pressing START at t=45.5
and therefore gambles on hitting one window, and logo length varies by ten
seconds or more between runs. gameplay.pad now uses new_game.pad's full measured
prefix and starts play at t=80, clear of the last START.

WHAT DECIDES WHETHER IT ARRIVES: not known, and the audio device is NOT it.
Across nine runs the boot reaches New Game roughly two times in five. Always
read the SCENE verdict before using a run; a title-plateau run produces a full
log, a full pad trace and plausible audio counters, and means nothing.

I got this wrong three times in a row and the sequence is the useful part:

    1 run    "the one success had a dead audio device"   a hunch
    2 v 2    forced off twice reached New Game, live     written up as a
             device twice did not                        CLEAN SEPARATION
    n = 6    forced off 2 of 4, live device 0 of 2       no evidence at all

0/2 against 2/4 is what one ~40% rate looks like. Anything built on the middle
row -- including "force audio off for non-audio runs" -- was resting on nothing.

THE LEAD THAT DID COME OUT OF IT came from diffing a successful boot against a
failed one instead of running more of them. Both reach the 1342 plateau at
t=36-37, so the failure is NOT slow booting. The difference is the A press: in
the good run the A at t=47 moved it 1342 -> 1344 -> 1408, i.e. that A selected
New Game; in the bad run the A presses at t=39, 47, 55, 63 and 71 each did
nothing. So a group's START,START may be moving off the menu before the group's
own A lands. gameplay.pad now fires bare A presses after the groups stop. One
run, one success, against a baseline that already lands two in five -- untested,
not fixed.

DENSER INPUT IS NOT THE FIX, and this was tried: groups every 4 s to t=118
instead of every 8 s to t=71 still gave 1342. That is the documented masher
plateau, and this project's notes already said not to retune those timings.

TWO CONFOUNDS THAT LOOK LIKE HEALTHY RUNS, both now gated in play_scripted.sh:
  * INPUT-POLL STALL. One run fired 128 of 202 events with a SEVENTY-SIX SECOND
    window in which the guest polled nothing -- while its mean poll interval,
    18.7 ms, matched a healthy run's 18.9 ms, and the schedule still ran to
    completion. No counter we print could see it. The gate reports the largest
    gap between pad events.
  * COREAUDIO FAILING THE DEVICE. Wedges repeatedly on this machine, including
    mid-session, and makes a run's audio figures void while se= stays healthy.

STILL NOT DONE: the schedule reaches gameplay and then does LITTLE. Best run is
on=22 off=16 idle_trap=19, trapped=184, against a human's on=109 off=103
idle_trap=22371. Whether that is the Corn tutorial gating the player or the
synthetic pad not driving him is UNSETTLED. That is the next job.


4. THE PARSER TRAP THAT WAS DOCUMENTED BACKWARDS
=================================================
Overlapping STICK events on the SAME AXIS do not hand over. xinput_device.c:743
writes a scripted deflection only while the axis is still near neutral:

    if (ev->lx && st->Gamepad.sThumbLX > -4096 && st->Gamepad.sThumbLX < 4096)

so an overlapping event finds the axis at 30000 and is REFUSED; the first event
in FILE ORDER wins until it expires. (The guard is deliberate -- it is what lets
a live controller take over a scripted run.)

moving.pad's header asserted the OPPOSITE, that a later event replaces an
earlier one. It reached the right behaviour anyway because its segments happen
to be adjacent rather than overlapping. Header corrected; test_pad_schedule.py
now asserts it, along with the event-count limit and the post-t=48 START rule
(new_game.pad carries an explicit waiver comment for the one real exception).


5. THE AUDIO "REGRESSION" WAS THE MAC. I LOST AN HOUR TO IT; YOU SHOULD NOT
===========================================================================
A gameplay run read [APU-PACE] gen_hz=0 batches=0 frames=0 against the previous
binary's 46086 / 44571 / 11410176. The sound engine still reported se=405138
rendered subframes, so `se=` looked perfectly healthy.

I called it a regression and suspected the new KeSynchronizeExecution bridge,
which is on the two audio interrupt vectors. WRONG, twice:

  1. The comparison was CROSS-SCENE. The baseline never left the title; the new
     run reached gameplay. This tree's own rule says scene-match before
     believing a number, and I did not.
  2. The actual cause was one line further up the log:

         [APU-SDL] output open failed: CoreAudio error (AudioQueueStart): -66681

     The host audio device never opened. apu_sdl2_init() failed, the APU fell
     back to a waveOut path that does nothing on macOS, and every audio figure
     in the run was void.

PROVED it was the host, not us, by reproducing it in a standalone 12-line SDL2
program linking none of this code -- same error, same minute. It did NOT clear
on its own or after killing every jsrf process. Fix: `sudo killall coreaudiod`.

play_scripted.sh now prints this as the FIRST verdict, before any audio number.

I briefly gated both new bridges behind env switches on the strength of the
wrong diagnosis, then reverted it once the cause was known: the switches were
justified by a measurement error, and leaving them in would have left a false
claim in a comment in kernel_bridge.c. Both ordinals are routed unconditionally.


6. WHAT ctest CANNOT SEE
=========================
The suite passed 24/26 throughout the whole audio episode. NO TEST IN THIS TREE
GENERATES AN AUDIO OUTPUT BATCH, so a total audio failure is invisible to it --
just as no test retires a voice, which is why the trap storm survived so long.
If you want audio regressions caught, that is the gap to close.


7. STILL OPEN
==============
  * Make the schedule actually PLAY once it is in (section 3). Highest value.
  * RECOMP_APU_SE_WHILE_TRAPPED=1 remains BUILT, OFF AND NEVER HEARD. The A/B
    harness for it now exists; it needs a run with a working audio device and
    an idle_trap count big enough to have signal. At idle_trap=10 the A/B is
    underpowered and would produce a number that means nothing -- do not run it
    and report it.
  * One gameplay run under -fsanitize=undefined,alignment. Never done. Now
    cheap, because a schedule can reach gameplay unattended.
  * Finish the signed-condition fix: `neg` has BOTH the OF and the width
    defect; adc/sbb, and/or/xor, shl/shr/sar, shld/shrd have the width one.
  * MmSetAddressProtect (ordinal 182) still reaches host mprotect on guest
    memory -- the hazard CLAUDE.md names. LATENT here: 182 is not among the 23
    ordinals JSRF calls in a 250 s run. "Not hot", not "never" -- the kernel log
    budget caps logging.
  * The 15 ms of guest CPU: now profiled AT GAMEPLAY (see STATUS.md). ~93%
    blocked, largest single compute frame is sub_0013B180, a spin on 0x0025EFC0.
    The question is no longer whether it waits but what it waits on.


8. TRAPS PAID FOR THIS SESSION
===============================
  * `pgrep -f "cmake --build"` MATCHES THE WAITER'S OWN COMMAND LINE. I left
    fourteen shells all waiting for each other; no build was running at all.
    Match the real process (`pgrep -x jsrf_first_fault`) or use a marker file.
  * off= above zero does NOT mean a run played. Check the open count first.
  * `se=` in [APU-FRAME] stays healthy when the audio DEVICE is dead. It counts
    rendered subframes, not delivered ones. gen_hz is the one that tells you.
  * Do not change six things and then take one measurement. I changed flags,
    two lifter fixes, two bridges and the gen tree, then ran once -- which is
    why an unrelated host failure took an hour to attribute.

9. THE CONTROLLER WAS NEVER THE BUG, AND ORDINAL 153 WAS
=========================================================
Added late on 14 Sep, after a hand-played session and two read-only reviews.

"CONTROLLER INPUT NOT WORKING" IS THE GUEST'S USB DRIVER DYING. The XPP driver
stops submitting transfers, permanently, at a different moment every run.
Measure it with kernel ordinal 175 (MmLockUnlockBufferPages), already in every
log's histogram:

    reached New Game    ord175 = 12963 23022 27676 30174 72421 72737 73945 74150 74603
    stuck at the title  ord175 = 234 1100 5130 6684 10614

234 transfers in a 300 s run is enumeration and nothing else. That run was
never going to accept a button, however many were pressed.

DO NOT TRUST [PAD-TRACE] OR nonneutral= AS PROOF A PRESS REACHED THE GUEST.
With RECOMP_PAD_INJECT=1 our own host thread calls xbox_InputGetState at 50 Hz,
so a completely deaf guest still produces a healthy-looking trace. Healthy runs
poll at ~172/s, dead ones at EXACTLY 50/s -- the injector alone. This single
instrument produced three confident wrong claims in one session and has been
misleading this project since 10 Sep. "START works but A does not" was the same
illusion: one 20-byte report, one writer, no threshold anywhere -- the STARTs
landed before the driver died and the A presses after it.

ORDINAL 153 WAS THE REGRESSION, MEASURED THREE WAYS:

    yesterday's binary, no 153 bridge   3/3 New Game   ord175 74603 74150 73945
    today WITH 153 on                   1/3 New Game   ord175 27676 10614  5130
    today with 153 off (new default)    3/3 New Game   ord175 30174 72421 72737

Turning it off restores both the success rate and the transfer rate to within
2% of yesterday, and no 153-off run has produced an ADX stall. Three
hand-played sessions froze during a rail grind with it on; none has been played
with it off.

THE MECHANISM IS NOT THE ONE THE BRIDGE'S COMMENT FEARED. Both guest call sites
are inside DPC bodies, so its bounded spin and g_in_isr code never execute --
which makes g_sync_exec_unsynchronised vacuous, and reading "unsynchronised=0"
as "the interlock was always acquired" was wrong. What it really does is switch
on ~41 previously-dead DSOUND functions: the only instruction in the image that
sets a bit in the DSOUND state word [this+0x6FC] is inside the routine the
bridge calls. They run inside bridge_run_isr -> bridge_run_dpc, holding
g_vblank_delivery_active -- the same interlock bridge_device_irq_poll needs, and
that pump is the ONLY thing that runs the guest's USB ISR on vector 1.

So the freeze, the dying controller and the depressed transfer rate are ONE
fault: the interrupt-delivery interlock doubles as the IRQL model, so any guest
ISR or DPC body blocks interrupt delivery process-wide. FIXING THAT IS THE REAL
WORK; defaulting 153 off is a retreat, and it is marked as one in the code.

STILL UNEXPLAINED: verify153-1 reached New Game with ord175=30174, a 2.4x
depression with a healthy outcome, while runs 2 and 3 sat at ~72500. n=1, not
theorised about.

ALSO CORRECTED: RECOMP_USB=1 does nothing on macOS (src/usb/ohci.c has no
callers), so the 11 Sep elimination of both interrupt theories rested on dead
counters and is VOID. The lifter-regression hypothesis is dead too -- the same
binary succeeded and failed 20 minutes apart, and the and/or/xor + jbe/ja idiom
changed today occurs ZERO times in this image.
