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

Merged
kirigayakazima merged 1 commit from upstream-pr/1853 into main 2026-11-25 17:31:40 +00:00
kirigayakazima commented 2026-11-25 13:11:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T13:11:04Z.


Claimed in the coordination issue as: AB-CONTROL-FLOW-CRLF-BOM-AND-ATOMIC-TSV (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163364385)

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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5491983085 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1853). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-25T13:11:04Z. --- Claimed in the coordination issue as: AB-CONTROL-FLOW-CRLF-BOM-AND-ATOMIC-TSV (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163364385) ### 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)
madvillain91 commented 2026-11-25 13:31:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madvillain91 on 2026-11-25T13:31:16Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6058521470 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1853#pullrequestreview-6058521470). Originally posted by [madvillain91](https://github.com/madvillain91) on 2026-11-25T13:31:16Z. **Review:** COMMENTED --- 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.
GeorgiyDemo commented 2026-11-25 14:21:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-25T14:21:35Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7165155671 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1853#issuecomment-7165155671). Originally posted by [GeorgiyDemo](https://github.com/GeorgiyDemo) on 2026-11-25T14:21:35Z. --- 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.
DeadlyChirp commented 2026-11-25 15:37:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-25T15:37:39Z.


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.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7167133782 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1853#issuecomment-7167133782). Originally posted by [DeadlyChirp](https://github.com/DeadlyChirp) on 2026-11-25T15:37:39Z. --- 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.)
aslan2142 commented 2026-11-25 17:31:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T17:31:42Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7169631908 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1853#issuecomment-7169631908). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T17:31:42Z. --- 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1853
No description provided.