Skip to content

feat(runs): per-user daily ceiling (ADR-022 D5) — the second-hosted-seat prerequisite - #1091

Merged
lilyshen0722 merged 3 commits into
mainfrom
feat/per-user-daily-ceiling
Aug 22, 2026
Merged

lilyshen0722 merged 3 commits into
mainfrom
feat/per-user-daily-ceiling

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

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

… 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.
@lilyshen0722
lilyshen0722 merged commit b968290 into main Aug 22, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the feat/per-user-daily-ceiling branch August 22, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant