Enforce a global daily enrichment spend cap - #29
Conversation
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
| // Staging is the only submission-enabled environment today. Production config | ||
| // preparation remains testable with its deliberate empty vars block, while the | ||
| // runtime still fails closed if enrichment is invoked without this value. | ||
| const requiredEnvironmentVars = environmentName === "staging" | ||
| ? ["BENCHMAX_ENRICHMENT_DAILY_MICROUSD_BUDGET"] | ||
| : []; | ||
| for (const key of requiredEnvironmentVars) { | ||
| if (!/^[1-9][0-9]*$/.test(environment.vars?.[key] ?? "")) { | ||
| throw new Error( | ||
| `main Worker ${environmentName} environment must set a positive integer ${key} before deployment`, | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
🔍 Production and local deployments end up with no configured cap, so previews stay pending indefinitely
requiresEnrichmentBudget is true only for the literal staging environment or an environment with at least one route. Production in wrangler.jsonc:149-153 has "routes": [] and "vars": {}, so a production deploy passes this check while shipping no BENCHMAX_ENRICHMENT_DAILY_MICROUSD_BUDGET. At runtime configuredDailyEnrichmentBudget() then throws on every claim, and claimShowcaseEnrichment (lib/data/showcase-enrichment.ts:202-222) permanently defers every preview and writes one configuration-deferral audit row per enrichment per UTC day. The same applies to local development, where .env.example ships the key blank. This is a deliberate fail-closed posture, but it means preview enrichment is silently non-functional anywhere the key is absent, with no operator-visible surface other than audit rows (the operations dashboard reports judgeBudget only, lib/data/operations.ts:125-135); consider surfacing the enrichment budget/deferral state there.
Was this helpful? React with 👍 or 👎 to provide feedback.
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Adds an explicit UTC daily microUSD cap before preview-enrichment claims. Over-budget enrichments remain queued and public previews remain pending; deferral audits are deduplicated per enrichment and UTC day. Wires the staging cap and deployment contracts, with enrichment coverage and a green full gate.\n\nStaging value: 31,200 microUSD/day, derived from eight 120-second maximum enrichment sandboxes at the measured 117,000 microUSD/hour rate.\n\nOwner merges after Devin review.