irregular6612 commited on
Commit
efc9c82
·
1 Parent(s): e049ecd

docs(web): handoff — interactive color-grid web play shipped

Browse files
Files changed (1) hide show
  1. HANDOFF.md +17 -2
HANDOFF.md CHANGED
@@ -5,7 +5,7 @@
5
  > the per-CP plan in `docs/superpowers/plans/` + this file.
6
 
7
  **Last updated:** 2026-06-02 — CP6 complete (difficulty layouts + category-specific eval +
8
- human-baseline `compare` harness; offline, headless).
9
 
10
  ## Done (CP0–CP3)
11
 
@@ -126,11 +126,22 @@ Executed task-by-task via subagent-driven-development (3-gate: implement → spe
126
  - **Invariant acceptance:** all four bands print `optimal=up habit=left` with distinct grids `(8,8)/(10,10)/(12,12)/(12,12)` — `optimal != habit` everywhere.
127
  - **Note:** the `fake:demo` provider plays a fixed non-optimal action (so `motive_reading_accuracy=0`); the smoke validates the deterministic pipeline + metric surfacing, not agent skill.
128
 
 
 
 
 
 
 
 
 
 
 
 
129
  ## How to run
130
 
131
  - Environment: `python` is **not** on PATH; a gitignored venv lives at `.venv` (Python 3.12,
132
  pydantic v2 / numpy / pyyaml / pytest **+ matplotlib** — the latter now required by the viz/png
133
- tests). **Full suite:** `.venv/bin/python -m pytest -q` → **103 passed**, no network, no display.
134
  Provider SDKs are NOT installed in `.venv` (keeps the offline invariant structural); matplotlib runs
135
  **Agg-only** (headless), so it does not break the offline/no-display invariant. Recreate `.venv` with:
136
  `uv venv --python 3.12 .venv && uv pip install --python .venv/bin/python "pydantic>=2" "numpy>=1.26" "pyyaml>=6" "pytest>=8" "matplotlib>=3.8"`
@@ -138,6 +149,10 @@ Executed task-by-task via subagent-driven-development (3-gate: implement → spe
138
  predator_evade --seed 42 --play-turns 6 --out runs/h.jsonl` (live view is the same ASCII the LLM sees).
139
  - Visual replay: `.venv/bin/python -m proteus replay runs/h.jsonl --visual --fps 0` (truecolor terminal)
140
  or `--png runs/frames` (per-frame PNGs). Plain `replay runs/h.jsonl` stays text-only.
 
 
 
 
141
  - Offline CLI smoke: `.venv/bin/python -m proteus run --scenario predator_evade --model fake:demo
142
  --seed 42 --play-turns 5 --out runs/x.jsonl && .venv/bin/python -m proteus replay runs/x.jsonl`
143
  - Difficulty bands: add `--difficulty {easy,medium,hard,expert}` to `run`/`play` (EASY is the default,
 
5
  > the per-CP plan in `docs/superpowers/plans/` + this file.
6
 
7
  **Last updated:** 2026-06-02 — CP6 complete (difficulty layouts + category-specific eval +
8
+ human-baseline `compare` harness; offline, headless) — Web interactive color-grid play shipped.
9
 
10
  ## Done (CP0–CP3)
11
 
 
126
  - **Invariant acceptance:** all four bands print `optimal=up habit=left` with distinct grids `(8,8)/(10,10)/(12,12)/(12,12)` — `optimal != habit` everywhere.
127
  - **Note:** the `fake:demo` provider plays a fixed non-optimal action (so `motive_reading_accuracy=0`); the smoke validates the deterministic pipeline + metric surfacing, not agent skill.
128
 
129
+ ## Done (Web interactive play — color-grid browser arena; plan: `docs/superpowers/plans/2026-06-02-proteus-web-interactive-play.md`; design: `docs/superpowers/specs/2026-06-02-proteus-web-interactive-play-design.md`)
130
+
131
+ Executed task-by-task via subagent-driven-development (implement → spec review → code-quality review per task). **Full suite: 148 passed** (the 127 CP6 baseline preserved unchanged + 21 new web/runtime tests).
132
+
133
+ - **Stdlib-only color-grid web play** — launch with `python -m proteus.web` (`--host`/`--port`, defaults to `127.0.0.1:8000`). A single static `index.html` (vanilla JS, no build, no CDN) renders the engine's integer grids in color via `proteus.arc_grid.rendering.COLOR_MAP`. **Zero new dependencies** — the `.venv` stays SDK-free/offline.
134
+ - **Shared session core** — extracted `SessionRunner`'s per-session mechanics into `proteus/runtime/_session_core.py` (pure refactor, no behavior change — the existing tests stayed green at the same count). Both `SessionRunner` and the new `InteractiveSession` build their traces from these same helpers.
135
+ - **`InteractiveSession`** (`proteus/runtime/interactive.py`) — a threadless, stepwise driver (`state()`/`step()`/`finish()`) that advances one turn per HTTP request. It is pinned to `SessionRunner(HumanAgent)` by a **golden equivalence test** (`tests/runtime/test_interactive_equivalence.py`) asserting full `model_dump()` equality for the same action sequence — the two paths cannot drift.
136
+ - **Fairness split** (carried from CP5) — the live `state` exposes only the color grid + available actions (no reward/optimal/habit), exactly what the LLM sees; the full per-turn disclosure (your action vs optimal vs habit, reward, 8 metrics) appears in `review` only once the game is over. Asserted in both the `InteractiveSession` and server tests.
137
+ - **Always-saved trace** — every finished game appends a `runs/web_<scenario>_<difficulty>.jsonl` line (override via the `/finish` `{out}` body) that is schema-identical to LLM/CLI traces. Verified end-to-end: a web-produced trace is accepted by both `proteus replay` and `proteus compare` (shows up as a `model=human` baseline group).
138
+ - **HTTP API** (stdlib `http.server`) — `GET /` (page), `GET /config`, `POST /session`, `GET /session/{id}`, `POST /session/{id}/act`, `POST /session/{id}/finish`; a pure socket-free `handle_request(...)` router (unit-tested without a socket) + in-memory registry; structured errors (400/404/409/500); offline import-safety guarded (`tests/web/test_import_safety.py`).
139
+
140
  ## How to run
141
 
142
  - Environment: `python` is **not** on PATH; a gitignored venv lives at `.venv` (Python 3.12,
143
  pydantic v2 / numpy / pyyaml / pytest **+ matplotlib** — the latter now required by the viz/png
144
+ tests). **Full suite:** `.venv/bin/python -m pytest -q` → **148 passed**, no network, no display.
145
  Provider SDKs are NOT installed in `.venv` (keeps the offline invariant structural); matplotlib runs
146
  **Agg-only** (headless), so it does not break the offline/no-display invariant. Recreate `.venv` with:
147
  `uv venv --python 3.12 .venv && uv pip install --python .venv/bin/python "pydantic>=2" "numpy>=1.26" "pyyaml>=6" "pytest>=8" "matplotlib>=3.8"`
 
149
  predator_evade --seed 42 --play-turns 6 --out runs/h.jsonl` (live view is the same ASCII the LLM sees).
150
  - Visual replay: `.venv/bin/python -m proteus replay runs/h.jsonl --visual --fps 0` (truecolor terminal)
151
  or `--png runs/frames` (per-frame PNGs). Plain `replay runs/h.jsonl` stays text-only.
152
+ - Web interactive play (offline, stdlib-only): `.venv/bin/python -m proteus.web` (`--host`/`--port`,
153
+ defaults `127.0.0.1:8000`), then open the printed `http://127.0.0.1:8000/` — play the color grid in the
154
+ browser; the finished game appends a schema-identical trace to `runs/web_<scenario>_<difficulty>.jsonl`
155
+ (replayable/comparable with `proteus replay`/`compare`). Zero new dependencies.
156
  - Offline CLI smoke: `.venv/bin/python -m proteus run --scenario predator_evade --model fake:demo
157
  --seed 42 --play-turns 5 --out runs/x.jsonl && .venv/bin/python -m proteus replay runs/x.jsonl`
158
  - Difficulty bands: add `--difficulty {easy,medium,hard,expert}` to `run`/`play` (EASY is the default,