Artifacts Fork Run Workflow
A durable Cloudflare Workflow that gives every agent run its own disposable fork of a reviewed Artifacts baseline, then gates the merge back. The baseline is created readOnly so no agent token can push to it, and each run forks it with defaultBranchOnly so the copy carries the tip instead of every branch and tag it will never read. The fork name is derived from the Workflow instanceId and event.timestamp, never Date.now(), which is what makes the fork step idempotent: a retry recomputes the same name, collides with ALREADY_EXISTS (10201), and adopts the existing repo rather than creating a second one, while FORK_IN_PROGRESS (10303) is absorbed by a retrying readiness step instead of handing the sandbox a remote that is not clonable yet. Write tokens are minted per run with a two hour TTL and sensitive step output, the agent is dispatched with an ArtifactFS blobless mount so file contents hydrate on read, and promotion into the baseline happens only after a merge-decision event from a human or a policy engine, since the binding has no merge call. The review step is deliberately thin about what it can prove, because the binding is a control plane with no log, readCommit, or readTree on it: what it checks is lastPushAt, the one server-side fact the sandbox cannot forge in its completion event, and anything richer is a git clone by whatever renders the review. Teardown runs in a finally block and again in a cron sweeper that decides on createdAt and guards on the run-name prefix, because terminate() skips the finally and Artifacts bills storage at $0.50 per GB-month until a repo is explicitly deleted.
npx shadcn@latest add https://ui.aryank.space/r/artifacts-fork-run-workflow.jsonInstalls from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.
Each agent run forks a read-only baseline into a disposable copy; a durable workflow gates the merge back, so an unreviewed fork is released (discarded) rather than pushed to the baseline.
@cloudflare/[email protected]