Milestone 2: direct deploys as build jobs, logs, cancel, redeploy, sweeper
startDeploynow creates abuild_jobsrow first (executordirect, environmentpreview,max_attempts1, triggermanualor, for a pinned SHA,redeploy). Thedeploymentsrow storesbuild_job_idandtrigger.runDirectDeploymoves the job through queued → claimed → uploading → succeeded, or to failed or canceled. Each step writes a redacted log line: queued (repo, branch, commit, profile), claimed, selected N files and their size, uploading to the Worker, the live URL, and an error line with a hint if something fails. Thedeploymentsrow follows the job, so the existing UI keeps working.- Cancel is checked at two points: once after the job is claimed and again before the upload starts. An upload that has already started is allowed to finish.
GET /api/deployments/:id/logs?after=<seq>returns only the owner's data: the deployment, the job and up to 500 log lines afterafter.nextgives the last sequence number, so polling can resume where it stopped.POST /api/deployments/:id/cancelrequires same-origin, is owner-scoped and can be called repeatedly. It returns 409 for older deployments that have no build job./deployments/[id]shows the status, a timeline of the build phases, logs that refresh every 2 seconds while the job is active, a Cancel button (only while active) and a Redeploy button (only when finished). Redeploy sends the stored commit SHA to the existingPOST /api/projects/:id/deploy. Each item in a project's deployment timeline links to this page.- Sweeper cron:
wrangler.jsonchastriggers.crons: ["*/5 * * * *"]andmain: custom-worker.ts, which wraps the OpenNext worker and adds ascheduledhandler that callssweepBuilds. It was checked locally withwrangler dev --test-scheduledandwrangler deploy --dry-run. It only takes effect when the Worker is deployed.
Source: docs/platform/MILESTONE-2-DIRECT-JOBS.md · /docs/platform/milestone-2-direct-jobs.md