Files
PaperClipAI/packages/paperclip-runner/docs/capability-clean-room-chat.md
Dotta 560e7e48b5 feat(runner): add SDK and developer tooling (#12608)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The runner package already provides the production protocol and
execution spine.
> - Contributors still need stable SDK surfaces, deterministic test
tools, and local inspection tools.
> - Those surfaces share generated contracts and must change as one
package boundary.
> - This pull request adds the package-local SDK, labs, examples, and
drift checks.
> - The benefit is a reviewable developer platform that does not change
application execution selection.

## Linked Issues or Issue Description

**Subsystem affected**

`packages/paperclip-runner` — runner SDK, conformance tools, and
developer tooling.

**Problem or motivation**

The production runner spine is present, but package consumers cannot
build deterministic integrations, inspect sessions, or verify
provider-neutral behavior through supported surfaces.

**Proposed solution**

Add browser, React, standalone, live-session, scenario, conformance, and
evaluation surfaces. Add generated contract inventories and
package-local verification scripts. Keep production application routing
unchanged.

**Alternatives considered**

We considered splitting each generated catalog, SDK surface, and demo
into separate pull requests. Those changes share exports, fixtures, and
drift gates. Splitting them would create intermediate package states
that do not build.

**Roadmap alignment**

No overlapping item appears in `ROADMAP.md`. This work extends the
runner package that is already on `master`.

## What Changed

- Add browser, React, standalone, live-session, and issue-thread SDK
surfaces.
- Add deterministic mock control-plane, scenario, conformance, replay,
and evaluation tools.
- Add bounded Codex, OpenCode, and ACPX development transports and
fixtures.
- Keep deferred managed-provider execution fail-closed. Persisted
compatibility data remains readable.
- Add generated capability inventories with their source files and drift
checks.
- Add examples, package documentation, browser checks, and
clean-consumer checks.
- Preserve the reviewed protocol bounds, replay compatibility aliases,
process environment isolation, and semantic redaction limits.
- Update the ACPX package patch that the existing workspace patch
registry already tracks.
- Do not change `pnpm-lock.yaml`, repository workflows, server runtime
selection, or the application UI.

## Verification

GitHub Actions is the verification authority for this pull request. The
repository CI, package TypeScript and Rust checks, package tests,
generated-output drift checks, browser checks, security scans, and
Greptile review must pass on the exact head.

Local test suites were not run because this series uses parallel GitHub
Actions for verification.

## Risks

This is a large greenfield package change. The main risks are public
export drift, generated-output drift, and optional React consumer
compatibility. Package boundary checks, clean-consumer checks, and
browser tests cover those risks. Production adapter selection and server
execution are outside this pull request.

## Stack

1. **This PR:** runner SDK and developer tooling.
2. [Codex production server
integration](https://github.com/paperclipai/paperclip/pull/12616).
3. [Provider-neutral task-thread
UI](https://github.com/paperclipai/paperclip/pull/12617).

## Model Used

OpenAI Codex, GPT-5, high-reasoning mode, with tool use and code
execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have described the issue in-PR following the feature request
template
- [x] I have not referenced internal/instance-local Paperclip issues or
links
- [x] My branch name describes the change and contains no internal
Paperclip ticket id
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-08-31 21:33:11 -05:00

8.5 KiB

Capability clean-room live chat

Capability adds a second primary path beside the preset scenario explorer. A board user opens a blank chat, sends a free-form message, and watches real Codex work a mock Paperclip issue through real runnerd. There is no scenario to pick, no recorded transcript, and no scripted tool tour.

Both paths ship in the same app and share one view contract. What separates them is what the session is seeded with, and whether a fixture is allowed to stand in for a provider.

Preset scenario explorer Clean-room chat
Route #/issue/<fixtureProfile> #/chat
Seed A recorded eval case: transcript, scripted calls, parity verdicts A company, an agent, and one blank issue
Modes fake (default), replay, mode=live Live only — no fixture, no recording
Tool calls Fixed by the scenario Chosen by the conversation
Evidence drawer Collapsed by default Collapsed by default

What "clean room" means

Every open mints a new mock tenant — a new company, actor, task, and MCK- identifier — and seeds nothing else. assertCapabilityCleanRoomSeedIsBlank fails the open if any comment, document, interaction, approval, artifact, blocker, wake, or fault is present, so "the thread starts blank" is enforced at the seam that creates the session rather than assumed.

The only mutation an open performs is the run checking the mock issue out, which is why a fresh room reads in_progress rather than todo.

Live only, and loudly so

The clean room never falls back:

  • parseCapabilityRoute pins mode to live on #/chat and drops shot and at. No URL can talk it into rendering a fixture or a recording.
  • The package server has no scripted path for this route. It projects the live session and refuses any view that is not mode=live with a Real Codex agent label.
  • When runnerd or the Codex app-server cannot start, the surface says exactly that and offers Try again. It does not render a canned thread.

Exposure profile

The profile is deterministic and inspectable even though the calls are not. CAPABILITY_CLEAN_ROOM_CLAIMS grants the read, comment, document, interaction, deliverable, delegation, dependency, wake, and approval-request operations.

Three grants stay withheld on purpose:

Withheld grant Effect
governance:approvals:decide The agent may request an approval; the board decides it.
workspace:control No service lifecycle changes from a chat.
test:generic_api_request The escape hatch stays off.

Withholding them keeps a denial reachable in a conversation nobody scripted: if the model reaches for one, it gets a typed denial with a named code and the mock state does not move. The Evidence drawer's Tools section lists all three under Control plane (not exposed to the agent).

The run itself holds the wider adapter claim set that the mock command boundary requires (capabilityFixtureRunCapabilities). That union widens the port, never the catalog the model sees: effective claims are the intersection of run claims, scenario claims, and explicitly delegated claims.

Session lifecycle

GET  /api/capability/ui/cleanroom/session[?sessionId=…]   open or reconnect
POST /api/capability/ui/cleanroom/session {sessionId?}    New chat (retires the caller's room)
POST /api/capability/ui/message      {sessionId, message}
POST /api/capability/ui/interrupt    {sessionId}
POST /api/capability/ui/reconnect    {sessionId}
POST /api/capability/ui/reset        {sessionId}
POST /api/capability/ui/interaction  {sessionId, interactionId, outcome, result}

Reset and New chat both stop active work, clear the previous session's authority, drop its workspace directory, and open a new tenant. A retired session id answers 404 on every route afterwards — the rotation is verifiable, not just visible. Refresh reconnects to the same durable session; a stale id from localStorage opens a fresh room rather than dead-ending.

The clean room stores its session id under its own localStorage key, so a scenario session can never be handed to the chat route or the reverse.

Bounds

Bound Value
Turns per chat 24, then a named turn_limit refusal that points at New chat
Message size 8 KiB
Concurrent clean rooms 4; the oldest yields to a new board user
Turn timeout 120 s (CapabilityLiveSessionService default)

Real-API block

CapabilityLiveSession routes every Paperclip operation through the in-process mock ControlPlanePort; no code path reaches a Paperclip URL. The projection turns that into a record rather than a claim: the Control plane section of the Evidence drawer carries a network-guard-<sessionId> row reading Real Paperclip API requests: 0. Child PAPERCLIP_* environment keys: none.

The child environment is allowlisted by createSanitizedCodexEnvironment, so no PAPERCLIP_* value reaches runnerd or Codex, and the browser receives no provider, runner, or control-plane credential.

DevTools state inspector

Opening DevTools opens a Redux-DevTools-style inspector over the live mock company. Its timeline starts at the pristine fixture, adds a revision for each successful semantic mutation, and lets the operator inspect or diff the complete browser-safe company scaffolding: company, actors, tasks, comments, documents, interactions, approvals, artifacts, work products, blockers, workspace services, budgets, runs, wakes, audit records, decisions, idempotency records, and configured faults. Separate tabs expose the protocol boundary records, runner/runtime facts, and effective authority. A dedicated Documents tab renders every mock document and lets the operator switch between its retained revisions without digging through raw JSON.

The Evidence log consolidates repeated tool-exposure snapshots into one deduplicated catalog. Its Always, Granted, and Control-plane groups fold independently; selecting a tool opens its catalog title, description, placement, required claims, allowed task modes and roles, and full input schema.

Pause pins a revision while work continues, Export downloads the redacted DevTools snapshot, and Fork rN retires the current mock session and starts a new executable branch from that retained state. Provider payloads, session checkpoints, artifact content references, working directories, and secret-shaped strings remain server-side or are withheld by the explicit browser projection.

While a turn runs, a live status rail appears immediately after send and tracks the newest safe Codex activity. Reasoning, planning, shell-command, file-change, MCP/dynamic-tool, assistant-stream, and Paperclip semantic-tool lifecycle events each trigger an interim frame. Discrete tools remain separate rows; only noisy text deltas are grouped. Structured shell items show a bounded, credential-redacted command preview; raw command output, other provider payloads, and chain of thought stay withheld.

Remote preview gateway

The tailnet preview keeps the package server on loopback and exposes it through dist/capability/tailnet-gateway.js. Every API call requires the gateway's high-entropy HttpOnly capability cookie. Mutations additionally require the exact configured Origin and application/json.

Fetch Metadata is checked as defense in depth: any supplied Sec-Fetch-Site, Sec-Fetch-Mode, or Sec-Fetch-Dest value must describe the expected same-origin fetch() request. Browsers that omit one or all of those optional headers are still accepted after the capability, Origin, and content-type checks pass. This keeps Safari and embedded/private browser clients working without weakening the explicit cross-site denial.

Verification

Surface Command
Seed, exposure profile, and identity rotation pnpm --filter @paperclipai/paperclip-runner test:scenarios
Clean-room HTTP routes end to end (stub provider) included in test:scenarios
Browser entry, blank state, evidence-on-demand, narrow layout, axe pnpm --filter @paperclipai/paperclip-runner test:browser:issue-thread
Real Codex through real runnerd pnpm --filter @paperclipai/paperclip-runner smoke:capability:cleanroom
Live screenshots pnpm --filter @paperclipai/paperclip-runner recorded-evidence campaign (deferred)

See the clean-room chat tutorial for the clean-start walkthrough, execution modes and identity for the fake/live eligibility rules, and the issue-thread UI reference for the thread, composer, and Evidence panel this surface reuses.