5.2 KiB
Phase 2: Run the Local Runner and Fake Harness
What this phase is
Phase 2 is a local live-run path. A TypeScript mock core starts a Rust runner. The Rust runner starts a scripted fake harness. The processes use JSON lines over stdio.
What this phase proves
This phase proves that a native session can run from start to finish without Paperclip, a network provider, or a real model. It proves cleanup, request resolution, interruption, bounded logs, one terminal result, and live/replay parity.
Prerequisites
- Node.js 20 or newer
- pnpm 9 or newer
- a stable Rust toolchain with
cargo - a Chromium-compatible browser
Run every command from the repository root on the
PAP-16679-paperclip-runner branch. Install the package dependencies and browser:
pnpm install --filter @paperclipai/paperclip-runner --lockfile=false --ignore-scripts --dev
pnpm --filter @paperclipai/paperclip-runner exec playwright install chromium
On a minimal Linux host, install the browser libraries too:
pnpm --filter @paperclipai/paperclip-runner exec playwright install-deps chromium
playwright install-deps requires root. On a Debian or Ubuntu host where root
is unavailable, use the package's rootless verification command instead. It
downloads the required browser-library packages into a user-owned cache,
extracts them without installing system packages, and scopes LD_LIBRARY_PATH
to the verification process:
pnpm --filter @paperclipai/paperclip-runner verify:rootless
1. Run the package verification path
pnpm --filter @paperclipai/paperclip-runner verify
Expected: Rust, TypeScript, protocol, boundary, documentation, and browser checks pass. The final Phase 2 line reports one terminal event and a successful semantic result.
2. Run the happy path in the CLI
pnpm --filter @paperclipai/paperclip-runner trace:phase2 -- --scenario happy-path --quiet
Expected summary facts:
eventCountis19;terminalCountis1;semanticResultisdone;- harness and runner exit codes are
0.
Capture the live trace as a validated replay fixture:
pnpm --filter @paperclipai/paperclip-runner record:phase2
The command writes
packages/paperclip-runner/knowledge/evidence/phase-02-happy-path.json.
3. Run the scripted control flows
pnpm --filter @paperclipai/paperclip-runner trace:phase2 -- --scenario permission-input --quiet
pnpm --filter @paperclipai/paperclip-runner trace:phase2 -- --scenario interrupted --quiet
pnpm --filter @paperclipai/paperclip-runner trace:phase2 -- --scenario error --quiet
pnpm --filter @paperclipai/paperclip-runner trace:phase2 -- --scenario duplicate-terminal --quiet
pnpm --filter @paperclipai/paperclip-runner trace:phase2 -- --scenario happy-path --duplicate-turn-command --quiet
Expected:
- permission and input finish with
done; - interruption exits the harness with
130and reportsyielded; - scripted error exits the harness with
7and reportsyielded; - duplicate terminal still reports
terminalCount: 1; - duplicate turn command does not start a second turn.
4. Use the live browser
Start the package-local server:
pnpm --filter @paperclipai/paperclip-runner browser:dev --host 127.0.0.1 --port 4179
Open http://127.0.0.1:4179, then follow these steps:
- Keep
Happy pathselected and choose Start local run. - Confirm the terminal badge says
succeeded. - Confirm
Harness process exitis0andSemantic resultisdone. - Confirm
Live and replay reducer outputsaysMatch. - Select
Permission and input, start the run, and choose Allow. - Enter a trace name and choose Send input. Confirm the run completes. Each interactive request remains open for five minutes. If it expires, the page reports that the run finished and asks you to start a new run.
- Select
Interruption, start the run, and choose Interrupt turn when the button becomes active. - Confirm the terminal badge says
cancelled, the semantic result saysyielded, and the timeline contains onerun.terminalevent. - Switch to Static replay and confirm the Phase 1 fixture path still works.
Stop Vite with Ctrl+C.
The browser regression suite writes its temporary screenshots under the
ignored packages/paperclip-runner/test-results/ directory. It never rewrites
the committed evidence images linked below.
5. Inspect the evidence
What this proves
- the Rust runner owns and cleans the fake-harness process group;
- the fake driver emits deterministic live events and requests;
- logs are bounded;
- process exit and semantic result stay separate;
- duplicate commands and terminal proposals do not repeat effects;
- every browser event passes the Phase 1 validator and reducer;
- replay after completion produces the same final snapshot.
Phase 3 must not begin until the Phase 2 human checkpoint is accepted.