You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Bulk Budget Reset at Tenant or Parent-Scope Level #99
Currently, the cycles protocol requires an individual reset call for every budget within a tenant. In a complex multi-scope, multi-budget system, this creates significant operational overhead. When a new billing period or execution cycle begins, a user must:
Query all existing budgets under a tenant.
Iterate through them to issue separate reset commands.
Proposed solution
All budgets are already connected to a tenant-level root scope. Since the hierarchy is already established, the system should ideally support a top-down command that respects these existing links.
I propose adding a Bulk Reset capability to the Admin API. This could be implemented in two ways:
Tenant-Level Reset: A single operation that resets all budgets associated with that tenant ID.
Cascading Scope Reset: An optional flag on the budget management endpoint that recursively resets all child budgets nested under that scope.
Alternatives considered
Client-Side Iteration: While budgets can be reset individually, a native recursive reset is more efficient. It reduces network overhead and updates the entire hierarchy through a single protocol action.
Thanks for raising this — it's a real gap and the operational overhead gets worse fast at 1k+ budgets per tenant.
One shape worth considering before we commit to a dedicated resetBudgets endpoint: a unified filter-spec bulk-ops endpoint that subsumes reset and the other per-budget operations we already expose (CREDIT, DEBIT, RESET, RESET_SPENT, REPAY_DEBT).
Rough shape:
POST /v1/admin/budgets:bulk
{
"filter": {
"tenant_id": "tenant_abc", // or
"scope_id": "scope_xyz", // with optional cascade
"cascade": true,
"utilization_min": 0.9, // composable with other filters
"...": "..."
},
"operation": "RESET_SPENT",
"amount": null, // operation-specific fields
"spent": 0
}
Why unified vs. a dedicated reset endpoint:
Covers this use case and future asks ("credit all budgets in scope X," "repay debt across a subtree," etc.) without a new endpoint each time.
One place to put the authorization, rate-limit, audit-log, and idempotency contract — vs. duplicating them per operation.
Matches the cross-cutting "bulk ops by filter spec" pattern the dashboard is already building for tenant suspend/resume and webhook pause/resume (see the Phase 4 rate-limited bulk runner).
Tradeoffs to call out:
Slightly more surface to validate on the server (operation-discriminated payload). Mitigable with a tagged-union schema in the YAML spec.
Cascading semantics across a scope tree still need to be specified carefully (ordering, partial-failure behavior, whether child budgets of a different tenant are ever in scope — probably not).
Response shape needs to handle long-running cascades gracefully: async job id + status endpoint vs. synchronous counts. For 10k-budget tenants, async is safer.
If this direction resonates, happy to open a spec PR that pins down the YAML and the failure/ordering semantics. If you'd rather keep a dedicated budgets:reset for simplicity, that works too — just wanted to flag the reuse opportunity before we lock it in.
Status update — foundational bulk-action infrastructure shipped in v0.1.25.26
The admin server just shipped two bulk-action endpoints in PR #109 (spec v0.1.25.21 → server v0.1.25.26):
POST /v1/admin/tenants/bulk-action — SUSPEND | REACTIVATE | CLOSE
POST /v1/admin/webhooks/bulk-action — PAUSE | RESUME | DELETE
Both use the filter-spec shape discussed above (status / parent_tenant_id / search on tenants; tenant_id / status / event_type / search on webhooks) and share a common envelope:
expected_count preflight → 409 COUNT_MISMATCH (no writes)
500-row hard cap → 400 LIMIT_EXCEEDED
15-minute idempotency replay via shared IdempotencyStore (Redis)
Per-row outcome envelope: succeeded[] / failed[] / skipped[] with BulkActionRowOutcome
AdminKeyAuth only
What this unlocks for this issue: the reusable pieces (BulkActionRowOutcome, IdempotencyStore, filter→count→gate→apply pattern, matchForBulk cap+1 repo sentinel) now exist and are test-covered (≥95% JaCoCo, 646/646 tests). Extending to /v1/admin/budgets/bulk-action for RESET / RESET_SPENT / CREDIT / DEBIT / REPAY_DEBT is mostly a matter of:
Adding the spec in cycles-protocol (schemas for BudgetBulkFilter, operation-discriminated request, reusing BulkActionRowOutcome).
Cloning the tenant/webhook bulk-action pattern onto BudgetController, backed by a BudgetRepository.matchForBulk.
Deciding cascade semantics across scope trees (the main spec-design question flagged in the earlier comment — still open).
Remaining design questions (unchanged from the earlier comment — calling out so this doesn't get lost):
Cascade ordering + partial-failure behavior across scope subtrees.
Cross-tenant safety on scope-cascade: child budgets under a different tenant MUST NOT be in scope.
Sync counts vs. async job-id for large cascades (10k+ budgets/tenant).
Keeping this issue open — the infrastructure is ready, but the budget-specific spec and cascade semantics haven't been designed yet. When the spec PR lands on cycles-protocol, the server implementation will slot into the same pattern as tenants/webhooks.
Activity
amavashev commentedon Apr 16, 2026
Thanks for raising this — it's a real gap and the operational overhead gets worse fast at 1k+ budgets per tenant.
One shape worth considering before we commit to a dedicated
resetBudgetsendpoint: a unified filter-spec bulk-ops endpoint that subsumes reset and the other per-budget operations we already expose (CREDIT,DEBIT,RESET,RESET_SPENT,REPAY_DEBT).Rough shape:
Why unified vs. a dedicated reset endpoint:
Tradeoffs to call out:
If this direction resonates, happy to open a spec PR that pins down the YAML and the failure/ordering semantics. If you'd rather keep a dedicated
budgets:resetfor simplicity, that works too — just wanted to flag the reuse opportunity before we lock it in.amavashev commentedon Apr 17, 2026
Status update — foundational bulk-action infrastructure shipped in v0.1.25.26
The admin server just shipped two bulk-action endpoints in PR #109 (spec v0.1.25.21 → server v0.1.25.26):
POST /v1/admin/tenants/bulk-action—SUSPEND | REACTIVATE | CLOSEPOST /v1/admin/webhooks/bulk-action—PAUSE | RESUME | DELETEBoth use the filter-spec shape discussed above (status / parent_tenant_id / search on tenants; tenant_id / status / event_type / search on webhooks) and share a common envelope:
expected_countpreflight → 409COUNT_MISMATCH(no writes)LIMIT_EXCEEDEDIdempotencyStore(Redis)succeeded[] / failed[] / skipped[]withBulkActionRowOutcomeWhat this unlocks for this issue: the reusable pieces (
BulkActionRowOutcome,IdempotencyStore, filter→count→gate→apply pattern,matchForBulkcap+1 repo sentinel) now exist and are test-covered (≥95% JaCoCo, 646/646 tests). Extending to/v1/admin/budgets/bulk-actionforRESET/RESET_SPENT/CREDIT/DEBIT/REPAY_DEBTis mostly a matter of:cycles-protocol(schemas forBudgetBulkFilter, operation-discriminated request, reusingBulkActionRowOutcome).BudgetController, backed by aBudgetRepository.matchForBulk.Remaining design questions (unchanged from the earlier comment — calling out so this doesn't get lost):
Keeping this issue open — the infrastructure is ready, but the budget-specific spec and cascade semantics haven't been designed yet. When the spec PR lands on
cycles-protocol, the server implementation will slot into the same pattern as tenants/webhooks.spec(admin): v0.1.25.26 — bulk-action budget endpoint
feat(v0.1.25.29): bulk-action endpoint on budgets (spec v0.1.25.26)