gamedata_graph: fix manifest/root summary invariants and --json path guards (GAMEDATA-GRAPH-COUNTS-AND-CLI-GUARDS) #1550

Open
github-bot wants to merge 1 commit from github-bot/gh-1550 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 04:11 UTC · original
IlyassRS3:fix/gamedata-graph-counts-and-cli → main · +64 −9 · 2 files · 1 commits · open

What

Fix four summary-accounting and CLI path-guard bugs in tools/gamedata_graph.py:

  1. Unparsed manifest payloads inflated per-category/per-root manifest_documents (build_graph):
    • Top-level summary["manifest_documents"] counts only parsed manifest documents (report["parsed"] and report["root"] in MANIFEST_ROOT_SET), whereas category_stats and root_stats omitted report["parsed"]. Require report["parsed"] in both so per-category and per-root totals match summary["manifest_documents"].
  2. Rootless payloads ("") counted as a named root in categories["uncatalogued"]["roots"] (build_graph):
    • summary["root_count"] excludes "" (empty/rootless payloads are counted under summary["rootless"]), yet the category root count included "", making sum(c["roots"]) exceed summary["root_count"] by 1 whenever any rootless payload exists. Skip empty root names when counting named roots per category.
  3. Well-formed parsed documents could be marked complete=False (scan_document):
    • Once ET.fromstring(data) succeeds, mark report["complete"] = True (matching gamedata_xml.py:file_row) instead of keeping doc.get("complete", True), so summary["parsed"] can never exceed summary["documents"].
  4. Empty/whitespace --json and directory-mode .bin guard (main):
    • Check args.json is not None and reject empty/whitespace --json values with parser.error(...) instead of silently ignoring --json "" or writing a whitespace filename.
    • Gate the carve-stream .bin/.bk2 overwrite guard on is_carve (directory containing index.json) using realpath and case-insensitive suffix matching, so directory mode does not reject unrelated .bin outputs while carve mode protects both .bin and .bk2 streams.

Claimed in the coordination issue as

GAMEDATA-GRAPH-COUNTS-AND-CLI-GUARDS — verified 0 open PRs and 0 prior claims; unable to post a comment on #14 because GitHub disabled commenting once #14 reached its 2,500-comment cap (and no successor "Coordinating who works on what" issue is open yet).

Testing

  • python3 -I -W error tests/test_gamedata_graph.py -v: 24/24 OK (including 3 new regression tests).

  • python3 -I -W error tests/test_gamedata_graph_bad_index.py -v: 5/5 OK.

  • python3 -I tests/test_text_write_line_endings.py: 3/3 OK.

  • python3 -I scripts/check_no_game_data.py tools/gamedata_graph.py tests/test_gamedata_graph.py: clean.

  • python3 -m compileall -q tools/gamedata_graph.py tests/test_gamedata_graph.py: clean.

  • Mutation check against unpatched main:tools/gamedata_graph.py: all 3 new tests (4 assertions/subtests) fail on main (FAILED (failures=4)).

  • AI-assisted: yes

  • GPUs tested: none (CPU-only XML graph tool tests on macOS; no GPU or game files needed)

**@⁠IlyassRS3** on GitHub · 2026-11-25 04:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1550) `IlyassRS3:fix/gamedata-graph-counts-and-cli` → `main` · +64 −9 · 2 files · 1 commits · open ## What Fix four summary-accounting and CLI path-guard bugs in `tools/gamedata_graph.py`: 1. **Unparsed manifest payloads inflated per-category/per-root `manifest_documents`** (`build_graph`): - Top-level `summary["manifest_documents"]` counts only parsed manifest documents (`report["parsed"] and report["root"] in MANIFEST_ROOT_SET`), whereas `category_stats` and `root_stats` omitted `report["parsed"]`. Require `report["parsed"]` in both so per-category and per-root totals match `summary["manifest_documents"]`. 2. **Rootless payloads (`""`) counted as a named root in `categories["uncatalogued"]["roots"]`** (`build_graph`): - `summary["root_count"]` excludes `""` (empty/rootless payloads are counted under `summary["rootless"]`), yet the category root count included `""`, making `sum(c["roots"])` exceed `summary["root_count"]` by 1 whenever any rootless payload exists. Skip empty root names when counting named roots per category. 3. **Well-formed parsed documents could be marked `complete=False`** (`scan_document`): - Once `ET.fromstring(data)` succeeds, mark `report["complete"] = True` (matching `gamedata_xml.py:file_row`) instead of keeping `doc.get("complete", True)`, so `summary["parsed"]` can never exceed `summary["documents"]`. 4. **Empty/whitespace `--json` and directory-mode `.bin` guard** (`main`): - Check `args.json is not None` and reject empty/whitespace `--json` values with `parser.error(...)` instead of silently ignoring `--json ""` or writing a whitespace filename. - Gate the carve-stream `.bin`/`.bk2` overwrite guard on `is_carve` (directory containing `index.json`) using `realpath` and case-insensitive suffix matching, so directory mode does not reject unrelated `.bin` outputs while carve mode protects both `.bin` and `.bk2` streams. ## Claimed in the coordination issue as `GAMEDATA-GRAPH-COUNTS-AND-CLI-GUARDS` — verified 0 open PRs and 0 prior claims; unable to post a comment on `#14` because GitHub disabled commenting once `#14` reached its 2,500-comment cap (and no successor `"Coordinating who works on what"` issue is open yet). ## Testing - `python3 -I -W error tests/test_gamedata_graph.py -v`: **24/24 OK** (including 3 new regression tests). - `python3 -I -W error tests/test_gamedata_graph_bad_index.py -v`: **5/5 OK**. - `python3 -I tests/test_text_write_line_endings.py`: **3/3 OK**. - `python3 -I scripts/check_no_game_data.py tools/gamedata_graph.py tests/test_gamedata_graph.py`: clean. - `python3 -m compileall -q tools/gamedata_graph.py tests/test_gamedata_graph.py`: clean. - Mutation check against unpatched `main:tools/gamedata_graph.py`: all 3 new tests (4 assertions/subtests) fail on `main` (`FAILED (failures=4)`). - AI-assisted: yes - GPUs tested: none (CPU-only XML graph tool tests on macOS; no GPU or game files needed)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:56:18 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 04:11 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 04:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1550#pullrequestreview-6051748808) · **reviewed** 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1550/head:github-bot/gh-1550'
git switch 'github-bot/gh-1550'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1550'
git switch 'github-bot/gh-1550'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1550'
git switch 'github-bot/gh-1550'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1550'
git switch 'main'
git merge --squash 'github-bot/gh-1550'
git switch 'main'
git merge --ff-only 'github-bot/gh-1550'
git switch 'main'
git merge 'github-bot/gh-1550'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.