docs: document quarterly budgets and fiscal quarter configuration - #6000
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughQuarterly budget resets now use ChangesQuarterly budget resets
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant BudgetHandler
participant BudgetState
participant ResetWorker
Client->>BudgetHandler: update quarterly reset_config
BudgetHandler->>BudgetState: preserve LastReset and CurrentUsage
BudgetHandler-->>Client: return updated configuration
ResetWorker->>BudgetState: evaluate new fiscal WindowStart
ResetWorker->>BudgetState: converge due budget boundary
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/deployment-guides/config-json/governance.mdx`:
- Line 128: Update the reset_config example in the governance configuration
table to use a concrete JSON number such as 4 for quarter_start_month, and
describe separately that valid values range from 1 through 12 while preserving
the existing January default.
In `@docs/features/governance/virtual-keys.mdx`:
- Line 41: Update the calendar-alignment description adjacent to the Reset
Duration list to include quarter alongside day, week, month, and year,
reflecting support for quarterly budgets.
In `@transports/config.schema.json`:
- Around line 6498-6509: Update the schema containing the reset_config property
to add an if/then conditional: when reset_config is present, require
reset_duration to equal "1Q". Preserve the existing reset_config validation and
reject configurations using it with other durations such as "1M" or "1h".
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6b9dd12c-20f7-41a2-b995-d9efd44f0c25
📒 Files selected for processing (8)
docs/deployment-guides/config-json/governance.mdxdocs/enterprise/access-profiles.mdxdocs/features/governance/budget-and-limits.mdxdocs/features/governance/virtual-keys.mdxdocs/openapi/openapi.jsondocs/openapi/schemas/management/accessprofiles.yamldocs/openapi/schemas/management/governance.yamltransports/config.schema.json
dcbff0d to
59065b6
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/governance/vkbudget_test.go`:
- Around line 216-227: Guard the type assertions in the budget response checks,
including the reads of resetConfig["quarter_start_month"] and
budget["last_reset"] near the shown block and the corresponding assertions
around the later budget validation block. Use comma-ok assertions, call t.Fatalf
with the observed value when a field is missing or has the wrong type, and only
convert or parse the values after validation.
- Around line 372-378: Update the cleanup branch around ExtractIDFromResponse in
the request-rejection test to read the virtual-key ID directly from resp’s
response body without invoking the fatal helper. Delete the returned entity when
an ID is present, then preserve the intended failure message for unexpectedly
accepted requests.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: cd495a93-fc3e-4b55-8855-e411fd7825fc
📒 Files selected for processing (8)
docs/features/governance/budget-and-limits.mdxdocs/openapi/openapi.jsondocs/openapi/schemas/management/governance.yamlplugins/governance/budgetcycle_test.gotests/governance/test_utils.gotests/governance/vkbudget_test.gotransports/bifrost-http/handlers/governance.gotransports/bifrost-http/handlers/governance_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
- docs/openapi/schemas/management/governance.yaml
- docs/openapi/openapi.json
- docs/features/governance/budget-and-limits.mdx
40ad078 to
3b145d7
Compare
1f59867 to
789e32e
Compare
3b145d7 to
b1da7d1
Compare
789e32e to
06daa9a
Compare
06daa9a to
57b0928
Compare
b1da7d1 to
178280c
Compare
Merge activity
|
The base branch was changed.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
178280c to
e5e5794
Compare
…ximhq#6000) ## Summary Adds `1Q` (quarterly) as a valid `reset_duration` for budgets and introduces a companion `reset_config` object that lets operators configure a custom fiscal quarter start month. This allows budgets to reset on non-calendar-year fiscal quarters (e.g. UK/India April, US federal October, Australia July). ## Changes - `1Q` is added to the `reset_duration` enum on budget schemas across the OpenAPI spec, config JSON schema, and all documentation. Rate limit schemas intentionally retain the existing enum without `1Q`, since quarterly token/request limits are not supported. - A new optional `reset_config` object with a single `quarter_start_month` field (integer 1–12) is added to budget create/update requests and the `Budget` response schema. It is only valid when `reset_duration` is `1Q`; the API rejects it on any other window. - `quarter_start_month` sets the first month of Q1. Omitting it defaults to January (standard calendar quarters: Jan/Apr/Jul/Oct). Because quarter boundaries repeat every three months, only the value modulo 3 meaningfully shifts reset dates; the eight non-modulo-equivalent months (e.g. February) genuinely move boundaries. - Calendar-aligned quarterly budgets reset on the 1st of the relevant month at 00:00 UTC. A non-calendar-aligned quarterly budget ignores the fiscal calendar and rolls on a 90-day window from creation. - Changing `quarter_start_month` on a live calendar-aligned budget moves `last_reset` to the new fiscal boundary but **preserves** current accumulated spend. - The `ResetDuration` schema in `accessprofiles.yaml` is split into `BudgetResetDuration` and `RateLimitResetDuration` to enforce the distinction between budget and rate-limit windows at the schema level. - Documentation in `budget-and-limits.mdx`, `governance.mdx`, `virtual-keys.mdx`, and `access-profiles.mdx` is updated to cover the new duration, the `reset_config` field, fiscal quarter examples, and calendar-alignment behaviour for quarterly budgets. ## Type of change - [ ] Bug fix - [x] Feature - [ ] Refactor - [x] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [x] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [x] Docs ## How to test 1. Create a budget with `"reset_duration": "1Q"` and no `reset_config` — verify it resets on standard calendar quarters (Jan/Apr/Jul/Oct). 2. Create a budget with `"reset_duration": "1Q"` and `"reset_config": { "quarter_start_month": 4 }` — verify reset dates shift to Apr/Jul/Oct/Jan. 3. Attempt to create a budget with `"reset_duration": "1M"` and a `reset_config` body — verify the API returns a validation error. 4. Attempt to create a rate limit with `"reset_duration": "1Q"` — verify the API rejects it. 5. On a live calendar-aligned quarterly budget, update `quarter_start_month` — verify `last_reset` moves to the new boundary and current usage is unchanged. 6. Validate the OpenAPI spec and config JSON schema parse without errors. ```sh go test ./... ``` ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations None. This change is additive and scoped to budget configuration; no authentication, secrets, or PII are affected. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [x] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
Adds
1Q(quarterly) as a validreset_durationfor budgets and introduces a companionreset_configobject that lets operators configure a custom fiscal quarter start month. This allows budgets to reset on non-calendar-year fiscal quarters (e.g. UK/India April, US federal October, Australia July).Changes
1Qis added to thereset_durationenum on budget schemas across the OpenAPI spec, config JSON schema, and all documentation. Rate limit schemas intentionally retain the existing enum without1Q, since quarterly token/request limits are not supported.reset_configobject with a singlequarter_start_monthfield (integer 1–12) is added to budget create/update requests and theBudgetresponse schema. It is only valid whenreset_durationis1Q; the API rejects it on any other window.quarter_start_monthsets the first month of Q1. Omitting it defaults to January (standard calendar quarters: Jan/Apr/Jul/Oct). Because quarter boundaries repeat every three months, only the value modulo 3 meaningfully shifts reset dates; the eight non-modulo-equivalent months (e.g. February) genuinely move boundaries.quarter_start_monthon a live calendar-aligned budget moveslast_resetto the new fiscal boundary but preserves current accumulated spend.ResetDurationschema inaccessprofiles.yamlis split intoBudgetResetDurationandRateLimitResetDurationto enforce the distinction between budget and rate-limit windows at the schema level.budget-and-limits.mdx,governance.mdx,virtual-keys.mdx, andaccess-profiles.mdxis updated to cover the new duration, thereset_configfield, fiscal quarter examples, and calendar-alignment behaviour for quarterly budgets.Type of change
Affected areas
How to test
"reset_duration": "1Q"and noreset_config— verify it resets on standard calendar quarters (Jan/Apr/Jul/Oct)."reset_duration": "1Q"and"reset_config": { "quarter_start_month": 4 }— verify reset dates shift to Apr/Jul/Oct/Jan."reset_duration": "1M"and areset_configbody — verify the API returns a validation error."reset_duration": "1Q"— verify the API rejects it.quarter_start_month— verifylast_resetmoves to the new boundary and current usage is unchanged.go test ./...Breaking changes
Related issues
Security considerations
None. This change is additive and scoped to budget configuration; no authentication, secrets, or PII are affected.
Checklist
docs/contributing/README.mdand followed the guidelines