OLD-8645: restore old upstream PR 8645 - vs_layout_census: refuse a --json that is an input or a directory before survey() (BUILD-589) #730

Manually merged
github merged 1 commit from gh-pr/730/head into gh-pr/730/base 2026-11-26 09:18:30 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 13:01 UTC · original
aslan2142:build589-vs-layout-census-guard → main · +151 −7 · 2 files · 1 commits · merged 2026-11-25 22:27 UTC

Claimed in the coordination issue as: OLD-8645 #14

Restoration of my original pull request, old upstream PR 8645 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 51f3160923; the one commit cherry-picked cleanly and is unchanged. The tool is scripts/vs_layout_census.py, and it already uses the shared tools/report_paths.same_report_path guard that CONTRIBUTING.md names.

What and why

  • On main, --json is compared only with index.json, using a raw os.path.samefile (scripts/vs_layout_census.py:189).
  • So a --json that names an indexed .dxbc container or a disasm/<stem>.s listing overwrites that input.
  • A --json that is a directory runs survey() first (that includes llvm-mc on every unlisted payload) and fails only at the write.
  • main() now checks --json before survey() runs and refuses:
    • an existing directory;
    • any path that same_report_path matches to index.json or to a container or listing named in the index.
  • The list of inputs comes from the new input_paths(). It shares the new load_index() with survey(), so the guard and the census read the same index.
  • Each refusal prints one error line and exits with status 2. A separate --json path still runs as before.
  • Open PR #490 changes how report_paths works inside, without changing the call. It shares no files with this one and does not conflict.

Tested

Linux, Python 3.14.10, CPU only. All inputs are synthetic and built by the test: index.json, FSSM payloads in DXBC containers and hand-written .s listings. No game files.

  • python -I tests/test_vs_layout_census.py:
    • main plus only this pull request's test changes: 16 tests run, 8 of the 11 new ones fail (3 failures, 5 errors), 1 skipped;
    • this branch: 16 tests run, OK, 1 skipped.
  • The skipped test is the other-case spelling. It needs a case-folding volume, and this Linux filesystem keeps letter case apart.
  • python -I tests/test_report_paths.py: OK.
  • python -m compileall -q tools tests scripts: clean.
  • git diff --check: clean.
  • python -I scripts/check_no_game_data.py on both changed files: clean.

GPUs tested: n/a

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: no translator change)

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

**@⁠aslan2142** on GitHub · 2026-11-24 13:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/730) `aslan2142:build589-vs-layout-census-guard` → `main` · +151 −7 · 2 files · 1 commits · merged 2026-11-25 22:27 UTC Claimed in the coordination issue as: OLD-8645 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 Restoration of my original pull request, old upstream PR 8645 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 51f31609236a952badeb9c9aba9efc2a6e4dc2ff; the one commit cherry-picked cleanly and is unchanged. The tool is `scripts/vs_layout_census.py`, and it already uses the shared `tools/report_paths.same_report_path` guard that CONTRIBUTING.md names. ### What and why - On main, `--json` is compared only with `index.json`, using a raw `os.path.samefile` (`scripts/vs_layout_census.py:189`). - So a `--json` that names an indexed `.dxbc` container or a `disasm/<stem>.s` listing overwrites that input. - A `--json` that is a directory runs `survey()` first (that includes llvm-mc on every unlisted payload) and fails only at the write. - `main()` now checks `--json` before `survey()` runs and refuses: - an existing directory; - any path that `same_report_path` matches to `index.json` or to a container or listing named in the index. - The list of inputs comes from the new `input_paths()`. It shares the new `load_index()` with `survey()`, so the guard and the census read the same index. - Each refusal prints one error line and exits with status 2. A separate `--json` path still runs as before. - Open PR #490 changes how `report_paths` works inside, without changing the call. It shares no files with this one and does not conflict. ### Tested Linux, Python 3.14.10, CPU only. All inputs are synthetic and built by the test: `index.json`, FSSM payloads in DXBC containers and hand-written `.s` listings. No game files. - `python -I tests/test_vs_layout_census.py`: - main plus only this pull request's test changes: 16 tests run, 8 of the 11 new ones fail (3 failures, 5 errors), 1 skipped; - this branch: 16 tests run, OK, 1 skipped. - The skipped test is the other-case spelling. It needs a case-folding volume, and this Linux filesystem keeps letter case apart. - `python -I tests/test_report_paths.py`: OK. - `python -m compileall -q tools tests scripts`: clean. - `git diff --check`: clean. - `python -I scripts/check_no_game_data.py` on both changed files: clean. GPUs tested: n/a 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: no translator change) AI-assisted (Claude Code, Claude Opus 5.5).
--json was checked with a raw os.path.samefile against index.json only, so
naming an indexed .dxbc container or a disasm/*.s listing overwrote that
input, and a directory ran survey() (llvm-mc over the corpus) before the
write failed.

main() now refuses, before survey() runs, a --json that is an existing
directory, and one that tools/report_paths.same_report_path matches against
index.json or any container or listing the index names (input_paths(), which
shares load_index() with survey()). Each refusal is one error line and exit 2.

Synthetic tests in tests/test_vs_layout_census.py: a listing, a container and
index.json refuse and stay unchanged; a directory refuses with survey() and
default_disasm mocked and never called; a ../ spelling, a symlink, a hard link
and (on a case-folding volume) another case refuse; a separate --json still runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:18:28 +00:00
github manually merged commit ad136ffb9c into gh-pr/730/base 2026-11-26 09:18:30 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:14 UTC · original · approved these changes

LGTM. Properly validates --json output path against directory targets and input collision via same_report_path before running survey(). Clean-room synthetic test suite added to ests/test_vs_layout_census.py.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/730#pullrequestreview-6039831157) · **approved these changes** LGTM. Properly validates --json output path against directory targets and input collision via same_report_path before running survey(). Clean-room synthetic test suite added to ests/test_vs_layout_census.py.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:27 UTC · original

Merged: vs_layout_census refuses a --json that is an input or a directory before survey().

  • Changed since review: Nothing. It merges cleanly with main, and no review point is open.
  • Tested: tests/test_vs_layout_census.py passes on main + this head (Linux, CPython 3.14).
  • Checked on main d601736ce + ad136ffb9: the semantic suite passes (492 files, 6,315 tests, 0 files failed); test_vs_layout_census 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 22:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/730#issuecomment-7176378693) Merged: `vs_layout_census` refuses a `--json` that is an input or a directory before `survey()`. - **Changed since review:** Nothing. It merges cleanly with `main`, and no review point is open. - **Tested:** `tests/test_vs_layout_census.py` passes on `main` + this head (Linux, CPython 3.14). - **Checked on `main` `d601736ce` + `ad136ffb9`:** the semantic suite passes (492 files, 6,315 tests, 0 files failed); `test_vs_layout_census` 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.