Skip to content

feat(coderd/x/chatd): record capacity wait as a lifecycle stage - #28973

Closed
jscottmiller wants to merge 1 commit into
scott/chatd-stages/5-turn-spanfrom
scott/chatd-stages/6-capacity-wait
Closed

jscottmiller wants to merge 1 commit into
scott/chatd-stages/5-turn-spanfrom
scott/chatd-stages/6-capacity-wait

Conversation

@jscottmiller

@jscottmiller jscottmiller commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #29771. Closed in favor of the reduced stack #29773.

The acquisition loop remembers when each chat was first refused a concurrent-agent capacity slot and, when the chat is acquired, records a capacity_wait stage from that refusal. Chats admitted on their first attempt record nothing. The stage is recorded before the runner is spawned, so a failed spawn still records the wait.

Bookkeeping: the wait start is dropped when a candidate is skipped for a non-capacity reason (live runner, archived, not runnable) and pruned only when the candidate batch is shorter than its limit, since a chat missing from a truncated batch is still waiting. The map is touched only by the acquisition goroutine.

capacity_wait is a per-occurrence stage only: it is measured before the turn exists and its window lies inside acquisition, so the turn accounting in PR 7 does not categorize it. ARCHITECTURE.md gains a "Capacity wait" section.

Multi-replica caveat. The refusal history is per worker and in memory while the limit is deployment-wide, so the value is a lower bound: a chat refused on one replica and acquired by another is measured from the acquiring replica's first refusal, or not at all if it was admitted first try, and a restart discards history. All replicas wake together on the chat:ownership hint and refusal suppresses it, so retries fall back to each replica's 30s acquisition timer and the undercount is bounded by about one interval rather than growing with replica count. An exact measurement would need the first refusal persisted on the chat row.

🤖 This PR was generated by Coder Agents on behalf of @jscottmiller.

@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 773324f to b901eb5 Compare September 9, 2026 23:19
@jscottmiller jscottmiller added the experimental Changes that might not necessarily be merged, until its approved to proceed with. label Sep 11, 2026
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from b901eb5 to 09ef319 Compare September 11, 2026 02:25
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 09ef319 to 388e95d Compare September 11, 2026 19:17
@jscottmiller jscottmiller removed the experimental Changes that might not necessarily be merged, until its approved to proceed with. label Sep 14, 2026
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 388e95d to 8a9b2b9 Compare September 14, 2026 20:16
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 8a9b2b9 to e088fd5 Compare September 14, 2026 22:06
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from e088fd5 to 374d503 Compare September 15, 2026 21:39
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 374d503 to 86f721b Compare September 16, 2026 03:12
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 86f721b to 6021e64 Compare September 17, 2026 16:55
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 6021e64 to d5a1357 Compare September 17, 2026 20:31
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from d5a1357 to 2e4f1de Compare September 17, 2026 21:26
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 2e4f1de to 68dc259 Compare September 21, 2026 00:09
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 68dc259 to 2e9bde2 Compare September 21, 2026 22:52
@linear-code

linear-code Bot commented Sep 22, 2026

Copy link
Copy Markdown

CODAGT-1102

@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 2e9bde2 to 09bc9cf Compare September 23, 2026 01:37
The acquisition loop remembers when each chat was first refused a
capacity slot and, on the acquisition that follows, emits a
capacity_wait stage measured from that first refusal. Chats admitted on
their first attempt record nothing. Wait starts are dropped when a chat
is skipped for a reason other than capacity, and pruned when a batch
short enough to hold every candidate no longer lists the chat.
@jscottmiller
jscottmiller force-pushed the scott/chatd-stages/6-capacity-wait branch from 09bc9cf to e697290 Compare September 23, 2026 02:15
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant