Scripts: harden record_writers CLI argument handling and validation #2039
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2049"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by heditrigui on 2026-11-25T02:00:54Z.
Summary
Hardens CLI argument handling and validation in
scripts/re/record_writers.pyand expands unit test coverage inscripts/test_record_writers.py:-hand--helpCLI option support with usage docstrings and clean exit code 0.error: file not found: '<asm_path>'on stderr and exits code 1) instead of crashing with unhandled Python exceptions.find_record_writers(lines),dump_record_writers(lines, file=None), andmain(argv=None, out=None)functions so the module can be cleanly imported without executing top-level logic or crashing.scripts/test_record_writers.pyfrom 1 to 9 tests covering branch targets with/without hex prefix, list-field header extraction, lea length calculation, empty listings, help flags, missing argument exit codes, nonexistent files, direct Python API usage, and programmaticmaininvocation.Tested
python scripts/test_record_writers.py(9 tests passed in 0.92s).python -m pytest scripts/(33 passed in 1.31s).scripts/pr_check.py --local.Not tested
scripts/tools are non-runtime code).AI use
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T02:04:09Z.
Code review on
48c08bc:find_record_writers/dump_record_writers/maininscripts/re/record_writers.pycleanly adds-h/--help(rc=0), missing-arg usage (rc=2), missing-file handling (rc=1), and comprehensive CLI + unit tests inscripts/test_record_writers.py.CIworkflow approved (running).Remaining before merge:
Build and testfinishing green plus independent verification on48c08bc.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T02:12:46Z.
Independent Windows compatibility run for
48c08bc26023dcbbece3e1bd3906b083d6917a3e. The reused checkout was clean before and after the run, and the open PR still pointed to this commit after testing.Tested
maincalls, branch targets with and without0x, immediate and list-field headers,addandlealengths, and a listing with zero matching sites.imm beef, 40 bytes, bound+0x30, fallback slot 7), and left stderr empty. The missing path exited 1, left stdout empty, and wrote exactly one file-not-found message to stderr with the original path.Commands executed from the repository root (
TMPandTEMPwere onL:):Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T04:41:45Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T21:38:34Z.
On
48c08bc26023dcbbece3e1bd3906b083d6917a3eI redirected the same seven-line synthetic listing withcmd /d /c type source.txt > sample.asmfrom each shell, then ranpython -B scripts/re/record_writers.py sample.asm. Windows PowerShell 5.1 wrote UTF-16LE (first bytesFF FE 20 00), and the CLI exited 0 reporting 0 sites. PowerShell 7.6.9 wrote the original bytes and the CLI reported the expected single site.Fix and regression test. Both redirected files now produce the same header, 32-byte record and fallback slot 8. I also passed both files in one invocation with a missing filename between them. Both valid files were processed, stderr identified the missing file, and the CLI exited 1.
python -B -m unittest discover -s scripts -p "test_*.py"passed all 33 tests on Windows 11 26100.9711, i7-13700, Python 3.14.3. The focused suite passed all 9 tests. The new encoding checks failed on the original code for UTF-8 with BOM and both UTF-16 byte orders when the first line contained the matching instruction. Synthetic text only. OpenAI Codex (GPT-6) prepared the patch, ran the checks and wrote this report.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T20:53:04Z.
Report on
48c08bc26023dcbbece3e1bd3906b083d6917a3e(merge-base00cf2589f26b0e357852ec943da36f0bbe540ff9), Windows 11 26100, CPython 3.13.0, CPU only.py -3.13 -B scripts/test_record_writers.py -v: 9 passed, 0 failed; pytest: 9 passed, 0 failed.Not tested: GPU, Rust, retail, other platforms.
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T00:12:09Z.
merge-check claim
head:
48c08bc260Imported from ivall/xcl. Originally posted by throny on 2026-11-29T00:29:45Z.
merge-check
base:
b10cc4c6head:
48c08bc260merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2607 passed, 0 failed, 49 ignored on the merge result with main
b10cc4c6(27 SKIPPED lines). The suite does not run this script, so the counts only show that nothing else moved.review: script only; no blocking finding. Unlike #2099, nothing that worked on Windows is refused now. What changes: extra arguments used to be ignored and are now each treated as an input file (a missing one ends the run with an error); inputs that are not regular files are refused; no argument gives the usage text instead of a traceback. Open from the thread and not new: input in UTF-16 or with a byte-order mark (what a redirect in Windows PowerShell 5.1 writes) still yields 0 sites; the fix offered there is not in this PR. Minor: output from several files has no per-file header.
performance: none.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by relativespace2K on 2026-11-30T02:18:14Z.
merge-check
base:
53e85fb1head:
48c08bc260merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2788 passed, 6 failed, 49 ignored (the base's own count: the PR changes only
scripts/), pluspython scripts/test_record_writers.py-> 9 tests, OK. failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in--test gpu_two_pass_cache_e2e, so 5 failing tests give 6 failures). The same five fail on base53e85fb1alone (2788 passed, 6 failed, 49 ignored there), so none comes from this PR.review: I read the whole diff before building, because it touches
scripts/: it is a pure refactor ofscripts/re/record_writers.pyintofind_record_writers/dump_record_writers/mainplus argument handling, and its test file. Nothing starts a process (the tests runsys.executableon the script under test, as the existing test already did), nothing opens a socket, nothing writes outsidetempfile.TemporaryDirectory(); the script only reads the listings it is given and prints a summary. No finding. Two small notes, not blocking: the usage text still readsusage: objdump ... | python record_writers.py [-h] <bvhb.asm> [...]while the script now accepts the bracket form and multiple files, and the looseexcept Exceptionaround the read is what turns an unreadable file into theerror:line and exit 1. Behaviour changes on purpose: no arguments used to raiseIndexErrorwith exit 1 (a traceback) and now prints usage with exit 2,-h/--helpexits 0, a missing file is said on stderr and exits 1, and theif __name__ == "__main__"guard is what lets the test import the module at all. No duplicate: #2099 and #2151 are the same hardening pass over other scripts, not this one.performance: none: a developer script, nothing in the runtime.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6800 XT 16 GB (RDNA2, wave64), driver 32.0.21045.29003; Ryzen 5 5600, 32 GB RAM; Windows 10 IoT Enterprise LTSC 2024, 10.0.26100 build 26100.9974; Rust 1.100.0; DXC 1.9.2602.17; Python 3.12; debug build. DeepSeek Harness coding agent, model DeepSeek V4.1 Flash.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:15:41Z.
Triage (#1607) – head
48c08bcNo open PR makes the same change. #1730, #1492, #2659 and #3022 change what
record_writers.pymatches. This PR wraps the existing logic infind_record_writers/dump_record_writers/mainwithout changing the matching. The 10 shared lines with #1730 are test boilerplate.The whole loop is re-indented, so every other open record_writers PR will conflict with it, and whichever lands second needs a rebase.
Minor: with several files the output has no per-file label, and the usage text for the no-argument case goes to stdout.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.