leonida_mods: trim model ID whitespace (MODS-PARSE-MODEL-WHITESPACE) #852

Merged
KernelSmoker merged 1 commit from upstream-pr/852 into main 2026-11-28 13:05:50 +00:00
KernelSmoker commented 2026-11-24 14:33:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T14:33:47Z.


Claimed in the coordination issue as: MODS-PARSE-MODEL-WHITESPACE — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134562317

What and why

Trim surrounding whitespace before parsing or hashing a textual model ID in a mod manifest. This makes accidental spaces/tabs/newlines resolve to the intended model ID instead of silently hashing a different name. Whitespace-only values remain invalid. Hex IDs also accept surrounding whitespace.

Tested

  • python3 -I tests/test_leonida_mods.py -v: 10/10 passed.
  • python3 -I -m py_compile tools/leonida_mods.py tests/test_leonida_mods.py: passed.
  • git diff --check: passed.
  • Synthetic names and manifests only; no game files used.

GPUs tested: n/a (CPU-only parser tests)

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474174445 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/852). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T14:33:47Z. --- Claimed in the coordination issue as: MODS-PARSE-MODEL-WHITESPACE — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134562317 ### What and why Trim surrounding whitespace before parsing or hashing a textual model ID in a mod manifest. This makes accidental spaces/tabs/newlines resolve to the intended model ID instead of silently hashing a different name. Whitespace-only values remain invalid. Hex IDs also accept surrounding whitespace. ### Tested - `python3 -I tests/test_leonida_mods.py -v`: 10/10 passed. - `python3 -I -m py_compile tools/leonida_mods.py tests/test_leonida_mods.py`: passed. - `git diff --check`: passed. - Synthetic names and manifests only; no game files used. GPUs tested: n/a (CPU-only parser tests) AI-assisted: yes
abnalstlll-byte commented 2026-11-24 14:38:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:38:25Z.

Review: APPROVED


Audited and verified. Trimming surrounding whitespace in parse_model_id handles leading/trailing whitespace in manifest model names and hexadecimal IDs while properly rejecting whitespace-only inputs with ValueError('empty model name'). Unit tests in ests/test_leonida_mods.py pass cleanly. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041254750 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/852#pullrequestreview-6041254750). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:38:25Z. **Review:** APPROVED --- Audited and verified. Trimming surrounding whitespace in parse_model_id handles leading/trailing whitespace in manifest model names and hexadecimal IDs while properly rejecting whitespace-only inputs with ValueError('empty model name'). Unit tests in ests/test_leonida_mods.py pass cleanly. Approved.
abnalstlll-byte commented 2026-11-24 14:39:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:39:22Z.

Review: APPROVED


Clean-Room Audit & Verification — PR #852 (MODS-PARSE-MODEL-WHITESPACE)

Thank you @KernelSmoker for picking up and addressing our finding so quickly!

Technical Verification

  1. Whitespace Trimming:
    • parse_model_id now strips leading/trailing whitespace before inspecting whether the string is a hex literal or archetype name.
    • Guarded empty string check ensures parse_model_id(" \t\n ") raises ValueError("empty model name") cleanly.
  2. Test Suite Coverage:
    • Added unit test cases to tests/test_leonida_mods.py covering padded names (" player_story000_00 \t" -> 0xE472B687, "\n0xD7C0CDFF " -> 0xD7C0CDFF), whitespace-only ValueError verification, and manifest validation with padded names in archetype_swaps.
    • Verified locally with Python: python -I -m unittest tests/test_leonida_mods.py — PASS.
  3. Clean-Room Compliance:
    • 0 game data, synthetic test fixtures only, 100% standard library compliance.

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041273889 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/852#pullrequestreview-6041273889). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:39:22Z. **Review:** APPROVED --- ### Clean-Room Audit & Verification — PR #852 (`MODS-PARSE-MODEL-WHITESPACE`) Thank you @KernelSmoker for picking up and addressing our finding so quickly! #### Technical Verification 1. **Whitespace Trimming**: - `parse_model_id` now strips leading/trailing whitespace before inspecting whether the string is a hex literal or archetype name. - Guarded empty string check ensures `parse_model_id(" \t\n ")` raises `ValueError("empty model name")` cleanly. 2. **Test Suite Coverage**: - Added unit test cases to `tests/test_leonida_mods.py` covering padded names (`" player_story000_00 \t"` -> `0xE472B687`, `"\n0xD7C0CDFF "` -> `0xD7C0CDFF`), whitespace-only ValueError verification, and manifest validation with padded names in `archetype_swaps`. - Verified locally with Python: `python -I -m unittest tests/test_leonida_mods.py` — **PASS**. 3. **Clean-Room Compliance**: - 0 game data, synthetic test fixtures only, 100% standard library compliance. **Verdict: APPROVED**
tiguan26 commented 2026-11-25 03:56:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T03:56:59Z.

Review: APPROVED


Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). A model id is stripped before use and an all-whitespace one is refused as empty.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051646469 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/852#pullrequestreview-6051646469). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T03:56:59Z. **Review:** APPROVED --- Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). A model id is stripped before use and an all-whitespace one is refused as empty. AI-assisted (Claude).
MoonEyes commented 2026-11-28 13:05:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T13:05:46Z.


Red/green: tests/test_leonida_mods.py 2 failed on main, 12 passed with the PR.
Targeted batch of 30 PRs (their tests, the tests importing the changed modules, the docs tests, the translator suite) on main a997a3c: no new failure, Windows 11 / Python.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239686887 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/852#issuecomment-7239686887). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T13:05:46Z. --- Red/green: tests/test_leonida_mods.py 2 failed on main, 12 passed with the PR. Targeted batch of 30 PRs (their tests, the tests importing the changed modules, the docs tests, the translator suite) on main a997a3c: no new failure, Windows 11 / Python. AI-assisted (Claude Code, Claude Opus 5.5)
OreoFR commented 2026-11-28 21:44:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:44:48Z.


Verified by OreoFR

  • Base: main 4a54aedcb + PR head 43b445ca3
  • Test: python -I tests/test_leonida_mods.py
  • Red on main: 2 failures (spaces around the model name hashed)
  • Green with the PR: 12 OK
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246241471 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/852#issuecomment-7246241471). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:44:48Z. --- **Verified by OreoFR** - Base: main `4a54aedcb` + PR head `43b445ca3` - Test: `python -I tests/test_leonida_mods.py` - Red on main: 2 failures (spaces around the model name hashed) - Green with the PR: 12 OK - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 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!852
No description provided.