Commit 0f4276d
authored
fix(api): skip the shared rate-limit budget when chat Q&A is off for the repo (#9734)
The chat-qa route counted a prior invocation and recorded a
COMMAND_RATE_LIMIT_EVENT_TYPE audit row (the SAME counter the @Loopover chat
PR-comment command uses), then built a planNextWork grounding bundle, before
calling generateChatQaAnswer -- which, on a repo where chat Q&A is not enabled,
is guaranteed to return `disabled`. So every request to a chat-disabled repo
spent a slot in the shared budget and paid for the grounding bundle for an answer
that never came, and could drive the maintainer's genuine @Loopover chat usage on
that PR to its limit.
Gate the route on isRepoChatQaEnabled(settings) -- the same predicate the
maintainer dashboard's capability map already reads, so the two can never
disagree -- immediately after resolving settings. When it is false, return
generateChatQaAnswer's own disabled result (its bundle is unused on that path)
before the rate-limit block and before planNextWork. The enabled path -- counting,
the audit row, planNextWork, and the rate_limited response -- is unchanged, and
ai-chat-qa.ts is not touched.
Adds tests asserting a disabled repo writes no audit row and never calls
planNextWork, while the existing enabled-path rate-limit/audit/rate_limited tests
continue to pass. One existing enabled-path test that had never stubbed the
chatQa-enabling manifest (and only passed because the route used to run
unconditionally) now enables it explicitly.
Closes #97141 parent 0c67c5e commit 0f4276d
2 files changed
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3537 | 3537 | | |
3538 | 3538 | | |
3539 | 3539 | | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
3540 | 3559 | | |
3541 | 3560 | | |
3542 | 3561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
107 | 138 | | |
108 | 139 | | |
109 | 140 | | |
| |||
153 | 184 | | |
154 | 185 | | |
155 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
156 | 190 | | |
157 | 191 | | |
158 | 192 | | |
| |||
0 commit comments