[PR #6712] [MERGED] Agent control: input provenance and replayable repro recordings #7049

Closed
opened 2026-11-03 06:32:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/agent-input-provenance-repro


📝 Commits (5)

  • f1cf4aa Tell input apart by who caused it, and record repros for bug reports
  • 39f2aa3 Review: scrub repro bundles, gate the recording keys, replay only input
  • c2fb2e7 Merge main into the repro branch; the AI Agent page's lines moved to status_lines
  • 1d938d5 Trace input only while something can read it
  • 7ba8331 Merge main into #6712

📊 Changes

24 files changed (+3160 additions, -34 deletions)

View changed files

📝 crates/horizon-client-render/src/extras.rs (+18 -2)
📝 crates/horizon-client-render/src/options_ui.rs (+39 -0)
📝 crates/horizon-client/assets/horizon/lang/en_us.json (+16 -1)
📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+20 -0)
📝 crates/horizon-client/src/bin/horizon-ctl/main.rs (+19 -6)
📝 crates/horizon-client/src/debug_keys.rs (+17 -0)
📝 crates/horizon-client/src/game.rs (+35 -3)
📝 crates/horizon-client/src/game/agent.rs (+21 -5)
📝 crates/horizon-client/src/game/agent_settings.rs (+6 -2)
📝 crates/horizon-client/src/game/control.rs (+35 -2)
📝 crates/horizon-client/src/game/debug_keys.rs (+12 -0)
📝 crates/horizon-client/src/game/events.rs (+10 -1)
➕ crates/horizon-client/src/game/input_trace.rs (+675 -0)
📝 crates/horizon-client/src/game/options.rs (+3 -0)
📝 crates/horizon-client/src/game/pad.rs (+38 -0)
📝 crates/horizon-client/src/game/pad_menu.rs (+1 -1)
📝 crates/horizon-client/src/game/remote.rs (+1 -0)
➕ crates/horizon-client/src/game/repro.rs (+1972 -0)
📝 crates/horizon-client/src/game/startup_menu.rs (+5 -1)
📝 crates/horizon-client/src/title/world_management.rs (+23 -6)

...and 4 more files

📄 Description

🤖 Opened by JustKarkat's AI agent (ZCode on deepseek-v4.1-flash), not by JustKarkat personally.

What

Adds input provenance and repro recordings to Horizon's agent/control surface:

  • Origins. Every input event carries user (the window's own keyboard, mouse or pad), agent (the control socket) or game (input the game made up). state and status expose an input section; input-log returns the recent events; a person's input during an agent's run logs once and pushes a user-input event, so wait-for event user-input catches an intrusion.
  • Recordings. record-start/stop/status/list write inputs.jsonl, tick-stamped state.jsonl, events.jsonl, session.json and — single player — a copy of the world. repro-export zips that with logs/latest.log, the newest crash report, a fresh status and a README.
  • Replay. record-replay loads the world copy, restores the recorded player position/rotation/velocity, and feeds keys, mouse, wheel, look, pad buttons and control lines back at their ticks (best effort).
  • Players. F3+R starts/stops a recording (stop auto-exports and shows the path), F3+E exports, and Settings → AI Agent has both buttons plus a live recording line — no horizon-ctl needed.

All of these come from the one command table, so horizon-ctl and MCP get them together; the pending shared horizon-mcp crate will serve them too without changes.

Why

In #6386 two identical "Saving and pausing game..." lines appeared and we could not tell whether a person or the agent pressed Escape: a repro result stayed ambiguous until the user answered. Provenance removes that guesswork, and a recording gives a bug report a direct, replayable artefact instead of a prose description.

Verification

pr_ready (tools/pr_ready.py --quick on cachy-josh-pc, against origin/main at 20c6194da, 1 min 24 s)

Check Result
Scope ⚠️ 21 files, +2645 −165; 2745 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 598 passed (30 s)
rustfmt ✅ (6 s)
clippy ✅
tests: horizon-client, horizon-client-input, horizon-client-lib, horizon-client-render ✅ 2994 passed (43 s)
doc tests ✅ 0 passed (4 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • tools/agent_control_e2e.py --scenario repro passes in both CLI and MCP modes on this branch: record → walk → stop → export (zip entries checked) → replay, ending 0.0 and 0.87 blocks from the recorded state.

Notes, and an explicit invitation

This is deliberately a foundation, and it is over the ~500-line guideline (mostly the new input_trace.rs and repro.rs and their tests). Another agent is explicitly invited to expand, split or restructure it. These are the seams I would use:

  • Replay fidelity is best effort: same build and machine, not frame-perfect, and a server recording only replays with --in-place. A follow-up could compare against state.jsonl and report divergence automatically.
  • Agent attribution is one agent class. The control socket could carry a connection/tool id so two agents on one game are distinguishable.
  • The provenance ring keeps 512 events; a streaming subscribe (already under "Later" in docs/agent-control.md) would suit long runs better.
  • repro-export writes a zip locally and stops there; the launcher's bug-report flow could offer to attach it with the same consent story as logs.
  • If a split is wanted: input_trace.rs (origins + ring) and repro.rs (recording/bundle/replay) are independent apart from the note_input hook; the recording half could land first and replay later.

Nothing is uploaded automatically and the recording contains no network traffic. Only Horizon's own code and documented vanilla behaviour were used.

🤖 Generated with ZCode (deepseek-v4.1-flash)


🔄 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/6712 **Author:** [@JustKarkat](https://github.com/JustKarkat) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/agent-input-provenance-repro` --- ### 📝 Commits (5) - [`f1cf4aa`](https://github.com/horizon-rust/horizon/commit/f1cf4aa2bc85939e56c6a7342f44b21ce8fe335d) Tell input apart by who caused it, and record repros for bug reports - [`39f2aa3`](https://github.com/horizon-rust/horizon/commit/39f2aa3e50538a8ab7cb4cb65093dd772983269e) Review: scrub repro bundles, gate the recording keys, replay only input - [`c2fb2e7`](https://github.com/horizon-rust/horizon/commit/c2fb2e7d78480ce111991daf045b52a33290d3db) Merge main into the repro branch; the AI Agent page's lines moved to status_lines - [`1d938d5`](https://github.com/horizon-rust/horizon/commit/1d938d5d06c11628e59a506283e24e98c5736c8a) Trace input only while something can read it - [`7ba8331`](https://github.com/horizon-rust/horizon/commit/7ba83315a858e1e60429da541012d73f7ccb94f0) Merge main into #6712 ### 📊 Changes **24 files changed** (+3160 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/extras.rs` (+18 -2) 📝 `crates/horizon-client-render/src/options_ui.rs` (+39 -0) 📝 `crates/horizon-client/assets/horizon/lang/en_us.json` (+16 -1) 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+20 -0) 📝 `crates/horizon-client/src/bin/horizon-ctl/main.rs` (+19 -6) 📝 `crates/horizon-client/src/debug_keys.rs` (+17 -0) 📝 `crates/horizon-client/src/game.rs` (+35 -3) 📝 `crates/horizon-client/src/game/agent.rs` (+21 -5) 📝 `crates/horizon-client/src/game/agent_settings.rs` (+6 -2) 📝 `crates/horizon-client/src/game/control.rs` (+35 -2) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+12 -0) 📝 `crates/horizon-client/src/game/events.rs` (+10 -1) ➕ `crates/horizon-client/src/game/input_trace.rs` (+675 -0) 📝 `crates/horizon-client/src/game/options.rs` (+3 -0) 📝 `crates/horizon-client/src/game/pad.rs` (+38 -0) 📝 `crates/horizon-client/src/game/pad_menu.rs` (+1 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -0) ➕ `crates/horizon-client/src/game/repro.rs` (+1972 -0) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+5 -1) 📝 `crates/horizon-client/src/title/world_management.rs` (+23 -6) _...and 4 more files_ </details> ### 📄 Description > 🤖 Opened by JustKarkat's AI agent (ZCode on deepseek-v4.1-flash), not by JustKarkat personally. ## What Adds input provenance and repro recordings to Horizon's agent/control surface: - **Origins.** Every input event carries `user` (the window's own keyboard, mouse or pad), `agent` (the control socket) or `game` (input the game made up). `state` and `status` expose an `input` section; `input-log` returns the recent events; a person's input during an agent's run logs once and pushes a `user-input` event, so `wait-for event user-input` catches an intrusion. - **Recordings.** `record-start/stop/status/list` write `inputs.jsonl`, tick-stamped `state.jsonl`, `events.jsonl`, `session.json` and — single player — a copy of the world. `repro-export` zips that with `logs/latest.log`, the newest crash report, a fresh status and a README. - **Replay.** `record-replay` loads the world copy, restores the recorded player position/rotation/velocity, and feeds keys, mouse, wheel, look, pad buttons and control lines back at their ticks (best effort). - **Players.** F3+R starts/stops a recording (stop auto-exports and shows the path), F3+E exports, and Settings → AI Agent has both buttons plus a live recording line — no `horizon-ctl` needed. All of these come from the one command table, so `horizon-ctl` and MCP get them together; the pending shared `horizon-mcp` crate will serve them too without changes. ## Why In #6386 two identical "Saving and pausing game..." lines appeared and we could not tell whether a person or the agent pressed Escape: a repro result stayed ambiguous until the user answered. Provenance removes that guesswork, and a recording gives a bug report a direct, replayable artefact instead of a prose description. ## Verification **pr_ready** (`tools/pr_ready.py --quick` on cachy-josh-pc, against origin/main at 20c6194da, 1 min 24 s) | Check | Result | | --- | --- | | Scope | ⚠️ 21 files, +2645 −165; 2745 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 598 passed (30 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ | | tests: horizon-client, horizon-client-input, horizon-client-lib, horizon-client-render | ✅ 2994 passed (43 s) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - **`tools/agent_control_e2e.py --scenario repro`** passes in both CLI and MCP modes on this branch: record → walk → stop → export (zip entries checked) → replay, ending **0.0** and **0.87 blocks** from the recorded state. ## Notes, and an explicit invitation This is deliberately a foundation, and it is over the ~500-line guideline (mostly the new `input_trace.rs` and `repro.rs` and their tests). **Another agent is explicitly invited to expand, split or restructure it.** These are the seams I would use: - **Replay fidelity** is best effort: same build and machine, not frame-perfect, and a server recording only replays with `--in-place`. A follow-up could compare against `state.jsonl` and report divergence automatically. - **Agent attribution** is one `agent` class. The control socket could carry a connection/tool id so two agents on one game are distinguishable. - **The provenance ring** keeps 512 events; a streaming `subscribe` (already under "Later" in `docs/agent-control.md`) would suit long runs better. - **`repro-export`** writes a zip locally and stops there; the launcher's bug-report flow could offer to attach it with the same consent story as logs. - **If a split is wanted:** `input_trace.rs` (origins + ring) and `repro.rs` (recording/bundle/replay) are independent apart from the `note_input` hook; the recording half could land first and replay later. Nothing is uploaded automatically and the recording contains no network traffic. Only Horizon's own code and documented vanilla behaviour were used. 🤖 Generated with ZCode (deepseek-v4.1-flash) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:32:50 +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#7049
No description provided.