[PR #4434] [MERGED] Mod registry: a mod may turn native once; a retry takes up its own branch #5619

Closed
opened 2026-11-03 05:13:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/mod-registry-kind-and-retry


📝 Commits (5)

  • 756e03f Mod registry: a mod may turn native once; a retry takes up its own branch
  • 1dde732 Mod registry: a retry proves the branch is its own with a signed tag
  • fae347c Merge main into fix/mod-registry-kind-and-retry
  • ed9c111 Separate submission tags from session cookies
  • 995c7aa Merge remote-tracking branch 'origin/main' into fix4434

📊 Changes

6 files changed (+403 additions, -15 deletions)

View changed files

📝 crates/horizon-mod-registry/Cargo.lock (+1 -0)
📝 crates/horizon-mod-registry/Cargo.toml (+2 -0)
📝 crates/horizon-mod-registry/src/github.rs (+47 -0)
📝 crates/horizon-mod-registry/src/lib.rs (+112 -10)
📝 crates/horizon-mod-registry/tests/submit.rs (+237 -4)
📝 docs/api/mod-index.md (+4 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Two bugs in the submission form's publish() (crates/horizon-mod-registry), behind playhorizon.dev/mods/submit.

1. A mod can turn native once

The form refused every kind change, so blockscope (kind mod) couldn't publish its .hnmod 0.3.0 ("blockscope is a mod").

The rule is the registry's own: horizon_mods::index::registry::review (e2f3d1a85, "a WebAssembly mod's entry may turn native once") allows exactly mod → native-mod and errors on any other kind change, and file_kind keeps the old .hmod versions checked as .hmods. horizon-mods' check.yml runs that review through cargo horizon-mod at HORIZON_REV 6f8c7a0, which already contains the rule. So such an entry passes its CI. docs/native-mods.md says the same: "may turn native-mod once (never back)".

  • publish() now allows mod → native-mod, still only for an owner (that check comes first), and sets the entry's kind. The old .hmod versions stay in the entry.
  • Every other kind change, including native-mod → mod, is a 400 that names the rule: "X is a native-mod, not a mod: a project's kind never changes (only a mod may turn native-mod, once)".
  • The pull request's table says "update: turns native, its .hmod versions stay published".

2. A retry after a timeout takes up its own branch

If GitHub timed out after submit/<id>-<version> was created (while writing the entry or opening the PR), the retry got 409 "already submitted" with no PR. Now, when the branch already exists:

  • an open PR from it → still 409, and the message gives the PR's address;
  • otherwise the branch's own commits (compare main...branch) decide. Each form commit carries a Submission: <tag> trailer: an HMAC of the branch and the login under the service's key, so only the service can write it. A commit's text or author can be set by anyone who writes to the repository. If the branch holds no commit of its own, or exactly one carrying this account's tag, it is reset to main (PATCH git/refs, force) and the submission writes the entry and opens the PR as usual. Anything else → still 409 ("already submitted by someone else"), with no reset;
  • a closed, unmerged PR doesn't hold the version.

New GitHub calls: open_pull, commits, reset. docs/api/mod-index.md has a sentence on each rule.

Tests (the fake GitHub in tests/submit.rs)

The fake now answers GET /pulls?head=&state=open, GET /compare/main...<branch> and PATCH /git/refs/heads/<branch>. It can also time out on POST /pulls without opening the PR.

  • a_mod_turns_native_once: a non-owner gets 403. The owner's .hnmod 0.2.0 → OK: the entry is native-mod with versions [coords_hud-0.2.0.hnmod, coords_hud-0.1.0.hmod], the asset is <sha>.hnmod, and the body says it turns native. Then a .hmod against the native entry → 400 with the message above.
  • a_retry_takes_up_its_own_branch: a branch whose commit copies alice's exact words with a forged Submission: tag → 409, nothing reset (the review's regression). A real timeout on opening the PR → 504, with the branch and commit left behind. The retry → OK: the branch is reset, the new commit carries the tag, and PR #1 is opened. Another try → 409 with the PR's address. Once that PR is closed → OK, PR #2. A branch with no commit yet → OK.
  • a_submission_becomes_a_pull_request now also checks that the 409 names the open PR.

cargo fmt --check, cargo clippy --all-targets -D warnings and cargo test inside the crate's own workspace: 7 + 2 tests pass.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at bb6985ecb, 2 min 17 s)

Check Result
Scope ✅ 6 files, +346 −15
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ✅ 480 passed (1 min 7 s)
rustfmt ✅ (5 s)
clippy ✅ (2 s)
tests: workspace ✅ 2709 passed (56 s)
doc tests ✅ 0 passed (5 s)
content root tests ✅ 5 passed
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 1 affected, to run in CI (--quick): lan_integration
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Merging redeploys the registry (Railway watches crates/horizon-mod-registry/**). No write to the real horizon-rust/horizon-mods was made: only the fake.

🤖 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/4434 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mod-registry-kind-and-retry` --- ### 📝 Commits (5) - [`756e03f`](https://github.com/horizon-rust/horizon/commit/756e03fb81fa17941824c6ef0718311ec5c24a93) Mod registry: a mod may turn native once; a retry takes up its own branch - [`1dde732`](https://github.com/horizon-rust/horizon/commit/1dde7323255514f996175a32bf44294ff2ce2285) Mod registry: a retry proves the branch is its own with a signed tag - [`fae347c`](https://github.com/horizon-rust/horizon/commit/fae347ca67a26cc4c5f878fa57e872257c9686a1) Merge main into fix/mod-registry-kind-and-retry - [`ed9c111`](https://github.com/horizon-rust/horizon/commit/ed9c111323e9d4971bb24031275856b09e633b87) Separate submission tags from session cookies - [`995c7aa`](https://github.com/horizon-rust/horizon/commit/995c7aa81752635464c35310bdaa788acd5db934) Merge remote-tracking branch 'origin/main' into fix4434 ### 📊 Changes **6 files changed** (+403 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-mod-registry/Cargo.lock` (+1 -0) 📝 `crates/horizon-mod-registry/Cargo.toml` (+2 -0) 📝 `crates/horizon-mod-registry/src/github.rs` (+47 -0) 📝 `crates/horizon-mod-registry/src/lib.rs` (+112 -10) 📝 `crates/horizon-mod-registry/tests/submit.rs` (+237 -4) 📝 `docs/api/mod-index.md` (+4 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Two bugs in the submission form's `publish()` (`crates/horizon-mod-registry`), behind playhorizon.dev/mods/submit. ## 1. A mod can turn native once The form refused every kind change, so `blockscope` (kind `mod`) couldn't publish its `.hnmod` 0.3.0 ("blockscope is a mod"). The rule is the registry's own: `horizon_mods::index::registry::review` (e2f3d1a85, "a WebAssembly mod's entry may turn native once") allows exactly `mod` → `native-mod` and errors on any other kind change, and `file_kind` keeps the old `.hmod` versions checked as `.hmod`s. horizon-mods' `check.yml` runs that review through `cargo horizon-mod` at `HORIZON_REV` 6f8c7a0, which already contains the rule. So such an entry passes its CI. docs/native-mods.md says the same: "may turn `native-mod` once (never back)". - `publish()` now allows `mod` → `native-mod`, still only for an owner (that check comes first), and sets the entry's kind. The old `.hmod` versions stay in the entry. - Every other kind change, including `native-mod` → `mod`, is a 400 that names the rule: "X is a native-mod, not a mod: a project's kind never changes (only a mod may turn native-mod, once)". - The pull request's table says "update: turns native, its `.hmod` versions stay published". ## 2. A retry after a timeout takes up its own branch If GitHub timed out after `submit/<id>-<version>` was created (while writing the entry or opening the PR), the retry got 409 "already submitted" with no PR. Now, when the branch already exists: - an **open PR** from it → still 409, and the message gives the PR's address; - otherwise the branch's **own commits** (`compare main...branch`) decide. Each form commit carries a `Submission: <tag>` trailer: an HMAC of the branch and the login under the service's key, so only the service can write it. A commit's text or author can be set by anyone who writes to the repository. If the branch holds no commit of its own, or exactly one carrying this account's tag, it is reset to main (`PATCH git/refs`, force) and the submission writes the entry and opens the PR as usual. Anything else → still 409 ("already submitted by someone else"), with no reset; - a closed, unmerged PR doesn't hold the version. New `GitHub` calls: `open_pull`, `commits`, `reset`. docs/api/mod-index.md has a sentence on each rule. ## Tests (the fake GitHub in `tests/submit.rs`) The fake now answers `GET /pulls?head=&state=open`, `GET /compare/main...<branch>` and `PATCH /git/refs/heads/<branch>`. It can also time out on `POST /pulls` without opening the PR. - `a_mod_turns_native_once`: a non-owner gets 403. The owner's `.hnmod` 0.2.0 → OK: the entry is `native-mod` with versions `[coords_hud-0.2.0.hnmod, coords_hud-0.1.0.hmod]`, the asset is `<sha>.hnmod`, and the body says it turns native. Then a `.hmod` against the native entry → 400 with the message above. - `a_retry_takes_up_its_own_branch`: a branch whose commit copies alice's exact words with a forged `Submission:` tag → 409, nothing reset (the review's regression). A real timeout on opening the PR → 504, with the branch and commit left behind. The retry → OK: the branch is reset, the new commit carries the tag, and PR #1 is opened. Another try → 409 with the PR's address. Once that PR is closed → OK, PR #2. A branch with no commit yet → OK. - `a_submission_becomes_a_pull_request` now also checks that the 409 names the open PR. `cargo fmt --check`, `cargo clippy --all-targets -D warnings` and `cargo test` inside the crate's own workspace: 7 + 2 tests pass. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at bb6985ecb, 2 min 17 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +346 −15 | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 7 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (2 s) | | tests: workspace | ✅ 2709 passed (56 s) | | doc tests | ✅ 0 passed (5 s) | | content root tests | ✅ 5 passed | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 1 affected, to run in CI (--quick): lan_integration | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Merging redeploys the registry (Railway watches `crates/horizon-mod-registry/**`). No write to the real horizon-rust/horizon-mods was made: only the fake. 🤖 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-03 05:13:49 +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#5619
No description provided.