[PR #897] [MERGED] BUILD-GAMEDATA-GRAPH-INDEX-AND-ATOMIC: gamedata_graph: index sibling parentPath lookups and write JSON atomically #935

Closed
opened 2026-11-26 20:19:33 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/897
Author: @narekshaghoyandev
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @QemmHD

Base: main ← Head: ubiq-gamedata-graph-index-and-atomic


📝 Commits (1)

  • 755283d gamedata_graph: index sibling parentPath lookups and write JSON atomically

📊 Changes

2 files changed (+87 additions, -6 deletions)

View changed files

📝 tests/test_gamedata_graph.py (+46 -0)
📝 tools/gamedata_graph.py (+41 -6)

📄 Description

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://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135309930)
AI-assisted: yes (Gemini)


🔄 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/897 **Author:** [@narekshaghoyandev](https://github.com/narekshaghoyandev) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `ubiq-gamedata-graph-index-and-atomic` --- ### 📝 Commits (1) - [`755283d`](https://github.com/ubiquitarianism/leonida/commit/755283da5980158eac5a6817e2e29340c85bd8d3) gamedata_graph: index sibling parentPath lookups and write JSON atomically ### 📊 Changes **2 files changed** (+87 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_gamedata_graph.py` (+46 -0) 📝 `tools/gamedata_graph.py` (+41 -6) </details> ### 📄 Description 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://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135309930) AI-assisted: yes (Gemini) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:33 +01:00
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#935
No description provided.