# Pi Wrapper Real-Envelope Fixture Coverage

audience: AI coding agents first.

**Goal:** Close the SPEC-P3 residual fixture gap: the Pi stub in the wrapper terminal-contract suite emits a generic `{"type":"result",...}` envelope instead of Pi's real `session.started` / `agent.finished` shape, and there is no coverage for the rate-limit path.

**Scope:** one file — `modules/harness/v2/test/wrapper-terminal-contract.test.js`.

## Task 1: Pi real envelope + rate-limit coverage

**Wave:** 1

**Files:** `modules/harness/v2/test/wrapper-terminal-contract.test.js`

**Contract:**

- Replace the Pi stub's generic `{"type":"result",...}` output with Pi's real envelope: a `session.started` line carrying the session identifier, followed by an `agent.finished` line carrying the terminal payload.
- The existing Pi success assertions must still hold: stdout ends with exactly one canonical usage event followed by exactly one canonical status line, continuity reported as `thread_id` (never `session_id`), exit code 0.
- Add one case where the Pi stub emits a rate-limit signal with a `resume_at` field: the wrapper must exit 75, still emit exactly one usage event and one status line, and the status line must carry the rate-limit failure class.
- Do not weaken or delete any existing assertion. Do not touch any wrapper script.

**Acceptance:** `node --test modules/harness/v2/test/wrapper-terminal-contract.test.js` — all tests pass, zero failures.
