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

Merged
leonida/mandy
KernelSmoker merged 1 commit from kernelsmoker/mods-parse-model-whitespace into main 2026-11-28 13:05:50 +00:00

Pull request successfully merged and closed

KernelSmoker commented 2026-11-24 14:33:47 +00:00

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

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 approved these changes 2026-11-24 14:38:25 +00:00
abnalstlll-byte left a comment

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.

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 approved these changes 2026-11-24 14:39:22 +00:00
abnalstlll-byte left a comment

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

### 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 approved these changes 2026-11-25 03:56:59 +00:00
tiguan26 left a comment

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).

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

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)

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

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).

**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 description provided.