root_sig_contract: handle deeply nested JSON, duplicate ptr64_hi error, and bad pack_layout inputs (OLD-5357) #573

Merged
Taffyyy-ops merged 1 commit from upstream-pr/573 into main 2026-11-24 09:27:06 +00:00
Taffyyy-ops commented 2026-11-24 08:45:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-24T08:45:27Z.


Claimed in the coordination issue as: OLD-5357 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7126487215)

What and why

Carried over from the closed upstream ItsNotRexed/Leonida PR #5357 and rebased cleanly onto ubiquitarianism/leonida main (a63d4bbd7).

Hardens tools/root_sig_contract.py for malformed or boundary inputs:

  • Handle deeply nested JSON (RecursionError) cleanly with exit code 2 instead of an unhandled traceback.
  • Avoid reporting a spurious duplicate ptr64_hi error alongside the primary incompatibility when reconciling constant/descriptor/table halves.
  • Reject bad pack_layout signature/parameter shapes cleanly without raising.
  • Add standard-library unittest regression coverage in tests/test_root_sig_contract_edges.py (6 tests).

Tested

On Windows 11 with Python 3.12+ after rebasing onto 1c93c8697:

  • python -I tests/test_root_sig_contract_edges.py -v -> Ran 6 tests in 0.259s, OK
  • python -I tools/root_sig_contract.py --example -> exit 0
  • python -m compileall -q tools/root_sig_contract.py tests/test_root_sig_contract_edges.py -> exit 0
  • python -I scripts/check_no_game_data.py -> exit 0
  • git diff --check upstream/main..HEAD -> exit 0

(Note: tests/test_root_sig_contract.py requires pytest, which is not installed in this host Python environment.)

GPUs tested: n/a (host CPU Python stdlib)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5468913557 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/573). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-24T08:45:27Z. --- Claimed in the coordination issue as: OLD-5357 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7126487215) ### What and why Carried over from the closed upstream `ItsNotRexed/Leonida` PR #5357 and rebased cleanly onto `ubiquitarianism/leonida` `main` (`a63d4bbd7`). Hardens `tools/root_sig_contract.py` for malformed or boundary inputs: - Handle deeply nested JSON (`RecursionError`) cleanly with exit code 2 instead of an unhandled traceback. - Avoid reporting a spurious duplicate `ptr64_hi` error alongside the primary incompatibility when reconciling constant/descriptor/table halves. - Reject bad `pack_layout` signature/parameter shapes cleanly without raising. - Add standard-library `unittest` regression coverage in `tests/test_root_sig_contract_edges.py` (6 tests). ### Tested On Windows 11 with Python 3.12+ after rebasing onto `1c93c8697`: - `python -I tests/test_root_sig_contract_edges.py -v` -> Ran 6 tests in 0.259s, OK - `python -I tools/root_sig_contract.py --example` -> exit 0 - `python -m compileall -q tools/root_sig_contract.py tests/test_root_sig_contract_edges.py` -> exit 0 - `python -I scripts/check_no_game_data.py` -> exit 0 - `git diff --check upstream/main..HEAD` -> exit 0 *(Note: `tests/test_root_sig_contract.py` requires `pytest`, which is not installed in this host Python environment.)* GPUs tested: n/a (host CPU Python stdlib) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
QemmHD commented 2026-11-24 09:27:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T09:27:03Z.


Merging. Why merged: root_sig_contract rejects non-object signatures and parameters, reports deeply nested JSON as a clean exit-2 error, and fixes the ptr64_hi double report.
Why it's good: the new edge tests go 4 passed / 15 failed on main -> 6 passed (20 subtests) on the merge; the existing 58 tests still pass; clean on main 7430f59; consistency 565/0.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7127428835 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/573#issuecomment-7127428835). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T09:27:03Z. --- Merging. Why merged: root_sig_contract rejects non-object signatures and parameters, reports deeply nested JSON as a clean exit-2 error, and fixes the ptr64_hi double report. Why it's good: the new edge tests go 4 passed / 15 failed on main -> 6 passed (20 subtests) on the merge; the existing 58 tests still pass; clean on main 7430f59; consistency 565/0. 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!573
No description provided.