Repository navigation
Commit 5a14f36
fix(intel-agent): wire quota eviction; count String overhead in the SSE cap
Two artifacts that claimed a memory guarantee they did not provide.
1. evict_expired_at was DEAD CODE. Defined at quota.rs:160, its only call
sites were inside mod tests (which starts at line 193), so no production
path ever called it. Worse than a missing feature: a public method with that
name and passing unit tests tells a reviewer expiry eviction is handled.
Same failure class as the README that claimed the quota bypass was closed.
Now called from check_and_record_at, which already holds &mut self under the
caller's mutex — no new lock, timer, or background task. The O(n) scan per
admission is acceptable and self-limiting: n is the number of tracked
scopes, and the scan reclaims stale entries precisely when accumulation
makes it worth paying for. Eviction semantics are unchanged; the
pre-existing window tests pass unmodified, which is what establishes that
evicting an elapsed entry and resetting one produce the same count.
2. The SSE buffer cap undercounted real memory by roughly 25x. data_bytes
accumulated only line content length, but data_lines is a Vec<String> and
each String carries ptr/len/cap overhead the 8 MB cap never counted. A
stream of 1-byte data: lines charged ~1 byte each while consuming ~25, so
the cap could admit on the order of 200 MB — while its own doc comment
claimed to bound memory "under adversarial streams".
Accounting now charges size_of::<String>() per retained line, computed
rather than hardcoded. SSE_BUFFER_CAP keeps its exact value; only the
accounting changed. The doc comment now states what is counted and stays
honest that allocator bookkeeping and unused Vec capacity are not.
Untouched by design, all proven live at 19d74ec: UTF-8/chunk behaviour,
terminal_received, notify_incomplete_answer, and quota scope keys.
Gates re-run independently by the orchestrator with exit codes captured
directly: 63 unit (was 61) + 14 e2e pass, clippy --all-targets -D warnings
clean, fmt clean.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>1 parent b4b2baa commit 5a14f36
2 files changed
Lines changed: 54 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
391 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
392 | 396 | | |
393 | 397 | | |
394 | 398 | | |
| |||
400 | 404 | | |
401 | 405 | | |
402 | 406 | | |
403 | | - | |
| 407 | + | |
404 | 408 | | |
405 | 409 | | |
406 | 410 | | |
| |||
474 | 478 | | |
475 | 479 | | |
476 | 480 | | |
477 | | - | |
| 481 | + | |
478 | 482 | | |
479 | 483 | | |
480 | 484 | | |
| |||
1015 | 1019 | | |
1016 | 1020 | | |
1017 | 1021 | | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
1018 | 1044 | | |
1019 | 1045 | | |
1020 | 1046 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
119 | 124 | | |
120 | 125 | | |
121 | 126 | | |
| |||
344 | 349 | | |
345 | 350 | | |
346 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
347 | 371 | | |
348 | 372 | | |
349 | 373 | | |
| |||
0 commit comments