File size: 4,511 Bytes
5a508d6
 
 
 
 
 
 
 
 
 
 
808786a
 
5a508d6
808786a
 
5a508d6
808786a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
---
title: ReplayProof  Agent POV  Verified Replay
emoji: 🌍
colorFrom: red
colorTo: yellow
sdk: gradio
sdk_version: 6.2.0
app_file: app.py
pinned: false
license: other
short_description: Play it. Prove it. Replay it.
thumbnail: >-
  https://cdn-uploads.huggingface.co/production/uploads/685edcb04796127b024b4805/PnZZVpPI2Q2FyyiwWyd7M.png
---
# ReplayProof__Agent_POV__Verified_Replay
**Play it. Prove it. Replay it.**

ReplayProof is a lightweight, game-like **Agent POV** simulation that records every step as a **signed, hash-chained receipt**.  
You can export a run as a ZIP bundle (receipts + optional GIF), then **verify** the run’s integrity and **replay** it deterministically on another machine.

This Space is intentionally simple and fast: CPU-friendly, no model downloads, no GPU needed.

---

## What this Space does

### ✅ Play
- Run a deterministic gridworld with an autonomous agent
- See both:
  - **World View** (top-down)
  - **Agent POV** (partial observability)

### ✅ Prove
- Every step is recorded as a receipt:
  - Canonical JSON
  - Hash chain linking each event to the previous
  - Ed25519 signatures

### ✅ Replay
- Upload a receipt bundle ZIP
- The Space re-simulates the run and checks that state hashes match
- Optionally exports a replay GIF

---

## Why this exists
Most “AI demos” are not reproducible. People share settings and results, but there’s no way to prove:
- what actually ran,
- whether it was altered,
- whether it can be reproduced.

ReplayProof turns **trust** into **verification**.

---

## Files in this repo
- `app.py` — Gradio UI (Play / Receipts / Verify / Replay)
- `replayproof_sim.py` — deterministic sim + POV + rendering
- `replayproof_receipts.py` — receipts, signing, bundle export, verify, replay
- `replayproof_media.py` — GIF export + optional watermark
- `requirements.txt`

---

## How to use (in the Space)

### 1) New Session
Pick seed + settings → click **New Session**.

### 2) Run
Use:
- **Step**
- **Run 50**
- **Run 250**

### 3) Export
In **Receipts** tab:
- toggle **Include GIF in bundle**
- toggle **Watermark final hash**
- click **Download Receipt Bundle (ZIP)**

You’ll get a ZIP containing:
- `events.jsonl`
- `root.json`
- optional `run_<session>.gif`

### 4) Verify
In **Verify** tab:
- upload the ZIP
- click **Verify Bundle**
- you’ll get a JSON report with checks + any errors

### 5) Replay
In **Replay** tab:
- upload the ZIP
- click **Replay From Bundle**
- you’ll see the reproduced end-state and (optionally) a replay GIF

---

## Receipt bundle format

### `events.jsonl`
One JSON object per step (one per line), including:
- `spec`: `replayproof-event-v0`
- `session_id`
- `ts` (UTC ISO)
- `step`
- `action`
- `seed`
- `cfg_sha256`
- `obs_sha256` (hash of what the agent “sees”)
- `state_sha256` (hash of full sim state)
- `prev_event_sha256` (hash-chain pointer)
- `event_sha256` (hash of canonical event body)
- `sig` (Ed25519 signature over `event_sha256`)
- `pubkey_id`

### `root.json`
A manifest for the run:
- `spec`: `replayproof-root-v0`
- session metadata + config
- public key (base64)
- first/final event hashes
- `final_state_sha256`
- optional `media_sha256`
- `root_sha256` + `root_sig`

---

## Determinism and verification notes
- The simulation is deterministic given:
  - seed
  - config
  - the exact sim logic
- The strongest check is **replay_state_hashes_ok**, which re-simulates and compares `state_sha256` at each step.
- Media hashes (GIF/MP4) can be environment-sensitive (encoding differences), so media verification is optional and separate from state verification.

---

## Security model (plain English)
ReplayProof proves:
- the run has not been tampered with (hash chain)
- the receipts were produced by the same signing key (Ed25519 signatures)
- the run can be reproduced to the same final state hash (replay verification)

It does NOT claim:
- the code itself is “trusted” (you can still inspect it)
- the agent is “honest” beyond what receipts prove

---

## Roadmap (sensible upgrades)
- Player-controlled mode (WASD) where actions are enforced from receipts
- Share links / seed leaderboard (“challenge this run”)
- MP4 export
- Multi-agent mode + dispute system (“show receipts” gameplay)
- Visual diff on verification failure (where exactly it diverged)

---

## Local run
```bash
pip install -r requirements.txt
python app.py


Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference