Skip to content

text_tables: ask report_paths for the report-path guard - #2741

Open
breachato wants to merge 2 commits into
ProjectLeonida:mainfrom
breachato:text-tables-output-guard-shared
Open

breachato wants to merge 2 commits into
ProjectLeonida:mainfrom
breachato:text-tables-output-guard-shared

Conversation

@breachato

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEXT-TABLES-OUTPUT-GUARD-SHARED

What and why

tools/text_tables.py still carried its own _same_output_path (os.path.normcase over realpath, then samefile) and used it for the distinct-outputs check and for the carve index.json guard, while input_under in the same file already asked report_paths.same_report_path. #1655 moved the source-file guard to the shared helper but left this copy, and #1228 was closed as superseded by it, so the remainder was still on main at 20fe0c75. This is that remainder.

The private copy is wrong on a case-sensitive directory: normcase lowercases both names before samefile, so --tables Out/T.csv --strings Out/t.csv is refused as one file. Measured on native Windows 11 NTFS with fsutil file setCaseSensitiveInfo <dir> enable, main and this branch, same fixture:

main:    rc=2  text_tables.py: error: outputs must be distinct files   files written: []
branch:  rc=0  0 string tables (); ...                                 files written: ['T.csv', 't.csv']

and on the two paths directly (old copy vs same_report_path, in a case-sensitive directory that really holds both files):

existing A.csv / a.csv   old=True  new=False
new N.csv / n.csv        old=True  new=False

The private function is removed, the module imports same_report_path once at the top (ROOT / sys.path.insert was already there, so -I works), and input_under's function-local import is dropped because the module-level one covers it. The tool also joins SHARED in tests/test_report_paths.py.

This is the same shape as the other tools in the series (#1162, #1170-#1173, #1214, #1215, #1227, #1229, #1243, #1244, #2636-#2640), and it edits the same tuple line, so it will need a rebase behind whichever of those lands first; the conflict is mechanical, both entries belong in the tuple alphabetically.

Tested

  • python -I tests/test_text_tables.py — 39 tests, OK
  • python -I tests/test_report_paths.py — 26 tests, OK (1 skipped: the macOS-only case), with text_tables in SHARED
  • python -I tests/test_report_path_case.py — 4 tests, OK (1 skipped, same)
  • python -I scripts/check_no_game_data.py tools/text_tables.py tests/test_report_paths.py — clean
  • the end-to-end A/B above (main vs this branch) on a case-sensitive NTFS directory

Synthetic resources and temporary folders; no game data, no GPU workload.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main (20fe0c75) and merges cleanly.
  • One topic; nothing else touched.
  • No game data, keys or hardware results invented.

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12.16 (pytest, no GPU), main f44904d21, head 8f23a4652.

  • MEASURED, green (main + this PR, merged): tests/test_text_tables.py + tests/test_report_paths.py: 63 passed, 2 skipped, 33 subtests passed. Skips: requires Windows directory case sensitivity (not runnable on macOS).
  • MEASURED, red (main + only this PR's tests): tests/test_report_paths.py: 25 passed, 1 skipped, the same as green. The updated test does not fail on main.
  • READ IN CODE, why: test_switched_tools_import_the_helper_and_define_no_copy looks for the string from report_paths import same_report_path, and main's text_tables.py already has it (the lazy import inside input_under). The removed _same_output_path is not in the forbidden names (same_report_path, _same_report_path, _path_key, _case_insensitive_volume), so the old copy would still pass.
  • READ IN CODE: no other file calls text_tables._same_output_path (the test_same_output_path_identity tests in test_pe_inspect.py / test_shader_profile.py cover those tools' own helpers).
  • MEASURED: no conflict with [integration] PageMirror, GPU detile, async queue & RDNA2->SPIR-V performance stack (INTEGRATION-PERF-CPU-GPU-R6) #2566 (merge-tree of main+[integration] PageMirror, GPU detile, async queue & RDNA2->SPIR-V performance stack (INTEGRATION-PERF-CPU-GPU-R6) #2566, then that result against this PR).
  • Verdict: green on Mac 63/65, 2 skipped (Windows-only), but the change itself is not pinned by a test that fails without it. One option, left to the author: add _same_output_path to the forbidden names, or require the import at module level.

AI-assisted: Claude Code

@aegish-zagi

Copy link
Copy Markdown
Contributor

VERIFY-2741 — PASS

  • PR: text_tables: ask report_paths for the report-path guard #2741 | head 8f23a46 | merge state vs main b17b22d: CLEAN (scratch merge, no conflicts)
  • Tests run (on PR head merged with current main): tests/test_report_paths.py — 26 tests OK (1 skipped); tests/test_text_tables.py — 39 tests OK (1 skipped); tests/test_report_path_case.py — 4 tests OK (1 skipped); python -m compileall tools/text_tables.py OK
  • Red-on-main vs green-on-PR: this is a behaviour-preserving refactor, so plain main passes the same suites (26/39/4, measured this run before checkout) — there is no red to turn green on Linux. What the diff does, audited line by line: tools/text_tables.py drops its private _same_output_path (normcase+realpath+samefile, OSError -> False), imports same_report_path from report_paths at module level (the lazy import inside input_under is removed), and both call sites (distinct-outputs check, carve index.json check) now use it; tests/test_report_paths.py adds text_tables to SHARED. The semantic difference is the one the claim names: the private copy folds case unconditionally via normcase, the shared helper asks the volume — that difference is only exercisable on a case-sensitive NTFS/APFS volume, which this Linux host cannot reproduce, so that part is READ IN CODE, not MEASURED here.
  • Diff audit: 2 files, +5/-14, no other call sites of _same_output_path remain in the tool, no game data.
  • Platform: Linux, Python 3.12, Profile Z (no GPU)
  • AI-assisted: yes (Muse Wonder, Muse by Meta)

@KelboLive

Copy link
Copy Markdown

Independent check on Windows (not the author), at 8f23a4652.

  • python -I tests/test_report_paths.py: 26 tests passed in 12.6 s.

Tool-only change; the report-path guard cases run under the standard library on Python 3.12.10. No game files needed.

Environment: Windows 11 Pro 10.0.26200.9711, Python 3.12.10.

AI-assisted: yes (opencode).

@breachato
breachato force-pushed the text-tables-output-guard-shared branch from 8f23a46 to e61612a Compare November 30, 2026 19:22
@breachato

breachato commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto main (8f41d7d0) to clear the SHARED tuple conflict that #2637 (bink_index) opened for every sibling: the entry now sits in the tuple next to bink_index.

Verified on the new head (e61612ad):

  • python -I tests/test_text_tables.py — OK
  • python -I tests/test_report_paths.py — OK (26 tests, 1 skipped)
  • python -I tests/test_report_path_case.py — OK
  • git diff main — 2 files: tools/text_tables.py and tests/test_report_paths.py

No behaviour change beyond the shared helper.

Ready to merge: MERGEABLE / CLEAN, all five checks green. Every sibling PR touches the same SHARED line, so please merge one at a time — I'll rebase the remaining ones after each merge and keep them green.

@breachato

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #2637 landed, so the SHARED tuple conflict is gone and the branch is two commits again on top of main (8f41d7d0; main is now d8ca1824, which does not touch tests/test_report_paths.py or tools/text_tables.py).

New head: e61612adda39ca14f12ad5a058f743150c67c83a.

Measured on that head, standard library only, Windows, Python 3.14, no game data:

python -I tests/test_report_paths.py   ->  Ran 26 tests, OK (skipped=1)
python -I tests/test_text_tables.py    ->  Ran 39 tests, OK

@OreoFR @aegish-zagi @KelboLive — your checks are on 8f23a4652, i.e. before the rebase. Could you re-run your checks on e61612ad and approve if they still hold? Merging on the old head would land code none of you has looked at.

The diff is unchanged in substance: same two commits, same SHARED entry, only the tuple context under it moved.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Dec 1, 2026

@aslan2142 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff against main: delegating the report-path guard in tools/text_tables.py to report_paths.same_report_path is clean and clean-room verified, but this branch currently conflicts with main in tests/test_report_paths.py:8-12 (SHARED tuple updated by #2639 and earlier merges). Please rebase onto current main so CI runs cleanly.

(AI-assisted review.)

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behaviour is right and cleanly scoped: both former _same_output_path call sites now use same_report_path, the lazy import is gone, and all four report flags (--dialogue, --tables, --strings, --native-speakers) go through the one preflight loop — so a failing path is refused for every report write, not at a single call site. I reproduced the case-sensitive NTFS A/B end to end: old code rc=2, outputs must be distinct files, nothing written; this branch rc=0 with both T.csv and t.csv. That is exactly the bug the shared helper exists for (the old copy lowercased unconditionally via normcase, merging case-distinct files on a case-sensitive volume).

But the test edit only pins the import string. Restoring the old helper locally leaves all three suites green (39 / 26 / 4 measured), so the removal is not actually guarded. Please add _same_output_path to the forbidden names in test_switched_tools_import_the_helper_and_define_no_copy, or add text_tables to test_report_path_case.HELPERS — either would make the re-added copy fail.

It also needs the rebase already requested: merge-tree against current origin/main conflicts only in the SHARED tuple of tests/test_report_paths.py (main added meshlet_page); tools/text_tables.py merges cleanly.

Residual, outside this PR's two guards: the direct source-file check at tools/text_tables.py:487 still uses raw os.path.exists/os.path.samefile rather than the helper. It only runs when the output exists and I found no bypass, but it is the same class of check and worth a follow-up.

@breachato
breachato force-pushed the text-tables-output-guard-shared branch from e61612a to cfcf07c Compare December 1, 2026 17:54
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Dec 1, 2026
The reviewers' red test: with this entry on main,
test_switched_tools_import_the_helper_and_define_no_copy fails with
"'from report_paths import same_report_path' not found"; with this branch
it passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants