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

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

📋 Pull Request Information

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

Base: main ← Head: fix/character-census-row-and-atomic-io


📝 Commits (1)

  • f1929f9 character_census: pass model dict in model_row, dedup mesh issues, trim manifest paths, atomic writes

📊 Changes

2 files changed (+115 additions, -14 deletions)

View changed files

📝 tests/test_character_census.py (+71 -0)
📝 tools/character_census.py (+44 -14)

📄 Description

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)

🔄 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/1543 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/character-census-row-and-atomic-io` --- ### 📝 Commits (1) - [`f1929f9`](https://github.com/ubiquitarianism/leonida/commit/f1929f9400b12739e4a1194b260228e08f5f8216) character_census: pass model dict in model_row, dedup mesh issues, trim manifest paths, atomic writes ### 📊 Changes **2 files changed** (+115 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_character_census.py` (+71 -0) 📝 `tools/character_census.py` (+44 -14) </details> ### 📄 Description ## 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) --- <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#1572
No description provided.