Log the account's snapshot quota utilization after verifying a build - #1513
Closed
CameronHall wants to merge 1 commit into
Closed
CameronHall wants to merge 1 commit into
CameronHall wants to merge 1 commit into
Conversation
Query the account's current billed snapshot usage and plan limit (monthly limit plus bonus usage), log it after the build is verified, and keep it on ctx so it lands in the diagnostics file. The query is fail-soft: if the API doesn't expose these fields to the project token, or the request fails for any reason, it is logged at debug level and the build is unaffected. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
After a build is verified, the CLI now logs the account's billed snapshot usage for the current billing period against the plan's included snapshots:
The figures are also kept on
ctx.accountUsage, so they show up in the--diagnostics-fileoutput.Why
Today you can only see quota usage in the web app's billing page. Accounts that run over their included snapshots often only find out when the invoice arrives. Showing usage in every CI log makes overage trends visible to the engineers who cause them, at the point where they can do something about it.
How
A new
AccountUsageQuery(node-src/tasks/verify/getAccountUsage.ts) reads the same fields the billing page uses:account.currentUsage { totalFinalBillableCount from to }account.subscription { monthlyUsageLimit bonusUsage }Utilization is
totalFinalBillableCount / (monthlyUsageLimit + bonusUsage). When the plan has no monthly limit, only the count is shown.This is a separate, fail-soft query rather than new fields on
VerifyBuildQuery. These fields may not be exposed to project-token auth yet (see theauthorizedBuildFieldsViaAppCodenote onVerifyBuildQuery). Adding them there would turn a GraphQL authorization error into a failed build. Here, any error, including an unauthorized field, is logged at debug level, nothing is printed, and the build carries on. It runs withretries: 0, so it never adds retry delay to a build.I could only check the field shapes against the web app's session-authenticated billing query. Please confirm whether
app.account.currentUsageandapp.account.subscription { monthlyUsageLimit bonusUsage }can be read with a project/app token. If they can't, this PR stays harmlessly silent until they're allow-listed server-side.Testing
getAccountUsage:undefinedand logs at debugapplyVerifyOutputtest forctx.accountUsage.CLI/Messages/Info: within limit, over limit, no limit.yarn tsc --noEmitand eslint are clean; the verify suites pass.🤖 Generated with Claude Code