Migrate all relayflows to v2 and deploy pr-proof on PR open
- Change type:
feature - RelayFlow case:
1792-relayflows-v2-spec-generation
Migrates every relayflow from the v1 @relayflows/core WorkflowBuilder to relayflows v2. workflows/ is gone.
| Source | Flow name | Entry point |
|---|---|---|
flows/ci/pr-proof.flow.ts | relay.ci.pr-proof | flows deploy (hosted listener) |
flows/verify/fleet-daytona.spec.ts | relay.verify.fleet-daytona | npm run verify:fleet-daytona |
flows/verify/cleanroom.spec.ts | relay.verify.cleanroom | npm run verify:cleanroom |
flows/verify/features.spec.ts | relay.verify.features | npm run verify:features |
flows/diagnose/orchestration.spec.ts | relay.diagnose.orchestration | npm run diagnose:orchestration |
flows/audit/feature-manifest.spec.ts | relay.audit.feature-manifest | npm run audit:feature-manifest |
All 141 v1 step names are preserved. Flow names are dot-namespaced relay.<domain>.<name> — dots rather than slashes because flows build seals a bundle as <name>@sha256:<digest> and validates against /^[A-Za-z0-9][A-Za-z0-9._-]*$/.
pr-proof deploys on PR open
relayflow-pr-proof.yml is deleted. The proof is now a hosted GitHub listener:
flows deploy flows/ci/pr-proof.flow.ts \
--repo AgentWorkforce/relay \
--on github:events=pull_request \
--approver <handle> --agents claude
There is no webhook to register — the GitHub App installation is the ingress, and each matching PR launches a run with { approver, issue, event } as input.
The dispatcher's security boundary moves rather than disappears. Its rule was "never check out PR head code on a credential-bearing runner"; a deployed flow has no runner, so the boundary is now that the listener's event envelope is reduced to a pull request number by scripts/pr-proof/event-from-input.mjs before anything trusts it. Every SHA, title, and body still comes from the GitHub API via prepare.mjs. Run input reaches the lowered shell command base64-encoded, so attacker-controlled PR text has no metacharacters to escape.
Listener staleness is real and NOT solved here
A hosted listener stores a snapshot of the flow source, so editing flows/ci/pr-proof.flow.ts and merging does nothing until someone redeploys. I wrote a workflow to automate that and then removed it, because it could never have authenticated.
POST /api/v1/flows/deploy, GET /api/v1/agents/flow-deployments, and DELETE /api/v1/flows/listeners/:id are each gated by !requireSessionAuth(auth) && !requireAuthScope(auth, "cli:auth") → 403 session_required, and requireAuthScope passes a non-session token only when its own scopes include cli:auth.
Nothing a user can mint carries cli:auth. The dashboard's "Flows Cloud token" — whose success banner literally says to store it as FLOWS_CLOUD_TOKEN — gets workflow:invoke:read|write + workflow:runs:read|logs:read. The operator mint script offers only deployment and workflow-invoke profiles. cli:auth comes solely from interactive browser login, with a 24-hour access token. Cloud's own test pins it: "rejects a token that does not carry cli:auth" → 403.
whoami has no scope guard, so the SDK's first call returns 200 and only the deploy call fails — which is why this looked workable.
So deploying a listener stays manual for now: agent-relay cloud login, then flows deploy. A Cloud-side change is needed (a real scope on those routes, included in a mintable purpose) before it can be automated; that is being worked separately.
⚠️ v2 does not enforce agent permissions
Worth knowing before merging, and larger than it looks. AgentStepSpec.permissions is carried as journal data and never enforced. Every reference across the SDK and kernel is parse, validate, or round-trip; the kernel says so at relayflowd-core/src/spec.rs — "Carried as data in gate 1; enforcement lands with agent dispatch" — and the RFC states the intent as future work.
v1's equivalent was enforced: packages/cloud/src/compiler.ts normalized files.read/write/deny, merged the .agentignore/.agentreadonly presets, and emitted relayfile scopes the mount applied.
So the migration's real cost is not a coarser policy — these agents were sandboxed and now are not. Affected: 5 lanes + 11 reviewers in cleanroom, 7 in fleet-daytona, 10 in diagnose. Each can currently read .env and *secret*, and write the runner, matrix, product source, tests, .git, and other lanes' evidence. Sealing runs after the lanes and hashes what is present, so it records a mutation rather than preventing one.
The permission blocks are kept in full — reviewable intent, and correct the moment gate 8 lands — with the warning written at the point each policy is built. Reported upstream as flows#487, which also proposes the cheap half: have flows check warn when a step declares permissions.
Practical exposure is low today: these three flows cannot run unattended yet anyway (Cloud deploy is unresolved, and codex model access is credential-bound). But do not run them locally on a machine holding credentials you care about until gate 8 lands.
Why most flows are generated specs, not .flow.ts
Only pr-proof is authored against @relayflows/surface. Three things the others depend on are reachable only from the data dialect:
- Steps longer than 15 minutes.
f.run's timeout is capped at 15 minutes (compile.ts,lease_exceeded), enforced at run and invisible toflows check. Five fleet-daytona steps exceed it, including each 85-minute board attempt. - Agent
permissions.AgentOptionshas no permissions field;AgentStepSpecdoes. - Named deterministic steps.
f.runtakes no id, so a TypeScript body labels every gaterun-7.
The hybrid that would have avoided this — use: plus f.dispatch — is accepted by flows check and then refused at run (unsupported_header: use).
flows/spec-builder.ts holds the v1→v2 translation in one reviewable place, so the flows that were mostly large shell bodies keep their authoring calls byte-identical.
OpenCode adapter
v2 refuses OpenCode as cli_unsupported. Four flows use it deliberately — a third-party model reviewing Relay's own evidence is the property under test — so scripts/flows/opencode-agent-cli.mjs implements the relayflows-agent-cli-v1 contract rather than resubstituting Claude, which would make those steps attest something they never checked.
Nothing to do if OpenCode is already logged in — a credential under HOME works on every path, because HOME is allowlisted.
The constraint is narrower and asymmetric, and worth knowing because it is a check/run trapdoor: flows check probes through runProbe (cli/check.ts), which passes the full process.env, while execution goes through runWrapperSession (worker-cli.ts), which passes wrapperEnvironment(process.env) — a closed allowlist that strips OPENCODE_API_KEY. So an environment-only credential passes preflight and then fails at run. The adapter's authStatus reads the credential store rather than the environment precisely so the probe answers the question execution will actually ask.
Fidelity lost, recorded in AGENTS.md
Agent steps take no timeoutMs in v2, so v1's per-agent bounds are planning inputs only. permissions survives but has no read/write split, deny list, or exec allowlist — the runners' own seals remain what prove evidence was not mutated. The relaycast channel, idleNudge, agent preset/role, and repoReads have no equivalent.
Two mappings worth review:
failOnError: falsebecomes<command> || true, keeping the explicit gate the only thing that decides.- A crashed cleanroom lane agent now fails the run instead of being judged by
gate-<lane>, since v2 has nofailOnError: falsefor agent steps.
retries: n maps to maxIterations: n + 1 (the kernel's retry bound). The TypeScript surface exposes no retry knob, which is why pr-proof has none.
Codex model pin
Every Codex agent was pinned to gpt-5.1-codex-mini, carried over verbatim from v1. It is the oldest entry in the registry, which marks gpt-5.5 as the default — and v2's preflight is what surfaced it, since v1 never probed the model and only failed mid-run.
Probing every registry entry against a real credential shows the constraint is not specific to mini: a ChatGPT-account credential accepts gpt-5.5 and refuses everything else (gpt-5.4, gpt-5.3-codex, gpt-5.3-codex-spark, gpt-5.2-codex, gpt-5.2, gpt-5.1-codex-max, gpt-5.1-codex-mini all return "not supported when using Codex with a ChatGPT account"). gpt-5.5 is therefore the only pin that works on both credential types and is now the default everywhere.
The reviewer/lane split stays expressible rather than collapsed: cleanroom keeps separate CODEX_REVIEW_MODEL and CODEX_LANE_MODEL, both defaulting to gpt-5.5 and each overridable (CLEANROOM_CODEX_MODEL, CLEANROOM_CODEX_LANE_MODEL), so a credential allowing cheaper models can drop the lane executors — which only invoke one deterministic runner command and are judged by gate-<lane> — without touching the reviewers. Diagnose gains DIAGNOSE_CODEX_MODEL; fleet already had VERIFY_FLEET_CODEX_MODEL.
Verification
flows checkon all six flows passes clean — zero refusals, every step gated: fleet-daytona 28, cleanroom 51, features 31, diagnose 30, audit 9, pr-proof passing.- The OpenCode adapter satisfies the real contract end to end: identity probe, auth probe, model probe, and a
runWrapperSessionagent step that ran and passed its gate. - PR-proof case
1642-verify-features-escalationruns end to end and writes the exact outcome and signaturecase.jsonexpects. - pr-proof's first step ran for real against PR #1786;
prepare.mjscorrectly refused it for an unfilled template (fail-closed working). tsc -p flows/tsconfig.jsonclean; 400 fixture tests pass.
flows check does not typecheck — verified by feeding it a flow assigning Promise<string> to number, which passed. flows/tsconfig.json plus npm run flows:check closes that hole.
Before merging
- Repoint branch protection — the PR-proof required status check no longer comes from GitHub Actions.
- Deploy the listener manually after merge:
agent-relay cloud login, thenflows deploy flows/ci/pr-proof.flow.ts --repo AgentWorkforce/relay --on github:events=pull_request --approver <handle> --agents claude. Nothing proves a PR until that runs, and it must be re-run whenever the flow source changes.
Not verified — needs a real Cloud deploy
run-arm.mjs requires SANDBOX_ID, and cloud-storage.mjs requires RUN_ID/AGENT_RELAY_CLOUD_WORKER_RUN_ID. Those come from agent-relay Cloud's SandboxedStepExecutor. Whether the flows-v2 Cloud executor sets them — and gives each agent step a distinct sandbox, which the red/green proof depends on — could not be tested here. Same for whether GITHUB_TOKEN/gh are present in a deployed run.
Also unaddressed: scripts/pr-proof/run-cloud.mjs (875 lines) is unreachable in production now that its dispatcher is gone, but pr-proof-contract.test.ts still imports and pins it, so it is not a clean delete.
🤖 Generated with Claude Code
[!NOTE]
Low Risk
Documentation-only changes to Agent Skills; no runtime, auth, or workflow execution code in this diff.
Overview
This PR reshapes the .agents/skills library so agents stop pointing at deprecated @relayflows/core WorkflowBuilder docs and get clearer split guidance for orchestrators vs workers vs v2 flows.
choosing-swarm-patterns now documents @agent-relay/sdk with YAML-first pattern examples (replacing fluent workflow() snippets), updated MCP naming, and source-of-truth paths under packages/sdk.
writing-agent-relay-workflows (~1.5k lines) is removed; writing-relayflows is added for the journal-based v2 engine (flows CLI, run/llm/agent, flows check/run/resume).
orchestrating-agent-relay is a new end-to-end playbook (broker bootstrap, spawn/monitor, MCP vs CLI messaging, fleet, troubleshooting).
relay-80-100-workflow switches imports to @agent-relay/sdk, makes review depth configurable (light/standard/deep) instead of always Claude-then-Codex, and simplifies commit verification (drops HEAD-baseline gate).
using-agent-relay is trimmed/reordered; CLI examples move toward agent-relay local; orchestrator vs participant routing is tightened.
Smaller edits: creating-agent-skills rename/cleanup, setting-up-relayfile adds a cloud flush-timeout symptom, swarm pattern table formatting fixes.
Reviewed by Cursor Bugbot for commit bb8183d22d6f0764fd9b9e5203cb1f83578a77a9. Bugbot is set up for automated code reviews on this repo. Configure here.