character_census: pass model dict in model_row, dedup mesh issues, trim paths, atomic writes (CHARACTER-CENSUS-ROW-AND-ATOMIC-IO) #1543

Merged
IlyassRS3 merged 1 commit from upstream-pr/1543 into main 2026-11-28 10:44:54 +00:00
IlyassRS3 commented 2026-11-25 04:01:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T04:01:09Z.


What changed

  • Pass input model instead of output row in model_row() (tools/character_census.py:model_row, _bones): model_row() previously passed the blank output row dictionary to _kind(), _bones(), and _skin_8(), causing top-level IsFragment, HasBoneBindings, skin_8, and skin_influences keys in a model.json to be silently ignored. _bones() also avoids duplicating its model/manifest check when row is model.
  • Deduplicate repeated mesh issues (tools/character_census.py:model_row): _mesh_count() runs up to three times (vertices, triangles, indices) over the same meshes list, previously repeating identical "mesh N is not an object" and "mesh N index count is not a non-negative integer" issues on a single row.
  • Trim and validate string manifest paths (tools/character_census.py:_entry_path): strip surrounding whitespace from string/dict path entries and return None for blank strings ("" / " ") so blank entries are reported cleanly instead of resolved as filesystem paths.
  • Atomic CSV and JSON report writes (tools/character_census.py:write_csv, write_json, main): stage reports through sibling temp files with explicit newline=, preserve permissions via file_mode.published_mode, publish with replace_retry.replace, enforce allow_nan=False on JSON output, clean up temp files on error, and catch ValueError alongside OSError in main().
  • Tests (tests/test_character_census.py): added 4 synthetic regression tests covering every fix above.

Claimed in the coordination issue as:

CHARACTER-CENSUS-ROW-AND-ATOMIC-IO (#14 reached GitHub's 2,500-comment cap with no successor coordination issue open yet; checked #14 and open PRs — 0 claims and 0 open PRs touch tools/character_census.py)

How it was tested

  • python3 -I -W error tests/test_character_census.py: 27/27 passed (0 warnings).
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/character_census.py tests/test_character_census.py: passed.
  • python3 -m compileall -q tools/character_census.py tests/test_character_census.py: passed.
  • Mutation check against unpatched main:tools/character_census.py: all 4 new tests fail (FAILED (failures=3, errors=1)), all 23 baseline tests pass.

Metadata

  • AI-assisted: yes
  • GPUs tested: none (CPU-only synthetic JSON/CSV/CLI unit tests on macOS arm64; no game files used)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5484930574 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1543). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T04:01:09Z. --- ## What changed - **Pass input `model` instead of output `row` in `model_row()` (`tools/character_census.py:model_row`, `_bones`)**: `model_row()` previously passed the blank output `row` dictionary to `_kind()`, `_bones()`, and `_skin_8()`, causing top-level `IsFragment`, `HasBoneBindings`, `skin_8`, and `skin_influences` keys in a `model.json` to be silently ignored. `_bones()` also avoids duplicating its `model`/`manifest` check when `row is model`. - **Deduplicate repeated mesh issues (`tools/character_census.py:model_row`)**: `_mesh_count()` runs up to three times (vertices, triangles, indices) over the same `meshes` list, previously repeating identical `"mesh N is not an object"` and `"mesh N index count is not a non-negative integer"` issues on a single row. - **Trim and validate string manifest paths (`tools/character_census.py:_entry_path`)**: strip surrounding whitespace from string/dict path entries and return `None` for blank strings (`""` / `" "`) so blank entries are reported cleanly instead of resolved as filesystem paths. - **Atomic CSV and JSON report writes (`tools/character_census.py:write_csv`, `write_json`, `main`)**: stage reports through sibling temp files with explicit `newline=`, preserve permissions via `file_mode.published_mode`, publish with `replace_retry.replace`, enforce `allow_nan=False` on JSON output, clean up temp files on error, and catch `ValueError` alongside `OSError` in `main()`. - **Tests (`tests/test_character_census.py`)**: added 4 synthetic regression tests covering every fix above. ## Claimed in the coordination issue as: `CHARACTER-CENSUS-ROW-AND-ATOMIC-IO` (#14 reached GitHub's 2,500-comment cap with no successor coordination issue open yet; checked #14 and open PRs — 0 claims and 0 open PRs touch `tools/character_census.py`) ## How it was tested - `python3 -I -W error tests/test_character_census.py`: 27/27 passed (0 warnings). - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/character_census.py tests/test_character_census.py`: passed. - `python3 -m compileall -q tools/character_census.py tests/test_character_census.py`: passed. - Mutation check against unpatched `main:tools/character_census.py`: all 4 new tests fail (`FAILED (failures=3, errors=1)`), all 23 baseline tests pass. ## Metadata - AI-assisted: yes - GPUs tested: none (CPU-only synthetic JSON/CSV/CLI unit tests on macOS arm64; no game files used)
copilot-pull-request-reviewer[bot] commented 2026-11-25 04:01:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T04:01:20Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051677034 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1543#pullrequestreview-6051677034). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T04:01:20Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
MoonEyes commented 2026-11-28 10:44:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:44:51Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 19 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238095632 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1543#issuecomment-7238095632). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T10:44:51Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 19 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. 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!1543
No description provided.