[PR #7762] [MERGED] Cosmetics: what other players wear, fetched in batches and cached #7802

Closed
opened 2026-11-03 07:24:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7762
Author: @ludovic111
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: feat/cosmetics-fetch


📝 Commits (1)

  • b72413d Cosmetics: what other players wear, fetched in batches and cached

📊 Changes

7 files changed (+678 additions, -2 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-cosmetics/Cargo.toml (+2 -1)
➕ crates/horizon-cosmetics/src/fetch.rs (+401 -0)
➕ crates/horizon-cosmetics/src/fetch_tests.rs (+254 -0)
📝 crates/horizon-cosmetics/src/lib.rs (+2 -0)
📝 crates/horizon-cosmetics/src/pose.rs (+1 -1)
📝 docs/cosmetics.md (+17 -0)

📄 Description

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

Part of #7722. Follows #7720 (the item format).

What

How a Horizon client learns what other players wear, without the frame ever waiting on the network (horizon_cosmetics::Cosmetics, crates/horizon-cosmetics/src/fetch.rs). Nothing in the game calls it yet; the next PR draws with it, behind the flag. Protocol and rules: docs/cosmetics.md, "What other players wear".

  • The frame reads a cache: cosmetics.frame() locks once; Frame::worn(uuid) answers from memory and notes the players it doesn't know yet. A worker thread of its own asks the service and wakes on a condvar when there is something to ask.
  • One batched request for the players in view: POST /v1/worn with up to 64 UUIDs, nothing else about them or the server. A player who wears nothing is left out of the answer.
  • Cached for the service's TTL, clamped to 1 min–1 h; past it the last answer stays drawn while the player is asked for again (stale while revalidate). 4096 players remembered, least recently seen dropped.
  • Item files fetched once per id+hash and kept on disk (<id>-<hash>.json); a file past the format's limits is left out and not asked for again.
  • Offline: a failed request changes nothing already known; the next one waits 15 s, doubling to 10 min. A player whose item didn't arrive is retried after 15 s.
  • Http transport: ureq, 10 s timeout, answers capped at 1 MB. Tests use an in-memory transport and a hand-driven clock.

The game protocol doesn't change: servers and vanilla clients see nothing.

Tests

8 tests, with a scripted transport and a clock the test moves (no network):

  • 100 new players: two posts of 64 and 36, each item fetched once however many wear it; once everyone is known, nothing more is asked; nothing in view asks nothing;
  • after the TTL: the old answer still drawn while the player is asked again, then the new one;
  • an outage: answers kept, no request before 15 s, then none before another 30 s, then the answer;
  • item files: kept on disk under their hash, read back by a new client without a fetch; an item past the limits is left out and not asked for again; an item that didn't arrive is asked for again after 15 s;
  • the real worker thread answers a frame.

pr_ready

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 2111ead65, 18 min 45 s)

Check Result
Scope ⚠️ 27 files, +5950 −2; 5935 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ✅ 614 passed (3 min 28 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 46 s)
tests: workspace ❌ 3544 passed, 2 failed (9 min 30 s)
doc tests ✅ 0 passed (7 s)
content root tests ✅ 24 passed (2 min 14 s)
mod API up to date ➖ native hooks untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (2 s)
launcher clippy ✅ (53 s)
launcher tests ✅ 452 passed (38 s)
Parity ➖ 382 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, anvil_turtle_egg, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute and 370 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Two rows need a word:

  • Scope counted 20 untracked perf-bench result files (benchmarks/perf/cosm-*.json) left in that worktree, not part of this PR, which is 7 files, +678 −2 (≈260 of them tests).
  • tests: workspace fails only horizon-client-render's crash::tests::a_panic_becomes_a_report and the_debug_crash_is_reported_as_vanillas, a crate this PR doesn't touch: this run used CARGO_PROFILE_DEV_DEBUG=0 to fit the Mac mini's disk, and those tests look for crash.rs in backtrace frames, which needs line tables. The next PR's run (with line-tables-only) runs them.

🤖 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/7762 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/cosmetics-fetch` --- ### 📝 Commits (1) - [`b72413d`](https://github.com/horizon-rust/horizon/commit/b72413d1de320d5c9ffba57dc6bafe6f739201d9) Cosmetics: what other players wear, fetched in batches and cached ### 📊 Changes **7 files changed** (+678 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-cosmetics/Cargo.toml` (+2 -1) ➕ `crates/horizon-cosmetics/src/fetch.rs` (+401 -0) ➕ `crates/horizon-cosmetics/src/fetch_tests.rs` (+254 -0) 📝 `crates/horizon-cosmetics/src/lib.rs` (+2 -0) 📝 `crates/horizon-cosmetics/src/pose.rs` (+1 -1) 📝 `docs/cosmetics.md` (+17 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of #7722. Follows #7720 (the item format). ## What How a Horizon client learns what other players wear, without the frame ever waiting on the network (`horizon_cosmetics::Cosmetics`, `crates/horizon-cosmetics/src/fetch.rs`). Nothing in the game calls it yet; the next PR draws with it, behind the flag. Protocol and rules: `docs/cosmetics.md`, "What other players wear". - **The frame reads a cache**: `cosmetics.frame()` locks once; `Frame::worn(uuid)` answers from memory and notes the players it doesn't know yet. A worker thread of its own asks the service and wakes on a condvar when there is something to ask. - **One batched request for the players in view**: `POST /v1/worn` with up to 64 UUIDs, nothing else about them or the server. A player who wears nothing is left out of the answer. - **Cached for the service's TTL**, clamped to 1 min–1 h; past it the last answer stays drawn while the player is asked for again (stale while revalidate). 4096 players remembered, least recently seen dropped. - **Item files** fetched once per `id`+`hash` and kept on disk (`<id>-<hash>.json`); a file past the format's limits is left out and not asked for again. - **Offline**: a failed request changes nothing already known; the next one waits 15 s, doubling to 10 min. A player whose item didn't arrive is retried after 15 s. - `Http` transport: ureq, 10 s timeout, answers capped at 1 MB. Tests use an in-memory transport and a hand-driven clock. The game protocol doesn't change: servers and vanilla clients see nothing. ## Tests 8 tests, with a scripted transport and a clock the test moves (no network): - 100 new players: two posts of 64 and 36, each item fetched once however many wear it; once everyone is known, nothing more is asked; nothing in view asks nothing; - after the TTL: the old answer still drawn while the player is asked again, then the new one; - an outage: answers kept, no request before 15 s, then none before another 30 s, then the answer; - item files: kept on disk under their hash, read back by a new client without a fetch; an item past the limits is left out and not asked for again; an item that didn't arrive is asked for again after 15 s; - the real worker thread answers a frame. ## pr_ready **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 2111ead65, 18 min 45 s) | Check | Result | | --- | --- | | Scope | ⚠️ 27 files, +5950 −2; 5935 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ✅ 614 passed (3 min 28 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 46 s) | | tests: workspace | ❌ 3544 passed, 2 failed (9 min 30 s) | | doc tests | ✅ 0 passed (7 s) | | content root tests | ✅ 24 passed (2 min 14 s) | | mod API up to date | ➖ native hooks untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (2 s) | | launcher clippy | ✅ (53 s) | | launcher tests | ✅ 452 passed (38 s) | | Parity | ➖ 382 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, anvil_turtle_egg, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute and 370 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Two rows need a word: - **Scope** counted 20 untracked perf-bench result files (`benchmarks/perf/cosm-*.json`) left in that worktree, not part of this PR, which is 7 files, +678 −2 (≈260 of them tests). - **tests: workspace** fails only `horizon-client-render`'s `crash::tests::a_panic_becomes_a_report` and `the_debug_crash_is_reported_as_vanillas`, a crate this PR doesn't touch: this run used `CARGO_PROFILE_DEV_DEBUG=0` to fit the Mac mini's disk, and those tests look for `crash.rs` in backtrace frames, which needs line tables. The next PR's run (with `line-tables-only`) runs them. 🤖 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 07:24:23 +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#7802
No description provided.