# Forester.py json.dump without sort\_keys makes output fragile to row order

**URL:** <https://ghostforum.org/t/forester-py-json-dump-without-sort-keys-makes-output-fragile-to-row-order/142>\
**Category:** Submitted\
**Tags:** ghost-preclaims\
**Created:** [October 5, 2026, 2:42am UTC](https://ghostforum.org/t/forester-py-json-dump-without-sort-keys-makes-output-fragile-to-row-order/142 "2026-10-05T02:42:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rusdiwireng](https://ghostforum.org/letter_avatar_proxy/v4/letter/r/9de0a6/32.png) [@Rusdiwireng](https://ghostforum.org/u/Rusdiwireng)\
**Post date:** [October 5, 2026, 2:42am UTC](https://ghostforum.org/t/forester-py-json-dump-without-sort-keys-makes-output-fragile-to-row-order/142/1 "2026-10-05T02:42:52Z")

</div>

**Component:** `ghost-preclaims` @ `1538567`, `forester.py` (~line 128 key insertion, ~line 150 `json.dump(output_packages, f, indent=2)` without `sort_keys=True`).

**Description:** Output key order = first-appearance order of addresses in the snapshot. The root hash is unaffected (the tree is indexed by `item['index']`), but the file bytes change if snapshot row order changes.

**Impact:** Only matters to anyone verifying integrity via file hash.

**Reproduction:** Local: shuffle rows of `snapshots/7001.json` (seed 42), run `PYTHONHASHSEED=7 python forester.py --network-id 7001` → `=== FINAL MERKLE ROOT [7001]: 793b300540c6530c24be7cc40b1ba91f0a586da8e180b98e91b055a9a12f45e2 ===` → `cmp` shows `BYTES DIFFER despite same multiset of leaves` (identical root, same key set and payload, only key order differs).

**Severity: Low.** Reason: pure serialization fragility; unreachable in practice because `finder.py` always appends in `token_id` order (sequential `range()` loop). Only affects file-hash integrity checks.

**Recommendation:** `json.dump(output_packages, f, indent=2, sort_keys=True)` (and consider the same in `finder.py` ~line 66).

**Verification:** VERIFIED.
