Repository navigation
app/: per-organization credit override for staff, with its reminder email and heartbeat (sc-8900) - #144
Merged
Conversation
VisualCIdocspring/visualci · build #215 · 2 added, 339 unchanged · approved by visualci features agent for Nathan Broadbent This PR vs base: 8 changed since #187, across 2 builds
docspring/visualci · journeys · build #213 · 12 unchanged · no changes This PR vs base: nothing since #188, across 2 builds Updated as builds change. Agents can review with VisualCI's MCP tools. |
…mail and heartbeat (sc-8900) Staff raise an organization's monthly credits until a date (a big open source project beyond the 1M pool): the override replaces the plan's monthly allowance while it applies (never lowering it), falls back on its own the day after `until`, is set with `org:set-credits` (and the admin MCP tool, next), records every change in credit_override_audit, shows on the billing page by its public label, and its organization's admins get an email a week before it ends (`credits:override-reminders`, daily, VISUALCI_CREDIT_OVERRIDES_HEARTBEAT_*).
ndbroadbent
force-pushed
the
app-credit-override
branch
from
December 3, 2026 19:11
b9e6c0d to
b5b5c69
Compare
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.
Staff can raise an organization's monthly credits until a date, for example for a big open source project that needs more than the standard 1,000,000 open source pool (sc-8900, from marketing). This is PR (c) of the staff tooling port. The admin MCP tool
set_credit_overridecomes with or after the/mcp/adminPR, which callsdomain::credit_overrides::set/clear.Design
2026_12_04_100000_credit_overrides):credit_overridesholds at most one override per organization:credits,until(a UTC date, inclusive),label,reason,set_by.credit_override_audithas a row for every change: user (or NULL for the console),actor(staff email orconsole),old_allowance,new_allowance, the override set (all NULL when cleared),reasonandcreated_at.Plan::included_credits), and nothing else.max(plan, override), so it only ever raises it.credits_left,out_of_credits,take(spending),blocked, the out-of-credits build error andusage.untilthe organization is back on its plan's allowance and no job has to run. Credits already used that month still count.domain::credit_overrides::set(Change { org, credits, until, label, reason }, Actor::Staff(&user) | Actor::Console)andclear(org, reason, actor).laravel::Result<Result<serde_json::Value, String>>. The innerErris a refusal to show as it is: an unknown organization, a reason under 5 characters, an end date not after today, credits that don't raise the plan's allowance, an unlimited plan, or a label over 60 characters.{org, override, allowance, was: {allowance, override}}.org:set-credits --org <slug> --credits <n> --until <YYYY-MM-DD> [--label "..."] --reason "...", and--clear --reason "..."./api/ui, MCPget_organization):included_creditsis the allowance in effect.credit_override: {credits, until, label}appears only while an override applies, so existing goldens don't change. Staff'sreasonis never shown to the customer.credit_override_ending, goes to the organization's admins. It has no opt-out and is in the staff email preview's samples.credits:override-remindersruns daily at 06:00 UTC. It queues the email for every override whoseuntilis within 7 days.VISUALCI_CREDIT_OVERRIDES_HEARTBEAT_URL/_TOKEN(Heartbeat::CreditOverrides), and a run that errors fails the heartbeat..env.examplewere regenerated.What changes in this PR's VisualCI build
screenshots:seedgives Side project (Free) an override: 3,000,000 a month until 2027-06-01, labelled "Open source sponsorship".… / 3,000,000) changes wherever that page is captured.credit_override_ending-acme-s-extra-visualci-credits-run-until.Tests (on agents-build-1)
cargo fmt --all --checkandcargo clippy --locked --workspace --all-targets -- -D warningsare clean.cargo test --locked -p visualci-app: 261 passed. The rest of the workspace passes too.app/tests/credit_overrides.rs:out_of_credits,blocked);org:set-creditssets, clears, and refuses an unknown organization, a past date and a missing reason;screenshots_seedtest checks the seeded override.pnpm buildandpnpm testpass (44 tests, including the newcredit-override.test.ts), andnode scripts/skills.mjs --checkpasses.Deploy note
The heartbeat only alerts once its Gatus external endpoint exists and the
VISUALCI_CREDIT_OVERRIDES_HEARTBEAT_*secrets are set. That needs an infra change, like the other heartbeats.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.