Skip to content

fix(cost): enforce verifiable scan spending limits - #465

Draft
mldangelo-oai wants to merge 3 commits into
mainfrom
mdangelo/codex/enforce-verifiable-scan-budgets
Draft

fix(cost): enforce verifiable scan spending limits#465
mldangelo-oai wants to merge 3 commits into
mainfrom
mdangelo/codex/enforce-verifiable-scan-budgets

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Enforce explicitly requested scan spending limits when final root or delegated-worker token usage cannot be verified.

Fixes #223. Related prior work: #224.

Changes

  • Fail budgeted scans when attributable root or worker usage is missing, unreadable, incomplete, unavailable, or unpriceable.
  • Detect disappearing tracked sessions while continuing to ignore unrelated sessions.
  • Reconcile final root and delegated-worker usage and make repeated tracker finalization idempotent.
  • Preserve best-effort cost tracking and scan completion when no spending limit was requested.
  • Verify delegated-worker completion and ownership, including missing root metadata, replayed or restarted workers, cancellation, and incomplete final events, without interrupting ordinary polling or failed-scan accounting.

Testing

  • bun test --timeout 30000 tests-ts/cost.test.ts — 82 passed, 171 assertions.
  • Focused Bedrock and budget API regressions — 16 passed, 120 assertions.
  • bun test --timeout 30000 tests-ts/api.test.ts — 117 passed, 1,769 assertions.
  • pnpm run types — passed.
  • pnpm run format and git diff HEAD^ HEAD --check — passed.
  • Simulated effective-root execution — seven permission-dependent tests skipped safely.

Risk and rollout

Scans with an explicit spending limit now fail when their final cost cannot be verified instead of succeeding with understated or unknown usage. Scans without explicit limits retain best-effort tracking. No arbitrary retry or input-size limits are added. This overlaps the unreadable-session work in #224 but also covers final worker attribution, disappearing sessions, and explicit-limit enforcement.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions github-actions Bot added the bug Something isn't working label Aug 15, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: a147e46ca9

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a147e46ca9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/tests-ts/cost.test.ts Outdated
Comment thread sdk/typescript/src/cost.ts Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 95b3782aef

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95b3782aef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/src/cost.ts
Comment thread sdk/typescript/src/cost.ts
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: ce460fe36a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: ce460fe36a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An unreadable Codex session log fails every cost poll for the rest of the scan, and can fail a scan that succeeded

1 participant