146: Stand up factory-test-infra: Cloudflare-based ephemeral verification environments (Workers for Platforms + Containers) + factory provider wiring#182
Conversation
|
End-to-end merge blocker from the Factory-wide verification pass:
I am marking this draft so the current provider/unit-test green cannot be read as satisfying the issue's explicit real-environment acceptance criteria. Ready-to-merge evidence needs the infrastructure repository and scripts, a trusted real-Cloudflare workflow run with teardown artifacts, every guardrail assertion demonstrated (including failure when removed), current-main local/hosted suites green, and zero unresolved review threads. |
…force-factory-80c19421
|
Addressed the blocker in the coupled implementation now published as AgentWorkforce/factory-test-infra#2. Concrete fixes:
Validation on these heads: Factory build + 71 files/1,332 tests + CLI/featuremap + tier-2 dry-run/status; infra typecheck + 14 tests + Wrangler Container/reaper dry-runs + Terraform fmt/validate + actionlint; exact Miniflare up/run-suite/down with 403 cross-environment isolation, quota/concurrency refusals, cost/time aborts, orphan deletion, 200 requests/0 errors, and idempotent teardown. The remaining acceptance item is intentionally not overstated: a trusted owner must supply the protected Cloudflare Resource secret and run the real job so the dispatch namespace, Container, k6, and teardown artifacts exist. |
|
Final safe-work update before the owner-gated real run:
The real Cloudflare job is the sole remaining acceptance proof. The dedicated repository currently has no factory-verification environment or cloudflare_resource_json secret, and this runner has no Cloudflare Resource credentials, so I have not represented the skipped real job as success. Happy to walk an owner through the Resource shape, protection settings, expected artifacts, or any implementation trade-off before that run. |
…force-factory-80c19421
…force-factory-80c19421
|
Current-base verification update:
The protected real-Cloudflare job remains the only unmet issue acceptance item; neither repository secrets nor this runner currently provide the required Resource credentials. |
Part of Epic: Factory Verification & Environments (#141). This is the tier-5/6 data-plane home. The provider (#142) and gate (#145) run on what this stands up. Best done first in Track C.
Decision: Cloudflare-first, in a dedicated
factory-test-infrarepofactoryis a library (@agent-relay/factory) — it must not own or operate the environment substrate. The org is already all-in on Cloudflare + SST + wrangler + workerd/miniflare, so tier-5/6 verification environments run on Cloudflare, not a bespoke Kubernetes cluster:@cloudflare/vitest-pool-workers/ miniflare (cloud already runs this —test:integration,miniflare-sage).Kept in its own repo (not merged into cloud's
infra/) so the spiky, ephemeral verification account/config is isolated from product infra for blast-radius + cost accounting. K8s/Daytona remain optional escape-hatch providers behind the sameEnvironmentProviderport (#142) for the minority of target stacks that genuinely can't run on Cloudflare — Cloudflare Containers is not a general Kubernetes replacement for arbitrary heavy container stacks.What (in
factory-test-infra)verification-stackdescriptors (Verification-stack descriptor contract + deployer: repos declare their full stack, Factory brings it up #143) render into.What (in
factory)CloudflareEnvironmentProvider(EnvironmentProvider port + Cloudflare ephemeral-environment provider (Workers for Platforms + Containers); K8s/Daytona optional #142) reads thefactory-test-infraaccount/API-token config (via aResource.*-style secret, notprocess.env); a reusable CI workflow that runs the Track-C E2E suites (EnvironmentProvider port + Cloudflare ephemeral-environment provider (Workers for Platforms + Containers); K8s/Daytona optional #142–Verification gate: provision → deploy → E2E → load → evaluate → teardown, wired into the merge gate #145) against miniflare + a real dispatch namespace, and tears down.Acceptance
factory-test-infrarepo exists with Cloudflare account/config as code (dispatch namespace(s), Containers, bindings) documented + scripted; miniflare path for CI.CloudflareEnvironmentProviderconnects; reusable CI workflow runs EnvironmentProvider port + Cloudflare ephemeral-environment provider (Workers for Platforms + Containers); K8s/Daytona optional #142–Verification gate: provision → deploy → E2E → load → evaluate → teardown, wired into the merge gate #145 suites and tears down.✅ End-to-end verification — Factory success criteria (REQUIRED)
"Compiles" is not done. Provision a real dispatch namespace + Container, prove the guardrails bind, and prove CI runs the suite end to end.
Run it
The E2E must prove the guardrails bind (not just exist):
Deliverable
factory-test-infraci/verification-env/{up,run-suite,down}.sh+ reusable CI workflow, one-command.Anchor points
factory-test-infra:infra/(SST or wrangler + Terraform Cloudflare provider),containers/(Container service defs),ci/verification-env/(up/run/down + miniflare), Cron-Trigger reaper worker.factory:src/environments/cloudflare-provider.ts(from EnvironmentProvider port + Cloudflare ephemeral-environment provider (Workers for Platforms + Containers); K8s/Daytona optional #142) reads the account/token;src/config/schema.tsenv config;.github/workflows/reusable verification workflow.src/orchestrator/reaper.ts(identity-checked reaper pattern to mirror).relaycast-cloud(workerd +@cloudflare/vitest-pool-workers), cloud'sminiflare-sageservice +test:integration.Fixes #146
Summary by cubic
Adds Cloudflare-based ephemeral verification environments and a reusable CI workflow. Each run gets an untrusted Workers for Platforms dispatch namespace with a sentinel metadata Worker, strict guardrails, and an identity-checked reaper, meeting #146.
CloudflareEnvironmentProvider: provisions one dispatch namespace per run; attaches a metadata Worker; enforces TTL, max-concurrency, run-cost, and container instance caps; adds a serializing + cross-instance reconciliation fix to close concurrency races; identity-checked destroy and a TTL/owner reaper.resourcename; credentials come from a linked Resource object at runtime (noprocess.env), with a narrow token used by an HTTP client..github/workflows/cloudflare-verification.ymlrunsfactory-test-infra’sci/verification-env/{up,run-suite,down}.shin Miniflare and real modes, materializes a JSON resource file for the real run, always tears down, and uploads artifacts.docs/cloudflare-environment-provider.md(lifecycle, guardrails, workflow usage);factory-test-infra/README.mdhandoff updated for Cloudflare; config schema, exports, and tests added.Written for commit 52bf6b4. Summary will update on new commits.