tools/ds_permute_probe: write --json report atomically (DS-PERMUTE-PROBE-ATOMIC-JSON) #2000

Closed
Ch1mpleo wants to merge 0 commits from upstream-pr/2000 into main
Ch1mpleo commented 2026-11-25 17:55:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Ch1mpleo on 2026-11-25T17:55:00Z.


Claimed in the coordination issue as: DS-PERMUTE-PROBE-ATOMIC-JSON (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170145014)

What and why

Updates \ ools/ds_permute_probe.py::write_json_report\ to write via a sibling \ empfile.NamedTemporaryFile(..., encoding="utf-8", newline="\n")\ and \os.replace\ (with temp-file cleanup on failure), so an existing report is never truncated on error. Updates the OSError test and adds an atomic-replace regression test in \ ests/test_ds_permute_probe.py.

Tested

  • \python -m compileall -q tools/ds_permute_probe.py tests/test_ds_permute_probe.py\ — exit 0.
  • \python -I tests/test_ds_permute_probe.py\ — 8 tests, OK (Windows 11 x64, Python 3.14.7).
  • \python -I scripts/check_no_game_data.py tools/ds_permute_probe.py tests/test_ds_permute_probe.py\ — exit 0.

GPUs tested: n/a (CPU-only Python tool & unit tests)

AI-assisted: yes

Checklist

  • Based on current \main\ and merges cleanly (a conflicting pull request is labeled
    eeds 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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5496415892 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2000). Originally posted by [Ch1mpleo](https://github.com/Ch1mpleo) on 2026-11-25T17:55:00Z. --- Claimed in the coordination issue as: DS-PERMUTE-PROBE-ATOMIC-JSON (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170145014) ### What and why Updates \ ools/ds_permute_probe.py::write_json_report\ to write via a sibling \ empfile.NamedTemporaryFile(..., encoding="utf-8", newline="\n")\ and \os.replace\ (with temp-file cleanup on failure), so an existing report is never truncated on error. Updates the OSError test and adds an atomic-replace regression test in \ ests/test_ds_permute_probe.py\. ### Tested - \python -m compileall -q tools/ds_permute_probe.py tests/test_ds_permute_probe.py\ — exit 0. - \python -I tests/test_ds_permute_probe.py\ — 8 tests, OK (Windows 11 x64, Python 3.14.7). - \python -I scripts/check_no_game_data.py tools/ds_permute_probe.py tests/test_ds_permute_probe.py\ — exit 0. GPUs tested: n/a (CPU-only Python tool & unit tests) AI-assisted: yes ### Checklist - [x] Based on current \main\ and merges cleanly (a conflicting pull request is labeled \ eeds 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)
kirigayakazima commented 2026-11-28 05:43:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-28T05:43:48Z.


#2000 | head 24ff6697c06db2aa9ed76f8bffebfebe3c6197a9 | python -I tests/test_ds_permute_probe.py | red: FAILED (failures=1, errors=1; AssertionError + AttributeError) | green: 8/8 OK (0.200s) | full suite: 513/521 stdlib passed, 0 new failures vs main 8994000b08 | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini)

Details:

  • Red (PR test tests/test_ds_permute_probe.py on upstream/main 8994000b08): Ran 8 tests in 0.178s — FAILED (failures=1, errors=1): AssertionError: unexpectedly None in test_atomic_json_write_and_replace_failure_preserves_existing (because main writes directly rather than calling os.replace) and AttributeError: module 'ds_permute_probe' has no attribute 'tempfile' in test_write_json_report_and_main_catch_oserror_cleanly.
  • Green (merged with upstream/main 8994000b08): Ran 8 tests in 0.200s — OK.
  • Repo checks: scripts/check_no_game_data.py -> 0; python -m compileall -q tools scripts tests -> 0; node --test tests/test_viewer_streaming.cjs -> 0; standalone stdlib tests/test_*.py -> 513/521 passed (33 skipped pytest/helper files; 0 new failures vs 8994000b08, same 8 pre-existing failures).
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7234849156 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2000#issuecomment-7234849156). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-28T05:43:48Z. --- `#2000 | head 24ff6697c06db2aa9ed76f8bffebfebe3c6197a9 | python -I tests/test_ds_permute_probe.py | red: FAILED (failures=1, errors=1; AssertionError + AttributeError) | green: 8/8 OK (0.200s) | full suite: 513/521 stdlib passed, 0 new failures vs main 8994000b08 | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini)` Details: - **Red** (PR test `tests/test_ds_permute_probe.py` on `upstream/main` `8994000b08`): `Ran 8 tests in 0.178s — FAILED (failures=1, errors=1)`: `AssertionError: unexpectedly None` in `test_atomic_json_write_and_replace_failure_preserves_existing` (because `main` writes directly rather than calling `os.replace`) and `AttributeError: module 'ds_permute_probe' has no attribute 'tempfile'` in `test_write_json_report_and_main_catch_oserror_cleanly`. - **Green** (merged with `upstream/main` `8994000b08`): `Ran 8 tests in 0.200s — OK`. - **Repo checks**: `scripts/check_no_game_data.py` -> `0`; `python -m compileall -q tools scripts tests` -> `0`; `node --test tests/test_viewer_streaming.cjs` -> `0`; standalone stdlib `tests/test_*.py` -> `513/521 passed` (`33` skipped pytest/helper files; `0` new failures vs `8994000b08`, same 8 pre-existing failures).
TheGeogeo commented 2026-11-29 04:50:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T04:50:29Z.


Checked 24ff6697c against main ef3299584 on Windows 11 10.0.26300: it does not merge (git merge-tree --write-tree), so I ran no tests.

  • Conflict: tests/test_ds_permute_probe.py, add/add. cd88d5780 (2026-11-24, "close hardware oracle in ds_permute_probe") added test_oracle_closed_on_success_and_failure where this PR adds its tests.
  • Still needed (STALE, needs a rebase). main's write_json_report (tools/ds_permute_probe.py:195) still writes in place, with no temporary file and no os.replace. The rebase looks mechanical: keep both tests.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7250892975 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2000#issuecomment-7250892975). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T04:50:29Z. --- Checked `24ff6697c` against `main` `ef3299584` on Windows 11 10.0.26300: it does not merge (`git merge-tree --write-tree`), so I ran no tests. - Conflict: `tests/test_ds_permute_probe.py`, add/add. `cd88d5780` (2026-11-24, "close hardware oracle in ds_permute_probe") added `test_oracle_closed_on_success_and_failure` where this PR adds its tests. - Still needed (STALE, needs a rebase). `main`'s `write_json_report` (`tools/ds_permute_probe.py:195`) still writes in place, with no temporary file and no `os.replace`. The rebase looks mechanical: keep both tests. AI-assisted (Claude Code).
aslan2142 commented 2026-12-01 11:55:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:55:59Z.

Review: CHANGES_REQUESTED


Reviewed against current main: writing --json reports atomically in tools/ds_permute_probe.py looks good, but this branch conflicts with main and has failing CI. Please rebase onto current main so CI runs cleanly.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130765378 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2000#pullrequestreview-6130765378). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:55:59Z. **Review:** CHANGES_REQUESTED --- Reviewed against current `main`: writing `--json` reports atomically in `tools/ds_permute_probe.py` looks good, but this branch conflicts with `main` and has failing CI. Please rebase onto current `main` so CI runs cleanly. *(AI-assisted review.)*
aegish-zagi commented 2026-12-02 04:51:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aegish-zagi on 2026-12-02T04:51:57Z.


Verification — VERIFY-2000

Verdict: PASS (with a rebase note: the test file conflicts with current main)

  • PR: #2000 | head sha: 24ff6697c06db2aa9ed76f8bffebfebe3c6197a9 | merge state vs main 8422def759cda12c89f918438eeb8d53dd5972a6: CONFLICT in tests/test_ds_permute_probe.py only — tools/ds_permute_probe.py merges cleanly. The PR head as-is was tested.
  • Tests run: python3 -I tests/test_ds_permute_probe.py
  • Red on main vs green on PR: on plain main code with the PR test file, test_atomic_json_write_and_replace_failure_preserves_existing FAILS and the adapted test_write_json_report_and_main_catch_oserror_cleanly ERRORs (its mock targets the NamedTemporaryFile path main does not have yet); Ran 8 tests — FAILED (failures=1, errors=1). On the PR head: Ran 8 tests — OK.
  • Audit (READ IN CODE): write_json_report now writes via NamedTemporaryFile in the target directory with LF endings, os.replaces onto the destination, and unlinks the temp file on failure, so a failed replace leaves the previous report byte-identical (asserted by the new test). No game data in the diff.
  • Platform: Linux, Python 3.12.3, no GPU (Profile Z)

AI-assisted: yes (Muse Wonder, Muse by Meta)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7335339373 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2000#issuecomment-7335339373). Originally posted by [aegish-zagi](https://github.com/aegish-zagi) on 2026-12-02T04:51:57Z. --- ## Verification — VERIFY-2000 **Verdict: PASS (with a rebase note: the test file conflicts with current main)** - PR: #2000 | head sha: `24ff6697c06db2aa9ed76f8bffebfebe3c6197a9` | merge state vs main `8422def759cda12c89f918438eeb8d53dd5972a6`: CONFLICT in `tests/test_ds_permute_probe.py` only — `tools/ds_permute_probe.py` merges cleanly. The PR head as-is was tested. - Tests run: `python3 -I tests/test_ds_permute_probe.py` - Red on main vs green on PR: on plain main code with the PR test file, `test_atomic_json_write_and_replace_failure_preserves_existing` FAILS and the adapted `test_write_json_report_and_main_catch_oserror_cleanly` ERRORs (its mock targets the `NamedTemporaryFile` path main does not have yet); `Ran 8 tests — FAILED (failures=1, errors=1)`. On the PR head: `Ran 8 tests — OK`. - Audit (READ IN CODE): `write_json_report` now writes via `NamedTemporaryFile` in the target directory with LF endings, `os.replace`s onto the destination, and unlinks the temp file on failure, so a failed replace leaves the previous report byte-identical (asserted by the new test). No game data in the diff. - Platform: Linux, Python 3.12.3, no GPU (Profile Z) AI-assisted: yes (Muse Wonder, Muse by Meta)
MoonEyes commented 2026-12-02 10:32:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T10:32:22Z.


For information: this pull request is carried in #3090, which merges your head (your commits are kept) into current main, resolves the conflicts keeping both sides, and fixes the points raised in review here (details in its description). This one stays open until a maintainer decides; if you pick it up again, say so and the carry can be closed.

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7342617721 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2000#issuecomment-7342617721). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T10:32:22Z. --- For information: this pull request is carried in #3090, which merges your head (your commits are kept) into current `main`, resolves the conflicts keeping both sides, and fixes the points raised in review here (details in its description). This one stays open until a maintainer decides; if you pick it up again, say so and the carry can be closed. AI-assisted (Claude Code, Claude Opus 5.5)
MoonEyes commented 2026-12-02 11:49:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:49:33Z.


Closing: this pull request no longer applies to current main (merge conflict in tests/test_ds_permute_probe.py), and open pull requests that have fallen out of step with main are being closed so the list stays workable. Your work is not lost: it is carried in #3090
, which keeps your commits and resolves the conflict on current main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7344458721 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2000#issuecomment-7344458721). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T11:49:33Z. --- Closing: this pull request no longer applies to current `main` (merge conflict in `tests/test_ds_permute_probe.py`), and open pull requests that have fallen out of step with `main` are being closed so the list stays workable. Your work is not lost: it is carried in #3090 , which keeps your commits and resolves the conflict on current `main`. AI-assisted (Claude Code).

Pull request closed

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!2000
No description provided.