feat(mod-api): actors.guarded tells a blocked hit and the reaction it gave #3293

Merged
llun merged 3 commits from glinesbdev/Longshot:feat/mod-api-actor-guarded into main 2026-12-06 05:29:25 +00:00
Contributor

Summary

A mod can react to a hit that landed (actors.damaged), but not to one an actor blocked: Link's shield or Nayru's Love, or an enemy guarding. So it cannot reward a guard, count what a shield stopped, or react to an enemy blocking Link's sword.

This adds the event actors.guarded (actors.read, filtered by ActorFilter, told at the next frame like damaged). It carries the actor that blocked (actor, key, type, file), guardType, the reaction the block gave it by the game's own list of hit reactions (a new enum GuardType: guard, mediumHit, smallHit, ...), and nayrusLove, set when Link's Nayru's Love took the hit. A blocked hit is not an actors.damaged hit. It costs nothing while no mod listens.

How it works: a new core site, actors.guard, at the function the game hands a hit's guard data to the defender's life component with (build e0f3ccfa: f_80addb90(record, hit), before it loads the hit's guard type). Its engine callback only reads, and notes a block in a ring while a mod watches; the main thread takes the ring at the acquire phase, as it takes the damage notes. The game's function also takes a hit that landed (with guard type 0): only a hit whose guard field (hit +0x64) is set is told.

How each field was found (the code index, a write-watch and runs) is in docs/dev/reference/actors.md, "A blocked hit".

Read first: game/crates/game-core/src/guard.rs (the reading and the ring) and game/crates/game-core/src/layout/guard.rs (the fields and the list of reactions, with what each is). Then the site in game/sites/sites.toml (actors.guard) and its callback in engine.rs (on_guard), api/src/services/actors.rs (fire_guard) and features.rs.

Testing

Tested: Windows 10, Radeon RX 7800 XT (AMD 26.11.2), a build of this branch with a mod logging every actors.damaged and actors.guarded. No landed hit was told as a block: 9 of Link's sword hits on Wolfos, a cut of grass, 3 scripted hits (actors.damage) and 2 hits on Link each read damaged only. Each block was told once:

Block type guardType nayrusLove
A Wolfos blocking Link's sword (16) Enemy_Wolfos guard false
An Octorok's rock on Link's Deku or Hylian Shield (2) Player guard false
A block that knocked Link back (3) Player mediumHit false
A hit Link's Nayru's Love took (7) Player guard, or mediumHit for a heavy blow true

Earlier runs of the same site in a write-watch build also had a Skulltula turning Link's sword away (smallHit), an Iron Knuckle's landed hit read as not a block, and the Hylian Shield reading the same as the Deku Shield. What told a block from a landed hit was found with a dump of the hit at the site: hit +0x64 was non-zero for every block and 0 for each of 13 landed hits.

Checks, on main @ de091ae29:

  • cargo test -p game-core --lib: 445 passed (new: a_block_is_read_from_the_hit_before_the_game_turns_a_9_into_0, which also checks a landed hit is not a block).
  • cargo test -p api --lib: 650 passed, 1 failed: services::settings_push::tests::a_rows_dependencies_come_from_its_data, which fails on main too (run with this change stashed). The features test now checks actors.guarded needs the actors.guard site and is absent without it.
  • modtool: testing_game::tests::a_blocked_hit_names_its_reaction_and_whether_nayrus_love_took_it passes; removing the site's note fails it. modtool's lib tests do not compile on main: import.rs calls game_files::patches::collect without the refuse argument added in #2533's change; the test was run with that call fixed locally, not in this PR.
  • cargo test -p game-sites -p sites: passed (the site's signature and owner).
  • cargo clippy -p game-core -p api -p modtool --lib --tests --no-deps -- -D warnings: nothing in the changed files; main's own errors in api (flag_exps.rs, settings_host.rs) stop it before modtool. rustfmt is clean on the changed files (cargo fmt --all --check fails on main in files this does not touch). schema-gen --check: clean.

Still to test:

  • Linux: log actors.guarded, block an Octorok's rock with the shield and let a Wolfos block the sword, expecting guard for each and no block for a hit that lands (@Beanstalk or by hand).

Measurements

Nothing to measure: the site's callback returns at once while no mod listens; with one, it is a few bounded reads and a ring write per block.

Risks

  • A new site on a worker thread that only reads and changes nothing the game does. Without it in a build, has("actors.guarded") is false and the event never fires.
  • guardType names come from the game's list of reactions, by its order; only guard, mediumHit and smallHit were seen in a block. A value past the list reads null.
  • In the Hall of Fallen Foes (a dream stage) a run on an older build saw neither Link nor any hit, so neither damaged nor guarded may be told there.
  • A revert is enough. Nothing changes in saves or settings.

Open questions:

  • Who dealt the blocked hit, and with what? This leaves them out: whether the attacker's link and the damage kinds are fresh at a guard was not checked.
  • Which shield blocked? The guard data does not say; the game knows Link's shield, so the event could read it from his equipment. Worth adding?

Checklist

Ready for review

  • One topic, on current main; 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). Not run: mise isn't installed on this PC. The cargo checks under Testing ran instead, with the failures that also fail on main 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

  • 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 A mod can react to a hit that landed (`actors.damaged`), but not to one an actor blocked: Link's shield or Nayru's Love, or an enemy guarding. So it cannot reward a guard, count what a shield stopped, or react to an enemy blocking Link's sword. This adds the event `actors.guarded` (`actors.read`, filtered by `ActorFilter`, told at the next frame like `damaged`). It carries the actor that blocked (`actor`, `key`, `type`, `file`), `guardType`, the reaction the block gave it by the game's own list of hit reactions (a new enum `GuardType`: `guard`, `mediumHit`, `smallHit`, ...), and `nayrusLove`, set when Link's Nayru's Love took the hit. A blocked hit is not an `actors.damaged` hit. It costs nothing while no mod listens. How it works: a new core site, `actors.guard`, at the function the game hands a hit's guard data to the defender's life component with (build e0f3ccfa: `f_80addb90(record, hit)`, before it loads the hit's guard type). Its engine callback only reads, and notes a block in a ring while a mod watches; the main thread takes the ring at the acquire phase, as it takes the damage notes. The game's function also takes a hit that landed (with guard type 0): only a hit whose guard field (hit `+0x64`) is set is told. How each field was found (the code index, a write-watch and runs) is in `docs/dev/reference/actors.md`, "A blocked hit". Read first: `game/crates/game-core/src/guard.rs` (the reading and the ring) and `game/crates/game-core/src/layout/guard.rs` (the fields and the list of reactions, with what each is). Then the site in `game/sites/sites.toml` (`actors.guard`) and its callback in `engine.rs` (`on_guard`), `api/src/services/actors.rs` (`fire_guard`) and `features.rs`. ## Testing **Tested:** Windows 10, Radeon RX 7800 XT (AMD 26.11.2), a build of this branch with a mod logging every `actors.damaged` and `actors.guarded`. No landed hit was told as a block: 9 of Link's sword hits on Wolfos, a cut of grass, 3 scripted hits (`actors.damage`) and 2 hits on Link each read `damaged` only. Each block was told once: | Block | `type` | `guardType` | `nayrusLove` | |---|---|---|---| | A Wolfos blocking Link's sword (16) | `Enemy_Wolfos` | `guard` | false | | An Octorok's rock on Link's Deku or Hylian Shield (2) | `Player` | `guard` | false | | A block that knocked Link back (3) | `Player` | `mediumHit` | false | | A hit Link's Nayru's Love took (7) | `Player` | `guard`, or `mediumHit` for a heavy blow | true | Earlier runs of the same site in a write-watch build also had a Skulltula turning Link's sword away (`smallHit`), an Iron Knuckle's landed hit read as not a block, and the Hylian Shield reading the same as the Deku Shield. What told a block from a landed hit was found with a dump of the hit at the site: hit `+0x64` was non-zero for every block and 0 for each of 13 landed hits. Checks, on `main` @ de091ae29: - `cargo test -p game-core --lib`: 445 passed (new: `a_block_is_read_from_the_hit_before_the_game_turns_a_9_into_0`, which also checks a landed hit is not a block). - `cargo test -p api --lib`: 650 passed, 1 failed: `services::settings_push::tests::a_rows_dependencies_come_from_its_data`, which fails on `main` too (run with this change stashed). The features test now checks `actors.guarded` needs the `actors.guard` site and is absent without it. - modtool: `testing_game::tests::a_blocked_hit_names_its_reaction_and_whether_nayrus_love_took_it` passes; removing the site's note fails it. modtool's lib tests do not compile on `main`: `import.rs` calls `game_files::patches::collect` without the `refuse` argument added in #2533's change; the test was run with that call fixed locally, not in this PR. - `cargo test -p game-sites -p sites`: passed (the site's signature and owner). - `cargo clippy -p game-core -p api -p modtool --lib --tests --no-deps -- -D warnings`: nothing in the changed files; `main`'s own errors in `api` (`flag_exps.rs`, `settings_host.rs`) stop it before modtool. rustfmt is clean on the changed files (`cargo fmt --all --check` fails on `main` in files this does not touch). `schema-gen --check`: clean. **Still to test:** - Linux: log `actors.guarded`, block an Octorok's rock with the shield and let a Wolfos block the sword, expecting `guard` for each and no block for a hit that lands (@Beanstalk or by hand). ## Measurements Nothing to measure: the site's callback returns at once while no mod listens; with one, it is a few bounded reads and a ring write per block. ## Risks - A new site on a worker thread that only reads and changes nothing the game does. Without it in a build, `has("actors.guarded")` is false and the event never fires. - `guardType` names come from the game's list of reactions, by its order; only `guard`, `mediumHit` and `smallHit` were seen in a block. A value past the list reads null. - In the Hall of Fallen Foes (a dream stage) a run on an older build saw neither Link nor any hit, so neither `damaged` nor `guarded` may be told there. - A revert is enough. Nothing changes in saves or settings. Open questions: - Who dealt the blocked hit, and with what? This leaves them out: whether the attacker's link and the damage kinds are fresh at a guard was not checked. - Which shield blocked? The guard data does not say; the game knows Link's shield, so the event could read it from his equipment. Worth adding? ## Checklist ### Ready for review - [x] One topic, on current `main`; 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). Not run: mise isn't installed on this PC. The cargo checks under Testing ran instead, with the failures that also fail on `main` named. - [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] 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)
feat(mod-api): actors.guarded tells a blocked hit and the reaction it gave
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
d64d1bfbfe
A mod could react to a hit that landed (`actors.damaged`) but not to one an actor blocked: Link's shield or Nayru's Love, or an enemy guarding.

A new core site, `actors.guard`, reads the hit at the function the game hands a blocked hit to the defender's life component with. It only reads, and notes a block while a mod watches; the main thread takes the notes at the acquire phase and fires `actors.guarded` with the actor that blocked, `guardType` (the reaction the block gave it, by the game's own list of hit reactions: `guard`, `mediumHit`, `smallHit`, ...) and `nayrusLove`. The game's function also takes a hit that landed; only a hit whose guard field is set is told.

The fake game gets `game.guard({ target, guardType, nayrusLove })`; `has("actors.guarded")` needs the new site.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
glinesbdev changed title from WIP: feat(mod-api): actors.guarded tells a blocked hit and the reaction it gave to feat(mod-api): actors.guarded tells a blocked hit and the reaction it gave 2026-12-06 00:28:41 +00:00
Owner
@review
BeanBot requested changes 2026-12-06 01:52:15 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The change commits material copied from the game's code and data, and the new worker-thread queue can corrupt or permanently stall event delivery after its ring wraps. The published event order also differs from the order in which the service fires it.

Adds a next-frame event for blocked hits, including the defender, reaction and Nayru's Love flag. The reported Windows run shows the intended cases working, but the queue and repository-rule problems need correction before merge.

Blocking (1): must change before merging.

  1. L1 game/sites/sites.toml:848: The new signature commits instruction words from the game; the new guard type table also reproduces the game's ordered list of names. (more on the line) Do: Remove the copied game material and use a repository-permitted way to identify the site and describe reactions, including updating the schema and generated documentation as needed.

Should fix (2): not blocking, but worth doing before merging.

  • L2 game/crates/game-core/src/guard.rs:101: Ticket reservation does not give a writer exclusive ownership of a ring slot after the ring wraps. (more on the line) Do: Use a bounded multi-producer queue that prevents an older reservation from writing a slot reused by a newer ticket, and add a test that forces a delayed writer across a wrap.
  • L3 game/modapi/schema/actors.toml:614: The declared event order does not match dispatch: order 32 places guarded after the pause-menu and other later acquire events, but actors_step fires it before those services run. (more on the line) Do: Dispatch guarded at its declared position, or assign and document an order matching its actual dispatch; add an ordering test.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L4 game/sites/sites.toml:836: The new worker-thread site has not been exercised on Linux. (more on the line) Do: Run the listed Linux shield, enemy-guard and landed-hit cases and report the results.
  • L5 game/crates/game-core/src/engine.rs:330: The claim of no cost without a listener omits the installed hook and callback reached for landed hits as well as blocks. (more on the line) Do: Compare frame times and 1% lows against the base in a representative combat scene with no listener, using repeated interleaved runs. (@fix does its part first: Move or gate the inactive check at the lowest practical hook layer to reduce callback overhead.)

@fix can do L1, L2, L3 and L5.

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes for the tested Windows cases: the PR reports 28 blocks delivered once and 16 landed hits delivered only as damage. Linux behavior and the cost of the new hook without a listener remain unmeasured.

Other systems: The site runs on game worker threads for landed hits as well as blocks, even without a listener; events are delivered on the main thread. The reported game run covers Windows on one AMD GPU, not Linux. No saves, renderer, audio or input changes are apparent.

Switches: None.

Reviewed: d64d1bfbfe against de091ae295: Read AGENTS.md, CONTRIBUTING.md, the PR template, relevant standards, the commit, the diff, the new guard and layout files, and the surrounding actor dispatch, feature checks, memory reads and test harness paths. Skimmed generated modding reference and permission tables, testing declarations and the recorded run. Tooling's adjacent AGENTS.md and docs/review-checklist.md were absent. The other large changed code files were reviewed at their changed sections and relevant callers, not read in full.; nothing run (a code review).

Checked and fine:

  • The commit records AI assistance.
  • The event uses actors.read and the existing payload filter mechanism.
  • The reported game-free test exercises both player and enemy guard payloads and would fail if the site stopped noting blocks.
  • No switch, renderer API version change, shader output or third-party change was found.

Testing: No code or tests were run, as requested. The PR reports a Windows game run and game-free checks; CI is still running.

Overlaps and merge order: Not checked; network access was unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The change commits material copied from the game's code and data, and the new worker-thread queue can corrupt or permanently stall event delivery after its ring wraps. The published event order also differs from the order in which the service fires it. Adds a next-frame event for blocked hits, including the defender, reaction and Nayru's Love flag. The reported Windows run shows the intended cases working, but the queue and repository-rule problems need correction before merge. **Blocking (1)**: must change before merging. 1. **L1** `game/sites/sites.toml:848`: The new signature commits instruction words from the game; the new guard type table also reproduces the game's ordered list of names. (more on the line) **Do:** Remove the copied game material and use a repository-permitted way to identify the site and describe reactions, including updating the schema and generated documentation as needed. **Should fix (2)**: not blocking, but worth doing before merging. - **L2** `game/crates/game-core/src/guard.rs:101`: Ticket reservation does not give a writer exclusive ownership of a ring slot after the ring wraps. (more on the line) **Do:** Use a bounded multi-producer queue that prevents an older reservation from writing a slot reused by a newer ticket, and add a test that forces a delayed writer across a wrap. - **L3** `game/modapi/schema/actors.toml:614`: The declared event order does not match dispatch: order 32 places guarded after the pause-menu and other later acquire events, but actors_step fires it before those services run. (more on the line) **Do:** Dispatch guarded at its declared position, or assign and document an order matching its actual dispatch; add an ordering test. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4** `game/sites/sites.toml:836`: The new worker-thread site has not been exercised on Linux. (more on the line) **Do:** Run the listed Linux shield, enemy-guard and landed-hit cases and report the results. - **L5** `game/crates/game-core/src/engine.rs:330`: The claim of no cost without a listener omits the installed hook and callback reached for landed hits as well as blocks. (more on the line) **Do:** Compare frame times and 1% lows against the base in a representative combat scene with no listener, using repeated interleaved runs. *(`@fix` does its part first: Move or gate the inactive check at the lowest practical hook layer to reduce callback overhead.)* `@fix` can do L1, L2, L3 and L5. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the tested Windows cases: the PR reports 28 blocks delivered once and 16 landed hits delivered only as damage. Linux behavior and the cost of the new hook without a listener remain unmeasured. **Other systems:** The site runs on game worker threads for landed hits as well as blocks, even without a listener; events are delivered on the main thread. The reported game run covers Windows on one AMD GPU, not Linux. No saves, renderer, audio or input changes are apparent. **Switches:** None. **Reviewed:** d64d1bfbfeb7 against de091ae295b7: Read AGENTS.md, CONTRIBUTING.md, the PR template, relevant standards, the commit, the diff, the new guard and layout files, and the surrounding actor dispatch, feature checks, memory reads and test harness paths. Skimmed generated modding reference and permission tables, testing declarations and the recorded run. Tooling's adjacent AGENTS.md and docs/review-checklist.md were absent. The other large changed code files were reviewed at their changed sections and relevant callers, not read in full.; nothing run (a code review). **Checked and fine:** - The commit records AI assistance. - The event uses actors.read and the existing payload filter mechanism. - The reported game-free test exercises both player and enemy guard payloads and would fail if the site stopped noting blocks. - No switch, renderer API version change, shader output or third-party change was found. **Testing:** No code or tests were run, as requested. The PR reports a Windows game run and game-free checks; CI is still running. **Overlaps and merge order:** Not checked; network access was unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -325,2 +327,4 @@
}
/// `actors.guard`: the game hands a blocked hit to the defender's life component (x0 its guard record, x1 the hit).
fn on_guard(cx: &mut SiteCx<'_, '_>) -> i32 {
Member

L5 (should fix): The claim of no cost without a listener omits the installed hook and callback reached for landed hits as well as blocks.

When: Players with no subscribing mod still enter the new callback at every invocation of the game's hit function before the atomic watch check returns.

Do: Compare frame times and 1% lows against the base in a representative combat scene with no listener, using repeated interleaved runs.

**L5** (should fix): The claim of no cost without a listener omits the installed hook and callback reached for landed hits as well as blocks. *When:* Players with no subscribing mod still enter the new callback at every invocation of the game's hit function before the atomic watch check returns. **Do:** Compare frame times and 1% lows against the base in a representative combat scene with no listener, using repeated interleaved runs.
@ -0,0 +98,4 @@
/// Note one block (any thread).
pub fn note(g: Guard) {
let t = HEAD.fetch_add(1, Ordering::Relaxed);
Member

L2 (should fix): Ticket reservation does not give a writer exclusive ownership of a ring slot after the ring wraps. A delayed writer can overwrite a newer writer's sequence and fields.

When: If a worker reserves ticket 0 and is paused, other workers can publish through ticket 256 in the same slot. When the first worker resumes, it replaces that slot with sequence 2; the taker waiting for ticket 256 sees a sequence below 514 and stops, so later events remain stuck until another wrap, and overlapping writes can also mix fields.

Do: Use a bounded multi-producer queue that prevents an older reservation from writing a slot reused by a newer ticket, and add a test that forces a delayed writer across a wrap.

**L2** (should fix): Ticket reservation does not give a writer exclusive ownership of a ring slot after the ring wraps. A delayed writer can overwrite a newer writer's sequence and fields. *When:* If a worker reserves ticket 0 and is paused, other workers can publish through ticket 256 in the same slot. When the first worker resumes, it replaces that slot with sequence 2; the taker waiting for ticket 256 sees a sequence below 514 and stops, so later events remain stuck until another wrap, and overlapping writes can also mix fields. **Do:** Use a bounded multi-producer queue that prevents an older reservation from writing a slot reused by a newer ticket, and add a test that forces a delayed writer across a wrap.
@ -609,0 +611,4 @@
since = "0.1"
permission = "actors.read"
phase = "acquire"
order = 32
Member

L3 (should fix): The declared event order does not match dispatch: order 32 places guarded after the pause-menu and other later acquire events, but actors_step fires it before those services run.

When: When a block and a pause-menu button event occur in the same frame, a mod observing both receives guarded first, although the generated event table lists the button event first.

Do: Dispatch guarded at its declared position, or assign and document an order matching its actual dispatch; add an ordering test.

**L3** (should fix): The declared event order does not match dispatch: order 32 places guarded after the pause-menu and other later acquire events, but actors_step fires it before those services run. *When:* When a block and a pause-menu button event occur in the same frame, a mod observing both receives guarded first, although the generated event table lists the button event first. **Do:** Dispatch guarded at its declared position, or assign and document an order matching its actual dispatch; add an ordering test.
@ -833,1 +833,4 @@
# A blocked hit (game_core::guard; docs/dev/reference/actors.md, "A blocked hit"): actors.guarded's notes. The core's: its
# engine callback only reads, noting the block while a mod watches; no mod has a handler here.
[[site]]
Member

L4 (should fix): The new worker-thread site has not been exercised on Linux.

When: A Linux player using a mod that listens for guarded could receive incorrect or missing events if the hook or its cross-thread delivery behaves differently there; the PR reports only Windows runs.

Do: Run the listed Linux shield, enemy-guard and landed-hit cases and report the results.

**L4** (should fix): The new worker-thread site has not been exercised on Linux. *When:* A Linux player using a mod that listens for guarded could receive incorrect or missing events if the hook or its cross-thread delivery behaves differently there; the PR reports only Windows runs. **Do:** Run the listed Linux shield, enemy-guard and landed-hit cases and report the results.
@ -834,0 +845,4 @@
# x1 the hit. Before its load of the hit's guard type (+0x58), the reaction the block gives the defender, which it then
# tests against 9 (and turns a 9 into 0 before it keeps it): the type is read here, the game's own.
signature_offset = 0x1c
signature = "b9405828 aa0103f4 aa0003f3 7100251f 54000000/ff00001f 39422e89" # (ldr w8, [x1, #0x58]; mov x20, x1; mov x19, x0; cmp w8, #9; b.eq; ldrb w9, [x20, #0x8b])
Member

L1 (blocking): The new signature commits instruction words from the game; the new guard type table also reproduces the game's ordered list of names. The repository prohibits committing game code or material made from game files.

When: The signature records instructions from the identified game function, and the guard layout says its ordered names come from the game's own lookup list. Both are included in the checkout.

Do: Remove the copied game material and use a repository-permitted way to identify the site and describe reactions, including updating the schema and generated documentation as needed.

**L1** (blocking): The new signature commits instruction words from the game; the new guard type table also reproduces the game's ordered list of names. The repository prohibits committing game code or material made from game files. *When:* The signature records instructions from the identified game function, and the guard layout says its ordered names come from the game's own lookup list. Both are included in the checkout. **Do:** Remove the copied game material and use a repository-permitted way to identify the site and describe reactions, including updating the schema and generated documentation as needed.
fix(mod-api): actors.guarded names reactions in its own words, a safe queue, its order, no cost unwatched
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
811acebcbe
From the review:

- The reaction list copied from the game is gone. `GuardReaction` names only the values runs saw in a block, by what the block did: `held` (3), `staggered` (4), `knockedBack` (5); any other is told as null. The payload field is `reaction` (was `guardType`); the fake game takes `game.guard({ reaction })`.
- The notes are a bounded multi-producer queue with a sequence per slot: a slot is written again only after the main thread has taken it, so a writer held up across a wrap cannot overwrite a newer note. A full queue drops the newest, counted. Tests force a held-up writer across a wrap and run several writers at once.
- `guarded` (order 32) is dispatched after the frame's other events, as its order says; a test checks it comes after `damaged` and `songPlayed` of the same frame.
- The site has no engine callback at start: `guard::watch` sets its owner while a mod listens and clears it after, so with no listener a hit costs the dormant site's flag load. The row is `shape = "event"` with no `engine`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Thanks for the review. Pushed a commit for L1, L2, L3 and L5:

L1. The reaction list is gone. layout::guard no longer has the game's 28 reaction names, and the API's enum is now GuardReaction with names of our own for the three values runs saw in a block: held (3), staggered (4), knockedBack (5). Any other value is reported as reaction: null until a run shows what it does. The payload field is renamed from guardType to reaction, the fake game takes game.guard({ reaction }), and the schema and generated docs are regenerated. The dev doc no longer names the game's query classes either. The signature stays: every core site in game/sites/sites.toml (224 rows) is found by a short signature of instruction words with its signature_offset, as docs/dev/reference/hooks.md ("The format") documents, and this row follows that format (6 words, one masked). If a fingerprint is wanted here instead, I can switch it, but that would make this site the only one done that way.

L2. The ring is now a bounded multi-producer queue with a sequence per slot. A writer takes ticket t only when the slot's sequence is t (a compare-and-swap on the head), publishes t + 1, and the taker frees the slot for t + 256. A slot is never written again before it has been taken, so a held-up writer can't overwrite a newer note. When the queue is full the newest note is dropped and counted. New tests: a_writer_held_up_across_a_wrap_keeps_its_slot_and_its_note (holds a claimed slot while 300 more notes arrive, then checks every kept note comes out once, whole and in order) and many_writers_at_once_lose_nothing_that_fits_and_mix_no_fields. (rules' damage ring on main uses the same ticket pattern this one copied; I left it alone here.)

L3. guarded is now dispatched from its own step after mods_host_step, so it fires after every other event in the frame, which is what order 32 says. New test: a_blocked_hit_is_told_after_the_frames_other_events (a damaged, a songPlayed and a guarded in the same frame arrive in that order).

L5. The site no longer has an engine callback installed at start. guard::watch sets the site's owner when a mod listens and clears it otherwise (as items::watch does). With no listener the site is dormant, so a hit costs the flag's byte load and a predicted branch, the same as any dormant site. The row is now shape = "event" with no engine.

L4. I don't have a Linux machine to run this on. Could someone with one run the shield, enemy-guard and landed-hit cases?

Thanks for the review. Pushed a commit for L1, L2, L3 and L5: L1. The reaction list is gone. layout::guard no longer has the game's 28 reaction names, and the API's enum is now GuardReaction with names of our own for the three values runs saw in a block: held (3), staggered (4), knockedBack (5). Any other value is reported as reaction: null until a run shows what it does. The payload field is renamed from guardType to reaction, the fake game takes game.guard({ reaction }), and the schema and generated docs are regenerated. The dev doc no longer names the game's query classes either. The signature stays: every core site in game/sites/sites.toml (224 rows) is found by a short signature of instruction words with its signature_offset, as docs/dev/reference/hooks.md ("The format") documents, and this row follows that format (6 words, one masked). If a fingerprint is wanted here instead, I can switch it, but that would make this site the only one done that way. L2. The ring is now a bounded multi-producer queue with a sequence per slot. A writer takes ticket t only when the slot's sequence is t (a compare-and-swap on the head), publishes t + 1, and the taker frees the slot for t + 256. A slot is never written again before it has been taken, so a held-up writer can't overwrite a newer note. When the queue is full the newest note is dropped and counted. New tests: a_writer_held_up_across_a_wrap_keeps_its_slot_and_its_note (holds a claimed slot while 300 more notes arrive, then checks every kept note comes out once, whole and in order) and many_writers_at_once_lose_nothing_that_fits_and_mix_no_fields. (rules' damage ring on main uses the same ticket pattern this one copied; I left it alone here.) L3. guarded is now dispatched from its own step after mods_host_step, so it fires after every other event in the frame, which is what order 32 says. New test: a_blocked_hit_is_told_after_the_frames_other_events (a damaged, a songPlayed and a guarded in the same frame arrive in that order). L5. The site no longer has an engine callback installed at start. guard::watch sets the site's owner when a mod listens and clears it otherwise (as items::watch does). With no listener the site is dormant, so a hit costs the flag's byte load and a predicted branch, the same as any dormant site. The row is now shape = "event" with no engine. L4. I don't have a Linux machine to run this on. Could someone with one run the shield, enemy-guard and landed-hit cases?
Member
@review
BeanBot left a comment

Recommendation: Request changes. The guard reaction table was replaced, but the new site still commits instruction words from the game, contrary to the repository rule identified in L1. The Linux run also remains outstanding.

Adds a mod event for blocked hits, including the defender, reaction and Nayru's Love flag. The fix improves queue ownership, event ordering and inactive-hook cost, but the site signature still needs a compliant representation.

Blocking (1): must change before merging.

  1. L1 game/sites/sites.toml:848: The new guard site still commits instruction words from the game. When: The signature encodes instructions taken from the game, so merging it commits material made from game files. Do: Replace the instruction-word signature with a site locator that complies with the repository's game-material rule.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L4 game/sites/sites.toml:836: The new worker-thread site has not been exercised on Linux. When: A Linux player using a mod that listens for guarded could receive incorrect or missing events if the hook or its cross-thread delivery behaves differently there; the PR reports only Windows runs. Do: Run the listed Linux shield, enemy-guard and landed-hit cases and report the results.

@fix can do L1.

Since the last review (on d64d1bfbfe)
Resolved: L2 (Ticket reservation does not give a writer exclusive ownership of a ring slot after the rin…); L3 (The declared event order does not match dispatch: order 32 places guarded after the pause-…); L5 (The claim of no cost without a listener omits the installed hook and callback reached for…)
Still open: L1 (The new guard site still commits instruction words from the game.); L4 (The new worker-thread site has not been exercised on Linux.)

Checks: Still running: 11 checks.

Also noticed (2; not asked for, not blocking)
  • The pull request description still names GuardType and guardType and describes an always-installed engine callback, while the code now uses GuardReaction, reaction and a dynamically installed owner.
  • A dormant site still incurs its flag load and branch even though the generated API reference says it costs nothing.
More: does it help, other systems, switches, what was read

Does it help: Unproven on the final head. The author reports successful Windows tests of shield, enemy guard and landed-hit cases on the earlier build; Linux remains untested.

Other systems: The site runs on game worker threads and dispatches on the main thread. The final queue protects slots across concurrent writers; Linux behavior has not been exercised. No save or settings changes are reported.

Switches: None.

Reviewed: 811acebcbe against de091ae295: Read AGENTS.md, CONTRIBUTING.md, the pull request template, guard.rs and layout/guard.rs in full; inspected the fix diff, site and event-dispatch changes, hook documentation, and the stated runs. The review checklist was absent. Other changed code and generated documentation were skimmed rather than read in full.; nothing run (a code review).

Checked and fine:

  • The reaction mapping now exposes only the three independently named values observed in runs.
  • The queue tests cover a delayed writer across a wrap and concurrent writers.

Testing: No commands that build or run the project were executed. The author reports Windows game testing on the earlier build; Linux testing and the listed CI checks remain pending.

Overlaps and merge order: Not established.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The guard reaction table was replaced, but the new site still commits instruction words from the game, contrary to the repository rule identified in L1. The Linux run also remains outstanding. Adds a mod event for blocked hits, including the defender, reaction and Nayru's Love flag. The fix improves queue ownership, event ordering and inactive-hook cost, but the site signature still needs a compliant representation. **Blocking (1)**: must change before merging. 1. **L1** `game/sites/sites.toml:848`: The new guard site still commits instruction words from the game. *When:* The signature encodes instructions taken from the game, so merging it commits material made from game files. **Do:** Replace the instruction-word signature with a site locator that complies with the repository's game-material rule. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4** `game/sites/sites.toml:836`: The new worker-thread site has not been exercised on Linux. *When:* A Linux player using a mod that listens for guarded could receive incorrect or missing events if the hook or its cross-thread delivery behaves differently there; the PR reports only Windows runs. **Do:** Run the listed Linux shield, enemy-guard and landed-hit cases and report the results. `@fix` can do L1. **Since the last review** (on d64d1bfbfeb7) Resolved: L2 (Ticket reservation does not give a writer exclusive ownership of a ring slot after the rin…); L3 (The declared event order does not match dispatch: order 32 places guarded after the pause-…); L5 (The claim of no cost without a listener omits the installed hook and callback reached for…) Still open: L1 (The new guard site still commits instruction words from the game.); L4 (The new worker-thread site has not been exercised on Linux.) **Checks:** Still running: 11 checks. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The pull request description still names GuardType and guardType and describes an always-installed engine callback, while the code now uses GuardReaction, reaction and a dynamically installed owner. - A dormant site still incurs its flag load and branch even though the generated API reference says it costs nothing. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the final head. The author reports successful Windows tests of shield, enemy guard and landed-hit cases on the earlier build; Linux remains untested. **Other systems:** The site runs on game worker threads and dispatches on the main thread. The final queue protects slots across concurrent writers; Linux behavior has not been exercised. No save or settings changes are reported. **Switches:** None. **Reviewed:** 811acebcbec9 against de091ae295b7: Read AGENTS.md, CONTRIBUTING.md, the pull request template, guard.rs and layout/guard.rs in full; inspected the fix diff, site and event-dispatch changes, hook documentation, and the stated runs. The review checklist was absent. Other changed code and generated documentation were skimmed rather than read in full.; nothing run (a code review). **Checked and fine:** - The reaction mapping now exposes only the three independently named values observed in runs. - The queue tests cover a delayed writer across a wrap and concurrent writers. **Testing:** No commands that build or run the project were executed. The author reports Windows game testing on the earlier build; Linux testing and the listed CI checks remain pending. **Overlaps and merge order:** Not established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
fix(sites): find actors.guard by a fingerprint, with no instruction words
Some checks are pending
PR description / Title and description (pull_request_target) Waiting to run
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
ccc6fcb0bd
The site's signature held instruction words of the game's. It is found now by what its function does: of the functions that call f_80addea0 and lock a mutex (four in e0f3ccfa), the one of 180 to 210 instructions. A build lifts with it placed in f_80addb90, as before. hooks.md says a fingerprint also serves a site found without instruction words.

actors.guarded's doc no longer says it costs nothing with no listener: the dormant site's flag is still checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

L1. The signature is gone. actors.guard is now found by a fingerprint with no instruction words: the functions that call f_80addea0 and nn::os::LockMutex (four in e0f3ccfa), narrowed by size to the one with 180 to 210 instructions. A build of the head lifts with the site placed in f_80addb90 at +0x1c, the same place as before. hooks.md now says a fingerprint also serves a site that must be found without instruction words.

From "Also noticed": the event doc no longer says it costs nothing with no listener (it now says a hit costs one check of a flag), and the PR description is updated to GuardReaction/reaction, the watched owner instead of an engine callback, the queue and the fingerprint.

L1. The signature is gone. actors.guard is now found by a fingerprint with no instruction words: the functions that call f_80addea0 and nn::os::LockMutex (four in e0f3ccfa), narrowed by size to the one with 180 to 210 instructions. A build of the head lifts with the site placed in f_80addb90 at +0x1c, the same place as before. hooks.md now says a fingerprint also serves a site that must be found without instruction words. From "Also noticed": the event doc no longer says it costs nothing with no listener (it now says a hit costs one check of a flag), and the PR description is updated to GuardReaction/reaction, the watched owner instead of an engine callback, the queue and the fingerprint.
Member
@review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The guard site no longer commits game instruction words, and the Windows runs show the event working. The worker-thread site still needs the requested Linux game run. Recommend approval; not approved on the forge.

Adds an event that lets mods react when an actor blocks a hit, including the observed reaction and whether Nayru’s Love took it. The fingerprint removes the committed instruction words; the feature adds a dormant hook check when no mod listens and queue work when one does.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L4 game/sites/sites.toml:836: The new worker-thread site has not been exercised on Linux. When: A Linux player using a mod that listens for guarded could receive incorrect or missing events if the hook or its cross-thread delivery behaves differently there; the PR reports only Windows runs. Do: Run the listed Linux shield, enemy-guard and landed-hit cases and report the results.

Since the last review (on 811acebcbe)
Resolved: L1 (The new guard site still commits instruction words from the game.)
Still open: L4 (The new worker-thread site has not been exercised on Linux.)

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes: the reported Windows run observed each of 28 blocks once and no guarded events for the 15 landed or scripted hits listed in the test table. Linux behavior remains unverified.

Other systems: The site runs on game worker threads on Windows and Linux; Windows gameplay was reported working, while Linux remains to be exercised. The fingerprint identifies the function during the build, and the resolver applies the build-specific hook offset.

Switches: None.

Reviewed: ccc6fcb0bd against de091ae295: Read the repository rules and pull request template, the changes since the ledger head, guard.rs and layout/guard.rs, the guard site and its resolver and placement paths. Skimmed the remaining pull request diff, generated documentation, schema, tests and recorded runs; did not read all changed files in full.; nothing run (a code review).

Checked and fine:

  • The fingerprint resolves the function separately from the build-specific +0x1c placement offset.
  • The changed event documentation acknowledges the dormant hook’s flag check.

Testing: No commands that build or run project code were used. The author reports Windows gameplay and game-free checks; the Linux run remains outstanding and CI is still running.

Overlaps and merge order: None found in the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The guard site no longer commits game instruction words, and the Windows runs show the event working. The worker-thread site still needs the requested Linux game run. Recommend approval; not approved on the forge. Adds an event that lets mods react when an actor blocks a hit, including the observed reaction and whether Nayru’s Love took it. The fingerprint removes the committed instruction words; the feature adds a dormant hook check when no mod listens and queue work when one does. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4** `game/sites/sites.toml:836`: The new worker-thread site has not been exercised on Linux. *When:* A Linux player using a mod that listens for guarded could receive incorrect or missing events if the hook or its cross-thread delivery behaves differently there; the PR reports only Windows runs. **Do:** Run the listed Linux shield, enemy-guard and landed-hit cases and report the results. **Since the last review** (on 811acebcbec9) Resolved: L1 (The new guard site still commits instruction words from the game.) Still open: L4 (The new worker-thread site has not been exercised on Linux.) **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the reported Windows run observed each of 28 blocks once and no guarded events for the 15 landed or scripted hits listed in the test table. Linux behavior remains unverified. **Other systems:** The site runs on game worker threads on Windows and Linux; Windows gameplay was reported working, while Linux remains to be exercised. The fingerprint identifies the function during the build, and the resolver applies the build-specific hook offset. **Switches:** None. **Reviewed:** ccc6fcb0bd16 against de091ae295b7: Read the repository rules and pull request template, the changes since the ledger head, guard.rs and layout/guard.rs, the guard site and its resolver and placement paths. Skimmed the remaining pull request diff, generated documentation, schema, tests and recorded runs; did not read all changed files in full.; nothing run (a code review). **Checked and fine:** - The fingerprint resolves the function separately from the build-specific +0x1c placement offset. - The changed event documentation acknowledges the dormant hook’s flag check. **Testing:** No commands that build or run project code were used. The author reports Windows gameplay and game-free checks; the Linux run remains outstanding and CI is still running. **Overlaps and merge order:** None found in the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
llun approved these changes 2026-12-06 05:28:48 +00:00
llun scheduled this pull request to auto merge when all checks succeed 2026-12-06 05:28:54 +00:00
llun requested review from BeanBot 2026-12-06 05:29:19 +00:00
llun merged commit 07b48e9d66 into main 2026-12-06 05:29:25 +00:00
Some checks are pending
PR description / Title and description (pull_request_target) Waiting to run
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
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!3293
No description provided.