WIP: feat(modapi): game.flags and flagChanged take a mod's content flags by their ids (":Seen") #2287

Draft
ChloeNow wants to merge 2 commits from ChloeNow/Longshot:feat/modapi-flags-by-id into mod-api
Contributor

Summary

The runtime takes a mod's content by its id (items.grant(":Rupee7")), but its flags only by their game names. A mod
that declares a flag with content.flag({ id: "Seen" }) had to write "M1a2b3c4d.Seen" everywhere it used it: the
FNV-1a hash of its own id, worked out by hand (the flags feature mod computed it with a loop in its script; Magic Singing
hardcoded it). content.md listed this as "not yet".

Now game.flags.get, has and set, and flagChanged's filter, take a mod's content flags by their ids, as the rest
of the runtime takes its content:

flagChanged.on((e) => log.info(`${e.flag}: ${e.value}`), { flag: ":ChestOpened" });   // e.flag: "M37444242.ChestOpened"
flags.set(":ChestOpened", 1);
flags.get("other/mod:Seen");                                                           // another mod's
  • ":id" is the calling mod's own flag, "owner/name:id" another mod's; each is read as the game name content.flag
    makes (the mod's word and the id). A game name is taken as it is.
  • flagChanged tells the flag's game name in e.flag, whichever way the listener named it: the filter is kept as the
    game name when the listener subscribes, so it matches the event.
  • A name with a : that names no flag (no id after it, an id that is not a declaration's) is UnknownNameError;
    has() is false.
  • The test game's flag() and setFlag() take the same names, in the fake game and (through game.flags) in the game.

Read first: modrt_flag_name and modrt_watch_refused in host/modapi/game_events.c, mod_content_flag_ref in
host/mod_content.c, then the three callers in services_game.c and writes.c. The fake game: _flagName in
lib/fake-game.js, services.js, and the kept filter in lib/prelude.js.

Part of #1958's Modding API; targets mod-api. It and #2267 both touch the flags feature mod's tests and the generated
API files, so whichever merges second takes a short rebase. A later change to #2268 (held for the hooks rework) can name
a flow patch's flags the same way, with this same mod_content_flag_ref.

Testing

Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24, an adult save in Kakariko Village, with
#2267 and #2268 beside it. Magic Singing, changed to name its flags by their ids (":ButtonsToo") with no hash in its
script: its script's flags.set(":ButtonsToo", 1) was written as game.flags.set Me1c8f220.ButtonsToo 0 -> 1 once
in play, and a song played on the buttons went on as the setting says. Checks: tests/test_game_flag_ids.py (the
naming cut from the sources against an FNV-1a of its own: a game name as it is, the own flag, another mod's, six names
refused; and that get, has, set and flagChanged's on() name the flag first); in the fake game, the flags feature mod (its
own flag read, written and watched as ":Seen", e.flag its game name, a bad name refused), and Magic Singing's own
tests; modapi/generate.py --check; test_game_watch.py, test_game_pause.py, test_heart_containers.py.

Still to test:

  • Linux: mise run test, including test_modrt.py (the real runtime over the scripted game, which links
    game_events.c) (by hand, or CI)

Measurements

Nothing to measure: a name without a : costs one memchr; a :id name is one FNV-1a over the mod's id per call, and flagChanged names it once, at on().

Risks

A game flag's name never holds a :, so no name that worked before reads anything else now. A filter given as :id
tells e.flag as the game name, which a listener comparing e.flag to the text it gave would not expect: the docs and
the record's doc say so.

Checklist

Ready for review

  • One topic, on current mod-api; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened. (the flags feature mod uses ":Seen")
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary The runtime takes a mod's content by its id (`items.grant(":Rupee7")`), but its flags only by their game names. A mod that declares a flag with `content.flag({ id: "Seen" })` had to write `"M1a2b3c4d.Seen"` everywhere it used it: the FNV-1a hash of its own id, worked out by hand (the flags feature mod computed it with a loop in its script; Magic Singing hardcoded it). `content.md` listed this as "not yet". Now `game.flags.get`, `has` and `set`, and `flagChanged`'s filter, take a mod's content flags by their ids, as the rest of the runtime takes its content: ```ts flagChanged.on((e) => log.info(`${e.flag}: ${e.value}`), { flag: ":ChestOpened" }); // e.flag: "M37444242.ChestOpened" flags.set(":ChestOpened", 1); flags.get("other/mod:Seen"); // another mod's ``` - `":id"` is the calling mod's own flag, `"owner/name:id"` another mod's; each is read as the game name `content.flag` makes (the mod's word and the id). A game name is taken as it is. - `flagChanged` tells the flag's game name in `e.flag`, whichever way the listener named it: the filter is kept as the game name when the listener subscribes, so it matches the event. - A name with a `:` that names no flag (no id after it, an id that is not a declaration's) is `UnknownNameError`; `has()` is false. - The test game's `flag()` and `setFlag()` take the same names, in the fake game and (through `game.flags`) in the game. Read first: `modrt_flag_name` and `modrt_watch_refused` in `host/modapi/game_events.c`, `mod_content_flag_ref` in `host/mod_content.c`, then the three callers in `services_game.c` and `writes.c`. The fake game: `_flagName` in `lib/fake-game.js`, `services.js`, and the kept filter in `lib/prelude.js`. Part of #1958's Modding API; targets `mod-api`. It and #2267 both touch the flags feature mod's tests and the generated API files, so whichever merges second takes a short rebase. A later change to #2268 (held for the hooks rework) can name a flow patch's flags the same way, with this same `mod_content_flag_ref`. ## Testing **Tested:** Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24, an adult save in Kakariko Village, with #2267 and #2268 beside it. Magic Singing, changed to name its flags by their ids (`":ButtonsToo"`) with no hash in its script: its script's `flags.set(":ButtonsToo", 1)` was written as `game.flags.set Me1c8f220.ButtonsToo 0 -> 1` once in play, and a song played on the buttons went on as the setting says. Checks: `tests/test_game_flag_ids.py` (the naming cut from the sources against an FNV-1a of its own: a game name as it is, the own flag, another mod's, six names refused; and that get, has, set and flagChanged's on() name the flag first); in the fake game, the flags feature mod (its own flag read, written and watched as `":Seen"`, `e.flag` its game name, a bad name refused), and Magic Singing's own tests; `modapi/generate.py --check`; `test_game_watch.py`, `test_game_pause.py`, `test_heart_containers.py`. **Still to test:** - Linux: `mise run test`, including `test_modrt.py` (the real runtime over the scripted game, which links `game_events.c`) (by hand, or CI) ## Measurements Nothing to measure: a name without a `:` costs one `memchr`; a `:id` name is one FNV-1a over the mod's id per call, and `flagChanged` names it once, at `on()`. ## Risks A game flag's name never holds a `:`, so no name that worked before reads anything else now. A filter given as `:id` tells `e.flag` as the game name, which a listener comparing `e.flag` to the text it gave would not expect: the docs and the record's doc say so. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). <!-- Windows half run; the Linux half is CI's --> - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. (the flags feature mod uses `":Seen"`) - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. <!-- Windows built and played; Linux: CI --> - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
scripts/parity_gates.py plays one fixed scripted run through the control bridge
on two builds and compares them: gate 3 (behaviour: map, Link's age, life and
rupees exactly; position, facing and camera within a tolerance; changed flags'
values exactly), gate 4 (the save folders byte for byte, but caption.sav's date
and picture) and gate 5 (with no mods, no script runtime, merged-file cache,
broker or mod thread: a log, folder and /proc check). ab runs A, B and A again,
each a --mode shared job of the PC's queue, and measures the noise from the two
runs of A. A game run refuses to start outside a job or on a RAM file system.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
docs/parity-gates.md: the scenario, what each gate compares and with what
tolerance and why, the noise, gate 5's log, folder, thread and process names
for the pieces still to come, the first runs that calibrate it, and the limits.
CONTRIBUTING.md lists it with the checks that need a run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
From the cold review:
- SIGTERM (job_queue.py cancel) becomes KeyboardInterrupt: the run records why,
  quits its game and stops; ab passes it on to the queued run and waits.
- A value that is not a number never passes gate 3.
- A widened tolerance stops at a ceiling per checkpoint kind; two runs of A past
  it, or differing in an exact value, fail; noise of another scenario, of
  unfinished runs or with too many noisy flags or save bytes is not used.
- Gate 4 compares the save files copied and hashed before quit, needs a save
  the run wrote on both sides, and calls empty folders inconclusive.
- The second run of A reads the flags B saw change; a flag with a value on one
  side only is inconclusive, never a failure.
- Every exception is recorded in the result; both sides need every checkpoint;
  ab never passes a run that exited with an error.
- Run folders a1-/b-/a2-<label>; --name and --save may not leave their folder.
- Only --mode shared jobs, never on Windows; unreadable threads or children fail
  gate 5; run --dry-run prints its queue command; the caller's own HOS_, RX_,
  A64_ and OOT_ variables are dropped; encodings on every text open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The game services' first two pieces (Modding API plan, M3 piece 1), as a refactor: the same behaviour,
the old paths deleted.

- host/game/game.c game_call: the one way host code calls the game's functions. The Debug tab's
  pouch, clock and teleport calls (host/hos_main.c) each looked a function up, copied the context,
  set the stack and arguments and called it; they call game_call now. A guest thread that gave its
  virtual core up takes one back for the call and gives it up again (hos_vcore_held, new in
  host/hos_thread.c); a thread that is not a guest thread is refused. hos_call_guest
  (host/hos_hostcall.c), which nothing called, is deleted.
- host/game/flags.c: the one reader and writer of GameDataMgr. host/hos_main.c called the game's
  getters (f_8022d9c0, f_80cd0ea0) for Bools and String64s and walked the Bool table itself for
  writes; host/oot_state_tap.c read every container directly; host/oot_voice.c walked the Enum
  container a third way. All read through flags.c now: the state tap's bounded reader, moved, with
  the getters' layout (the Bool getter reads the entries flags.c reads). GameDataMgr's slot is in
  host/game/flags.h alone.
- nx2/build.py compiles host/game/*.c (objects host_game_<name>.o).

Two edges differ: a String64 is read up to 64 bytes (the getter path copied up to the caller's
buffer, 80), and the Voice Language option's entry index past the count reads as no option (the
game reads the first entry there).

Tests: tests/test_game_flags.py (flags.c over a synthetic GameDataMgr); the state tap, song
inventory, teleport minimap, perf pose, heart containers, voice option and HLE stats checks follow
the code to its new place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The frame phase scheduler (Modding API plan, M3 piece 2; the interface script runtimes code
against, host/game/phases.h), with nothing added to it yet.

- host/game/phases.c: callbacks added to a phase run in order (by order, ties by add order),
  each called with the frame. A fixed table under one small lock, never held over a callback; no
  allocation; a run with nothing added is one relaxed atomic load and a return. A remove waits until
  the callback has returned, unless it is the callback's own thread; an add during a run counts from
  the next run.
- GAME_PHASE_ACQUIRE runs first in host/nn_vi.c hos_vi_native_acquire, the main thread's window
  acquire: once a frame in every state (spike S1), where the console blocks for a free texture and
  the pacing sleeps (outside the game's locks as far as is known; the present is not), before the
  pacing's early
  returns and its sleep (a callback's time comes out of the frame's wait), with the virtual core
  given up (nvnWindowAcquireTexture). The frame is the count of acquisitions before it.

Tests: tests/test_game_phases.py builds phases.c alone with tests/game_phases_test.c (order, adds
and removes inside a callback and from other threads while one runs, a full table, stale handles,
three threads churning against a running phase) and checks the empty run and the hook's place in
the source.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
From the cold review of the first three commits:
- game_call put the whole context back after the call, poll too: a virtual-core request another thread wrote to
  c->poll during the call (hos_thread.c vc_acquire's kick, set only while vc_kick was clear) was lost, and the thread
  holding the core was never asked again. Every register is put back but poll, never written whole; poll is set again
  when a request was pending before the call or still stands after it (hos_vcore_kicked, new in host/hos_thread.c).
- A context that is not the caller's own (hos_ctx: the thread's, or the fiber's it runs) is refused.
- The refusal's log names its real reason: a negative count and arguments counted but not given were logged as
  "more than 8 arguments".
- game.h: a thread that gave its core up must not call while holding a lock a core-holding thread may wait on.
- hos_thread.c: hos_vcore_held moved above hos_vcore_checkpoint's comment, which it had split from its function.

Tests: tests/test_game_call.py builds game.c with tests/game_call_test.c (stub virtual-core calls logging their order, a
callee recording what it saw): back, the call, away for a thread without its core and neither for one with it; the
stack aligned down to 16, LR 0, x0..x7, *ret the callee's x0, the context put back; poll kept; every refusal calling
nothing. And hos_vcore_held, away and back cut from hos_thread.c: cores off, not a guest thread, held, away, escaped,
escaped then away. Not run here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
From the cold review of the first three commits:
- phases.h: a guest thread holding a core must not remove a callback that may be running (the callback may wait for a
  core while the remove waits for it); game_phase_on_thread is 0 until the phase first ran with a callback added.
- phases.c: _Static_assert that a handle's low 8 bits can name every phase's slot.
- nn_vi.c: the acquire's comment said `until` is fixed before the callbacks; it is computed after them, from values only
  the present writes, which a callback cannot move.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
From the cold review: nx2/entry_hooks.py and nx2/standalone.py read only host/*.c for ENTRY_HOOK_SYM, imp_ and HLE()
definitions, while nx2/build.py compiles host/game/*.c too: one defined there would have been compiled but not hooked.
Both read host/*.c and host/game/*.c now (host/posix, Linux's Win32 stand-ins, has none). No file in host/game/ has one
today.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
From the cold review:
- hos_main.c oot_map_refresh ignored game_flag_bool's result: the game's getter it called before wrote 0 for a flag
  not found, so the load and the age read 0 (not loading, the adult); they kept their defaults (the child) since the
  flags service. They read 0 again.
- tests/game_flags_test.c: a slot rewritten between game_flag_slot's two reads of it (its second read sees another
  entry) reads -1, with no key or value; tests/test_game_flags.py's hos_guest_range calls a hook of the test's for it.
  Not run here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The hook compiler of the Modding API plan's M2, piece 1: one table of hook sites per game build
(game/<build id>/sites.toml), read and checked whole by nx2/hooks.py; each site found in main's code by
a signature of masked instruction words, exactly once or the build stops naming the site; and its hook
recorded where the lifter's emit picks it up (the kit's Lifter.after after a plain instruction, or
Lifter.site_entry, which a wrapper of emit_function puts first in the function, before its locals).
Nothing matches the lifted text. The host gives each site a flag byte and a callback slot
(host/game/sites.def, sites.c), so a dormant site is one byte load and a predicted branch.

The supported build's table is present and has no sites: the lift writes what it wrote before (parity
gate 1). A vslot kind (a vtable slot, data per build: the plan's S3) is in the format and stops the
lift as not implemented. The tables' hash is in the lift key; the builder package and the AppImage
carry game/; host/game/*.c is compiled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The first feature moved from a text patch over the lifted C to the site table (the Modding API
plan's M2, piece 2). The site is after f_80b1e140+0x74, the load of a text pane's letter count
(signature: that ldrh, the cbz on it and the next tbnz, branch targets masked), with
host/oot_text_step.c's hos_text_letter_step as the engine's subscriber, on from the start.

The callback is the patch's C on the same registers: s0 times hos_text_scale when it is not 1, then
hos_oot_text_pane with x19. The patch ran after the count's test (cbz w9 to the return); the hook
runs before it, after the load, and the callback makes the same test itself, so it does nothing
when the game would return; the test reads only w9, which nothing in the callback writes. The
function keeps its registers in the context, now through the splice (guest_locals keep_spliced)
where it was through the patch's addresses. patch_text_speed and its constants are deleted.

tests/test_text_speed.py runs the old patch's C and the new hook with the callback, each in its
place, over counts, scales and times, and compares the whole guest context and the Text size calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
docs/hooks.md: the format (with the Text speed site as the example), signatures and their masks, what
a table may hold under the rule that no game data leaves the PC, how a site is resolved and placed,
why a build stops there and what to do, adding a site or converting a text patch (with the parity
gates), and what a site costs at play and at build time. The development guide's layout names game/
and host/game/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The site forms M2's conversions need beyond entry and after:
- entry with can_return: if (on && fn(c)) return;, as nx2/entry_hooks.py's hooks;
- return: the function lifted as f_1<address> under a wrapper f_<address> that calls it and then the hook, so
  every way out (ret, tail call, indirect jump) runs it and the body keeps its locals;
- before: before the instruction at offset, of any kind, after its label;
- replace: if (on) fn(c); else { the instruction }, a plain instruction only;
- branch: before a conditional branch, a non-zero answer takes it.
before, replace and branch are emitted by lines of nx2/fastfp.py's copy of the kit's emit_function tagged
"# (hooks)" (tests/test_fastfp_override.py takes both tags out before comparing with the kit), from
Lifter.site_before, site_replace and site_branch, sent to the emit's processes with the others. Every
callback is int fn(Ctx *): only can_return and branch read the answer (hos_text_letter_step returns 0).

Inline data rules (rule = mul_f32, scale_f32, note_u64): the compiler's own C inlined at the site,
reading a host value named in host/game/sites.def (HOS_VALUE, the feature's own variable): one load and
a predicted branch when off, no call. The host fills a value with one atomic store and a table by
publishing a new one with one pointer exchange, the old kept until a quiescent point
(host/game/sites.c hos_value_set, hos_table_publish, hos_tables_quiesce): no lock on the game's side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
M2 piece 5. nx2/hooks.py patch_clashes(build_id, code, base, files) checks each patch file's writes on
their own against main's code as shipped: a write into a word a site is found by (its signature) or
hooked at (its point; the function's first word for entry and return), or one that makes the site's
signature match a second place, is a clash. nx2/exefs_patches.py collect refuses such a file (kind
"refused", the note naming the site), which apply() then leaves out and exefs_patches.txt and the Mods
tab report as cannot be applied; the other files apply and the build goes on. Files that stop a site
only together still stop the lift, whose message now says to turn the code mods off to tell.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The new-game opening's three text patches (nx2/oot_patches.py patch_opening) are the sites
opening.request, opening.timeline and opening.skipQuery: the entries of f_80d9a820, f_83b5bfb0 (can
return) and f_80de6cb0 (can return), with host/oot_sites.c's callbacks over hos_oot_opening.

Identity: the patches put hos_oot_opening(c, 0); and if (hos_oot_opening(c, k)) return; first in each
function; the hooks are first too, before anything of the function (its locals now load after them),
the flag on from the start, the callback that very call with its answer. The functions no longer
named by nx2/oot_patches.py may now get locals (nx2/ran_funcs.txt): only their bodies' C changes, not
what they do. patch_opening, its constants and its count are deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
f_80bc72d0's text patch (if (hos_oot_trace_save(c)) return; first in the function: the save request
trace and the Insert menu's Transition autosave) is the site save.request, the function's entry with
can_return, its callback host/oot_sites.c's hos_site_save_request over hos_oot_trace_save.

Identity: the same call, first in the function, returning when it answers non-zero (it has set x0 to
0); what it reads (x1, x2, x30 and the stack at sp + 24) is the context as the caller left it, before
any of the function's locals are loaded, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The four turn-speed functions' text patch (nx2/oot_patches.py patch_camera_speed: s0 times
hos_camera_scale in place of each return;) is four sites at = "return": camera.yawSpeed and
camera.pitchSpeed (f_80643f10, f_80643b60) and their level-2 pair (f_82ea21f0, f_82ea2220), with
host/oot_sites.c's hos_site_camera_turn_speed.

Identity: each function has one way out, its ret (no tail call, no indirect jump: read in the lifted
C), and the patch scaled s0 there after the epilogue; the return wrapper scales it after the function
has returned, with the same C (two volatile reads of hos_camera_scale, s0 written with the rest of v0
zeroed). The registers are the same when the caller gets them back. The functions' bodies may now get
locals (no longer named by the patches); the wrapper adds one call, which the compiler may inline.
tests/test_camera_speed.py runs the patch's C and the callback side by side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
f_80825aa0's text patch (nx2/oot_patches.py patch_dynres: the config flag's test widened to
if (hos_fixed_resolution || !(w8 & 1)) goto fixed; hos_dynres_runs++;, and hos_fixed_scale_bits in place of
the fixed path's 1.0) is three sites with host/oot_sites.c's callbacks:
- dynres.fixedPath, a branch site before the tbz at +0x130: taken while hos_fixed_resolution is set;
- dynres.dynamicFrame, before the cmp at +0x134, which only the tbz's fall-through reaches (no label):
  hos_dynres_runs++;
- dynres.fixedScale, a replace site on mov w9, #0x3f800000 at +0x980: w9 = hos_fixed_scale_bits.

Identity: the patch's widened test is the branch site's test followed by the tbz's own; the count runs on
the same path, after the test; w9 gets the same value (one volatile read, the upper half cleared as
the mov's own second line does). The function keeps its registers in the context, as it did for the
patch. tests/test_dynres_sites.py runs the patch's C and the emitted hooks side by side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The engine's two step divides' text patch (nx2/oot_patches.py patch_frame_seconds: base * the frame's
seconds in place of the quotient while host/nn_vi.c gives them, and hos_step_probe = x19) is three
sites with inline rules, no callback: frame.stepDivide (mul_f32 after fdiv s8, s1, s0 at
f_80706be0+0xe4), frame.globalStepDivide (mul_f32 after fdiv s0, s1, s0 at f_83b6ea90+0x68) and
frame.stepProbe (note_u64, x19 into hos_step_probe, after the first). host/game/sites.def names
host/nn_vi.c's own variables as the rules' values (HOS_VALUE frame.seconds, frame.stepObject): the host
side is unchanged.

Identity: the patch let the divide run (its flags as before) and replaced the quotient with base *
seconds read once from hos_frame_seconds_bits, base the dividend's register; the rule runs after the
divide with the same arithmetic on the same register (s1 is not the divide's destination in either
function), writing the result with the rest of v0 zeroed as the divide did. Expected cost: as the patch's,
one volatile load and a predicted branch at 60 fps or below, a multiply above; no call. The report's
"both or neither" rule and its unpatching go: the two sites are placed together or the lift stops.
The hook no longer depends on the divide's text, so the hot list's float-call rewrite cannot lose it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The acquire phase is the main thread's alone: the game's background threads run through it and the job
workers' join there is not proven (spike S1), so a hook on another thread may hold the old table at that
point. Each table counts its readers (hos_table_enter / hos_table_leave, for the first template that
reads one), and hos_tables_reclaim (was hos_tables_quiesce) frees a retired table once its count is seen
at 0 after the exchange. hos_table_publish calls it, and the first retirement adds it to the acquire
phase at order 20 (the engine's range); with no table replaced nothing is added (parity gate 5).
docs/hooks.md has the argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The runtime's lines all begin "script runtime:" (started, did not start, faults, budgets), it makes no
thread of its own (scripts run on the main thread at the acquire phase), and it unpacks packages into
modcache/packages, beside host/mods.c's size table and list note: the modcache row named only M5's
merged files. The names themselves already matched; no runtime change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The hook site callbacks became int (an entry that can return, a branch) after the text.letterStep site
was written, and the two checks still cut "void hos_text_letter_step(", which no source has: both would
stop on the missing marker. sites.h and docs/hooks.md said the sites' several subscribers come with the
script runtime, which is in without them: they come with the API's hook namespaces.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
test_hooks.py: "before" is a valid at now (an unknown one is refused); an inline rule site has no HOS_SITE line, and its
value's HOS_VALUE line is checked instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The player camera's update's text patch (nx2/oot_patches.py patch_mouse_camera: hos_mouse_camera(c->x[0]);
first in f_80644c80) is the site camera.update, the function's entry, its callback host/oot_sites.c's
hos_site_mouse_camera over hos_mouse_camera. The signature (5 words at +0x30: the frame's set-up and the
loads of the camera's x0 and x1) finds it once in the supported build.

Identity: the same call with the same x0, first in the function, before any of its locals are loaded;
the callback answers 0 and the update runs on, as after the patch's call. f_80644c80 stays in the context
for the camera centering's text patch, which is still there. patch_mouse_camera and its report entry are
deleted. tests/sitecheck.py is the converted features' shared check of their sites (the table, the host
slot, the callback, the patch gone); tests/test_mouse_native.py uses it.

Gates: gate 1 (code parity: nx2/test_leaf.py with the table, f_80644c80's C differs by the hook alone) and
gate 3 (behaviour: the mouse turns the camera in a scripted run with Mouse camera on) need a lift and a
game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The menus' two text patches (nx2/oot_patches.py patch_menu_focus and patch_menu_tick: hos_oot_menu_focus(c, x0,
x1, x30) first in f_802ed660, a menu screen's handler of a pane getting the focus, and hos_oot_menu_tick(c, x0)
first in f_802f1380, every menu screen's update) are the sites menu.focus and menu.update, the functions'
entries, with host/oot_sites.c's callbacks over host/oot_menu.c.

Identity: the same calls with the same registers (x30 is the caller's return address at the entry, as at the
patch's first line), before anything of the functions; the callbacks answer 0 and the functions run on. Both
functions may now get locals (no longer named by nx2/oot_patches.py): only their bodies' C changes. The patches,
their constants and their report entries are deleted; tests/test_menu_hooks.py checks the sites.

Gates: gate 1 (nx2/test_leaf.py with the table: the two functions differ by their hooks and locals) and gate 3
(a scripted run through the pause menu with the mouse: focus follows the pointer, toggles clear on Linux) need a
lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The button prompts' three text patches (nx2/oot_patches.py patch_text_draw, patch_text_layout and patch_glyph:
hos_prompts_text_draw(x0), hos_prompts_text_layout(x0) and hos_prompts_glyph(x1) first in f_8152b670, a text
box's draw, f_8152aec0, its layout, and f_81680c60, FreeType's ft_smooth_render) are the sites text.boxDraw,
text.boxLayout and font.glyphRender, the functions' entries, with host/oot_sites.c's callbacks over
host/prompts.c.

Identity: the same calls with the same registers, before anything of the functions; the callbacks answer 0
and the functions run on. The functions may now get locals: only their bodies' C changes. The patches, the
helper they shared (_hook_head), their constants and report entries are deleted; tests/test_menu_hooks.py
checks the five entry sites (the menus' two and these three) through tests/sitecheck.py.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (a run that changes the controller while a text
box shows: its prompts are redrawn for the new pad) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The two text patches of the native zstd decodes (nx2/oot_patches.py patch_zstd_stream and patch_zstd_frames:
if (hos_zstd_stream(c)) return; first in f_80115c80, the game's stream decode of one chunk, and the same with
hos_zstd_frames first in f_8010b380, the resource loaders' whole-buffer decode) are the sites zstd.stream and
zstd.frames, the functions' entries with can_return, with host/oot_sites.c's callbacks answering what
host/hos_zstd.c answers.

Identity: the same calls, first in the functions, before any of their locals are loaded; an answer of 1
(the host did the call, x0 its result) returns at once, 0 (the switch off, or a stream the host cannot take)
runs the function as lifted. HOS_NATIVE_ZSTD and HOS_NATIVE_ZSTD_FRAMES still decide inside the host
functions. Both functions may now get locals. tests/test_native_zstd.py checks the sites.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (a load through two areas and a cutscene, with
both switches on and off: the same frames decoded, docs/tested's zstd runs repeated) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The cloth solve job's text patch (nx2/oot_patches.py patch_cloth_solve: if (!hos_oot_cloth_solve(the frame
step at 0x84d61fc8)) { x0 = 0; return; } first in f_81b47080) is the site cloth.solve, the job's entry with
can_return, its callback host/oot_sites.c's hos_site_cloth_solve: it reads the step as the patch did and
answers 1, x0 = 0, for a frame the gate holds.

Identity: the same call with the same word read, before the job saves anything (its first line, the
prologue's store, comes after the entry hook as it came after the patch); a held frame returns with x0 = 0
and the stack pointer as given. tests/test_oot_cloth_60.py builds the job with the emitted hook and with the
patch's line side by side and checks they solve and hold the same frames in every case (240, 144, 120, 60 and
30 fps, a cap of 60, a step of 0 and NaN, a load), for HOS_FPS_CLOTH_60 unset, 1 and 0. The patch, its
constants and its report line are deleted; the job may now get locals.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Zora's Domain near King Zora at a cap of 240 with
HOS_FPS_CLOTH_60=1: the cloth solved some 60 times a second, HOS_FPS_LOG's counts as on main) need a lift and a
game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The movie player's text patch (nx2/oot_patches.py patch_movie_frames: the count's add at f_83b7c710, +760 of the
player, made _b=hos_movie_frames(x20) in place of 1) is the site movie.frameCount, a replace site on that add
(add w8, w8, #1 at +0xb8), its callback host/oot_sites.c's hos_site_movie_frame_count:
w8 = (uint32_t)(w8 + hos_movie_frames(x20)).

Identity: the same call, once an update, on the same path, and the same 32-bit sum into w8 before the store;
with the site off the add runs as the game has it. The player's other branch (+0x1f8, the same three
instructions) is left as the patch left it: the signature takes the load, the add, the store and the branch
after them, which only the first branch has. tests/test_movie_frame_count.py builds the update with the
emitted hook and with the patch's add side by side: both pass the checks at 120, 240 and 40 fps, several
movies and more players than places; the hook switched off fails them, as the game's own count does. The
patch, its constants and its report entry are deleted; f_83b7c710 may now get locals.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (the Deku Tree's movie and a cutscene with one at a
cap of 120: narration and rumble with the picture, HOS_FPS_MOVIE=0 the game's own count) need a lift and a
game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The scene format's text patch (nx2/oot_patches.py patch_scene_format: f_80672260's mov w9, #0x1a, the
R11G11B10F choice, made w9 = hos_scene_rgba16f ? 0x2c : 0x1a) is the site render.sceneFormat, a replace site on
that mov (+0xec), its callback host/oot_sites.c's hos_site_scene_format setting w9 the same way.

Identity: w9 gets the same value (one volatile read), on the same path, before the same csel; with the site
off the mov runs as the game has it. The signature covers the pick (mov w10, #0x2c; the flags' orr and test;
the mov; the csel), which the patch matched as text. tests/test_scene_format.py builds the pick with the
emitted hook and with the patch's lines side by side: the same registers and flags for every flag and
setting. The patch, its constants and its report entry are deleted; f_80672260 may now get locals.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Native HDR with PsychoV35: the scene buffer made
RGBA16F, Vanilla: R11G11B10F, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The life write's text patch (nx2/oot_patches.py patch_life: a guard before each of f_804bd8c0's two
compare-and-swaps of an actor's life, which hands a lowering of the player's own life to hos_oot_damage) is
the sites player.lifeHit and player.lifeWrite, before the cas at +0x438 and +0x610, with host/oot_sites.c's
callbacks over one guard (life_write): x9 is the hit at the first, the difference at the second, as the
patch had them.

Identity: the same test (w12 below w11, the actor the player, x13 its life field) and the same call into
w12, before the same instruction on every way into it (the patch's text went after any label of the cas,
as a before site does); the hit is computed before the test now, from the same registers, which nothing
changes in between. The signatures take each cas with the instructions that set its registers, which the
patch's count of the cas text stood for. tests/test_oot_damage.py runs each hook as emitted and the patch's
guard side by side on copies of every case: the same registers. The patch and its constants and report
entry are deleted (LIFE_BUILD_ID stays: it names the supported build for the other patches).

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Damage taken Half and Quadruple, heart protection,
a hit from an enemy and a fall, on a fixed save: the life as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The flight's two text patches (nx2/oot_patches.py patch_movement: hos_oot_lift_player(c, x19) before
f_82c415e0's test of the actor's flag byte, and hos_oot_flight_pose(c, x19, x25) after its label L_82c41778;
patch_flight_rotation: hos_oot_flight_rotation(c, x0, x1) before f_806d2530's call of the controller's virtual
method) are the sites player.update (+0x14c), player.pose (+0x198) and player.flightRotation (+0x94), all
before sites, with host/oot_sites.c's callbacks.

Identity: the same calls with the same registers, at the same points: a before site's C goes after the
instruction's label and before its own C, where the patches put theirs (the tbnz has no label; +0x198 is
the label both paths reach, as L_82c41778 was; the blr's C follows). hos_oot_lift_player is also Link's
update for the state tap and the player service, so tests/test_oot_state_tap.py now finds it through the
site. tests/test_player_update_sites.py checks the three sites. The patches and their constants and report
entries are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (the Debug tab's flight on a fixed save: Link lifted,
turned and posed as on main; the control bridge's player state each frame) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The free camera's text patch (nx2/oot_patches.py patch_view: hos_oot_free_view(c, x20) after f_804e48c0's label
L_804e5068, the head of its loop over a camera's views, with or without the interrupt poll after the label) is
the site camera.view, before the instruction at +0x7a8, with host/oot_sites.c's callback.

Identity: the same call with the same register, after the label and before the instruction's C, on the loop's
entry and each time round, as the patch's text after the label ran. The site is placed by the address, so the
two forms of the label's line the patch looked for (nx2/poll.py's poll before or after) no longer matter.
tests/test_free_view_anchor.py checks the site and where the emit puts a before site's C. The patch and its
constants and report entry are deleted. (The lift reports the site as in a loop: it ran there before too.)

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (the Debug tab's free camera moved on a fixed save: the
view as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Movement speed's text patch (nx2/oot_patches.py patch_cct_speed: hos_oot_cct_speed(c, x0, per_second) after
four anchors) is four sites with host/oot_sites.c's two callbacks: player.speedMove and player.speedMoveOther,
after f_809552f0's two loads of the controller (ldr x0, [x8, #8] at +0x134 and +0x1ec, a frame's speed);
player.speedSet, the setter f_80559df0's entry; player.speedSetComponent, after f_80964bf0's first load
(+0x0; the last two a second's speed).

Identity: the same call with the same registers at each place: the patch's text followed the label and the load
at the first two (an after site follows the load), was first in the setter (its entry), and followed the
component's load. The setter's code is in the game twice (0x827abdd0's copy runs into more code); its
signature ends with the padding after this copy, which makes it unique. tests/test_movement_speed.py checks the
four sites and their units; its host and menu checks are as before. The patch, SPEED_PLACES and the report's
count are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Movement speed 2x on a fixed save: Link's run, a
swim and a ledge climb as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The horse jump's text patch (nx2/oot_patches.py patch_horse_jump: if (hos_oot_horse_whole_step(s10, the time
object's slot)) goto L_82c5ae48; between f_82c59eb0's test of its step against 1 and its b.pl to that label) is
the site horse.jumpStep, a branch site on that b.pl (+0xf70), its callback host/oot_sites.c's
hos_site_horse_jump_step answering the host's test.

Identity: the patch's line went to the b.pl's own target before the b.pl's own test; a branch site takes the
branch on a non-zero answer and runs the branch's test otherwise, at the same place, with the same call and
registers. The signature takes the fmov of 1.0, the fcmp and the b.pl, which the patch matched as text.
tests/test_horse_jump_step.py builds the update with the emitted hook and with the patch's line side by side:
both keep the game's blend frames at 70 to 240 fps and take the game's own test elsewhere; the update without
the hook, or with its flag off, fails the 120 fps check. The patch, its constants and report line are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Epona over a fence at Lon Lon Ranch at a cap of 120:
she jumps it, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The texture compaction's text patch (nx2/oot_patches.py patch_tex_compact: f_80797240's test of its flag bit 1,
if (!bit1) goto past the ask, widened to if (!bit1 || !hos_oot_tex_compact_due()) goto) is the site
texture.compactAsk, a branch site on that tbz (+0x38), its callback host/oot_sites.c's
hos_site_tex_compact_ask: bit 1 set and the host saying not now takes the branch; otherwise the tbz's own test.

Identity: the branch is taken exactly when !bit1 || !due, and the host is asked only when bit 1 is set, as the
patch's || did. tests/test_tex_compact.py builds the step with the emitted hook and with the patch's line side by
side: for every flag and answer the same way out and the same asks. The patch, its constants, its report line and
its paragraph in the module's notes are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (standing in Castle Town's market with
HOS_TEX_COMPACT_MS unset, 0 and off: the rounds the log counts as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The solver steps' text patch (nx2/oot_patches.py patch_solver_steps: x1 = hos_oot_solver_steps(x1, s0, s1)
between the cut of frame step * steps a frame (fcvtzs w1, s0) and its store at +712, in f_838ceb80 and
f_838cfc10) is the sites physics.solverSteps and physics.solverStepsOther, after each fcvtzs (+0x74, +0x110),
with host/oot_sites.c's one callback.

Identity: the same call with the same registers right after the cut, before the store, as the patch's line
was; x1 gets the 32-bit answer zero-extended as before. The signatures take each update's loads of the step
and the steps a frame, the fmadd, the cut and the store (the first loads through x25, the second x19), which
the patch matched as the cut and the store. tests/test_high_fps_fixes.py builds each site's hook as emitted and
the patch's line side by side: the same registers and the same stored count for every input. The patch, its
constants and its report line are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Link on a moving platform, the Deku Tree's and the
Forest Temple's elevators, at a cap of 144: he stays on, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The three text patches of the sound job above 60 fps (nx2/oot_patches.py patch_sound_job: the gate first in
f_80435300 and its phase 0's step through hos_oot_sound_step; patch_bgm_time: f_83373400's step and seconds
through the host; patch_bgm_flags: hos_oot_bgm_begin first in f_83373400 and its four reads of the battle
manager's change flags through hos_oot_bgm_flags) are eight sites with host/oot_sites.c's callbacks:
sound.job (the job's entry, can_return: held when the gate says so), sound.jobStep (after its ldr s0 at +0x34),
music.update (the update's entry), music.time (after its ldr s9 at +0x48: s8 and s9 the host's) and
music.changeFlags, changeFlags1, changeFlags2 and changeFlags6 (after each ldrb w8, [x26, #0x898], named by
the bit each tests).

Identity: the same calls with the same arguments, in the same order, at the same points: the gate first and a
held job returning before anything of it; each load's value through the host right after the load, as the
patches' lines that wrapped the load; the seconds given the step as read from guest memory, as the patch
re-read it. tests/test_high_fps_fixes.py builds the job and the update with the emitted hooks and with the
patches' lines side by side, over stand-ins that log every call to the host: the same registers and the
same calls, for each phase, gate answer and flag byte; its clock and flags checks run on the emitted hooks.
(Its flags check also gets stand-ins for HOS_HEAP_BASE and hos_guest_range, which host/oot_high_fps.c's
hos_oot_note_link reads and the check's world lacked.) The patches, their constants and report lines are
deleted; SOUND_SLOT stays for the floor carry and the driven target.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (at a cap of 144: a dozen loading zones with sounds
and music playing on, and a fight's music ending after it, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The driven target's text patch (nx2/oot_patches.py patch_drive_target: hos_oot_drive_target(x20, the body,
the time object's slot) between f_804f5030's load of the body (ldr x23 or x24, [x20, #0xf0]) and its reads of
the target, at the path's two copies) is the sites physics.driveTarget (+0x1b4) and physics.driveTargetOther
(+0xe6c), after each load, with host/oot_sites.c's callbacks.

Identity: the same call with the same registers right after the body's load and before the target's reads,
where the patch's line went (the patch matched the load and the reads as one text, so no label lies between
them). The signatures take the load and the two reads; the function's third load of x23 from +0xf0 (+0x500),
which the patch did not match either, reads other fields after it. tests/test_drive_target.py builds the
update with the emitted hooks and with the patch's lines side by side: both pass every climb check at 60 to
240 fps; the update without the hooks, or with their flags off, fails the 120 fps check. The patch, its
constants and its report line are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Link's pull-up onto a ledge at a cap of 120: he
gets up, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The cloth time's text patch (nx2/oot_patches.py patch_cloth_time: f_81b3aa48's load of its step context's time,
ldr d0, [x22, #8], with its low half made hos_oot_cloth_seconds(the time, the frame step at 0x84d61fc8)) is the
site cloth.time, after that load (+0x220), its callback host/oot_sites.c's hos_site_cloth_time.

Identity: the same call with the same values (the time as loaded, the step read from the same word), the low
half replaced and the high half kept, before the fdiv that reads s0, as the patch's rewritten load did.
tests/test_oot_cloth_time.py builds the setup with the emitted hook and with the patch's load side by side: the
same frame data for every step, scale and HOS_FPS_CLOTH value. The patch, its constants and its report line
are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Link's cap at a cap of 20: it swings and settles as
on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The whole frames' text patch (nx2/oot_patches.py patch_whole_frames: seven cuts of the frame step to a whole
number, fcvtzs or fcvtzu of s0, made hos_frame_whole(the counter's key, s0), the water's
hos_frame_whole_times(x21, s0, w8) with w8 then 1) is seven replace sites on those cuts, frame.wholePickup
(f_80a87e50+0x4b0), frame.wholeWater (f_800672e0+0x318), frame.wholeTimeOfDay (f_803edf70+0x50),
frame.wholeScarecrowPlay (f_832b32b0+0x160), frame.wholeScarecrowRecord (f_832b6840+0x2c8),
frame.wholeScarecrowLast (f_832b2690+0x38) and frame.wholeFloorWeb (f_80652cb0+0x50), with host/oot_sites.c's
callbacks (the two that share a key share one).

Identity: each callback writes the cut's register with the call the patch's line made, with the same key and
the same bits of s0 (the water's substeps register set to 1 after, as before); with a site off the cut runs as
the game has it. Each signature takes the cut with the lines the patch matched it by (the time of day's with its
store to +60, which leaves its other cut at +0x1f0 the game's; the recording's with its add of x10, which
leaves the mode-13 cut's add of x12 alone; the water's with the substeps' load). tests/whole_sites.py emits the
seven hooks into authored lifted C as the lift does, and the text patch's lines for comparison:
tests/test_frame_whole.py runs every site both ways over stand-ins that log each call (the same registers and
calls; off, the game's own cut), and the scarecrow, water and floor web checks run their behaviour with the hooks
and with the patch's lines. The patch, WHOLE_SITES and its report line are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (at a cap of 144: the pick-up indicator after a
rupee, the ripples in Zora's Domain, the time of day in Hyrule Field, Scarecrow's Song recorded and played, the
Deku Tree's web landed on: as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The fixed scale's text patch (nx2/oot_patches.py fixed_scale: after f_831f3200's label L_831f3efc, a recompute of
the 3D's scale asked for on the fixed path while +0xe5c is not the chosen one; after its load of the override
flags at L_831f3f08, hos_res_module = x20 and their bits 3/4 cleared on the fixed path) is the sites
render.fixedScaleApply, before the instruction at +0xcfc (that label's), and render.fixedScaleFlags, after the
load at +0xd08, with host/oot_sites.c's callbacks doing what the patch's lines did.

Identity: the same reads of guest memory and of the host's values, the same float arithmetic and the same
writes of w8, x8 and hos_res_module, at the same points (a before site's C follows the label, on every way into
it, as the patch's text did; the after site follows the load). One signature, the update of +0xe2c and the load
and test of the flags, places both. tests/test_fixed_scale_sites.py builds the block with the emitted hooks and
with the patch's lines side by side: the same registers, memory and hos_res_module for the fixed path on and
off, scales chosen and not, a 0 at +0xe50 and every flag. The patch, its constants, its report entry and its
paragraph in the module's notes are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Resolution at 50%, 75% and 100% on the fixed path,
docked and handheld: the 3D at the chosen size, no targets remade each frame, as on main) need a lift and a game
run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Three changes of control flow the text patches still made, as forms of the site table (docs/hooks.md, Forms):
- allow: the conditional branch at the offset is taken only when its own test holds and the callback, asked
  only then, answers non-zero: the branch's own if, its test and its goto kept inside the site's
  (if (<test> && on && fn(c)) <goto>), for a patch's narrowed condition (if (cond && host) goto);
- jump: before the instruction at the offset, as before, a non-zero answer jumps to the instruction at a new
  key, to, in the same function, which place() makes a label of every function the code is lifted in. The
  lift's flow analysis does not see that edge, so such a function keeps every flag store (site_keep_flags);
- replace on a call (bl, blr): the hook sets x30 to the return address and the callback makes the call itself
  (a64_lookup, a64_icall) when it wants it, as a wrapper of the callee; with the site off the call is lifted
  as before.

The reader checks the forms and to; place() records them (Lifter.site_allow, site_jump, site_keep_flags), one
before or jump site per instruction and one branch or allow per branch; nx2/fastfp.py's copy of the kit's emit
gets them in lines tagged (hooks); chunks.EMIT_TABLES sends the new tables to the emit's processes;
patch_clashes guards a jump's target. tests/test_hooks.py reads and places them and checks their C;
tests/test_hooks_emit.py emits each through the real emit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The camera centering's text patch (nx2/oot_patches.py patch_camera_centering: if (hos_disable_camera_centering())
{ x25 = x26; goto L_80645ad8; } on the fall-through of f_80644c80's b.ne at L_8064720c, the follow camera's
movement yaw) is the site camera.followYaw, a jump site before +0x2590 to +0xe58, its callback
host/oot_sites.c's hos_site_camera_follow_yaw: with the row on, x25 = x26 and the answer 1.

Identity: the same call at the same point (+0x2590 is the b.ne's fall-through and no label: nothing else reaches
it, so a before site there runs only where the patch's line ran), the same register written, the same label
jumped to. The function keeps every flag store now (the jump's edge, which the flow analysis does not see); the
patch's goto was not seen either, so this keeps more, never less. The signature takes the b.ne, the call the
movement path starts with and its x25 = x26. tests/test_camera_centering.py checks the site and runs a block
with the emitted hook and one with the patch's line, row off and on: the same way out, the same registers. The
patch, CAM_HEAD and its report entry are deleted: f_80644c80 is no longer named by nx2/oot_patches.py.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (walking with the row on and off on a fixed save:
the yaw follows Link's movement only with it off, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The floor carry's text patch (nx2/oot_patches.py patch_floor_carry: each of three update modules' b.gt to the
tenth of a floor's velocity, after its test of the physics' 1/dt against 100, made
if ((n == v) && !z && hos_oot_floor_carry_slow(s0, the time object's slot)) goto) is the sites
physics.floorCarry (f_80159dc0+0x2b0), physics.floorCarryOther (f_8015d490+0x280) and physics.floorCarryThird
(f_838baa40+0x1ec), allow sites on those b.gt, with host/oot_sites.c's one callback.

Identity: the branch is taken exactly when its own test holds and then the host answers non-zero, the host
asked only then, as the patch's && had it; the same call with the same s0 and slot. The signatures take each
module's load of 1/dt, the 100, the fcmp and the b.gt (the last two with the instructions after, which tell
them apart), which the patch matched as text. tests/test_floor_carry_step.py builds the updates with the
branches as the emit makes them around the allow sites and with the patch's branches side by side: both pass
every case; without the hooks, or with their flags off, the 120 fps check fails. The patch, its constants, its
report line and SOUND_SLOT (no patch names the time object's slot now) are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (on the Shadow Temple's barge at a cap of 144: Link and
the enemies ride it, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The voice option's text patch (nx2/oot_patches.py patch_voice_option: f_80a9ca30's call of f_80a9d1c0, "was the
option written?", made hos_oot_voice_option(c, f_80a9d1c0) after x30 = its return address) is the site
options.voiceWritten, a replace site on that bl (+0x68), its callback host/oot_sites.c's hos_site_voice_written:
hos_oot_voice_option(c, a64_lookup(0x80a9d1c0)).

Identity: the hook sets x30 to the call's return address, as the patch's line kept it, and the callback calls
the same wrapper with the game's function, found by its guest address instead of named in the lifted file (the
same function; a lookup once an update); with the site off the call is the game's own. The signature takes the
option's hash, the manager's load, the bl and the test of its answer. tests/test_oot_voice_option.py builds the
update with the emitted hook and with the patch's call side by side, over host/oot_voice.c and the flags service
as they are: both apply the saved choice once, follow writes and leave other questions to the game, and with
HOS_VOICE_OPTION_FOLLOW=0 both are the game's alone. The patch, its constants, its report entry and its paragraph
in the module's notes are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Japanese voices saved, a restart, Link's voice in a
cutscene in Japanese, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The heap retry's text patch (nx2/oot_patches.py patch_heap_retry: f_804566e0's two calls of f_80522050, its GPU
memory, made hos_oot_gpu_alloc(c, f_80522050), and its two tryAllocs, blr x8, wrapped in a refusal test and a
retry in the heap's parents for a null) is four replace sites on those calls: heap.gpuAlloc (+0x838),
heap.gpuAllocOther (+0x9b4), heap.cpuAlloc (+0x22c) and heap.cpuAllocOther (+0x6c0), with host/oot_sites.c's two
callbacks: hos_site_gpu_alloc, hos_oot_gpu_alloc with the game's function by a64_lookup; hos_site_heap_alloc, the
patch's lines with the call through a64_icall and the return address from x30.

Identity: the same calls with the same arguments in the same order, the same registers after; x30 is the call's
return address (set by the hook as the patch's lines set it), except under the test switch
HOS_GPU_ALLOC_TEST_FAIL, where the patch made no call and left x30 as it was and the hook leaves it as a call
would (nothing after a call reads x30 but as a call's). Each signature takes the call with the lines that set its
arguments; f_80522050's other callers stay as they are. tests/test_oot_heap_retry.py builds the four places with
the emitted hooks and with the patch's lines side by side over stand-ins that log every call (the same calls,
arguments and registers, for a refusal or not and a null or not), and its checks of the host's retries are as
before. The patch, its constants, its report check and its paragraph in the module's notes are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (a save loaded with HOS_GPU_ALLOC_TEST_FAIL=2: two
refusals made by the retry, the model drawn, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The song cue's text patch (nx2/oot_patches.py patch_song_cue: x0 = hos_oot_song_cue(site, x0) after
f_832b2af0's and f_832b2dc0's calls of f_832b7b50, the note flag's question) is the sites song.noteCue
(f_832b2af0+0x194) and song.noteCueOther (f_832b2dc0+0x114), before sites on the instruction after each call,
with host/oot_sites.c's callbacks (site 0 and 1).

Identity: C after a call is C before the next instruction when nothing else reaches it: neither return address
is a label in the lifted C (read in a lift of the supported build), so each hook runs exactly where the patch's
line ran, with the same call and register. The signatures take the call with the instructions around it.
tests/test_song_note_cue.py builds the playbacks with the emitted hooks and with the patch's lines side by side:
both pass every case at 60 to 240 fps; without the hooks, or with their flags off, the 120 fps check fails. (Its
world also gets stand-ins for what host/oot_high_fps.c now reads that it lacked: HOS_HEAP_BASE, hos_guest_range,
getenv's header and env_value_off.) The patch, its constants and its report line are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Zelda's Lullaby played at a cap of 144: its notes
shown one at a time with the melody, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The ocarina wait's text patch (nx2/oot_patches.py patch_ocarina_wait: lines in the note-wait action's start
f_828a9190 and tick f_828a9280 that set hos_oc_wait, hos_oc_last_kind and hos_oc_beat) is seven sites with
host/oot_sites.c's callbacks: ocarina.waitStart (after the start's load of the input kind, +0x48),
ocarina.waitTick (before the tick's running test, +0x1c: cleared, or re-armed and the beat stamped),
ocarina.waitMode, ocarina.waitContext and ocarina.waitOwner (before the three gates' branches, +0x4c, +0x60,
+0x98: cleared when they refuse), ocarina.waitDone (after the done store, +0x108) and ocarina.waitReset (before
the instruction after the input reset's call, +0x164, which nothing else reaches).

Identity: each callback writes the host's three words as the patch's lines did, from the same registers, at the
same points: the patch's lines inside a branch's block (taken) or after it (not taken) become a test of the
branch's own condition just before it (nothing lies between; the flags are in the context, as for every site
inside a function), and its line after the reset's call is the before site after the call. The signatures take
each place with what tells it from the game's many like it. tests/test_ocarina_wait.py builds both functions
with the emitted hooks and with the patch's edits side by side and runs them over every input kind, flag byte,
mode, context and owner: the same wait, kind, beat and registers. The patch, its constants, its report entry and
its paragraph in the module's notes are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (the ocarina played with the note controls, a song
lesson, a dialogue that takes the buttons, Scarecrow's Song: the pads swapped exactly while the game waits for
notes, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The loop step's and the loop pose's text patches (nx2/oot_patches.py patch_loop_steps: in f_802cfca0's two
multiplies of the step, s8, by the speed, the multiply's own copy of the step made hos_loop_step's;
patch_loop_pose: in f_80944aa0's store of a skeleton's time, the stored value made hos_loop_pose's) are three
pairs of sites with host/oot_sites.c's callbacks: anim.loopStep and anim.loopStepDone (before and after the
fmul at +0x164), anim.loopStepOther and anim.loopStepOtherDone (+0x530), anim.loopPose and anim.loopPoseDone
(before and after the str s0 at f_80944aa0+0x3b0). The before site swaps the host's value into the register
the instruction reads, the instruction runs as the game has it, and the after site puts the game's register
back (kept in a thread-local slot between the two, which run one right after the other).

Identity: the patch fed the host's value to the multiply (and its sign for the zero, computed from it) and to
the store without changing the register; here the multiply and the store read it from the register for one
instruction and the register is the game's again after it: the same product, the same stored word, the same
registers after. No new form was needed. tests/test_loop_step.py builds the updates with the emitted pairs and
with the patch's lines side by side: both keep a loop of one frame on one phase; without the hooks, or with
them off, the check fails. The patches, their constants and their lines in patch_file are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (the frozen Zoras in adult Zora's Domain at a cap of
165: they stand still, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The saved turn rate's text patch (nx2/oot_patches.py patch_turn_rate: in f_8263e8e0, the steering update, the
two multiplies of the saved rate's bounds by the step made divides while 0 < step < 1) is two replace sites on
those fmuls, steer.rateLower (+0x238, fmul s1, s0, s1) and steer.rateUpper (+0x23c, fmul s0, s0, s8), with
host/oot_sites.c's callbacks: the step's bits tested as the patch tested them (no host float compare, no guest
flag changed), then the divide or the game's multiply.

Identity: the same operands, the same choice, the same result register (its upper half cleared, as a64_vset64
does). The patch called the lift's fast helpers (a64_fpx_div32_div32, a64_fpx_mul32_fma32), which give the
exact helpers' value and FPSR when they can and call them otherwise; the callbacks call the exact helpers
(recomp_fpe_div32, recomp_fpe_fma32) directly: the same value and FPSR bits, a little slower on a path run once
an update per steering actor. The signature takes both multiplies with the instructions around them.
tests/test_saved_turn_rate.py builds the update with the emitted hooks and with the patch's arithmetic side by
side: both pass every step, sign and limit; without the hooks, or with them off, the short-step check fails.
The patch, its constants, its report entry and the report's last warning list are deleted.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Gohma at a cap of 144: she leaves the ceiling for
her next point, as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The barrier wait's text patch (nx2/oot_patches.py patch_barrier_wait: the 20 us sleeps of three parallel-for
jobs, f_800998a0, f_800738e0 and f_8007e200, made hos_oot_barrier_wait with the game's sleep behind it, and each
atomic OR into a polled mask word followed by hos_oot_barrier_wake) is five replace sites on the sleeps' calls
(barrier.sleepClaim, sleepGather, sleepDone, sleepOther, sleepThird) and seven after sites on the ORs' ldset
(barrier.orClaim, orClaimOther, orGather, orDone, orOther, orOtherSecond, orThird), with host/oot_sites.c's
callbacks: each sleep's the patch's wait with the same words, read only when the switch is on, and the game's
sleep (a64_lookup of SleepThread as the lift calls it, x30 set) when it is off or the wait answers 0; each OR's
the wake of its job block, the register the OR's address was made from.

Identity: the same calls with the same arguments in the same order, the same registers and memory: the patch
woke _a - off, the OR's address less the word's offset, which is the base register the signature's add made it
from (each OR's signature takes its add, so the offset and the register are the code's). The patch hooked a
function only where all its places and marks were found, at all of them; here every site resolves exactly once
or the build stops, so a sleep never waits for a wake that is not there. Its marks (where the loops load the
words the waits are told) were read in the supported build's code, as the patch's comment did; the table's
comment keeps them. tests/test_oot_barrier.py keeps its runs of the host's protocol and its broken variants;
the patch's checks are replaced by a side-by-side run of each of the twelve places with the emitted hook and
with the patch's text over stand-ins that log every call, the switch on or off and the wait yes or no, and three
broken callbacks that must fail it. patch_file and report are kept, empty, for nx2/chunks.py and the output
size; tests/test_patch_hooks_defined.py reads the output size's declarations, the patches' last.

Gates: gate 1 (nx2/test_leaf.py with the table) and gate 3 (Castle Town's market on 4 cores, HOS_OOT_BARRIER_WAIT
unset and 0: the barrier: log lines count waits moved and woken, frame time as on main) need a lift and a game run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
docs/hooks.md's Not yet list names the swap of an instruction's operand done with a before and an after site at
one instruction (anim.loop*) as a form to come, and the output size's edits, the last text patch, with why they
stay one for now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
nx2/fastfp.py's site_keep_flags test and allow site test ended in a longer comment, "# (hooks: ...)", which
tests/test_fastfp_override.py does not count as tagged: it would find the copy's untagged lines differ from the
kit's emit_function. Both end in "# (hooks)" now, their explanations on comment lines of their own, tagged
the same. The copy's untagged lines read the same as the kit's (compared by reading both, nothing run).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
anim.loop* were three before/after pairs sharing one thread-local slot: the before site swapped the host's
step (s8) or time (s0) into the register, the after site put the game's back. With each half's flag of its own,
a half turned off, or a flag stored between the two, could leave the host's value in the register or restore a
register from another pair's save. The pairs are gone: anim.loopStep and anim.loopStepOther replace the two
fmuls, their callback the multiply with the host's step through the runtime's exact float helper
(recomp_fpe_fma32, as steer.rate* do), and anim.loopPose replaces the str s0, its callback storing the host's
time through recomp_store32 (which marks its page). s8 and s0 are never changed; each site is one flag.

Identity: the text patch fed the host's step to the multiply's own copy of the operand (its zero's sign from it)
and the host's time to the store's, leaving the registers as they were: the same here. tests/test_loop_step.py
adds a side-by-side run of each place alone, hooked and as the patch had it, from random contexts and memory:
the whole context (every register, s8 and s0 among them, and FPSR) and memory must match, so a callback that
left a register changed fails. docs/hooks.md's Not yet entry says so.

Gates: as before, gate 1 and gate 3 (the frozen Zoras at a cap of 165).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
From the cold review of mods/hooks2:
- A replaced bl now tells its callback the callee: the hook stores the function the lift calls there (past any PLT
  stub; Lifter.callee) in hos_site_callee (host/game/sites.c, per thread) before the callback, which calls
  a64_lookup(hos_site_callee). The voice option's, the GPU memory's and the job barriers' sleeps' callbacks no longer
  write 0x80a9d1c0, 0x80522050 or 0x85106220. A bl to a function the lift does not call plainly (no entry, or a setjmp
  owner) cannot be replaced: the lift stops.
- The global slots the callbacks read (the time object's pointer, the cloth's clock) are named once in
  host/oot_sites.c, in a block for build e0f3ccfa; tests/sitecheck.py's callback() cuts it with each callback, and
  tests/test_oot_cloth_60.py uses it. docs/hooks.md says a callback naming an address belongs to one build.
- A site may carry guards: words elsewhere in its function, checked where its signature puts the function, which stop
  the build as a missing signature does (and which the mods' ExeFS patch check keeps as it keeps the signature's). The
  five barrier sleeps guard what their waits are told: the loop heads' loads of the polled words, the stack slots and
  the frame slot of the full mask, as the deleted patch's marks did.
- place(): a branch site where an allow is is refused in either order (and two branch sites at one branch); a jump
  whose code is lifted in a function without its target is refused, not left without its label there; a jump back is
  reported as a loop; a before site after a call on a label is reported with a warning. docs/hooks.md says what stacks
  at one instruction as the code does.
- The table gets back steer.rateLower, which the previous commit cut by mistake with the loop sites' rows (its
  HOS_SITE line and callback stayed; nothing resolved it).

tests/test_hooks.py: guards read, met and missed; the refusals above; the loop report and the warning; the replaced
call's callee through a PLT stub. tests/test_hooks_emit.py, test_oot_voice_option.py (which now also checks x30 is the
call's return address when the game's function runs), test_oot_heap_retry.py and test_oot_barrier.py pass the callee.
Written and syntax-checked only; nothing run. All 95 sites resolve exactly once against the local image, guards
included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
tests/test_hooks.py checked that each table row has its HOS_SITE line in host/game/sites.def, not the other way: an
engine callback whose row was gone (steer.rateLower, cut by mistake in an earlier commit of this branch and put back
since) linked, resolved nothing and placed no hook, and no check saw it. Each HOS_SITE_ENGINE line's site must now be a
row of a build's table. A plain HOS_SITE line, a slot for a mod's callback, is not required to have one yet. Written
and compiled only; read against the current table and sites.def by hand: all 92 engine lines have their row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
"texture packs:" joins RESERVED_LOG (host/texture_packs.c, the renderer's "vk: texture packs:"), and docs/parity-gates.md
says what texture packs start: nothing with no mods, the lsmod-texdec thread with a pack on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The decision of 2026-11-19 on hook shapes: on a worker thread a branch, allow or jump site, or an entry that can return,
is an engine feature's (a HOS_SITE_ENGINE line in host/game/sites.def) or an inline data rule, never a callback a mod's
service sets (a HOS_SITE line); scripts reach such a place only through data rules or filters on the serial thread.

nx2/hooks.py check_site takes the engine's site names (engine_sites(), read from host/game/sites.def by load()) and
refuses such a site that is not one, naming the site and the two ways a mod has; a table read without the host's list
(parse_table's tests of made-up tables) is not checked for it. docs/hooks.md says who may change the outcome. Every row
of game/e0f3ccfa/sites.toml keeps the rule already: its outcome-changing worker sites are all the engine's.
tests/test_hooks.py checks the forms, the threads, the list and the supported table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
An allow site's hook was if (<the branch's test> && on && fn(c)) <its goto>: with its flag off the branch was never
taken, so a dormant allow site changed the game, where every other form off is the game as shipped (a replace site
off runs the instruction itself). It is if (<the test> && (!on || fn(c))) now: the callback, asked only when the
test holds, may still keep the branch from being taken while the site is on. tests/test_floor_carry_step.py's
negative control (the hooks off fail the 120 fps check, as the updates without them do) passes again;
tests/test_hooks.py's expected C follows, and docs/hooks.md's forms table and nx2/hooks.py's notes say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
- tests/test_loop_step.py: the authored update's second multiply is fmul s1, s8, s0, as anim.loopStepOther's
  signature (1e200901) and its callback have it, not s2: the hooked update wrote s1 and the advance read the stale
  s2, failing three checks in the second mode. The update hands s1 to the advance.
- tests/test_oot_voice_option.py: the two direct calls of hos_oot_voice_option set x30 to the call's return address,
  as the site's hook does before its callback; the game's stand-in checks it.
- tests/test_song_note_cue.py, tests/test_high_fps_fixes.py: a stand-in for hos_step_probe (host/nn_vi.c), which
  host/oot_high_fps.c's cloth solve reads; the fixtures compile that file whole and did not link.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
A replace site's callback does the instruction's work, or a call's, in its place: it changes the game's outcome as a
branch, allow or jump site does. check_site's rule on worker threads (OUTCOME_FORMS) takes it in: an engine feature's
site (HOS_SITE_ENGINE) or an inline data rule only, never a mod's callback. Every replace row of game/e0f3ccfa/sites.toml
is an engine feature's already (the frame counters, the heap retries, the Voice Language option, the loop and steering
steps, the barriers, the scene format, the movie's frames). docs/hooks.md says which forms are checked; tests/test_hooks.py
refuses a mod-callback replace site there and keeps return, after and before open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The gates were written against the main before #1802, which removed scripts/job_queue.py and scripts/dev_build.py for
scripts/dev.py. parity_gates.py puts each game run in `dev.py queue run parity-<name> --mode shared --`, says so when it
refuses a run outside the queue, and takes the RAM file system check from scripts/devtools/common.py (on_ram, the
queue's own). docs/parity-gates.md builds the two game folders with `dev.py rt`, cancels with `dev.py queue cancel` and
links the developer pages where #1802 moved them; tests/test_parity_gates.py expects the new command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
#1802 laid the docs out as docs/dev (with its reference pages) for people working on Longshot and docs/user for players.
hooks.md and parity-gates.md, written before it, go to docs/dev/reference, listed in docs/dev/README.md, and every path
to them in code, checks and pages follows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
nx2/hooks.py names __doc__ for its command line (main.__doc__), which code_prints took for a module that may read
another's text, so every lift module was hashed whole and a comment changed the lift's key (tests/test_lift_cache.py).
It joins MARKS_NOT_OUTPUT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The OCB hold's text patch (nx2/oot_patches.py patch_ocb_hold, kept from main for #1763) is now an engine
site: before the update's test of its choice (tbnz w21, #31 at f_832b9880+0x548), after its label on
every way in as the patch was, its callback setting x21 from hos_oot_ocb_pick with the manager in x19.
oot_patches' per-file pass edits no function now; only the output size's eight whole-file edits are left
there. ExeFS patches that would break the place are now refused like any other site's. Changes the lift
key (the table's hash and nx2/oot_patches.py).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Two engine sites, menu.buttonWait (f_832e8ad0) and menu.buttonWaitNoDecideAnim (f_832e8d70), the enter of the
sequence nodes that wait for a screen's button, tell host/oot_autoload.c the screen each wait is on. A is pressed
only on Title_00, SystemLoadList_00 and SystemSaveLoad_00, 300 ms after each wait begins, instead of blind presses
from 20 s every 2 s. The game still chooses the save and loads it itself. The timed presses stay as the fallback:
a build without the sites, or no wait told by 45 s. One entry for every user: the Insert-menu row, dev.py ab and
the game's test mode. Each wait, press and the arrival in play are logged with their frame.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
#1855 added a text patch that wraps a menu screen's update so the shared map's projection is scoped to it. patch_file
had become a no-op when every other per-function patch became a hook site, which left the HUD's lines outside any
function (an IndentationError). patch_file now applies only the HUD wrapper, report() warns when it is not found once in
the supported build, and the docstring says it is the one edit inside a function left (no site form runs code around a
function's body). The menu.update entry hook is spliced in at the emit, before this pass, so it runs inside the scope, as
main's menu tick hook did. test_menu_hooks lets oot_patches.py name f_802f1380 only as the HUD wrapper's head.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The lift's hot pieces (nx2/split_hot.py) cut at the functions' heads, and text between two functions goes with the
one above: the wrapper's static declaration of gameplay_hud_update_game landed in another piece than the wrapper,
and #1937's build failed (code_hot_5: undeclared identifier). As on main, the body is not static and the wrapper
declares it; each other version a mod's ExeFS switch writes names it gameplay_hud_update_game__s<n>, so the
versions still do not clash at the link.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The title skip waits while option 1 is set, which is the Insert menu or a mod window that has the input. The check now
has a mod window take the input on the title (the menu closed) on both paths: the host's presses go on, and the Insert
menu opening still holds them. It fails here: with the mod inspector open on the title nothing is pressed, and the save
never loads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The title skip stopped pressing while option 1 was set, and option 1 is the Insert menu or a mod window that has the
input. Opening the mod inspector on the title (or any fullscreen mod window) then held the presses until the skip gave
up: the save never loaded, Link never existed and the control bridge's wait in_play timed out. Its presses are the
host's own (hos_hid_tap, ORed into the game's read after hold-to-toggle, whatever option 1 says), not the player's, so a
mod window has no reason to stop them.

HOS_OPT_INSERT_MENU (99) is the Insert menu alone, menu_is_open(), and the title skip waits on it. Option 1 keeps its
meaning for its other callers (the keys, the pads, the cheats, the HUD shortcut). An older renderer answers 0: the skip
then also presses while the menu is open, where its taps reach the game, not the menu.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
game/<build id>/sites.toml is host/game/sites/<build id>/sites.toml, beside host/game/sites.def (each site's flag
and slot): nx2/hooks.py GAME, make_game.py's lift key (tables_hash over it: the same relative paths, so the key is
unchanged), the AppImage and the Windows builder (host/ carries it; no top game/ folder), and the docs and tests.
A pull request built by the released launcher gets a nightly's tools with only the top folders they have replaced
by the pull request's; nightlies have no game/, so such a build said "hooks: no site table" and left every site out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
The pages and comments came from the Modding API's branch, where the mods' services, the script runtime and the
control bridge's guest-memory phase sat beside the hook sites. Here: host/game/ in the layout is the game services, the
frame phases and the hook sites; docs/dev/README.md lists the hook sites' and the parity gates' pages alone; hooks.md's
rule for a service's site and its Not yet, and host/game/sites.h's subscribers, say the mods' parts come with the
Modding API; parity-gates.md links to Run the game for a test, where #1802 put the in-game runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
fix(tests): the hook conversions' checks over main's own later edits
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 8s
CI / Conventional Commit title (pull_request) Successful in 8s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 13s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Website build and checks (pull_request) Failing after 32s
6b01227a98
main's takeoff velocity above 60 fps (patch_takeoff_velocity) is a text patch of f_804f5030, the function whose driven
body's target the sites physics.driveTarget* moved out of nx2/oot_patches.py: test_drive_target asks only that the old
patch's hos_oot_drive_target is gone, not the function's address. main's takeoff and ledge steps gave
test_high_fps_fixes' music manager fixture a bounded hos_guest_range of their own: the conversions' second one, which
redefined it, is gone (and its second hos_step_probe).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
fix(parity): the gates drive the game through tours/drive.py and longshot_bridge.py
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 10s
Third-party parts / As their notes say (pull_request) Successful in 12s
CI / Website build and checks (pull_request) Failing after 33s
PR description / Description follows the template (pull_request_target) Successful in 7s
8ebb143d9a
#1802 moved the driving out of pipeline_tour.py, so every gate 3 run stopped on
'pipeline_tour has no attribute ctl_module' before the game started.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
feat(mods)!: the Modding API
Some checks failed
beanstalk/approval not approved yet
ci/circleci: setup-pr
Third-party parts / The same as upstream (pull_request) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 15s
Third-party parts / As their notes say (pull_request) Successful in 19s
Website / Website on Cloudflare (pull_request) Failing after 54s
PR description / Description follows the template (pull_request_target) Failing after 1m11s
77362b5d7c
#1958's Modding API on the hook sites of the pull request before it: the script runtime, the game services over
host/game/, the mods' own sites and services, native and code mods, the broker, the UI channel, the TypeScript
compiler, the system mods and the SDK. One commit: the tree of mod-api a334ed6190, its 728 commits on main
(the old stack, its head a334ed6190) not rebased one by one, as the hook sites now come first and too many of them
met the moved sites, tables and docs to resolve each. snaildev99's 33 commits of that stack (the earlier Modding API
work of #1937) are part of it.

Co-authored-by: snaildev99 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3nBDxBnhodLguFyEt
fix(modapi): the mods' storage lets go of the save lock, so a save loads again (#2270)
Some checks failed
beanstalk/approval not approved yet
ci/circleci: setup-pr
Third-party parts / The same as upstream (pull_request) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 49s
Third-party parts / As their notes say (pull_request) Successful in 1m0s
PR description / Description follows the template (pull_request_target) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
9e2e8870c7
## Summary

On `mod-api`, loading a save never finishes: the game stays on the loading screen (the Triforce turning) for good, with
mods or without (`HOS_NO_MODS=1`), on any save, including the repository's own `kokiri-start`. `main` loads the same
saves. See #2190, which reports the same hang.

To see it on `mod-api`: start the game with Skip title screen on (or press A through the title and its file list) and
load any save. The log has `control: state menu -> loading` and never a `map:` line. A sample of every thread
(`HOS_SAMPLE_ALL`) shows `gmd::SaveDataMgr` waiting the whole time inside `nn::fs::OpenFile`, on the save lock.

The cause: since #607's staged saves, `hos_fs_save_root` in `host/nn_fs.c` answers the save folder with the save lock
held (shared), for a caller that reads the folder's files and then lets go with `hos_fs_save_end`, as the control
bridge does. The mods' storage (`save_user` in `host/modapi/storage.c`), which only wants the folder's name for
`storage.save`'s path, never let go. Whenever the game reads a slot's `progress.sav` (every load), the storage runs
`save_user`, the hold leaks, and the save thread's next open of a save file asks for the lock exclusive and waits for
ever. Now `save_user` lets go as soon as it has the name.

Read first: `save_user` in `host/modapi/storage.c`, then `tests/test_modstore_save_lock.py`.

## Testing

**Tested:** Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24. Before the fix: the player's own adult save
(Kakariko) and the repository's `kokiri-start` both stayed on the loading screen, with the mods on, with every mod off
(`HOS_NO_MODS=1`), with the sandbox on and off. After: the same adult save reaches Kakariko Village (`map: KakarikoVillage_Adult_Alternative`), with the
sandbox off and on, a script mod on.
`tests/test_modstore_save_lock.py` fails on `mod-api` (the lock is still held after `save_user`) and passes here.
`host/modapi/storage.c` compiles clean with `-Wall -Wextra` (llvm-mingw clang) before and after.

**Still to test:**
- Linux: `mise run test`, including `test_modstore.py` and `test_modrt.py`, whose stand-in host gets the new call (by hand, or CI)

## Measurements

**Verdict:** fixed: a save loads again; the check fails on `mod-api` and passes here.

Baseline: `mod-api` @ a334ed61, the branch this targets as it was when measured; `mod-api` was rewritten since (now 77362b5d), its tree the same but for `scripts/parity_gates.py`, so the before side still holds. main loads saves already: the leak is in the Modding API's storage.
Setup: Windows 11, RTX 4060 Laptop GPU, driver 621.24; Skip title screen on, an adult save in Kakariko and the
repository's `kokiri-start`; the game-free check.

| | Before: mod-api @ a334ed61 | After: this PR @ cd50c165 |
|---|---|---|
| `tests/test_modstore_save_lock.py` | fails (`holds == 0`: the lock still held after `save_user`) | passes |
| loading a save (no mods, `HOS_NO_MODS=1`) | the loading screen for good: `state loading`, no `map:` line | `map: KakarikoVillage_Adult_Alternative (adult)` |
| loading a save (a script mod on, sandbox on) | the loading screen for good | in play in Kakariko, 14 s after the first controller read |

## Risks

`save_user` only copies the folder's name, so letting go right away is safe; the control bridge's own hold is not
touched. A caller added later that reads the save folder's files still has to hold the lock and call
`hos_fs_save_end` itself.

## Checklist

### Ready for review

- [x] One topic, on current `mod-api`; the title is a Conventional Commit.
- [x] Tested on my own PC, in the game for a change the game runs, as Testing says.
- [ ] `mise run test` passes (any failure that also fails on `mod-api` is named). <!-- Windows half run; the Linux half is CI's -->
- [x] Measured against `main`, or Measurements says why there is nothing to measure.
- [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible.

### When it applies

- [x] A fix: a game-free test that fails on `mod-api` and passes here.
- [x] A check under `tests/` that reads changed source is updated, not weakened. (`tests/modrt_test.c`'s stand-in host)
- [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. <!-- Windows built and played; Linux: CI -->
- [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers.

### Ready to merge

- [ ] Everything in Still to test has run, its results in Tested.
- [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
- [ ] Approved in review, every comment answered.
- [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Reviewed-on: #2270
fix(modapi): a content mod's outputs are written under the Windows sandbox (#2269)
Some checks failed
beanstalk/approval not approved yet
ci/circleci: setup-pr
Third-party parts / The same as upstream (pull_request) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 50s
Third-party parts / As their notes say (pull_request) Successful in 56s
Website / Website on Cloudflare (pull_request) Failing after 3m9s
PR description / Description follows the template (pull_request_target) Failing after 3m31s
f055dd205c
## Summary

On Windows, a content mod (one with a `content` module that adds flags, items or actors) gets none of its content made
while the script mods' sandbox is on, which is the default. The log says `mods: content: cannot write
...modcache/content/...` and the mod's flags are missing; `tests/game-features/flags`' own-flag test fails on Windows.

To see it on `mod-api`: on Windows, with the sandbox on, run any content mod (`python -I scripts/dev.py game-tests
tests/game-features/flags`): the own-flag test fails, and the log has the "cannot write" line.

The cause: `make_dirs` in `host/modapi/content.c` makes and checks every folder of the output's path from the drive
down. The sandbox (an AppContainer) lets the game write in `modcache` but neither make nor read the folders above the
game folder (the user's own), so the check of the very first one fails and nothing is written. Now only the output's own
folder has to exist; a folder above it the sandbox hides is passed over.

Read first: `make_dirs` in `host/modapi/content.c`, then `tests/test_content_sandbox_dirs.py`.

## Testing

**Tested:** Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24, the sandbox on. `features/flags`: its
own-flag test failed (`cannot write`, WaitTimeout) before the fix and passes after; a content mod with two flags gets
both in the game's list. `tests/test_content_sandbox_dirs.py` fails on `mod-api` (inside the stand-in sandbox, the
output is refused) and passes here; with the fix's key line undone it fails again.

**Still to test:**
- Linux: `mise run test` (the sandbox there is not an AppContainer: nothing should change) (by hand, or CI)

## Measurements

**Verdict:** fixed: a content mod's outputs are written with the sandbox on; the check fails on `mod-api` and passes here.

Baseline: `mod-api` @ a334ed61, the branch this targets as it was when measured; `mod-api` was rewritten since (now 77362b5d), its tree the same but for `scripts/parity_gates.py`, so the before side still holds. main has no script-mod sandbox.
Setup: Windows 11, RTX 4060 Laptop GPU, driver 621.24; the sandbox on; `tests/game-features/flags` in the game, and the
game-free check.

| | Before: mod-api @ a334ed61 | After: this PR @ 4b6722fb |
|---|---|---|
| `tests/test_content_sandbox_dirs.py` | fails (output refused inside the stand-in sandbox) | passes |
| a content mod's flags, sandbox on | `mods: content: cannot write ...modcache/content/...`, flags missing | made, both flags in the game's list |

## Risks

A folder that really can't be made is still refused (the last folder's answer is the result), so a failed write still
says "cannot write". Nothing a player notices except content mods working.

## Checklist

### Ready for review

- [x] One topic, on current `mod-api`; the title is a Conventional Commit.
- [x] Tested on my own PC, in the game for a change the game runs, as Testing says.
- [ ] `mise run test` passes (any failure that also fails on `mod-api` is named). <!-- Windows half run; the Linux half is CI's -->
- [x] Measured against `main`, or Measurements says why there is nothing to measure.
- [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible.

### When it applies

- [x] A fix: a game-free test that fails on `mod-api` and passes here.
- [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. <!-- Windows built and played; Linux: CI -->
- [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers.

### Ready to merge

- [ ] Everything in Still to test has run, its results in Tested.
- [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
- [ ] Approved in review, every comment answered.
- [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Reviewed-on: #2269
The runtime takes a mod's content by its id (items.grant(":Rupee7")), but its flags only by their game names: a mod
wrote "M1a2b3c4d.Seen", the hash of its own id worked out by hand (the flags feature mod computed it with FNV-1a in its
script). game.flags.get, has and set and flagChanged's filter now take ":Seen", the calling mod's own flag, and
"owner/name:Seen", another mod's, as content.flag names them.

host/mod_content.c mod_content_flag_ref names it (the mod's word and the id); host/modapi/game_events.c modrt_flag_name
hands a game name through as it is and a name with a ":" as that flag's game name, or refuses it (UnknownNameError: a
":" with no declaration's id after it; has() false). flagChanged keeps a ":id" filter as its game name, so the event's
flag (its game name, whichever way the listener named it) matches it: modrt_watch_refused may give back another block,
which bindings.c hands over by address. The fake game names them the same way (lib/fake-game.js _flagName; its
subscribe answers with the filter kept, which lib/prelude.js matches on).

The flags feature mod names its own flag ":Seen" and watches it; tests/test_game_flag_ids.py runs the naming, cut from
the sources, against FNV-1a of its own, and checks that get, has, set and flagChanged's on() name the flag first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
feat(modapi): the test game's flag and setFlag take a mod's content flags by their ids, as game.flags does
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
50a54a61bd
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24, an adult save in Kakariko Village, sandbox off (for the control bridge), with #2267 and #2268 beside it. Magic Singing names its flag by id in its script: flags.set(":ButtonsToo", 1) was written as game.flags.set Me1c8f220.ButtonsToo 0 -> 1 once in play (before that, 'write not now (not in play)' with the same game name), and a Song of Storms played on the buttons went on as that flag says.

Tested in game: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24, an adult save in Kakariko Village, sandbox off (for the control bridge), with #2267 and #2268 beside it. Magic Singing names its flag by id in its script: flags.set(":ButtonsToo", 1) was written as game.flags.set Me1c8f220.ButtonsToo 0 -> 1 once in play (before that, 'write not now (not in play)' with the same game name), and a Song of Storms played on the buttons went on as that flag says.
ChloeNow force-pushed feat/modapi-flags-by-id from 50a54a61bd
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to f99bffce6e
Some checks are pending
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 20s
2026-11-22 19:04:14 +00:00
Compare
Some checks are pending
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 20s
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/modapi-flags-by-id:ChloeNow-feat/modapi-flags-by-id'
git switch 'ChloeNow-feat/modapi-flags-by-id'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'mod-api'
git merge --no-ff 'ChloeNow-feat/modapi-flags-by-id'
git switch 'ChloeNow-feat/modapi-flags-by-id'
git rebase 'mod-api'
git switch 'mod-api'
git merge --ff-only 'ChloeNow-feat/modapi-flags-by-id'
git switch 'ChloeNow-feat/modapi-flags-by-id'
git rebase 'mod-api'
git switch 'mod-api'
git merge --no-ff 'ChloeNow-feat/modapi-flags-by-id'
git switch 'mod-api'
git merge --squash 'ChloeNow-feat/modapi-flags-by-id'
git switch 'mod-api'
git merge --ff-only 'ChloeNow-feat/modapi-flags-by-id'
git switch 'mod-api'
git merge 'ChloeNow-feat/modapi-flags-by-id'
git push origin 'mod-api'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2287
No description provided.