Skip to content

FIX: exclude confirmed ChatGPT Auto-review checks from quota learning - #109

Merged
merefield merged 4 commits into
mainfrom
fix/guardian-plan-usage
Nov 18, 2026
Merged

merefield merged 4 commits into
mainfrom
fix/guardian-plan-usage

Conversation

@merefield

@merefield merefield commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Why

A native Guardian safety check on a ChatGPT session produced a valid, exact token record for the requested model codex-auto-review. Codexometer looked it up in the standard API price table, emitted UNPRICED USAGE and discarded an otherwise usable quota-learning interval. The reported response had a matching checkpoint for the main Codex limit on a recognised ChatGPT plan.

OpenAI’s ChatGPT plan guidance distinguishes plan-exempt Auto-review from ordinary usage. That is not a published $0 API rate. Codex’s pinned integration tests also show why the reviewer model name alone is not proof of ChatGPT billing.

What changes

  • Both Quota interfaces use the shared accounting fix. A confirmed plan safety check contributes neither API-equivalent spend nor an unpriced-call warning. Sessions still records its tokens, output and activity. Paid responses in the same learning interval keep their normal value.
  • Require native Guardian provenance, the OpenAI provider, the reviewer model and a complete main-Codex token checkpoint with a known plan. Pair an exact response by thread, turn, adjacent rollout ordinal and matching usage; allow a checkpoint split across two polls. A valid legacy token event can supply its own evidence. No current-login lookup, transcript inspection or new persistent data.
  • If evidence is missing, keep the unpriced diagnostic and explain why. A matched daemon reroute to a different model is priced normally. Benchmark pricing, the model price table and official quota percentages are unchanged.

Verification

  • Synthetic regression coverage for exact/legacy responses, a split append, model rerouting, ordinary sessions using the same slug, custom providers, missing/malformed plan data, mismatched turn/ordinal/usage, and subsequent paid usage and replay.
  • go test -race ./internal/codex ./internal/quotaestimate; go test ./...; go vet ./...; production duplication ratchet.

Scoped duplication cleanup

Three separate refactors share the DigBench interrupt handshake, slash-menu keyboard/wheel movement, and history button layout and hitboxes. DigBench cancellation and timeout outcomes remain distinct; command confirmation, inline filtering, and the full/compact history controls are unchanged. Regression tests cover unrelated thread and turn completions as well as input handling.

On the pinned production scan, exact-50 falls from 29 to 25 clone pairs (267 to 233 duplicated lines), and exact-100 from 2 to 1. The normalised scans also improve: 136 to 131 at 50 tokens, and 10 to 9 at 100. The tracked baseline is left to main CI.

Copilot AI 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.

🔵 Needs a closer look

Approval should wait for human validation because the quota exemption relies on pinned Codex rollout ordinals, the token_count rate-limit schema, and daemon/local polling behavior that cannot be verified here through the declared race and full tests.

No open issues 🎉

What changed in this PR

This PR updates quota-learning accounting so confirmed ChatGPT Guardian Auto-review usage remains in Sessions telemetry while being excluded from API-equivalent spend and unpriced-usage diagnostics.

Changes:

  • Validate Guardian provenance, OpenAI provider metadata, reviewer model, recognized plan, and matching token checkpoints before applying the exemption.
  • Handle exact and legacy token records, split checkpoints, reroutes, replay, mismatches, and subsequent paid usage while preserving normal pricing when evidence is incomplete.
  • Document the behavior and add comprehensive regression coverage.
File Description
README.md Documents confirmed Auto-review quota-learning exclusions and evidence requirements.
intro-post.md Updates user-facing guidance for Auto-review telemetry and quota accounting.
internal/​codex/​service_tier.go Implements Auto-review provenance detection, plan validation, and exempt quota accounting.
internal/​codex/​service_tier_test.go Updates reconciliation test callers for the new readiness parameter.
internal/​codex/​live_usage.go Tracks provider metadata, plan checkpoints, review evidence, and deferred reconciliation across polls.
internal/​codex/​live_usage_test.go Updates existing live-usage reconciliation test callers.
internal/​codex/​live_usage_guardian_test.go Adds regression coverage for Guardian Auto-review quota-accounting scenarios.
internal/​codex/​live_usage_exact.go Associates exact responses with adjacent matching token checkpoints and review evidence.

Review effort: Lite

Copilot AI 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.

🔵 Needs a closer look

The plan-type switch omits valid emitted variants, so eligible Guardian checkpoints can still produce unpriced usage until those variants and regression cases are added.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Recognize all supported plan types in the usage exemption

internal/​codex/​service_tier.go:39

This switch is not exhaustive for the plan_type values emitted in token_count.rate_limits: Codex rust-v0.169.0 also defines free_workspace, education, quorum, and k12 (with education distinct from edu). A valid Guardian checkpoint for one of those plans will therefore leave planReviewEvidence false and still produce UNPRICED USAGE, so the exemption remains incomplete. Include the supported plan variants and add regression cases for them.

Review effort: Lite

@merefield
merefield merged commit 831c8ad into main Nov 18, 2026
9 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.

2 participants