[PR #1762] psin_names: publish --refs atomically and match .JSON case-insensitively (PSIN-NAMES-ATOMIC-REFS-AND-CASE-JSON) #1775

Open
opened 2026-11-26 21:18:54 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1762
Author: @kirigayakazima
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/psin-names-atomic-refs-and-case-json


📝 Commits (1)

  • 8f2c0e3 psin_names: publish --refs atomically and match .JSON case-insensitively

📊 Changes

2 files changed (+106 additions, -6 deletions)

View changed files

📝 tests/test_psin_names.py (+76 -0)
📝 tools/psin_names.py (+30 -6)

📄 Description

Claimed in the coordination issue as: PSIN-NAMES-ATOMIC-REFS-AND-CASE-JSON https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161241950

What and why

Hardens tools/psin_names.py:

  1. Case-insensitive .json extension in load_names: Use path.lower().endswith(".json") so uppercase NAMES.JSON is parsed as JSON rather than split line-by-line as raw JSON syntax text.
  2. Normalize inside_src path comparison: Apply os.path.normcase after os.path.realpath when checking whether --refs falls inside src so commonpath matches same_report_path case semantics consistently.
  3. Atomic --refs TSV publish with Windows read-only cleanup: Stage --refs into tempfile.NamedTemporaryFile in the destination directory, apply published_mode(dest), publish via replace_retry, and restore 0o600 before unlinking on failure. Mid-scan errors or failed replaces over read-only targets preserve any previous TSV intact and leave no .psin_names-*.tmp files.

Adds 3 synthetic regression tests in tests/test_psin_names.py.

Tested

Windows 11 x64 (10.0.26100), Python 3.14.7, CPU only, synthetic PSIN inputs only (no game files). Commit 8f2c0e351254c778ba8a41b32629ff89dd93fb0b.

  • python -I tests/test_psin_names.py -v:
    • against main (bcaa13da) with all 20 tests: 2 failures (test_uppercase_json_extension_is_parsed_as_json and test_refs_failure_preserves_previous_file_and_cleans_staging — truncates previous refs.tsv on mid-run error);
    • with the fix: 20 tests, OK (0 skipped).
  • python -I tests/test_ci_registration.py: 16 tests, OK.
  • python -I tests/test_text_write_line_endings.py: 3 tests, OK.
  • python -I scripts/check_no_game_data.py tools/psin_names.py tests/test_psin_names.py, python -m compileall -q tools tests, git diff --check: exit 0.

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1762 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/psin-names-atomic-refs-and-case-json` --- ### 📝 Commits (1) - [`8f2c0e3`](https://github.com/ubiquitarianism/leonida/commit/8f2c0e351254c778ba8a41b32629ff89dd93fb0b) psin_names: publish --refs atomically and match .JSON case-insensitively ### 📊 Changes **2 files changed** (+106 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_psin_names.py` (+76 -0) 📝 `tools/psin_names.py` (+30 -6) </details> ### 📄 Description Claimed in the coordination issue as: PSIN-NAMES-ATOMIC-REFS-AND-CASE-JSON https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161241950 ### What and why Hardens `tools/psin_names.py`: 1. **Case-insensitive `.json` extension in `load_names`**: Use `path.lower().endswith(".json")` so uppercase `NAMES.JSON` is parsed as JSON rather than split line-by-line as raw JSON syntax text. 2. **Normalize `inside_src` path comparison**: Apply `os.path.normcase` after `os.path.realpath` when checking whether `--refs` falls inside `src` so `commonpath` matches `same_report_path` case semantics consistently. 3. **Atomic `--refs` TSV publish with Windows read-only cleanup**: Stage `--refs` into `tempfile.NamedTemporaryFile` in the destination directory, apply `published_mode(dest)`, publish via `replace_retry`, and restore `0o600` before unlinking on failure. Mid-scan errors or failed replaces over read-only targets preserve any previous TSV intact and leave no `.psin_names-*.tmp` files. Adds 3 synthetic regression tests in `tests/test_psin_names.py`. ### Tested Windows 11 x64 (`10.0.26100`), Python `3.14.7`, CPU only, synthetic PSIN inputs only (no game files). Commit `8f2c0e351254c778ba8a41b32629ff89dd93fb0b`. - `python -I tests/test_psin_names.py -v`: - against `main` (`bcaa13da`) with all 20 tests: **2 failures** (`test_uppercase_json_extension_is_parsed_as_json` and `test_refs_failure_preserves_previous_file_and_cleans_staging` — truncates previous `refs.tsv` on mid-run error); - with the fix: **20 tests, OK** (0 skipped). - `python -I tests/test_ci_registration.py`: **16 tests, OK**. - `python -I tests/test_text_write_line_endings.py`: **3 tests, OK**. - `python -I scripts/check_no_game_data.py tools/psin_names.py tests/test_psin_names.py`, `python -m compileall -q tools tests`, `git diff --check`: exit `0`. 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1775
No description provided.