wrangler.jsonc
This file
Path
apps/platform/wrangler.jsonc
356 lines · 12.9 KiB
Last changed by
Merge infra/drop-demo into mainoscabrielbefore adoptionc49b6bf
History of this fileTake it
1{2 // The platform Worker: the contracts over RPC at /rpc and MCP at /mcp, git3 // smart HTTP for every project's repos, the Project Durable Object and the4 // Answer and OnPush Workflows. Deploy only through infra/deploy.ts, to an5 // explicit stage.6 //7 // The top level is stage `local`: it builds and types the Worker and is8 // never deployed. Each stage under `env` repeats every binding, since9 // wrangler does not inherit bindings into an environment. Resource names10 // are jobs plus the stage, never the brand. A `database_id` or11 // KV `id` of zeros is a placeholder that infra/bootstrap.ts replaces with12 // the id of the resource it made.13 "$schema": "node_modules/wrangler/config-schema.json",14 "name": "platform",15 "main": "src/worker.ts",16 "compatibility_date": "2026-10-05",17 // isomorphic-git needs `Buffer` (the /isogit Lander). The OAuth provider18 // resolves a Client ID Metadata Document (the CLI's, served at /oauth/cli,19 // and an MCP client's) only with `global_fetch_strictly_public`, which20 // sends the fetch through the public internet (SSRF protection).21 "compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],22 // Rat Stack's byte limits are for a minified bundle (scripts/startup-budget.ts).23 "minify": true,24 // esbuild's name-keeping wraps every function and class in a helper call25 // that restores its name after minifying: about 130 KB of the entry.26 // Nothing here reads a name at run time: Effect's tagged errors27 // set `name` from their tag, services are keyed by strings, and the28 // runtime finds Durable Objects, Workflows and entrypoints by export name,29 // which minifying keeps. A stack trace shows minified names and positions.30 // The uploaded source maps take an uncaught exception's stack back to the31 // source, but a defect the platform reports itself is logged as thrown:32 // the same commit's `wrangler deploy --dry-run --outdir` gives the map to33 // read it by (README, Observability).34 "keep_names": false,35 "upload_source_maps": true,36 "workers_dev": true,37 "preview_urls": false,38 // Every invocation's logs and trace, unsampled, and Issues, which groups39 // what failed. The runtime's own spans record each Durable Object SQL40 // statement's bound values and each fetch's full URL, so these traces hold41 // the Project DO's layer names and repos and sealed values (never a plain42 // one). The maintainer keeps them in the account's trace store alone: no43 // `destinations`, and no Issues automation sends the platform's anywhere44 // (principle 7).45 // Unlike bindings, wrangler gives `observability` and `upload_source_maps`46 // to every stage that does not set its own47 // (packages/config/test/observability.test.ts holds each stage to them).48 "observability": {49 "enabled": true,50 "logs": {51 "enabled": true,52 "head_sampling_rate": 1,53 "invocation_logs": true,54 },55 "traces": { "enabled": true, "head_sampling_rate": 1 },56 "issues": { "enabled": true },57 },58 "migrations": [{ "tag": "v1", "new_sqlite_classes": ["Project"] }],59 "vars": {60 // Until sign-in exists, one operator holds a session.61 "OPERATOR_HANDLE": "oscabriel",62 "STAGE": "local",63 // "container" (apps/sandbox) or "isogit" (in this Worker).64 "LANDER_ADAPTER": "container",65 // The Workers AI model that drafts asks; swap it here, no code change.66 "DRAFT_MODEL": "@cf/moonshotai/kimi-k2.7-code",67 // The web app, which `/` links to: `vite dev`'s URL locally.68 "PUBLIC_WEB_URL": "http://localhost:5173",69 },70 "secrets": {71 // Declared in .env.schema; the user sets the values. SESSION_TOKENS is72 // optional; sign-in's cookie key and pepper are not, since accounts are73 // the platform's own and need no third party. MASTER_KEY wraps every74 // write-only env value: without it none can be stored or opened.75 "required": [76 "OPERATOR_TOKEN",77 "COOKIE_KEY",78 "PASSWORD_PEPPER",79 "MASTER_KEY",80 ],81 },82 "durable_objects": {83 "bindings": [{ "name": "PROJECT", "class_name": "Project" }],84 },85 "workflows": [86 { "name": "answer-local", "binding": "ANSWER", "class_name": "Answer" },87 { "name": "on-push-local", "binding": "ON_PUSH", "class_name": "OnPush" },88 ],89 // The public namespace, and the private one that holds every project's90 // layer repos. Only this Worker binds the private one: the Workers91 // that serve public pages bind neither (principle 7).92 "artifacts": [93 { "binding": "ARTIFACTS", "namespace": "projects-local" },94 { "binding": "ARTIFACTS_PRIVATE", "namespace": "layers-local" },95 ],96 "d1_databases": [97 {98 "binding": "FRONT_PAGE",99 "database_name": "front-page-local",100 "database_id": "00000000-0000-0000-0000-000000000000",101 "migrations_dir": "migrations",102 },103 ],104 // KV namespace `oauth-local`.105 "kv_namespaces": [106 { "binding": "OAUTH_KV", "id": "00000000000000000000000000000000" },107 ],108 // Lane logs, the CLI's releases the platform serves, and code history109 // (why and a path's log), kept by immutable ids across isolates.110 "r2_buckets": [111 { "binding": "EVIDENCE", "bucket_name": "evidence-local" },112 { "binding": "RELEASES", "bucket_name": "releases-local" },113 { "binding": "CODE_CACHE", "bucket_name": "code-cache-local" },114 ],115 // Sign-in's mail (Cloudflare Email Service). `wrangler dev` only logs116 // each mail, code included, so no real mail leaves a local run.117 "send_email": [{ "name": "EMAIL" }],118 "worker_loaders": [{ "binding": "LOADER" }],119 // Workers AI, for the drafter (no key: the account's own).120 "ai": { "binding": "AI" },121 // Domain metrics (landings, refusals, lanes, waits, drafts) in Workers122 // Analytics Engine, one dataset per stage so no stage's counts mix with123 // another's. A dataset is made by its first write, so bootstrap makes none;124 // its name takes `_`, since SQL reads it as a table.125 "analytics_engine_datasets": [126 { "binding": "METRICS", "dataset": "metrics_local" },127 ],128 "services": [{ "binding": "SANDBOX", "service": "sandbox" }],129 // Namespace ids differ per stage, so one stage's counts never spend130 // another's.131 "ratelimits": [132 {133 "name": "CLAIM_LIMIT",134 "namespace_id": "1001",135 "simple": { "limit": 10, "period": 60 },136 },137 {138 "name": "PROPOSAL_LIMIT",139 "namespace_id": "1002",140 "simple": { "limit": 5, "period": 60 },141 },142 // Sign-in attempts per handle and per client address: the143 // sixth in a minute is refused before the password is checked.144 {145 "name": "SIGN_IN_LIMIT",146 "namespace_id": "1003",147 "simple": { "limit": 5, "period": 60 },148 },149 // Drafts per person: each one is a model call and Checker runs.150 {151 "name": "DRAFT_LIMIT",152 "namespace_id": "1004",153 "simple": { "limit": 2, "period": 60 },154 },155 ],156 "triggers": {157 "events": [158 {159 "type": "cf.artifacts.repo.pushed",160 "filter": { "namespace": "projects-local" },161 "targets": [{ "type": "workflow", "workflow_name": "on-push-local" }],162 },163 ],164 },165 "env": {166 "dev-oscabriel": {167 "vars": {168 "OPERATOR_HANDLE": "oscabriel",169 "STAGE": "dev-oscabriel",170 "LANDER_ADAPTER": "container",171 "DRAFT_MODEL": "@cf/moonshotai/kimi-k2.7-code",172 "PUBLIC_WEB_URL": "https://web-dev-oscabriel.oscargabriel.workers.dev",173 },174 "secrets": {175 "required": [176 "OPERATOR_TOKEN",177 "COOKIE_KEY",178 "PASSWORD_PEPPER",179 "MASTER_KEY",180 ],181 },182 "durable_objects": {183 "bindings": [{ "name": "PROJECT", "class_name": "Project" }],184 },185 "workflows": [186 {187 "name": "answer-dev-oscabriel",188 "binding": "ANSWER",189 "class_name": "Answer",190 },191 {192 "name": "on-push-dev-oscabriel",193 "binding": "ON_PUSH",194 "class_name": "OnPush",195 },196 ],197 "artifacts": [198 { "binding": "ARTIFACTS", "namespace": "projects-dev-oscabriel" },199 { "binding": "ARTIFACTS_PRIVATE", "namespace": "layers-dev-oscabriel" },200 ],201 "d1_databases": [202 {203 "binding": "FRONT_PAGE",204 "database_name": "front-page-dev-oscabriel",205 "database_id": "49c4ccfe-c491-49f1-9985-8296db748c4b",206 "migrations_dir": "migrations",207 },208 ],209 // KV namespace `oauth-dev-oscabriel`.210 "kv_namespaces": [211 { "binding": "OAUTH_KV", "id": "ddf5c48366af4ed7b93f183e7ceb3e9a" },212 ],213 "r2_buckets": [214 { "binding": "EVIDENCE", "bucket_name": "evidence-dev-oscabriel" },215 { "binding": "RELEASES", "bucket_name": "releases-dev-oscabriel" },216 { "binding": "CODE_CACHE", "bucket_name": "code-cache-dev-oscabriel" },217 ],218 "send_email": [{ "name": "EMAIL" }],219 "worker_loaders": [{ "binding": "LOADER" }],220 "ai": { "binding": "AI" },221 "analytics_engine_datasets": [222 { "binding": "METRICS", "dataset": "metrics_dev_oscabriel" },223 ],224 "services": [225 { "binding": "SANDBOX", "service": "sandbox-dev-oscabriel" },226 ],227 "ratelimits": [228 {229 "name": "CLAIM_LIMIT",230 "namespace_id": "1101",231 "simple": { "limit": 10, "period": 60 },232 },233 {234 "name": "PROPOSAL_LIMIT",235 "namespace_id": "1102",236 "simple": { "limit": 5, "period": 60 },237 },238 {239 "name": "SIGN_IN_LIMIT",240 "namespace_id": "1103",241 "simple": { "limit": 5, "period": 60 },242 },243 {244 "name": "DRAFT_LIMIT",245 "namespace_id": "1104",246 "simple": { "limit": 2, "period": 60 },247 },248 ],249 "triggers": {250 "events": [251 {252 "type": "cf.artifacts.repo.pushed",253 "filter": { "namespace": "projects-dev-oscabriel" },254 "targets": [255 { "type": "workflow", "workflow_name": "on-push-dev-oscabriel" },256 ],257 },258 ],259 },260 },261 // Served on the brand's own domain, never workers.dev: infra/deploy.ts262 // passes its Custom Domain and PUBLIC_WEB_URL, which name the brand, so263 // they live in infra/stages.ts. The URL here is a stand-in the deploy's264 // --var replaces. Bootstrap writes the D1 and KV ids.265 "prod": {266 "workers_dev": false,267 "vars": {268 "OPERATOR_HANDLE": "oscabriel",269 "STAGE": "prod",270 "LANDER_ADAPTER": "container",271 "DRAFT_MODEL": "@cf/moonshotai/kimi-k2.7-code",272 "PUBLIC_WEB_URL": "https://from-infra-deploy.invalid",273 },274 "secrets": {275 "required": [276 "OPERATOR_TOKEN",277 "COOKIE_KEY",278 "PASSWORD_PEPPER",279 "MASTER_KEY",280 ],281 },282 "durable_objects": {283 "bindings": [{ "name": "PROJECT", "class_name": "Project" }],284 },285 "workflows": [286 { "name": "answer-prod", "binding": "ANSWER", "class_name": "Answer" },287 {288 "name": "on-push-prod",289 "binding": "ON_PUSH",290 "class_name": "OnPush",291 },292 ],293 "artifacts": [294 { "binding": "ARTIFACTS", "namespace": "projects-prod" },295 { "binding": "ARTIFACTS_PRIVATE", "namespace": "layers-prod" },296 ],297 "d1_databases": [298 {299 "binding": "FRONT_PAGE",300 "database_name": "front-page-prod",301 "database_id": "ebcdcb90-acd6-4fa5-ad04-eb2fc5484978",302 "migrations_dir": "migrations",303 },304 ],305 // KV namespace `oauth-prod`.306 "kv_namespaces": [307 { "binding": "OAUTH_KV", "id": "bcdfcea12a6e4986a0a760e7cc9c7981" },308 ],309 "r2_buckets": [310 { "binding": "EVIDENCE", "bucket_name": "evidence-prod" },311 { "binding": "RELEASES", "bucket_name": "releases-prod" },312 { "binding": "CODE_CACHE", "bucket_name": "code-cache-prod" },313 ],314 "send_email": [{ "name": "EMAIL" }],315 "worker_loaders": [{ "binding": "LOADER" }],316 "ai": { "binding": "AI" },317 "analytics_engine_datasets": [318 { "binding": "METRICS", "dataset": "metrics_prod" },319 ],320 "services": [{ "binding": "SANDBOX", "service": "sandbox-prod" }],321 "ratelimits": [322 {323 "name": "CLAIM_LIMIT",324 "namespace_id": "1301",325 "simple": { "limit": 10, "period": 60 },326 },327 {328 "name": "PROPOSAL_LIMIT",329 "namespace_id": "1302",330 "simple": { "limit": 5, "period": 60 },331 },332 {333 "name": "SIGN_IN_LIMIT",334 "namespace_id": "1303",335 "simple": { "limit": 5, "period": 60 },336 },337 {338 "name": "DRAFT_LIMIT",339 "namespace_id": "1304",340 "simple": { "limit": 2, "period": 60 },341 },342 ],343 "triggers": {344 "events": [345 {346 "type": "cf.artifacts.repo.pushed",347 "filter": { "namespace": "projects-prod" },348 "targets": [349 { "type": "workflow", "workflow_name": "on-push-prod" },350 ],351 },352 ],353 },354 },355 },356}