BUILD-GAMEDATA-GRAPH-INDEX-AND-ATOMIC: gamedata_graph: index sibling parentPath lookups and write JSON atomically #897

Manually merged
github merged 1 commit from gh-pr/897/head into gh-pr/897/base 2026-11-26 09:27:02 +00:00
Owner

@⁠narekshaghoyandev on GitHub · 2026-11-24 15:02 UTC · original
narekshaghoyandev:ubiq-gamedata-graph-index-and-atomic → main · +87 −6 · 2 files · 1 commits · merged 2026-11-24 23:22 UTC

Improves tools/gamedata_graph.py performance and JSON report safety with identical graph output:

  1. Linear-time sibling lookup in resolve_parent_paths: Lazily indexes siblings by (id(container), tag, attribute) -> {value: [siblings]} instead of scanning every sibling per parentPath element (O(N^2) o O(N)), preserving exact resolved/ambiguous counts and link order.
  2. Atomic JSON report writes (write_json, main): Publishes --json via tempfile.mkstemp + file_mode.published_mode + replace_retry.replace with allow_nan=False, trailing LF, and read-only-safe temp cleanup on failure (preserving existing reports and permissions). Also accepts optional argv=None in main(argv=None).

Verification

  • python3 -I tests/test_gamedata_graph.py -v: 21/21 pass (negative control fails on main).
  • 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.

Claimed in the coordination issue as: BUILD-GAMEDATA-GRAPH-INDEX-AND-ATOMIC (#14)
AI-assisted: yes (Gemini)

**@⁠narekshaghoyandev** on GitHub · 2026-11-24 15:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/897) `narekshaghoyandev:ubiq-gamedata-graph-index-and-atomic` → `main` · +87 −6 · 2 files · 1 commits · merged 2026-11-24 23:22 UTC Improves `tools/gamedata_graph.py` performance and JSON report safety with identical graph output: 1. **Linear-time sibling lookup in `resolve_parent_paths`**: Lazily indexes siblings by `(id(container), tag, attribute) -> {value: [siblings]}` instead of scanning every sibling per `parentPath` element ($O(N^2) o O(N)$), preserving exact resolved/ambiguous counts and link order. 2. **Atomic JSON report writes (`write_json`, `main`)**: Publishes `--json` via `tempfile.mkstemp` + `file_mode.published_mode` + `replace_retry.replace` with `allow_nan=False`, trailing LF, and read-only-safe temp cleanup on failure (preserving existing reports and permissions). Also accepts optional `argv=None` in `main(argv=None)`. ### Verification - `python3 -I tests/test_gamedata_graph.py -v`: 21/21 pass (negative control fails on `main`). - `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. Claimed in the coordination issue as: BUILD-GAMEDATA-GRAPH-INDEX-AND-ATOMIC (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) AI-assisted: yes (Gemini)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:27:01 +00:00
github manually merged commit 755283da59 into gh-pr/897/base 2026-11-26 09:27:02 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 15:06 UTC · original · approved these changes

Reviewed exact head 755283da5980158eac5a6817e2e29340c85bd8d3. The sibling lookup index is keyed by container/tag/attribute and preserves duplicate matches (so ambiguity behavior remains intact); synthetic 2,000/4,000/8,000 sibling chains resolved all expected links with no ambiguity. Atomic JSON output preserves the previous file on replace failure, cleans its temporary file, preserves existing permissions, and writes the trailing LF. Validation on Bazzite/Linux: python3 -I tests/test_gamedata_graph.py -v (19/19 passed), isolated Python compile and git diff --check passed. No game data or GPU used.

**@⁠KernelSmoker** on GitHub · 2026-11-24 15:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/897#pullrequestreview-6041789738) · **approved these changes** Reviewed exact head `755283da5980158eac5a6817e2e29340c85bd8d3`. The sibling lookup index is keyed by container/tag/attribute and preserves duplicate matches (so ambiguity behavior remains intact); synthetic 2,000/4,000/8,000 sibling chains resolved all expected links with no ambiguity. Atomic JSON output preserves the previous file on replace failure, cleans its temporary file, preserves existing permissions, and writes the trailing LF. Validation on Bazzite/Linux: `python3 -I tests/test_gamedata_graph.py -v` (19/19 passed), isolated Python compile and `git diff --check` passed. No game data or GPU used.
Author
Owner

@⁠LewisStephens99 on GitHub · 2026-11-24 15:13 UTC · original

Independent verification on Windows 11, Python 3.14:n- python -I tests/test_gamedata_graph.py: 21/21 passed.n- No game data or GPU used. AI-assisted.

**@⁠LewisStephens99** on GitHub · 2026-11-24 15:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/897#issuecomment-7135667726) Independent verification on Windows 11, Python 3.14:`n- `python -I tests/test_gamedata_graph.py`: 21/21 passed.`n- No game data or GPU used. AI-assisted.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 23:22 UTC · original

Merging.

Why merged: BUILD-GAMEDATA-GRAPH-INDEX-AND-ATOMIC: gamedata_graph builds an index of sibling parentPath lookups (O(N) instead of O(N²)), keeping duplicate matches so ambiguity is still detected. It also catches RecursionError and writes --json atomically (mkstemp + replace_retry + published_mode). KernelSmoker approved it, and LewisStephens99 got 21/21 on Windows.

Why it's good: 26 passed. The JSON now uses allow_nan=False, which is harmless because the graph holds only counts.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 0f98d193c. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

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

**@⁠QemmHD** on GitHub · 2026-11-24 23:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/897#issuecomment-7147329932) Merging. **Why merged:** BUILD-GAMEDATA-GRAPH-INDEX-AND-ATOMIC: gamedata_graph builds an index of sibling parentPath lookups (O(N) instead of O(N²)), keeping duplicate matches so ambiguity is still detected. It also catches RecursionError and writes --json atomically (mkstemp + replace_retry + published_mode). KernelSmoker approved it, and LewisStephens99 got 21/21 on Windows. **Why it's good:** 26 passed. The JSON now uses allow_nan=False, which is harmless because the graph holds only counts. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 0f98d193c. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.