fix(dev): dev.py ab compares the builder's handles as set or not, so a Windows A/B writes its measurements #3252

Merged
HumanBean merged 2 commits from llun/Longshot:fix/ab-builder-handles into main 2026-12-05 16:57:18 +00:00
Member

Summary

On Windows, dev.py ab never wrote a Measurements section for an A/B. It finished every run, then ended with exit status 3 ("the sides differed") and no measurements.md.

The cause: each run's vk: switches set log line includes LONGSHOT_BUILDER_PIPES and LONGSHOT_CRASH_BLOCK. These are handles the builder gives each game process: its pipes (build_core::sandbox_windows) and its crash block (build_core::crash_block, read by host/hos_crash_record.c). They get new numbers in every process, so two runs of the same side differ in them (A1 0x2b4, A2 0x2bc), and differences reported that as a setup difference. On Linux the builder's descriptors (LONGSHOT_PADS_FD, LONGSHOT_FILES_FD) can do the same.

How to see it on main: run any dev.py ab on Windows. The output ends with no write-up: switches LONGSHOT_BUILDER_PIPES: A2 has '0x2bc', A1 '0x2b4'; switches LONGSHOT_CRASH_BLOCK: ... and exit status 3.

The fix: these handles are now compared only as set or not set, the way HOS_CONTROL's per-run socket name already is. A run the builder gave no crash block or no pipes still counts as different. Every other switch is still compared by value, including HOS_SANDBOX, which also belongs to the builder but is a setting. --allow means what it did before.

The list (ab.BUILDER_HANDLES) comes from the source rule, not from guessing: every name in build_core::env_own's OWN (the variables only the builder may set) whose gpu/vk/switches.def row says "Set by the builder". A new check holds the list to that rule, so a new handle added to the builder cannot bring the refusal back, and a setting cannot slip into the list.

Read first: BUILDER_HANDLES and ON_OR_OFF in scripts/devtools/ab.py, then the three new tests in tests/test_dev_ab.py.

Found in MagicBeanDev/Longshot#3248, where BeanBot's L1 Market A/B was written up by hand, and in MagicBeanDev/Longshot#3242 (cloth). The same refusal was also hit in MagicBeanDev/Longshot#3099, MagicBeanDev/Longshot#3118, MagicBeanDev/Longshot#3142, MagicBeanDev/Longshot#3251, MagicBeanDev/Longshot#2957 and MagicBeanDev/Longshot#2523.

Testing

Tested: Windows 11. This is a development tool; the game's code is not changed, so there was no new game run. Instead, the real run folder of PR 3248's Market A/B (six runs, RTX 5080, %LOCALAPPDATA%\longshot-dev\runs\ab\20261205-081422-change-market) was summarised again with this branch's ab.summarise and ab.measurements, each run's switches read again from its own logged line. On main that folder gives 6 problems (all LONGSHOT_BUILDER_PIPES / LONGSHOT_CRASH_BLOCK) and no verdict. Here it gives no problems and the same verdict and table that 3248's hand-made Measurements show: +3.2 % fps (median 115.1 against 111.6), within the runs' spread.

Tests (tests/test_dev_ab.py, game-free):

  • Facts.test_builder_handles_compared_as_set_or_not: two runs whose switches lines differ only in the handle values do not differ. A handle present in one run and missing in the other, a different HOS_FPS_MAX, or a different HOS_SANDBOX each still count as one difference.
  • CommandPath.test_windows_runs_write_their_measurements: cmd_ab over six runs (run_one stubbed, logs shaped like 3248's) writes measurements.md and returns 0. With one run's HOS_FPS_MAX changed, it writes none and returns 3, with switches HOS_FPS_MAX as the only problem.
  • Facts.test_builder_handles_from_source: ab.BUILDER_HANDLES equals env_own.rs OWN ∩ the "Set by the builder" rows of switches.def, HOS_SANDBOX is not in it, and the handles are compared as set or not.

The first two fail on main (the test commit alone: exit 3, and the handle differences listed). All three pass here. With the fix's key line undone (ON_OR_OFF = ("HOS_CONTROL",)) all three fail again. tests/test_dev_ab.py also passes on Linux (WSL Ubuntu 24.04, python3 -I -B tests/test_dev_ab.py, 43 tests). mise run lint passes.

mise run test (Windows 11, llvm-mingw, Rust 1.99.1 gnullvm, 12 at once), run as --exact lists in parts: 843 of 844 checks pass. test_lifter fails, only in two parts known to fail on main and fixed in MagicBeanDev/Longshot#3248: host-sys's clippy (large_const_arrays, settings_abi.rs) and api's a_walked_reshade_folder_counts_a_change_once_two_walks_agree. Not run, because they fail on main (also fixed in 3248) and this change touches none of them: test_present_geometry_trace, test_present_image_free, test_present_held_image, test_present_acquire_ahead, test_dlssg, test_no_map_reload, test_sync_watch_event, test_turf_budget, test_ui_renderer, test_no_game_title. This change touches no Rust and no C or C++.

Still to test: None.

Measurements

Nothing to measure: a development tool's comparison of logged switches. The game and its frame times are unchanged. The re-summarised A/B above shows the write-up it now produces. No switch is added or changed: the five names in ab.BUILDER_HANDLES are existing rows of gpu/vk/switches.def that the builder sets. This PR only names them, so there is no default to ship.

Risks

dev.py ab alone changes. The only thing it no longer catches is two runs given different handle numbers by the builder, which carry no setting. A run the builder started without one of them still counts as different. Reverting is enough. Players notice nothing.

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. (Not a change the game runs; the real A/B run folder was summarised again.)
  • 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 fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened. (tests/test_dev_ab.py reads ab.py: three tests added, none changed)
  • 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 On Windows, `dev.py ab` never wrote a Measurements section for an A/B. It finished every run, then ended with exit status 3 ("the sides differed") and no `measurements.md`. **The cause:** each run's `vk: switches set` log line includes `LONGSHOT_BUILDER_PIPES` and `LONGSHOT_CRASH_BLOCK`. These are handles the builder gives each game process: its pipes (`build_core::sandbox_windows`) and its crash block (`build_core::crash_block`, read by `host/hos_crash_record.c`). They get new numbers in every process, so two runs of the same side differ in them (A1 `0x2b4`, A2 `0x2bc`), and `differences` reported that as a setup difference. On Linux the builder's descriptors (`LONGSHOT_PADS_FD`, `LONGSHOT_FILES_FD`) can do the same. **How to see it on `main`:** run any `dev.py ab` on Windows. The output ends with `no write-up: switches LONGSHOT_BUILDER_PIPES: A2 has '0x2bc', A1 '0x2b4'; switches LONGSHOT_CRASH_BLOCK: ...` and exit status 3. **The fix:** these handles are now compared only as set or not set, the way `HOS_CONTROL`'s per-run socket name already is. A run the builder gave no crash block or no pipes still counts as different. Every other switch is still compared by value, including `HOS_SANDBOX`, which also belongs to the builder but is a setting. `--allow` means what it did before. The list (`ab.BUILDER_HANDLES`) comes from the source rule, not from guessing: every name in `build_core::env_own`'s `OWN` (the variables only the builder may set) whose `gpu/vk/switches.def` row says "Set by the builder". A new check holds the list to that rule, so a new handle added to the builder cannot bring the refusal back, and a setting cannot slip into the list. Read first: `BUILDER_HANDLES` and `ON_OR_OFF` in `scripts/devtools/ab.py`, then the three new tests in `tests/test_dev_ab.py`. Found in [MagicBeanDev/Longshot#3248](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3248), where BeanBot's L1 Market A/B was written up by hand, and in [MagicBeanDev/Longshot#3242](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3242) (cloth). The same refusal was also hit in [MagicBeanDev/Longshot#3099](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3099), [MagicBeanDev/Longshot#3118](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3118), [MagicBeanDev/Longshot#3142](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3142), [MagicBeanDev/Longshot#3251](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3251), [MagicBeanDev/Longshot#2957](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2957) and [MagicBeanDev/Longshot#2523](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2523). ## Testing **Tested:** Windows 11. This is a development tool; the game's code is not changed, so there was no new game run. Instead, the real run folder of PR 3248's Market A/B (six runs, RTX 5080, `%LOCALAPPDATA%\longshot-dev\runs\ab\20261205-081422-change-market`) was summarised again with this branch's `ab.summarise` and `ab.measurements`, each run's switches read again from its own logged line. On `main` that folder gives 6 problems (all `LONGSHOT_BUILDER_PIPES` / `LONGSHOT_CRASH_BLOCK`) and no verdict. Here it gives no problems and the same verdict and table that 3248's hand-made Measurements show: +3.2 % fps (median 115.1 against 111.6), within the runs' spread. Tests (`tests/test_dev_ab.py`, game-free): - `Facts.test_builder_handles_compared_as_set_or_not`: two runs whose switches lines differ only in the handle values do not differ. A handle present in one run and missing in the other, a different `HOS_FPS_MAX`, or a different `HOS_SANDBOX` each still count as one difference. - `CommandPath.test_windows_runs_write_their_measurements`: `cmd_ab` over six runs (`run_one` stubbed, logs shaped like 3248's) writes `measurements.md` and returns 0. With one run's `HOS_FPS_MAX` changed, it writes none and returns 3, with `switches HOS_FPS_MAX` as the only problem. - `Facts.test_builder_handles_from_source`: `ab.BUILDER_HANDLES` equals `env_own.rs` `OWN` ∩ the "Set by the builder" rows of `switches.def`, `HOS_SANDBOX` is not in it, and the handles are compared as set or not. The first two fail on `main` (the test commit alone: exit 3, and the handle differences listed). All three pass here. With the fix's key line undone (`ON_OR_OFF = ("HOS_CONTROL",)`) all three fail again. `tests/test_dev_ab.py` also passes on Linux (WSL Ubuntu 24.04, `python3 -I -B tests/test_dev_ab.py`, 43 tests). `mise run lint` passes. `mise run test` (Windows 11, llvm-mingw, Rust 1.99.1 gnullvm, 12 at once), run as `--exact` lists in parts: 843 of 844 checks pass. `test_lifter` fails, only in two parts known to fail on `main` and fixed in [MagicBeanDev/Longshot#3248](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3248): host-sys's clippy (`large_const_arrays`, `settings_abi.rs`) and api's `a_walked_reshade_folder_counts_a_change_once_two_walks_agree`. Not run, because they fail on `main` (also fixed in 3248) and this change touches none of them: `test_present_geometry_trace`, `test_present_image_free`, `test_present_held_image`, `test_present_acquire_ahead`, `test_dlssg`, `test_no_map_reload`, `test_sync_watch_event`, `test_turf_budget`, `test_ui_renderer`, `test_no_game_title`. This change touches no Rust and no C or C++. **Still to test:** None. ## Measurements Nothing to measure: a development tool's comparison of logged switches. The game and its frame times are unchanged. The re-summarised A/B above shows the write-up it now produces. No switch is added or changed: the five names in `ab.BUILDER_HANDLES` are existing rows of `gpu/vk/switches.def` that the builder sets. This PR only names them, so there is no default to ship. ## Risks `dev.py ab` alone changes. The only thing it no longer catches is two runs given different handle numbers by the builder, which carry no setting. A run the builder started without one of them still counts as different. Reverting is enough. Players notice nothing. ## 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. (Not a change the game runs; the real A/B run folder was summarised again.) - [x] `mise run test` passes (any failure that also fails on `main` is 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] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. (`tests/test_dev_ab.py` reads `ab.py`: three tests added, none changed) - [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)
Every Windows run's "vk: switches set" line holds LONGSHOT_BUILDER_PIPES and LONGSHOT_CRASH_BLOCK, handles the builder
gives that one process: two runs of one side differ in them, and dev.py ab counts that as the sides differing, writes
no measurements.md and ends 3 (PRs 3248 and 3242, 2026-12-05). The test: runs that differ only in those handles give a
write-up; a run with another switch of its own still gives none and ends 3. It fails on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(dev): dev.py ab compares the builder's handles as set or not, so a Windows A/B writes its measurements
Some checks failed
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
PR description / Title and description (pull_request_target) Successful in 5s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 13m17s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m20s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 10m17s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 10m36s
CI / Website build and checks (pull_request) Failing after 38s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 46m55s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m6s
af7343f79b
The builder hands each game its pipes and crash block as handles (Windows: LONGSHOT_BUILDER_PIPES, LONGSHOT_CRASH_BLOCK,
LONGSHOT_NUP_HANDLE; Linux: LONGSHOT_PADS_FD, LONGSHOT_FILES_FD), new numbers in every process, and the game logs them in
its "vk: switches set" line. dev.py ab compared them by value, so two runs of one side differed, and every Windows A/B
ended 3 with no measurements.md (found in PRs 3248 and 3242; also met in 3099, 3118, 3142 and 2957). They are now
compared as set or not, as HOS_CONTROL's socket name already was: a run the builder gave no crash block still differs.
Every other switch is compared by value as before, HOS_SANDBOX (the builder's own too, but a setting) included, and
--allow keeps its meaning.

The list is the source's: every name build_core::env_own's OWN holds whose gpu/vk/switches.def row says "Set by the
builder" (a check holds it to that). PR 3248's Market A/B summarised again gives its Measurements' verdict, +3.2 %
within the runs' spread.

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

Possibly related, for context:

  • PR #3251 fix(vk): the lean draw path reads the Upscaler row as it runs β€” Reports the same A/B switch-handle refusal blocking its measurements
  • PR #3248 test: main's failing game-free checks and lints pass again β€” Its A/B measurements were manually written due to this issue
  • PR #3242 fix(cloth): above 60 fps the cloth steps by the frame's own time, every frame β€” Its cloth A/B encountered the same refusal
Possibly related, for context: - PR #3251 fix(vk): the lean draw path reads the Upscaler row as it runs β€” Reports the same A/B switch-handle refusal blocking its measurements - PR #3248 test: main's failing game-free checks and lints pass again β€” Its A/B measurements were manually written due to this issue - PR #3242 fix(cloth): above 60 fps the cloth steps by the frame's own time, every frame β€” Its cloth A/B encountered the same refusal
Author
Member
@review
BeanBot left a comment

Recommendation: Approve. The fix prevents per-process handle numbers from rejecting otherwise comparable A/B runs while retaining checks for missing handles and actual settings. The reported tests and re-summary support the fix; CI is still running. Nothing blocking is left. Recommend approval; not approved on the forge.

Developers can get a Measurements write-up from Windows A/B runs despite changing builder handle numbers. The change is small and keeps the existing comparison for settings.

Checks: Still running: 11 checks.

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

Does it help: Yes. The author reports that re-summarising six Windows runs changed the result from six handle-related differences and no verdict to no differences and a write-up matching the manually produced result. This is not a game performance change.

Other systems: The same comparison applies to Linux builder descriptors. It changes only A/B report validation, not game execution, rendering, saves, audio or input.

Switches: None added, changed or removed. Existing builder handle values are compared by presence in A/B validation; HOS_SANDBOX remains compared by value.

Reviewed: af7343f79b against 7bc53f8413: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the diff, commits, changed code and tests, and the relevant builder ownership and Windows pipe paths. Skimmed the surrounding developer documentation, standards and switch definitions. docs/review-checklist.md and the adjacent Tooling checkout were absent. Some long command output was truncated, so portions of unchanged code in ab.py and test_dev_ab.py were only skimmed.; nothing run (a code review).

Checked and fine:

  • Missing handles and differing ordinary switches remain differences.
  • The new tests exercise both the comparison and the command's write-up path, and the author reports they fail with the key fix undone.
  • Both commits record AI assistance; no game-derived output or generated files are included in the diff.

Testing: Read-only review; no tests or project code were run. The author reports game-free tests on Windows and Linux and a Windows re-summary; CI has not finished.

Overlaps and merge order: None found in the supplied review context.


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

**Recommendation: Approve.** The fix prevents per-process handle numbers from rejecting otherwise comparable A/B runs while retaining checks for missing handles and actual settings. The reported tests and re-summary support the fix; CI is still running. Nothing blocking is left. Recommend approval; not approved on the forge. Developers can get a Measurements write-up from Windows A/B runs despite changing builder handle numbers. The change is small and keeps the existing comparison for settings. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The author reports that re-summarising six Windows runs changed the result from six handle-related differences and no verdict to no differences and a write-up matching the manually produced result. This is not a game performance change. **Other systems:** The same comparison applies to Linux builder descriptors. It changes only A/B report validation, not game execution, rendering, saves, audio or input. **Switches:** None added, changed or removed. Existing builder handle values are compared by presence in A/B validation; HOS_SANDBOX remains compared by value. **Reviewed:** af7343f79bec against 7bc53f841323: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the diff, commits, changed code and tests, and the relevant builder ownership and Windows pipe paths. Skimmed the surrounding developer documentation, standards and switch definitions. docs/review-checklist.md and the adjacent Tooling checkout were absent. Some long command output was truncated, so portions of unchanged code in ab.py and test_dev_ab.py were only skimmed.; nothing run (a code review). **Checked and fine:** - Missing handles and differing ordinary switches remain differences. - The new tests exercise both the comparison and the command's write-up path, and the author reports they fail with the key fix undone. - Both commits record AI assistance; no game-derived output or generated files are included in the diff. **Testing:** Read-only review; no tests or project code were run. The author reports game-free tests on Windows and Linux and a Windows re-summary; CI has not finished. **Overlaps and merge order:** None found in the supplied review context. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch fix/ab-builder-handles 2026-12-05 16:57:19 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!3252
No description provided.