[PR #323] [MERGED] version_port.py: detect, prepare and diff Minecraft releases #2491

Closed
opened 2026-11-02 15:56:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/323
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/version-port-diff


📝 Commits (2)

  • 720e91f Design the version-port pipeline: detect, prepare, diff, regenerate, report
  • 58ad816 version_port.py: detect, prepare and diff Minecraft releases

📊 Changes

4 files changed (+972 additions, -0 deletions)

View changed files

📝 docs/README.md (+1 -0)
➕ docs/version-ports.md (+277 -0)
➕ tests/test_version_port.py (+144 -0)
➕ tools/version_port.py (+550 -0)

📄 Description

Stacked on #322 (the design). Slice (a) of docs/version-ports.md.

What

tools/version_port.py:

  • detect [--snapshots]: reads Mojang's version manifest. It reports a release or snapshot that is neither pinned nor seen before; exit 10 for a release, 11 for a snapshot.
  • prepare VERSION: downloads the version JSON (sha1 checked against the manifest) and both jars (sha1 checked against the version JSON) into the version store ~/code/horizon-parity/versions/ (HORIZON_VERSIONS), never into the repository. It then unpacks the bundler's game jar (sha256), runs vanilla's data generator (--reports, in a scratch folder deleted afterwards) and reads the jar's own version.json facts. The pinned version is not downloaded: prepare 26.3 records where .local already has it.
  • diff OLD NEW: facts (protocol, world version, pack formats, Java), packets per state/direction (added, removed, renumbered), registries (entries added/removed, protocol-id shifts), blocks (added/removed, properties, state counts, default states, global state-id shifts, report-format changes), item default components (per item and per component), command tree nodes, data-pack and asset files by kind (CRC; JSON path diff for changed files), and en_us keys. Writes diff-OLD-NEW/diff.json.
  • gc: keeps the pinned version, --keep and the newest two others; deletes the rest and scratch.

Proof: 26.2 → 26.3 (prepare 9 s, diff 2 s, 136 MB for 26.2)

Minecraft 26.2 -> 26.3
  data_pack: 107.1 -> 121.0
  protocol_version: 776 -> 777
  resource_pack: 88.0 -> 97.1
  world_version: 4903 -> 5023
  packets configuration/clientbound: 20 -> 21, +1 -0, 10 renumbered
  packets play/clientbound: 141 -> 144, +3 -0, 104 renumbered
  packets play/serverbound: 69 -> 69, +1 -1, 17 renumbered
  registries: +7 -7, 28 changed
    minecraft:attribute_type: +1 -0
    minecraft:block: +90 -0, 1173 ids shifted
    minecraft:block_predicate_type: +2 -0
    minecraft:chunk_status: +1 -3, 5 ids shifted
    minecraft:command_argument_type: +5 -0, 2 ids shifted
    minecraft:custom_stat: +1 -0, 16 ids shifted
    minecraft:data_component_type: +13 -2, 69 ids shifted
    minecraft:entity_type: +3 -0, 125 ids shifted
    minecraft:environment_attribute: +3 -0, 16 ids shifted
    minecraft:int_provider_type: +1 -0, 4 ids shifted
    minecraft:item: +121 -0, 1465 ids shifted
    minecraft:loot_condition_type: +3 -3, 1 ids shifted
    minecraft:loot_function_type: +0 -1, 11 ids shifted
    minecraft:map_decoration_type: +5 -0
    minecraft:memory_module_type: +0 -1, 72 ids shifted
    minecraft:outgoing_rpc_methods: +4 -0, 12 ids shifted
    minecraft:particle_type: +3 -0, 82 ids shifted
    minecraft:recipe_serializer: +1 -0, 1 ids shifted
    minecraft:recipe_type: +1 -0
    minecraft:rule_test: +4 -0, 6 ids shifted
    minecraft:sound_event: +23 -0, 1476 ids shifted
    minecraft:worldgen/block_state_provider_type: +10 -8
    minecraft:worldgen/density_function_type: +18 -8, 25 ids shifted
    minecraft:worldgen/foliage_placer_type: +1 -0
    minecraft:worldgen/placement_modifier_type: +4 -1, 12 ids shifted
    minecraft:worldgen/structure_placement: +1 -0, 2 ids shifted
    minecraft:worldgen/tree_decorator_type: +1 -0, 5 ids shifted
    minecraft:worldgen/trunk_placer_type: +1 -0
  blocks: +90 -0, 0 changed, states 32366 -> 35723, 1173 blocks' state ids shifted
    report format: fields definition appear or disappear
  items: +121 -0, 1537 with changed default components
    minecraft:attack_animation: added on 1537
    minecraft:interact_animation: added on 1537
    minecraft:swing_animation: removed on 1537
    minecraft:cooking_fuel: added on 280
    minecraft:compostable: added on 115
    minecraft:sign_text_back: added on 24
    minecraft:sign_text_front: added on 24
    minecraft:provides_pottery_pattern: added on 23
    minecraft:block_transformer: added on 21
    minecraft:villager_food: added on 4
  command nodes: +678 -297, 2 changed
  data files: +1600 -242 ~5276
  assets files: +666 -30 ~189
  en_us keys: +436 -0 ~56

/Users/ludovicmarie/code/horizon-parity/versions/diff-26.2-26.3/diff.json

These match what Horizon's 26.3 code has. Protocol 777 and DataVersion 5023 are hard-coded. ids.rs has ADD_TRANSIENT_BLOCK = 37, POST_EFFECTS and SWING_ANIMATION, and serverbound PUNCH instead of SWING. The DataFixers 4903 → 5023 are in datafix/fixes_c.rs. The attack_animation/interact_animation components are read by the client. The full ground-truth comparison comes with the port report PR.

How tested

  • python3 -m unittest tests.test_version_port: 12 tests on synthetic reports and jars (no game data). Covers detect decisions, unsafe version ids, json_diff, packets, registries, blocks (state-id shifts, format changes), items by component, command paths, jar contents/lang/facts, and gc.
  • python3 -m unittest discover -s tests: 214 tests. The 2 errors (test_parity_runner OracleReuse, test_rust_parity report_rejects) fail the same way on plain origin/main on the Mac mini.
  • tools/check_public_tree.py passes.
  • Ran for real on the Mac mini: detect --snapshots (26.4-snapshot-4), prepare 26.3, prepare 26.2, diff 26.2 26.3.

Needs Ludovic

Nothing.

🤖 Generated with Claude Code


🔄 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/horizon-rust/horizon/pull/323 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/version-port-diff` --- ### 📝 Commits (2) - [`720e91f`](https://github.com/horizon-rust/horizon/commit/720e91fb8cec9c7af5a530102ecde8baf7d8d748) Design the version-port pipeline: detect, prepare, diff, regenerate, report - [`58ad816`](https://github.com/horizon-rust/horizon/commit/58ad81674b383d4148daf31ed41a344fe9a4afee) version_port.py: detect, prepare and diff Minecraft releases ### 📊 Changes **4 files changed** (+972 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/README.md` (+1 -0) ➕ `docs/version-ports.md` (+277 -0) ➕ `tests/test_version_port.py` (+144 -0) ➕ `tools/version_port.py` (+550 -0) </details> ### 📄 Description Stacked on #322 (the design). Slice (a) of docs/version-ports.md. ## What `tools/version_port.py`: - `detect [--snapshots]`: reads Mojang's version manifest. It reports a release or snapshot that is neither pinned nor seen before; exit 10 for a release, 11 for a snapshot. - `prepare VERSION`: downloads the version JSON (sha1 checked against the manifest) and both jars (sha1 checked against the version JSON) into the version store `~/code/horizon-parity/versions/` (`HORIZON_VERSIONS`), never into the repository. It then unpacks the bundler's game jar (sha256), runs vanilla's data generator (`--reports`, in a scratch folder deleted afterwards) and reads the jar's own `version.json` facts. The pinned version is not downloaded: `prepare 26.3` records where `.local` already has it. - `diff OLD NEW`: facts (protocol, world version, pack formats, Java), packets per state/direction (added, removed, renumbered), registries (entries added/removed, protocol-id shifts), blocks (added/removed, properties, state counts, default states, global state-id shifts, report-format changes), item default components (per item and per component), command tree nodes, data-pack and asset files by kind (CRC; JSON path diff for changed files), and en_us keys. Writes `diff-OLD-NEW/diff.json`. - `gc`: keeps the pinned version, `--keep` and the newest two others; deletes the rest and scratch. ## Proof: 26.2 → 26.3 (prepare 9 s, diff 2 s, 136 MB for 26.2) ``` Minecraft 26.2 -> 26.3 data_pack: 107.1 -> 121.0 protocol_version: 776 -> 777 resource_pack: 88.0 -> 97.1 world_version: 4903 -> 5023 packets configuration/clientbound: 20 -> 21, +1 -0, 10 renumbered packets play/clientbound: 141 -> 144, +3 -0, 104 renumbered packets play/serverbound: 69 -> 69, +1 -1, 17 renumbered registries: +7 -7, 28 changed minecraft:attribute_type: +1 -0 minecraft:block: +90 -0, 1173 ids shifted minecraft:block_predicate_type: +2 -0 minecraft:chunk_status: +1 -3, 5 ids shifted minecraft:command_argument_type: +5 -0, 2 ids shifted minecraft:custom_stat: +1 -0, 16 ids shifted minecraft:data_component_type: +13 -2, 69 ids shifted minecraft:entity_type: +3 -0, 125 ids shifted minecraft:environment_attribute: +3 -0, 16 ids shifted minecraft:int_provider_type: +1 -0, 4 ids shifted minecraft:item: +121 -0, 1465 ids shifted minecraft:loot_condition_type: +3 -3, 1 ids shifted minecraft:loot_function_type: +0 -1, 11 ids shifted minecraft:map_decoration_type: +5 -0 minecraft:memory_module_type: +0 -1, 72 ids shifted minecraft:outgoing_rpc_methods: +4 -0, 12 ids shifted minecraft:particle_type: +3 -0, 82 ids shifted minecraft:recipe_serializer: +1 -0, 1 ids shifted minecraft:recipe_type: +1 -0 minecraft:rule_test: +4 -0, 6 ids shifted minecraft:sound_event: +23 -0, 1476 ids shifted minecraft:worldgen/block_state_provider_type: +10 -8 minecraft:worldgen/density_function_type: +18 -8, 25 ids shifted minecraft:worldgen/foliage_placer_type: +1 -0 minecraft:worldgen/placement_modifier_type: +4 -1, 12 ids shifted minecraft:worldgen/structure_placement: +1 -0, 2 ids shifted minecraft:worldgen/tree_decorator_type: +1 -0, 5 ids shifted minecraft:worldgen/trunk_placer_type: +1 -0 blocks: +90 -0, 0 changed, states 32366 -> 35723, 1173 blocks' state ids shifted report format: fields definition appear or disappear items: +121 -0, 1537 with changed default components minecraft:attack_animation: added on 1537 minecraft:interact_animation: added on 1537 minecraft:swing_animation: removed on 1537 minecraft:cooking_fuel: added on 280 minecraft:compostable: added on 115 minecraft:sign_text_back: added on 24 minecraft:sign_text_front: added on 24 minecraft:provides_pottery_pattern: added on 23 minecraft:block_transformer: added on 21 minecraft:villager_food: added on 4 command nodes: +678 -297, 2 changed data files: +1600 -242 ~5276 assets files: +666 -30 ~189 en_us keys: +436 -0 ~56 /Users/ludovicmarie/code/horizon-parity/versions/diff-26.2-26.3/diff.json ``` These match what Horizon's 26.3 code has. Protocol 777 and DataVersion 5023 are hard-coded. `ids.rs` has `ADD_TRANSIENT_BLOCK` = 37, `POST_EFFECTS` and `SWING_ANIMATION`, and serverbound `PUNCH` instead of `SWING`. The DataFixers 4903 → 5023 are in `datafix/fixes_c.rs`. The `attack_animation`/`interact_animation` components are read by the client. The full ground-truth comparison comes with the port report PR. ## How tested - `python3 -m unittest tests.test_version_port`: 12 tests on synthetic reports and jars (no game data). Covers detect decisions, unsafe version ids, json_diff, packets, registries, blocks (state-id shifts, format changes), items by component, command paths, jar contents/lang/facts, and gc. - `python3 -m unittest discover -s tests`: 214 tests. The 2 errors (`test_parity_runner` OracleReuse, `test_rust_parity` report_rejects) fail the same way on plain origin/main on the Mac mini. - `tools/check_public_tree.py` passes. - Ran for real on the Mac mini: `detect --snapshots` (26.4-snapshot-4), `prepare 26.3`, `prepare 26.2`, `diff 26.2 26.3`. ## Needs Ludovic Nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:56:39 +07:00
Sign in to join this conversation.
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
horizon-rust/horizon#2491
No description provided.