fix(builder): dev site-hooks keeps a caller's mark when a hook is entered again, so test_title_card_sites passes #2594

Merged
HumanBean merged 1 commit from HumanBean/Longshot:fix/site-hooks-reentrant-mark into main 2026-11-26 03:48:47 +00:00
Owner

Summary

tests/test_title_card_sites.py, new in #2589, fails on main (Assertion draws==3 failed), so every PR's game-free checks part 1/2 fails.

The cause is in the test harness, not the game. longshot-builder dev site-hooks wraps each hook site so a C test can run it. A wrapper tells the hook's paths apart by one thread-local mark: it sets the mark to 0, calls the hooked function, then reads it.

ui.titleDraw's callback draws the title card's three strips by calling the same function again, whose own wrapper then reset the mark under its caller. The outer hook read the inner call's answer and took itself for not handled, so the fixture's game draw ran a fourth time, with the picture already clobbered.

Each wrapper now saves the mark before its call and puts it back after. The lift itself lowers a hook to control flow, not to a mark, which is why the game drew the card correctly in #2589's run.

Read builder/crates/longshot-builder/src/dev/site_hooks.rs, wrapper.

Testing

Tested: Linux (CachyOS), through the job queue:

  • tests/test_title_card_sites.py fails on main: the fixture counts 4 draws (strips 2, 3, 4, then the whole picture again). It passes here.
  • All 47 checks that use tests/sitehooks.py pass (run_all.py --strict with those names), so the other sites' answers are unchanged.

Still to test: None.

Measurements

Nothing to measure: the test harness only.

Risks

None for players: dev site-hooks only builds test fixtures. Revert to undo.

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). (the 47 checks this touches; CI runs the rest)
  • 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 fix: a game-free test that fails on main and passes here.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • 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.ai/code/session_017vw8e1RP1VgcWpgA7Kq6ec

## Summary `tests/test_title_card_sites.py`, new in [#2589](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2589), fails on main (`Assertion draws==3 failed`), so every PR's game-free checks part 1/2 fails. The cause is in the test harness, not the game. `longshot-builder dev site-hooks` wraps each hook site so a C test can run it. A wrapper tells the hook's paths apart by one thread-local mark: it sets the mark to 0, calls the hooked function, then reads it. `ui.titleDraw`'s callback draws the title card's three strips by calling the same function again, whose own wrapper then reset the mark under its caller. The outer hook read the inner call's answer and took itself for not handled, so the fixture's game draw ran a fourth time, with the picture already clobbered. Each wrapper now saves the mark before its call and puts it back after. The lift itself lowers a hook to control flow, not to a mark, which is why the game drew the card correctly in #2589's run. Read `builder/crates/longshot-builder/src/dev/site_hooks.rs`, `wrapper`. ## Testing **Tested:** Linux (CachyOS), through the job queue: - `tests/test_title_card_sites.py` fails on main: the fixture counts 4 draws (strips 2, 3, 4, then the whole picture again). It passes here. - All 47 checks that use `tests/sitehooks.py` pass (`run_all.py --strict` with those names), so the other sites' answers are unchanged. **Still to test:** None. ## Measurements Nothing to measure: the test harness only. ## Risks None for players: `dev site-hooks` only builds test fixtures. Revert to undo. ## 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. - [x] `mise run test` passes (any failure that also fails on `main` is named). (the 47 checks this touches; CI runs the rest) - [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 `main` and passes here. - [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. - [ ] 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) https://claude.ai/code/session_017vw8e1RP1VgcWpgA7Kq6ec
fix(builder): dev site-hooks keeps a caller's mark when a hook is entered again, so test_title_card_sites passes
Some checks failed
PR description / Title and description (pull_request_target) Successful in 15s
CI / What the change needs (pull_request) Successful in 20s
CI / Third-party parts and guide screenshots (pull_request) Successful in 28s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 2m2s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 2m41s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m26s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 5m21s
CI / Website build and checks (pull_request) Successful in 3m34s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 9m3s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Successful in 18m42s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 31m27s
1c97dd3a51
The wrappers of longshot-builder dev site-hooks tell a hook's paths apart by one thread-local mark, set to 0
before the hooked function and read after. ui.titleDraw's callback draws the title card's strips through the
same function, whose own wrapper set the mark under its caller: the outer hook then read the inner one's
answer, took itself for not handled, and the fixture's game draw ran a fourth time (#2589's test, failing on
main: draws==3). Each wrapper now saves the mark and puts it back. Only the test harness: the lift itself
lowers a hook to control flow, which is why the game drew the card right.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e1RP1VgcWpgA7Kq6ec
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!2594
No description provided.