Skip to content
Myr

Add a prod stage served on the brand's own domain

Before adoption: this commit came in with the history the project adopted, so no landing records it.

The web runs at the apex and the platform at git., as Workers Custom Domains. infra/stages.ts names the hosts from @repo/brand and the deploy hands them to Wrangler with --domain and --var, so wrangler.jsonc holds only an .invalid stand-in. Seed, swarm and smoke --loop refuse prod.

authored by oscabriel · committed by oscabriel · parent 9a724f5 · Browse files · 21 files+406 added−80 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

21 files+406 added−80 removed

  • tests:+101 added−18 removed
  • other:+305 added−62 removed

21 files+406 added−80 removed

modified:apps/platform/src/platform.ts+1 added-1 removed
modified:apps/platform/test/bindings.test.ts+23 added-2 removed
261 unmodified lines
262 unknown: [],263 vars: keysOf(PlatformVars.fields),264 };265266 expect(Object.keys(stages)).toStrictEqual(["dev-oscabriel", "demo"]);266 expect(Object.keys(stages)).toStrictEqual([267 "dev-oscabriel",268 "demo",269 "prod",270 ]);271 expect({ top, ...stages }).toStrictEqual({272 demo: decoded,273 "dev-oscabriel": decoded,274 prod: decoded,275 top: decoded,276 });277 }).pipe(Effect.provide(NodeServices.layer))278 );
39 unmodified lines
318319 expect({320 demo: yield* read(env.demo),321 "dev-oscabriel": yield* read(env["dev-oscabriel"]),322 prod: yield* read(env.prod),323 top: yield* read(raw),324 }).toStrictEqual({325 demo: {326 ai: "AI",
6 unmodified lines
333 draftLimit: draftLimit("1104"),334 model,335 web: "https://web-dev-oscabriel.oscargabriel.workers.dev",336 },337 prod: {338 ai: "AI",339 draftLimit: draftLimit("1304"),340 model,341 // A stand-in: on the brand's own domain, `infra/deploy.ts` passes342 // the web's address as a `--var` (`packages/config/test/deploy.test.ts`).343 web: "https://from-infra-deploy.invalid",344 },345 top: {346 ai: "AI",347 draftLimit: draftLimit("1004"),348 model,
25 unmodified lines
374375 expect({376 demo: yield* codeCache(env.demo),377 "dev-oscabriel": yield* codeCache(env["dev-oscabriel"]),378 prod: yield* codeCache(env.prod),379 top: yield* codeCache(raw),380 }).toStrictEqual({381 demo: "code-cache-demo",382 "dev-oscabriel": "code-cache-dev-oscabriel",383 prod: "code-cache-prod",384 top: "code-cache-local",385 });386 }).pipe(Effect.provide(NodeServices.layer))387 );
82 unmodified lines
470 unknown: [],471 vars: [],472 };473458 expect(Object.keys(stages)).toStrictEqual(["dev-oscabriel", "demo"]);474 expect(Object.keys(stages)).toStrictEqual([475 "dev-oscabriel",476 "demo",477 "prod",478 ]);479 expect({ top, ...stages }).toStrictEqual({480 demo: read,481 "dev-oscabriel": read,482 prod: read,483 top: read,484 });485 }).pipe(Effect.provide(NodeServices.layer))486 );
1 unmodified line
modified:apps/platform/test/handlers.test.ts+2 added
915 unmodified lines
916 expect(limitsOf("CLAIM_LIMIT")).toStrictEqual([917 WorkerCaps.claim,918 WorkerCaps.claim,919 WorkerCaps.claim,920 WorkerCaps.claim,921 ]);922 expect(limitsOf("PROPOSAL_LIMIT")).toStrictEqual([923 WorkerCaps.proposal,924 WorkerCaps.proposal,925 WorkerCaps.proposal,926 WorkerCaps.proposal,927 ]);928 }).pipe(Effect.provide(NodeServices.layer))929 );930});
modified:apps/platform/worker-configuration.d.ts+30 added-2 removed
1/* eslint-disable */2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: f0d9c81078e02f30515626c844786037)2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: a47fb3ac3f72d983df90016b3fc3c8eb)3interface __BaseEnv_Env {4 OAUTH_KV: KVNamespace;5 EVIDENCE: R2Bucket;6 RELEASES: R2Bucket;
16 unmodified lines
23 COOKIE_KEY: string;24 PASSWORD_PEPPER: string;25 MASTER_KEY: string;26 PROJECT: DurableObjectNamespace<import("./src/worker").Project>;27 SANDBOX: Fetcher /* sandbox-dev-oscabriel */ | Fetcher /* sandbox-demo */ | Fetcher /* sandbox */;27 SANDBOX: Fetcher /* sandbox-dev-oscabriel */ | Fetcher /* sandbox-demo */ | Fetcher /* sandbox-prod */ | Fetcher /* sandbox */;28 ANSWER: Workflow<Parameters<import("./src/worker").Answer['run']>[0]['payload']>;29 ON_PUSH: Workflow<Parameters<import("./src/worker").OnPush['run']>[0]['payload']>;30}31declare namespace Cloudflare {
56 unmodified lines
88 SANDBOX: Fetcher /* sandbox-demo */;89 ANSWER: Workflow<Parameters<import("./src/worker").Answer['run']>[0]['payload']>;90 ON_PUSH: Workflow<Parameters<import("./src/worker").OnPush['run']>[0]['payload']>;91 }92 interface ProdEnv {93 OAUTH_KV: KVNamespace;94 EVIDENCE: R2Bucket;95 RELEASES: R2Bucket;96 CODE_CACHE: R2Bucket;97 FRONT_PAGE: D1Database;98 ARTIFACTS: Artifacts;99 ARTIFACTS_PRIVATE: Artifacts;100 CLAIM_LIMIT: RateLimit;101 PROPOSAL_LIMIT: RateLimit;102 SIGN_IN_LIMIT: RateLimit;103 DRAFT_LIMIT: RateLimit;104 LOADER: WorkerLoader;105 AI: Ai;106 OPERATOR_HANDLE: string;107 STAGE: string;108 LANDER_ADAPTER: string;109 DRAFT_MODEL: string;110 PUBLIC_WEB_URL: string;111 OPERATOR_TOKEN: string;112 COOKIE_KEY: string;113 PASSWORD_PEPPER: string;114 MASTER_KEY: string;115 PROJECT: DurableObjectNamespace<import("./src/worker").Project>;116 SANDBOX: Fetcher /* sandbox-prod */;117 ANSWER: Workflow<Parameters<import("./src/worker").Answer['run']>[0]['payload']>;118 ON_PUSH: Workflow<Parameters<import("./src/worker").OnPush['run']>[0]['payload']>;119 }120 interface Env extends __BaseEnv_Env {}121}122interface Env extends __BaseEnv_Env {}123type StringifyValues<EnvType extends Record<string, unknown>> = {
5 unmodified lines
modified:apps/platform/wrangler.jsonc+90 added
303 unmodified lines
304 },305 ],306 },307 },308 // Served on the brand's own domain, never workers.dev: infra/deploy.ts309 // passes its Custom Domain and PUBLIC_WEB_URL, which name the brand, so310 // they live in infra/stages.ts. The URL here is a stand-in the deploy's311 // --var replaces. Bootstrap writes the D1 and KV ids.312 "prod": {313 "workers_dev": false,314 "vars": {315 "OPERATOR_HANDLE": "oscabriel",316 "STAGE": "prod",317 "LANDER_ADAPTER": "container",318 "DRAFT_MODEL": "@cf/moonshotai/kimi-k2.7-code",319 "PUBLIC_WEB_URL": "https://from-infra-deploy.invalid",320 },321 "secrets": {322 "required": [323 "OPERATOR_TOKEN",324 "COOKIE_KEY",325 "PASSWORD_PEPPER",326 "MASTER_KEY",327 ],328 },329 "durable_objects": {330 "bindings": [{ "name": "PROJECT", "class_name": "Project" }],331 },332 "workflows": [333 { "name": "answer-prod", "binding": "ANSWER", "class_name": "Answer" },334 {335 "name": "on-push-prod",336 "binding": "ON_PUSH",337 "class_name": "OnPush",338 },339 ],340 "artifacts": [341 { "binding": "ARTIFACTS", "namespace": "projects-prod" },342 { "binding": "ARTIFACTS_PRIVATE", "namespace": "layers-prod" },343 ],344 "d1_databases": [345 {346 "binding": "FRONT_PAGE",347 "database_name": "front-page-prod",348 "database_id": "00000000-0000-0000-0000-000000000000",349 "migrations_dir": "migrations",350 },351 ],352 // KV namespace `oauth-prod`.353 "kv_namespaces": [354 { "binding": "OAUTH_KV", "id": "00000000000000000000000000000000" },355 ],356 "r2_buckets": [357 { "binding": "EVIDENCE", "bucket_name": "evidence-prod" },358 { "binding": "RELEASES", "bucket_name": "releases-prod" },359 { "binding": "CODE_CACHE", "bucket_name": "code-cache-prod" },360 ],361 "worker_loaders": [{ "binding": "LOADER" }],362 "ai": { "binding": "AI" },363 "services": [{ "binding": "SANDBOX", "service": "sandbox-prod" }],364 "ratelimits": [365 {366 "name": "CLAIM_LIMIT",367 "namespace_id": "1301",368 "simple": { "limit": 10, "period": 60 },369 },370 {371 "name": "PROPOSAL_LIMIT",372 "namespace_id": "1302",373 "simple": { "limit": 5, "period": 60 },374 },375 {376 "name": "SIGN_IN_LIMIT",377 "namespace_id": "1303",378 "simple": { "limit": 5, "period": 60 },379 },380 {381 "name": "DRAFT_LIMIT",382 "namespace_id": "1304",383 "simple": { "limit": 2, "period": 60 },384 },385 ],386 "triggers": {387 "events": [388 {389 "type": "cf.artifacts.repo.pushed",390 "filter": { "namespace": "projects-prod" },391 "targets": [392 { "type": "workflow", "workflow_name": "on-push-prod" },393 ],394 },395 ],396 },397 },398 },399}
modified:apps/sandbox/worker-configuration.d.ts+5 added-1 removed
1/* eslint-disable */2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: 834f9f6911d7397f08e3d315a4ba4497)2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: e2ded613bcc52924dd43b8200efe10af)3interface __BaseEnv_Env {4 CHECKER: DurableObjectNamespace<import("./src/worker").Checker>;5 LANDER: DurableObjectNamespace<import("./src/worker").Lander>;6}
9 unmodified lines
16 interface DemoEnv {17 CHECKER: DurableObjectNamespace<import("./src/worker").Checker>;18 LANDER: DurableObjectNamespace<import("./src/worker").Lander>;19 }20 interface ProdEnv {21 CHECKER: DurableObjectNamespace<import("./src/worker").Checker>;22 LANDER: DurableObjectNamespace<import("./src/worker").Lander>;23 }24 interface Env extends __BaseEnv_Env {}25}26interface Env extends __BaseEnv_Env {}
modified:apps/sandbox/wrangler.jsonc+27 added
100 unmodified lines
101 },102 },103 ],104 },105 "prod": {106 "durable_objects": {107 "bindings": [108 { "name": "CHECKER", "class_name": "Checker" },109 { "name": "LANDER", "class_name": "Lander" },110 ],111 },112 "containers": [113 {114 "class_name": "Checker",115 "scheduling_policy": "durable_object",116 "images": {117 "check": { "dockerfile": "./images/check.Dockerfile" },118 },119 },120 {121 "class_name": "Lander",122 "scheduling_policy": "durable_object",123 "images": {124 "land": {125 "dockerfile": "./images/land.Dockerfile",126 "build_context": "../..",127 },128 },129 },130 ],131 },132 },133}
modified:apps/web/worker-configuration.d.ts+6 added-2 removed
1/* eslint-disable */2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: aa7c6db610447e5e6e68b0fe0dbbcb47)2// Generated by Wrangler by running `wrangler types --include-runtime=false --strict-vars=false` (hash: a5ee49fb864c51bcf6b69dd189e7c486)3interface __BaseEnv_Env {4 PUBLIC_PLATFORM_URL: string;5 PLATFORM: Fetcher /* platform-dev-oscabriel */ | Fetcher /* platform-demo */ | Fetcher /* platform */;5 PLATFORM: Fetcher /* platform-dev-oscabriel */ | Fetcher /* platform-demo */ | Fetcher /* platform-prod */ | Fetcher /* platform */;6}7declare namespace Cloudflare {8 interface GlobalProps {9 mainModule: typeof import("./src/server");
5 unmodified lines
15 interface DemoEnv {16 PUBLIC_PLATFORM_URL: string;17 PLATFORM: Fetcher /* platform-demo */;18 }19 interface ProdEnv {20 PUBLIC_PLATFORM_URL: string;21 PLATFORM: Fetcher /* platform-prod */;22 }23 interface Env extends __BaseEnv_Env {}24}25interface Env extends __BaseEnv_Env {}26type StringifyValues<EnvType extends Record<string, unknown>> = {
5 unmodified lines
modified:apps/web/wrangler.jsonc+12 added
50 unmodified lines
51 "vars": {52 "PUBLIC_PLATFORM_URL": "https://platform-demo.oscargabriel.workers.dev",53 },54 },55 // Served on the brand's own domain, never workers.dev: infra/deploy.ts56 // passes its Custom Domain and PUBLIC_PLATFORM_URL, which name the brand,57 // so they live in infra/stages.ts. The URL here is a stand-in the58 // deploy's --var replaces, so the generated Env still types it a string.59 "prod": {60 "workers_dev": false,61 "cache": { "enabled": true },62 "services": [{ "binding": "PLATFORM", "service": "platform-prod" }],63 "vars": {64 "PUBLIC_PLATFORM_URL": "https://from-infra-deploy.invalid",65 },66 },67 },68}
modified:infra/deploy.ts+74 added-48 removed
19 unmodified lines
20import { schemaItems } from "./env-schema.ts";21import { notRecording } from "./recording.ts";22import type { RecordingInProgress } from "./recording.ts";23import {24 customHosts,25 platformOrigin,26 repoRoot,27 stageOf,28 subdomainFile,
32 unmodified lines
61}6263const bin = (app: string, name: string) => `${app}/node_modules/.bin/${name}`;6465// A stage on the brand's own domain gets its hostnames and the URL vars that66// name them here, never from `wrangler.jsonc` (see `customHosts`).67const hostArgs = (stage: Stage) =>68 Option.match(customHosts(stage), {69 onNone: () => ({ platform: [], web: [] }),70 onSome: ({ platform, web }) => ({71 platform: [72 "--domain",73 platform,74 "--var",75 `PUBLIC_WEB_URL:https://${web}`,76 ],77 web: [78 "--domain",79 web,80 "--var",81 `PUBLIC_PLATFORM_URL:https://${platform}`,82 ],83 }),84 });8586const stepsOf = (87 stage: Stage,88 options: {89 readonly web: boolean;90 readonly platformEnv: Readonly<Record<string, string>>;91 }70): readonly Step[] => [71 { args: ["run", "verify"], command: "bun", cwd: "", name: "verify" },72 {73 args: ["deploy", "--env", stage],74 command: bin("apps/sandbox", "wrangler"),75 cwd: "apps/sandbox",76 name: "sandbox",77 },78 {79 args: ["deploy", "--env", stage],80 command: bin("apps/platform", "varlock-wrangler"),81 cwd: "apps/platform",82 env: options.platformEnv,83 name: "platform",84 },85 // The Vite plugin takes the stage from CLOUDFLARE_ENV and writes its deploy86 // config under `dist/`, so Wrangler gets no --env. NODE_ENV stops a shell's87 // own value from making a development build, whose `#backend` is the dev world.88 ...(options.web89 ? [90 {91 args: ["run", "build"],92 command: "bun",93 cwd: "apps/web",94 env: { CLOUDFLARE_ENV: stage, NODE_ENV: "production" },95 name: "web build",96 },97 {98 args: ["deploy", "--env", stage],99 command: bin("apps/web", "wrangler"),100 cwd: "apps/web",101 name: "web",102 },103 ]104 : []),105 {106 args: ["run", "bootstrap", "--stage", stage, "--check-triggers"],107 command: "bun",108 cwd: "",109 name: "triggers",110 },111 {112 args: ["scripts/smoke.ts", "--stage", stage],113 command: "bun",114 cwd: "",115 name: "smoke",116 },117];92): readonly Step[] => {93 const hosts = hostArgs(stage);9495 return [96 { args: ["run", "verify"], command: "bun", cwd: "", name: "verify" },97 {98 args: ["deploy", "--env", stage],99 command: bin("apps/sandbox", "wrangler"),100 cwd: "apps/sandbox",101 name: "sandbox",102 },103 {104 args: ["deploy", "--env", stage, ...hosts.platform],105 command: bin("apps/platform", "varlock-wrangler"),106 cwd: "apps/platform",107 env: options.platformEnv,108 name: "platform",109 },110 // The Vite plugin takes the stage from CLOUDFLARE_ENV and writes its deploy111 // config under `dist/`, so Wrangler gets no --env. NODE_ENV stops a shell's112 // own value from making a development build, whose `#backend` is the dev world.113 ...(options.web114 ? [115 {116 args: ["run", "build"],117 command: "bun",118 cwd: "apps/web",119 env: { CLOUDFLARE_ENV: stage, NODE_ENV: "production" },120 name: "web build",121 },122 {123 args: ["deploy", "--env", stage, ...hosts.web],124 command: bin("apps/web", "wrangler"),125 cwd: "apps/web",126 name: "web",127 },128 ]129 : []),130 {131 args: ["run", "bootstrap", "--stage", stage, "--check-triggers"],132 command: "bun",133 cwd: "",134 name: "triggers",135 },136 {137 args: ["scripts/smoke.ts", "--stage", stage],138 command: "bun",139 cwd: "",140 name: "smoke",141 },142 ];143};144145const platformSecrets = (root: string) =>146 Effect.gen(function* () {147 const fs = yield* FileSystem.FileSystem;148 const path = yield* Path.Path;
146 unmodified lines
modified:infra/stages.ts+37 added-2 removed
1// The one table of stages and the resources each owns, each named by its job2// plus the stage, never the brand. `packages/config/test/bootstrap.test.ts`3// holds every Worker's `wrangler.jsonc` env blocks to it.4import { Brand } from "@repo/brand";5import { Effect, FileSystem, Option, Path, Schema } from "effect";67export const Stage = Schema.Union([8 Schema.TemplateLiteral([9 "dev-",10 Schema.String.check(Schema.isPattern(/^[a-z0-9]+$/u)),11 ]),12 Schema.Literal("demo"),13 Schema.Literal("prod"),14]);1516export type Stage = typeof Stage.Type;1718// Each has an `env` block in every Worker's `wrangler.jsonc`; add a stage to both.19export const stages = [20 "dev-oscabriel",21 "demo",22 "prod",23] as const satisfies readonly Stage[];2425// The stages people see: no script makes a throwaway project or seeds a26// fictional one on them without being told to.27export const publicStages: ReadonlySet<string> = new Set<Stage>([28 "demo",29 "prod",30]);3132export interface Hosts {33 readonly platform: string;34 readonly web: string;35}3637// A stage served on the brand's own domain, as Workers Custom Domains. The38// names live here, not in `wrangler.jsonc`, so the brand stays in39// `packages/brand`: `infra/deploy.ts` hands them to Wrangler as `--domain`40// and as the URL vars, and such a stage turns its `workers.dev` route off.41// What such a stage's `wrangler.jsonc` holds in each URL var: `.invalid`42// never resolves, so a deploy that skipped `--var` fails where it shows.43export const URL_FROM_DEPLOY = "https://from-infra-deploy.invalid";4445export const customHosts = (stage: Stage): Option.Option<Hosts> =>46 stage === "prod"47 ? Option.some({ platform: `git.${Brand.domain}`, web: Brand.domain })48 : Option.none();4950export interface Resources {51 readonly platform: string;52 readonly sandbox: string;53 readonly web: string;
97 unmodified lines
151 );152});153154export const platformOrigin = (stage: Stage, subdomain: string) =>155 Option.match(customHosts(stage), {156 onNone: () =>127 `https://${resources(stage).platform}.${subdomain}.workers.dev`;157 `https://${resources(stage).platform}.${subdomain}.workers.dev`,158 onSome: ({ platform }) => `https://${platform}`,159 });160161export const webOrigin = (stage: Stage, subdomain: string) =>130 `https://${resources(stage).web}.${subdomain}.workers.dev`;162 Option.match(customHosts(stage), {163 onNone: () => `https://${resources(stage).web}.${subdomain}.workers.dev`,164 onSome: ({ web }) => `https://${web}`,165 });
modified:packages/config/test/deploy.test.ts+49 added-4 removed
1import { NodeServices } from "@effect/platform-node";2import { describe, expect, it } from "@effect/vitest";3import { Brand } from "@repo/brand";4import {5 Console,6 ConfigProvider,7 Effect,
122 unmodified lines
130 expect(spawned).toStrictEqual([]);131 })132 );133133 it.live.each(["prod", "dev-", "dev-Alice", "dev-nobody", "local"])(134 it.live.each(["staging", "dev-", "dev-Alice", "dev-nobody", "local"])(135 "fails with UnknownStage for --stage %s and spawns nothing",136 (stage) =>137 Effect.gen(function* () {138 const { result, spawned } = yield* run(["--stage", stage]);
229 unmodified lines
368describe("what a failed deploy prints", () => {369 it.live("names the stages it knows when it refuses one", () =>370 Effect.gen(function* () {371 expect(yield* messageOf([])).toBe(371 "no --stage: name one of dev-oscabriel, demo"372 "no --stage: name one of dev-oscabriel, demo, prod"373 );373 expect(yield* messageOf(["--stage", "prod"])).toBe(374 "--stage prod is not a stage infra/stages.ts declares (dev-oscabriel, demo)"374 expect(yield* messageOf(["--stage", "staging"])).toBe(375 "--stage staging is not a stage infra/stages.ts declares (dev-oscabriel, demo, prod)"376 );377 })378 );379
68 unmodified lines
448 ]);449 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))450 );451});452453describe("a deploy to prod", () => {454 it.live(455 "puts the platform and the web on the brand's own domain, and hands each the other's URL",456 () =>457 Effect.gen(function* () {458 const { result, spawned } = yield* run(["--stage", "prod"]);459 const git = `git.${Brand.domain}`;460461 expect(Result.isSuccess(result)).toBeTruthy();462 expect(spawned.map(line)).toStrictEqual([463 ".$ bun run verify",464 "apps/sandbox$ wrangler deploy --env prod",465 `apps/platform$ varlock-wrangler deploy --env prod --domain ${git} --var PUBLIC_WEB_URL:https://${Brand.domain}`,466 "apps/web$ bun run build",467 `apps/web$ wrangler deploy --env prod --domain ${Brand.domain} --var PUBLIC_PLATFORM_URL:https://${git}`,468 ".$ bun run bootstrap --stage prod --check-triggers",469 ".$ bun scripts/smoke.ts --stage prod",470 ]);471 })472 );473474 it.live("names the Google redirect URI on the platform's own host", () =>475 Effect.gen(function* () {476 const printed: string[] = [];477478 const quiet: Console.Console = {479 ...console,480 log: (...args: readonly unknown[]) => {481 printed.push(args.map(String).join(" "));482 },483 };484485 const { result } = yield* run(["--stage", "prod"]).pipe(486 Effect.provideService(Console.Console, quiet)487 );488489 expect(Result.isSuccess(result)).toBeTruthy();490 expect(printed.at(-1)).toBe(491 `deploy prod: to offer Google sign-in, register https://git.${Brand.domain}/oauth/google/callback as the Google client's redirect URI (H4)`492 );493 })494 );495});
modified:packages/config/test/release.test.ts+4 added-4 removed
290 unmodified lines
291 releaseRun({292 build: false,293 env: { CLAUDECODE: "1" },294 publish: true,295 stage: "prod",295 stage: "staging",296 upload: true,297 })298 ).toStrictEqual(Result.fail(new UnknownStage({ stage: "prod" })));298 ).toStrictEqual(Result.fail(new UnknownStage({ stage: "staging" })));299 });300301 it("publishes last when a person runs it", () => {302 expect(
87 unmodified lines
390 unknown: releasePlan({391 build: false,392 env: {},393 publish: false,394 stage: "prod",394 stage: "staging",395 upload: true,396 }),397 }).toStrictEqual({398 none: Result.fail(new NoStage()),399 unknown: Result.fail(new UnknownStage({ stage: "prod" })),399 unknown: Result.fail(new UnknownStage({ stage: "staging" })),400 });401 });402});403
338 unmodified lines
modified:packages/config/test/smoke.test.ts+2 added-2 removed
633 unmodified lines
634 expect(yield* Effect.flip(main(["--url", origin]))).toStrictEqual(635 new NoStage()636 );637 expect(638 yield* Effect.flip(main(["--stage", "prod", "--url", origin]))639 ).toStrictEqual(new UnknownStage({ stage: "prod" }));638 yield* Effect.flip(main(["--stage", "staging", "--url", origin]))639 ).toStrictEqual(new UnknownStage({ stage: "staging" }));640 expect(seen).toStrictEqual([]);641 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))642 );643
51 unmodified lines
modified:packages/config/test/teardown.test.ts+1 added-1 removed
683 unmodified lines
684 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))685 );686687 it.live.each([688 [["--stage", "prod"], "prod"],688 [["--stage", "staging"], "staging"],689 [["--stage"], "--stage"],690 [["--force"], "--force"],691 [["--keep"], "--keep"],692 ] as const)(
14 unmodified lines
modified:packages/config/test/web-wiring.test.ts+20 added-5 removed
1import { NodeServices } from "@effect/platform-node";2import { describe, expect, it } from "@effect/vitest";3import { Effect, FileSystem, Path, Schema } from "effect";3import { Effect, FileSystem, Option, Path, Schema } from "effect";45import { blankJsonc } from "../../../infra/jsonc.ts";6import {7 customHosts,8 platformOrigin,9 URL_FROM_DEPLOY,10 resources,11 stages,12 subdomainFile,13 WorkersDev,
37 unmodified lines
51 services: Schema.Array(52 Schema.Struct({ binding: Schema.String, service: Schema.String })53 ),54 vars: Schema.Record(Schema.String, Schema.String),55 workers_dev: Schema.optionalKey(Schema.Boolean),56});5758const decodeBound = Schema.decodeUnknownEffect(Bound);59
67 unmodified lines
127 })128 );129130 it.effect(128 "points each stage's PLATFORM at that stage's platform Worker, and its public URL at that Worker's origin",131 "points each stage's PLATFORM at that stage's platform Worker, and its public URL at that Worker's origin, which a stage on the brand's domain takes from the deploy",132 () =>133 Effect.gen(function* () {134 const config = yield* presentJson("apps/web/wrangler.jsonc", Wrangler);135 const { subdomain } = yield* presentJson(subdomainFile, WorkersDev);136137 for (const stage of stages) {135 const { services, vars } = yield* decodeBound(config.env[stage]);138 const { services, vars, workers_dev } = yield* decodeBound(139 config.env[stage]140 );141142 expect(services).toStrictEqual([143 { binding: "PLATFORM", service: resources(stage).platform },144 ]);140 expect(vars.PUBLIC_PLATFORM_URL).toBe(141 platformOrigin(stage, subdomain)145 expect({146 stage,147 url: vars.PUBLIC_PLATFORM_URL,148 workers_dev,149 }).toStrictEqual(150 Option.isSome(customHosts(stage))151 ? { stage, url: URL_FROM_DEPLOY, workers_dev: false }152 : {153 stage,154 url: platformOrigin(stage, subdomain),155 workers_dev: undefined,156 }157 );158 }159 })160 );
117 unmodified lines
modified:scripts/lib/smoke/loop.ts+6 added-2 removed
13 unmodified lines
14import type { ChildProcessSpawner } from "effect/process";1516import { recordCreated } from "../../../infra/created.ts";17import type { Created } from "../../../infra/created.ts";18import { declaredStage, resources } from "../../../infra/stages.ts";18import {19 declaredStage,20 publicStages,21 resources,22} from "../../../infra/stages.ts";23import {24 acceptDraft,25 awaitDraft,26 awaitLanding,27 claimAsk,
128 unmodified lines
156> =>157 Effect.gen(function* () {158 const { origin, stage } = input;159156 if (stage === "demo") {160 if (publicStages.has(stage)) {161 return yield* new DemoStageRefused({ stage });162 }163164 const fs = yield* FileSystem.FileSystem;
205 unmodified lines
modified:scripts/lib/swarm/args.ts+6 added
155 unmodified lines
156 const stage = yield* stageOf(argv).pipe(157 Effect.mapError(({ message }) => failed(`${message}. ${USAGE}`))158 );159160 if (stage === "prod") {161 return yield* failed(162 "--stage prod: the swarm's contributors are fictional, so run it on a dev stage or demo"163 );164 }165166 if (stage === "demo" && !argv.includes("--allow-demo")) {167 return yield* failed(168 "--stage demo: its burrow family is for the recorded take; run it there only with --allow-demo"169 );
88 unmodified lines
modified:scripts/seed.ts+6 added
79 unmodified lines
80 const stage = yield* stageOf(argv).pipe(81 Effect.mapError(({ message }) => failed(message))82 );8384 if (stage === "prod") {85 return yield* failed(86 "--stage prod is the real platform: the examples are fictional, so seed them on a dev stage or demo"87 );88 }8990 if (stage === "demo" && !argv.includes("--yes")) {91 return yield* failed(92 "--stage demo is the stage the user records on (H7): seed it only between takes, with --yes"93 );
318 unmodified lines
modified:scripts/smoke.ts+2 added-1 removed
21 unmodified lines
22import { main as probeMain } from "../infra/smoke.ts";23import {24 flagValue,25 platformOrigin,26 publicStages,27 recordedSubdomain,28 stageOf,29 subdomainFile,30} from "../infra/stages.ts";
95 unmodified lines
126const loopMain = (argv: readonly string[]) =>127 Effect.gen(function* () {128 const stage = yield* stageOf(argv);129129 yield* stage === "demo"130 yield* publicStages.has(stage)131 ? Effect.fail(new DemoStageRefused({ stage }))132 : Effect.void;133134 const answerer = Option.getOrElse(flagValue(argv, "--as"), () => ANSWERER);
54 unmodified lines
modified:AGENTS.md+3 added-3 removed
61 unmodified lines
62- `prepare`: runs on `bun install` and patches TypeScript with the Effect language service.63- `env:check`: shows the env with its values redacted.64- `ops -- <command>`: runs cf with the ops credentials (see Boundaries).65- `bootstrap -- --stage <stage>`: makes a stage's Cloudflare resources; a second run creates nothing, and `--dry-run` only prints the plan.66- `deploy -- --stage <stage>`: the one way to deploy. It runs `verify`, deploys the three Workers with Wrangler, reads the push trigger back, then runs `smoke`.67- `smoke -- --stage <stage>`: read-only probes against a live stage. `--loop` then runs the whole core loop on a throwaway project, `smoke-<run>`, through the CLI and git, and refuses `demo`.68- `seed`: puts the two example projects on a platform (`--world node` on this machine, or `--stage <stage>`); a second run changes nothing. `--only <example> --as <name>` seeds a fresh copy under another name, and refuses a taken one.66- `deploy -- --stage <stage>`: the one way to deploy. It runs `verify`, deploys the three Workers with Wrangler, reads the push trigger back, then runs `smoke`. `prod` is served on the brand's own domain (the web at the apex, the platform at `git.`), which `infra/stages.ts` names and the deploy passes to Wrangler, so the name stays out of `wrangler.jsonc`.67- `smoke -- --stage <stage>`: read-only probes against a live stage. `--loop` then runs the whole core loop on a throwaway project, `smoke-<run>`, through the CLI and git, and refuses `demo` and `prod`.68- `seed`: puts the two example projects on a platform (`--world node` on this machine, or `--stage <stage>`); a second run changes nothing. `--only <example> --as <name>` seeds a fresh copy under another name, and refuses a taken one. It refuses `prod`, as `swarm` does: their projects and people are fictional.69- `import-examples -- --stage <stage>`: imports the open-source repos the code browser is previewed on, one at a time, onto a stage (`demo` included, with its reason in the stage's record), each recorded in the ledger as kept; `--tags` backfills the tags Artifacts' import leaves out, `--only <name>` imports one, and `--world node` imports onto this machine.70- `swarm -- --stage <stage> --project <name>`: plans six fictional contributors, on four harnesses, against one split family on a stage, claims each one's ask, prepares a workspace with a clone of its fork outside the checkout, starts each harness headless on the brief and sends every refusal back into the same session, at most three times, then writes the run's summary; `--view herdr` runs them in herdr panes beside a counter, and `--dry-run` only prints the plan.71- `release -- --build | --upload --stage <stage> | --publish`: builds the CLI's npm package and two binaries, uploads a release to the stage's own bucket, which the platform serves, and leaves `npm publish` to a person: under an agent it prints the command instead.72
67 unmodified lines