Skip to content

Enforce a global daily enrichment spend cap - #29

Merged
ItsJazii merged 8 commits into
mainfrom
codex/enrichment-daily-spend-cap
Aug 12, 2026
Merged

Enforce a global daily enrichment spend cap#29
ItsJazii merged 8 commits into
mainfrom
codex/enrichment-daily-spend-cap

Conversation

@ItsJazii

@ItsJazii ItsJazii commented Aug 12, 2026

Copy link
Copy Markdown
Owner

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.


Open in Devin Review

Co-authored-by: Codex <codex@openai.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: Codex <codex@openai.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: Codex <codex@openai.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

Open in Devin Review

Comment thread scripts/phase2-preflight.mjs Outdated
Comment thread scripts/prepare-main-deploy.mjs Outdated
Comment on lines +18 to +30
// 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`,
);
}
}

@devin-ai-integration devin-ai-integration Bot Aug 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Co-authored-by: Codex <codex@openai.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: Codex <codex@openai.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: Codex <codex@openai.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: Codex <codex@openai.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: Codex <codex@openai.com>
@ItsJazii
ItsJazii merged commit 3cb085d into main Aug 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant