Skip to content

fix(cost): enforce scan budgets from verified usage - #465

Merged
mldangelo-oai merged 192 commits into
mainfrom
mdangelo/codex/enforce-verifiable-scan-budgets
Nov 4, 2026
Merged

mldangelo-oai merged 192 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

Verify a requested scan cost limit against the scan's indexed Codex usage while work is running and before returning a completed result. The workbench already knows the scan window, thread relationships, worker registrations, and token receipts. Reusing it removes the parallel SDK accounting engine and the worker, CI, and packaging changes that accumulated on the original branch.

Changes

  • Stop when measured scan-owned spending exceeds the requested limit. A measured subtotal can stop additional work while some receipts are pending. Both normal completion and recovery of a budget-exhausted Deep Scan require complete usage.
  • Include custom validation, Deep Scan comparison turns, worker retries and descendants. Preserve late legacy cache classifications when the scan owns them, and reject ambiguous usage across the scan boundary.
  • An append-only workbench migration retains a missing worker attempt after a later retry succeeds. On upgrade, existing retried runs with too few recorded thread identities remain partially measured.
  • Read an indexed rollout or its compressed sibling, verify thread identity, and keep usage from the other measured sessions if one receipt is missing or truncated.
  • Keep optional activity reporting independent of monetary accounting. An unrelated unreadable session or an unregistered worker lookalike cannot spend the scan budget.

Testing

  • 406 SDK cost, scan-usage, policy and completion-accounting tests passed. Another 29 focused budget integration tests and the SDK/MCP type checks passed.
  • The complete Python plugin suite passed locally with 3,829 tests and 417 subtests passing, and 92 skips. Four compressed-rollout cases passed separately on Python 3.14. All 43 Node workbench database tests passed, including historical schema upgrades.
  • Portable plugin lint, formatting, CI-helper build, compatibility checks and SDK/plugin build.

Risk and rollout

Cost limits use the existing estimated short-context model prices. In-flight requests can exceed the limit. Older Python runtimes need the optional backports.zstd package to verify compressed rollouts. Missing indexed files with no compressed sibling, mismatched identities, or incomplete receipts prevent budgeted completion. Without a limit, usage is best effort.

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

chatgpt-codex-connector Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

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

Reviewed commit: a147e46ca9

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 Resolved
Comment thread sdk/typescript/src/cost.ts Resolved
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

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

Reviewed commit: 95b3782aef

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 Resolved
Comment thread sdk/typescript/src/cost.ts Resolved
@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

chatgpt-codex-connector Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

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

Reviewed commit: ce460fe36a

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.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, b9f37a9b17ed5f3c9122b25c6316ba01cc2ffde0.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

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

Reviewed commit: b9f37a9b17

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: b9f37a9b17

ℹ️ 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 Resolved
Comment thread sdk/typescript/tests-ts/cost.test.ts Resolved
Comment thread sdk/typescript/src/cost.ts Resolved
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: c0bf9e21d2

ℹ️ 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

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ 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 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: 4622f68ef7

ℹ️ 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 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: 41d0613491

ℹ️ 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".

Copy link
Copy Markdown
Collaborator Author

@codex review. I merged main and addressed the earlier findings in f89b6c1. Please take another look at the updated changes.

Copy link
Copy Markdown
Collaborator Author

@codex review. The final change removes a local dependency symlink caught by CI. The current head is 1d1e76f.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 1d1e76f78e

ℹ️ 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".

@mldangelo-oai
mldangelo-oai merged commit c9cb6b4 into main Nov 4, 2026
74 checks passed
@mldangelo-oai
mldangelo-oai deleted the mdangelo/codex/enforce-verifiable-scan-budgets branch November 4, 2026 23:59
@github-actions github-actions Bot mentioned this pull request Nov 5, 2026
3 tasks done
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.

5 participants