Repository navigation
feat(runs): per-user daily ceiling (ADR-022 D5) — the second-hosted-seat prerequisite - #1091
Merged
Merged
Conversation
… key Forward-only (the field never existed; no backfill possible). Sparse index on (userId, startedAt) so the ceiling is one indexed count, not a hot-path join through AgentInstallation.
…uilt Keyed on installedBy, summed across ALL the user's hosted installs; default 120/day via AGENT_USER_DAILY_RUN_CEILING (0 disables). Two deliberate reversals from the per-install cap it sits beside: the decline is TRUTHFUL (status failed, errorKind user_ceiling — never the empty-success shape the plan called out), and a count failure fails CLOSED, because a runaway guard and a spend ceiling have opposite safe directions. Unattributable installs (no installedBy) proceed with a warning — bricking legacy seats is not a spend control. Runs now stamp userId at creation.
Stamp, truthful decline before any model call, user-keyed count with no per-install keys, fail-closed on count failure, unattributable-proceeds, under-ceiling-proceeds, and the 0-disables escape hatch. Written failing against main, then implemented — the dailyCap and claims suites pin that the existing cap's fail-open semantics are untouched.
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.
The plan's own gate on Phase 2: 'a per-user daily ceiling is a prerequisite for offering the second hosted seat. Not a fast-follow.' Built TDD-first at two seams: AgentRun stamps userId from installedBy (forward-only, sparse-indexed), and runAgent declines truthfully before any model call when the user's runs-today across ALL their hosted installs meet the ceiling (default 120, env-tunable, 0 disables). Fail-closed on count failure — deliberately the opposite direction of the per-install cap, which keeps its runaway-guard fail-open semantics untouched (pinned by the existing suites, 22/22 green). With this merged, the hire endpoint can open Recorder as the second seat without 'per user' silently becoming 'per user per persona'.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8