[PR #248] [MERGED] Opt-in data collection (1/5): consent, payloads, outbox and a gated uploader #2436

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

📋 Pull Request Information

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

Base: main ← Head: feat/telemetry-consent


📝 Commits (1)

  • 4313815 Opt-in data collection (1/5): consent, payloads, outbox and a gated uploader

📊 Changes

14 files changed (+2105 additions, -1 deletions)

View changed files

📝 Cargo.lock (+27 -0)
📝 Cargo.toml (+1 -1)
➕ crates/horizon-telemetry/Cargo.toml (+28 -0)
➕ crates/horizon-telemetry/src/batch.rs (+198 -0)
➕ crates/horizon-telemetry/src/consent.rs (+191 -0)
➕ crates/horizon-telemetry/src/lib.rs (+97 -0)
➕ crates/horizon-telemetry/src/outbox.rs (+236 -0)
➕ crates/horizon-telemetry/src/payload.rs (+421 -0)
➕ crates/horizon-telemetry/src/scrub.rs (+354 -0)
➕ crates/horizon-telemetry/src/system.rs (+124 -0)
➕ crates/horizon-telemetry/src/upload.rs (+141 -0)
➕ crates/horizon-telemetry/tests/consent_gating.rs (+231 -0)
📝 docs/README.md (+1 -0)
➕ docs/telemetry.md (+55 -0)

📄 Description

What

First of five PRs for opt-in data collection (briefs/telemetry.md). This one adds crates/horizon-telemetry, the crate the launcher, the game and the ingest server share. Nothing uses it yet, and no server is configured (DEFAULT_ENDPOINT = None), so nothing is sent.

  • Consent (telemetry/consent.json in the game folder): four switches (performance, crashes, bugs, benchmarks), all off until the player answers.
    • CONSENT_VERSION makes the launcher ask again when what is collected changes. Until the player answers again, nothing is kept or sent.
    • The file records the answer's time.
    • A random 128-bit install ID is made at the first yes, kept for "Delete my data", and replaced on reset.
  • Payloads (SCHEMA = 1):
    • perf summaries: p50/p95/p99/max plus 14 frame-time buckets from a fixed 20 KB Timings recorder. Raw frame times are never kept. An item is under 1 KiB.
    • crash reports and bug reports
    • benchmark reports carried unchanged, as perf-2's docs/benchmark-report.md defines them (that doc isn't on main or any branch yet; the report is accepted as any JSON object up to 128 KiB, with its own schema field, so no second format exists).
    • Each kind has a size cap and a daily cap.
  • Scrubber: user folders in paths (/Users/<user>/…, C:\Users\<user>\…, also JSON-escaped), the user name, e-mail and IP (v4/v6) addresses, UUIDs, and terms the caller knows are private (world names, server addresses, account names).
  • Outbox: one file per item. Only allowed kinds get in. It holds at most 200 items or 2 MiB, and the oldest go first.
  • Wire format: zstd batches (pure-Rust ruzstd) of up to 64 items / 1 MiB. decode bounds inflation, which stops a zip bomb. A day's perf summaries are under 2 KB on the wire.
  • Uploader (feature upload, default; the server builds without it):
    • It reads the consent again and deletes anything no longer allowed before it connects.
    • After a failure it waits 1 min, doubling up to a day. It sends at most 8 batches a day, and drops a batch the server refuses with a 4xx.
  • docs/telemetry.md lists every field.

Why

Ludovic wants players asked whether they're OK with sending performance, crash and bug data, and the data stored efficiently. This crate is what the launcher and game PRs build on.

How tested

tests/consent_gating.rs: a local mock HTTP server counts every connection.

  • Zero connections when the consent is missing, outdated, or withdrawn. Withdrawn items are deleted, not kept.
  • Allowed kinds leave in exactly one zstd batch that decodes.
  • A 503 backs off with no second try.
  • A 400 drops the batch.
  • Preview sends nothing, and DELETE /v1/installs/<id> names the install.

Unit tests cover the consent file, Timings percentiles and buckets, size caps, the scrubber's hits and non-hits (Rust paths, versions, commit hashes), outbox caps and eviction, batch round trips, and the zip bomb.

The pr_ready block below was run before three small additions: System::detect, outbox::retain_allowed, and upload becoming an optional default feature. After them: cargo test -p horizon-telemetry passes with and without default features (25 unit + 7 gating), and clippy -D warnings is clean both ways.

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at 8df59b96a, 6 min 51 s)

Check Result
Scope ⚠️ 13 files, +1963 −1; 1677 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅ (1 s)
Python tests ➖ no Python change
rustfmt ✅ (5 s)
clippy ✅ (1 min 25 s)
tests: workspace ✅ 989 passed (5 min 20 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 300 affected, to run in CI (no vanilla data here): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 288 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: the root Cargo.toml gains a workspace member, so CI lists every harness. No game code changes.

Needs Ludovic

Nothing in this PR. The hosting choice (with its cost) comes with the server PR. Merge order: this, then the launcher, game, server and privacy-page PRs.

🤖 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/248 **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/telemetry-consent` --- ### 📝 Commits (1) - [`4313815`](https://github.com/horizon-rust/horizon/commit/43138159b2fb9576e4bb71ef3fda9cf93fce5ce3) Opt-in data collection (1/5): consent, payloads, outbox and a gated uploader ### 📊 Changes **14 files changed** (+2105 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+27 -0) 📝 `Cargo.toml` (+1 -1) ➕ `crates/horizon-telemetry/Cargo.toml` (+28 -0) ➕ `crates/horizon-telemetry/src/batch.rs` (+198 -0) ➕ `crates/horizon-telemetry/src/consent.rs` (+191 -0) ➕ `crates/horizon-telemetry/src/lib.rs` (+97 -0) ➕ `crates/horizon-telemetry/src/outbox.rs` (+236 -0) ➕ `crates/horizon-telemetry/src/payload.rs` (+421 -0) ➕ `crates/horizon-telemetry/src/scrub.rs` (+354 -0) ➕ `crates/horizon-telemetry/src/system.rs` (+124 -0) ➕ `crates/horizon-telemetry/src/upload.rs` (+141 -0) ➕ `crates/horizon-telemetry/tests/consent_gating.rs` (+231 -0) 📝 `docs/README.md` (+1 -0) ➕ `docs/telemetry.md` (+55 -0) </details> ### 📄 Description ## What First of five PRs for opt-in data collection (`briefs/telemetry.md`). This one adds `crates/horizon-telemetry`, the crate the launcher, the game and the ingest server share. Nothing uses it yet, and no server is configured (`DEFAULT_ENDPOINT = None`), so nothing is sent. - **Consent** (`telemetry/consent.json` in the game folder): four switches (performance, crashes, bugs, benchmarks), all off until the player answers. - `CONSENT_VERSION` makes the launcher ask again when what is collected changes. Until the player answers again, nothing is kept or sent. - The file records the answer's time. - A random 128-bit install ID is made at the first yes, kept for "Delete my data", and replaced on reset. - **Payloads** (`SCHEMA` = 1): - perf summaries: p50/p95/p99/max plus 14 frame-time buckets from a fixed 20 KB `Timings` recorder. Raw frame times are never kept. An item is under 1 KiB. - crash reports and bug reports - **benchmark reports carried unchanged**, as perf-2's `docs/benchmark-report.md` defines them (that doc isn't on main or any branch yet; the report is accepted as any JSON object up to 128 KiB, with its own schema field, so no second format exists). - Each kind has a size cap and a daily cap. - **Scrubber**: user folders in paths (`/Users/<user>/…`, `C:\Users\<user>\…`, also JSON-escaped), the user name, e-mail and IP (v4/v6) addresses, UUIDs, and terms the caller knows are private (world names, server addresses, account names). - **Outbox**: one file per item. Only allowed kinds get in. It holds at most 200 items or 2 MiB, and the oldest go first. - **Wire format**: zstd batches (pure-Rust `ruzstd`) of up to 64 items / 1 MiB. `decode` bounds inflation, which stops a zip bomb. A day's perf summaries are under 2 KB on the wire. - **Uploader** (feature `upload`, default; the server builds without it): - It reads the consent again and deletes anything no longer allowed **before** it connects. - After a failure it waits 1 min, doubling up to a day. It sends at most 8 batches a day, and drops a batch the server refuses with a 4xx. - `docs/telemetry.md` lists every field. ## Why Ludovic wants players asked whether they're OK with sending performance, crash and bug data, and the data stored efficiently. This crate is what the launcher and game PRs build on. ## How tested `tests/consent_gating.rs`: a local mock HTTP server counts every connection. - Zero connections when the consent is missing, outdated, or withdrawn. Withdrawn items are deleted, not kept. - Allowed kinds leave in exactly one zstd batch that decodes. - A 503 backs off with no second try. - A 400 drops the batch. - Preview sends nothing, and `DELETE /v1/installs/<id>` names the install. Unit tests cover the consent file, `Timings` percentiles and buckets, size caps, the scrubber's hits and non-hits (Rust paths, versions, commit hashes), outbox caps and eviction, batch round trips, and the zip bomb. The pr_ready block below was run before three small additions: `System::detect`, `outbox::retain_allowed`, and `upload` becoming an optional default feature. After them: `cargo test -p horizon-telemetry` passes with and without default features (25 unit + 7 gating), and clippy `-D warnings` is clean both ways. **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at 8df59b96a, 6 min 51 s) | Check | Result | | --- | --- | | Scope | ⚠️ 13 files, +1963 −1; 1677 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ (1 s) | | Python tests | ➖ no Python change | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 25 s) | | tests: workspace | ✅ 989 passed (5 min 20 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 300 affected, to run in CI (no vanilla data here): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 288 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: the root `Cargo.toml` gains a workspace member, so CI lists every harness. No game code changes. ## Needs Ludovic Nothing in this PR. The hosting choice (with its cost) comes with the server PR. Merge order: this, then the launcher, game, server and privacy-page PRs. 🤖 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:08 +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#2436
No description provided.