tools/ab_control_flow: handle UTF-8-SIG/CRLF inputs, subprocess encoding and atomic outcomes.tsv #1853

Manually merged
github merged 1 commit from gh-pr/1853/head into gh-pr/1853/base 2026-11-26 10:08:43 +00:00
Owner

@⁠kirigayakazima on GitHub · 2026-11-25 13:11 UTC · original
kirigayakazima:fix/ab-control-flow-safety → main · +128 −11 · 2 files · 1 commits · merged 2026-11-25 17:31 UTC

Claimed in the coordination issue as: AB-CONTROL-FLOW-CRLF-BOM-AND-ATOMIC-TSV (#1608)

What and why

  • Read --names and index.json in tools/ab_control_flow.py with encoding="utf-8-sig" and parse --names lines via splitlines() + .strip() so UTF-8 BOMs and Windows CRLF endings do not corrupt shader names.
  • Write outcomes.tsv atomically in write_outcomes() (tempfile.mkstemp beside os.path.realpath(...), os.fsync, published_mode, and replace_retry.replace), preserving any existing file and cleaning up staging files on failure.
  • Pass encoding="utf-8", errors="replace" to subprocess.run(..., capture_output=True, text=True) in render_targets() and main() for safe decoding under python -I.
  • Add regression tests in tests/test_ab_control_flow.py.

Tested

  • python -I tests/test_ab_control_flow.py -v -> Ran 70 tests in 1.849s, OK (skipped=1) (Windows skips chmod 000 test).
  • Detached upstream/main (98c2f777) baseline worktree with updated tests/test_ab_control_flow.py -> Ran 70 tests in 1.733s, FAILED (failures=2, errors=2, skipped=1).
  • python -I tests/test_ci_registration.py -> Ran 16 tests in 7.338s, OK.
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 14.354s, OK.
  • python -I scripts/check_no_game_data.py tools/ab_control_flow.py tests/test_ab_control_flow.py, python -I -m compileall -q tools/ab_control_flow.py tests/test_ab_control_flow.py, and git diff --check -> exit 0.

GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)
**@⁠kirigayakazima** on GitHub · 2026-11-25 13:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1853) `kirigayakazima:fix/ab-control-flow-safety` → `main` · +128 −11 · 2 files · 1 commits · merged 2026-11-25 17:31 UTC Claimed in the coordination issue as: AB-CONTROL-FLOW-CRLF-BOM-AND-ATOMIC-TSV (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why - Read `--names` and `index.json` in `tools/ab_control_flow.py` with `encoding="utf-8-sig"` and parse `--names` lines via `splitlines()` + `.strip()` so UTF-8 BOMs and Windows CRLF endings do not corrupt shader names. - Write `outcomes.tsv` atomically in `write_outcomes()` (`tempfile.mkstemp` beside `os.path.realpath(...)`, `os.fsync`, `published_mode`, and `replace_retry.replace`), preserving any existing file and cleaning up staging files on failure. - Pass `encoding="utf-8", errors="replace"` to `subprocess.run(..., capture_output=True, text=True)` in `render_targets()` and `main()` for safe decoding under `python -I`. - Add regression tests in `tests/test_ab_control_flow.py`. ### Tested - `python -I tests/test_ab_control_flow.py -v` -> `Ran 70 tests in 1.849s`, `OK (skipped=1)` (Windows skips `chmod 000` test). - Detached `upstream/main` (`98c2f777`) baseline worktree with updated `tests/test_ab_control_flow.py` -> `Ran 70 tests in 1.733s`, `FAILED (failures=2, errors=2, skipped=1)`. - `python -I tests/test_ci_registration.py` -> `Ran 16 tests in 7.338s`, `OK`. - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 14.354s`, `OK`. - `python -I scripts/check_no_game_data.py tools/ab_control_flow.py tests/test_ab_control_flow.py`, `python -I -m compileall -q tools/ab_control_flow.py tests/test_ab_control_flow.py`, and `git diff --check` -> exit `0`. GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64) AI-assisted: yes ### Checklist - [x] Based on current main and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:08:41 +00:00
github manually merged commit 3a84ae7aa8 into gh-pr/1853/base 2026-11-26 10:08:43 +00:00
Author
Owner

@⁠madvillain91 on GitHub · 2026-11-25 13:31 UTC · original · reviewed

Independent Windows 11 26H2 (26300.9711) check at 3a84ae7aa against main 384abe5b0 (PR base 98c2f7777), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_ab_control_flow.py (69 passed, 1 skipped on Windows mode-000 test, 3.226s) and test_text_write_line_endings.py (3/3 in 19.435s), with check_no_game_data.py and compileall clean. Verified UTF-8-SIG/CRLF handling for names files and index.json, encoding="utf-8", errors="replace" on subprocess.run calls under Windows python -I, and atomic outcomes.tsv publishing via replace_retry with staging cleanup on failure. LGTM.

**@⁠madvillain91** on GitHub · 2026-11-25 13:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1853#pullrequestreview-6058521470) · **reviewed** Independent Windows 11 26H2 (26300.9711) check at 3a84ae7aa against main 384abe5b0 (PR base 98c2f7777), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_ab_control_flow.py (69 passed, 1 skipped on Windows mode-000 test, 3.226s) and test_text_write_line_endings.py (3/3 in 19.435s), with check_no_game_data.py and compileall clean. Verified UTF-8-SIG/CRLF handling for names files and index.json, encoding="utf-8", errors="replace" on subprocess.run calls under Windows python -I, and atomic outcomes.tsv publishing via replace_retry with staging cleanup on failure. LGTM.
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 14:21 UTC · original

Tested 3a84ae7aa on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 71a769d7d (Python shader tool; no GPU):

  • pytest 9.2.0 on tests/test_ab_control_flow.py: 70 passed, 31 subtests passed at this head.
  • The same file on main: 4 failed, 66 passed — the UTF-8-SIG/CRLF names reading and the atomic TSV write are the new cases.
  • Not run: a real index.json/--names pair from a translation; the tests build them synthetically.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 14:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1853#issuecomment-7165155671) Tested `3a84ae7aa` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `71a769d7d` (Python shader tool; no GPU): - pytest 9.2.0 on `tests/test_ab_control_flow.py`: **70 passed, 31 subtests passed** at this head. - The same file on `main`: **4 failed**, 66 passed — the UTF-8-SIG/CRLF names reading and the atomic TSV write are the new cases. - Not run: a real `index.json`/`--names` pair from a translation; the tests build them synthetically. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠DeadlyChirp on GitHub · 2026-11-25 15:37 UTC · original

Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.

python -m pytest -q tests/test_ab_control_flow.py:

  • PR: 69 passed, 1 skipped. main: 65 passed, 1 skipped.
  • The skip is the existing mode 000 does not stop root or Windows test. The new tests pass.

(AI-assisted test run; output checked by hand.)

**@⁠DeadlyChirp** on GitHub · 2026-11-25 15:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1853#issuecomment-7167133782) Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main. `python -m pytest -q tests/test_ab_control_flow.py`: - PR: 69 passed, 1 skipped. main: 65 passed, 1 skipped. - The skip is the existing `mode 000 does not stop root or Windows` test. The new tests pass. (AI-assisted test run; output checked by hand.)
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 17:31 UTC · original

Merged. Thank you, @⁠kirigayakazima. UTF-8-SIG and CRLF inputs and subprocess encodings are handled, and the TSV is written atomically.

  • The new tests fail on main and pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check.
  • Checked on main 863c1616a + 3a84ae7aa: the semantic suite passes (490 files, 6,292 tests, 0 files failed); test_ab_control_flow pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 17:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1853#issuecomment-7169631908) Merged. Thank you, @⁠kirigayakazima. UTF-8-SIG and CRLF inputs and subprocess encodings are handled, and the TSV is written atomically. - The new tests fail on `main` and pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check. - **Checked on `main` `863c1616a` + `3a84ae7aa`:** the semantic suite passes (490 files, 6,292 tests, 0 files failed); `test_ab_control_flow` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.