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

Merged
aslan2142 merged 1 commit from upstream-pr/730 into main 2026-11-25 22:27:05 +00:00
aslan2142 commented 2026-11-24 13:01:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T13:01:36Z.


Claimed in the coordination issue as: OLD-8645 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7132204652

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5472642754 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/730). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T13:01:36Z. --- Claimed in the coordination issue as: OLD-8645 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7132204652 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).
abnalstlll-byte commented 2026-11-24 13:14:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T13:14:52Z.

Review: APPROVED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6039831157 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/730#pullrequestreview-6039831157). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T13:14:52Z. **Review:** APPROVED --- 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.
aslan2142 commented 2026-11-25 22:27:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T22:27:07Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7176378693 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/730#issuecomment-7176378693). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T22:27:07Z. --- 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).
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!730
No description provided.