Repository navigation
test(proxy): measure the dashboard latency guard in up to 3 rounds - #1014
Conversation
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | c86ce3b8ba14 |
blocking |
Verdict: blocking
Findings
- proxy/limitheaders.go:1 (file deleted) — the commit silently reverts three merged PRs while the commit message and the PR body say "test-only, no behavior change".
- What fails: merge this head and main loses shipped features:
- #991 (subscription limit headers, #984). The proxy stops reading
anthropic-ratelimit-unified-*response headers. Therequestsschema columns, the two partial indexes, theEvent.LimitsandEvent.AuthSubscriptionfields, the insert/scan code and theGET /api/me/limitsroute all go. Users lose that API. - #996 (restart seeding).
SeedSessionsgoes back to seeding any status, not 2xx only, and to a per-thread tier, not per thread and model.dash/restartseed_test.gois deleted. The mislabeledcache_miss_reasonvalues after a restart come back. - #1009 (Pi docs). The README "Pi (experimental)" section,
docs/reference/pi-vs-claude-code.mdand the mkdocs nav entry are deleted. - The
docs/data-dependence.mdrow for #984 is removed with the feature.
- #991 (subscription limit headers, #984). The proxy stops reading
- Proof:
git diff 1c624f0f..HEADtouches onlyproxy/dash_test.go(48 insertions, 32 deletions).1c624f0fis main right before #991 merged. So the head tree is old main plus the test edit, while the commit's parent is68113b9e, which contains #991, #996 and #1009. The diff68113b9e..HEADdeletes 23 files / 1,230 lines:proxy/limitheaders.go,proxy/limitheaders_test.go,dash/limits.go,dash/limits_test.go,dash/restartseed_test.go,docs/reference/pi-vs-claude-code.md, plus the schema, query, store, capture, api, proxy.go and doc hunks named above. The commit looks like it was built from a stale checkout. - Extra fact: GitHub reports the PR
mergeable_state: dirtyagainst current main (7fd26dcd, #999). - Fix: do not merge this head. Rebuild the branch from
68113b9ecarrying only theproxy/dash_test.gochange, and force-push. The test change itself is good (see below). Per RELEASING.md, removing a user-facing API and reverting a shipped fix needs a human's named decision at the top of the PR; nothing here names it.
- What fails: merge this head and main loses shipped features:
Non-blocking
- The new failure message in
proxy/dash_test.go:675reports only the last round'sadded,budgetand baseline. Round 1 and 2 figures appear only int.Logfoutput, which-v-less CI drops. Consider naming every round's added/budget pair in the error. - Best-of-3 slightly weakens the guard: a real regression now passes if any one round hides it, not only the single round. This needs the off side to stall ~8 ms more than the on side across the median of 40 pairs, so it stays unlikely. No change needed.
- The comment "noise only ever ADDS to the paired difference" (
proxy/dash_test.go:657) is not strictly true: a stall on the off request subtracts. The median of 40 pairs is what makes the claim hold in practice. Comment-only.
What I checked
- The full diff
68113b9e..HEAD: all 23 files, every hunk, including the deletedproxy/limitheaders.goand its 286-line test. - Tree proof of the silent revert:
git diff 1c624f0f..HEAD(one file),git ls-tree HEADfor the deleted files, and the GitHub PR file list (same 23 files). - The intended change,
proxy/dash_test.go: theroundclosure keeps pairing, interleaving and medians. The budget is recomputed from each round's own baseline. The test returns on the first round within budget and errors only after all 3 rounds fail.latencyBudget, the 45 ms cap andTestLatencyBudgetStillCatchesTheRedactionRegressionare unchanged, as the PR says. No CI skip was added. I found no defect in this part. - Greps at head for
me/limits,noteLimits,AuthSubscription,limitsRoutes,readLimitHeaders,callerIsSubscription,seedModels: no dangling references. The head tree is self-consistent (it is an old, compiling main tree plus one test edit). - The PR body and issue #1013: the intended change matches the issue's proposal.
- No builds or tests were run (not approved). Read-only review.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | c86ce3b8ba14 |
blocking |
Verdict: blocking
Findings
-
The diff is not test-only: it reverts merged features #991 and #996 and deletes the docs its own parent #1009 added.
- What fails: The PR says "Test-only. No behavior change." The commit
c86ce3b8deletesproxy/limitheaders.go,proxy/limitheaders_test.go,dash/limits.go,dash/limits_test.go,dash/restartseed_test.go, theGET /api/me/limitsroute, 8 schema columns, 2 partial indexes, the README Pi section anddocs/reference/pi-vs-claude-code.md(added by the parent commit68113b9e, #1009). That is 23 files and 1230 deleted lines against one test file named in the PR body. Users loseGET /api/me/limitsand the stored limit and auth-kind values. The commit message and the PR body name none of it. - Proof:
git diff 68113b9e..HEAD --statshows the 23 files.git ls-tree 68113b9e dash/listslimits.go,limits_test.go,restartseed_test.go;git ls-tree HEAD dash/does not.git rev-parse HEAD^=68113b9e, so the deletions are made by this commit, not by a stale branch point. The PR body section "What changed" names onlyproxy/dash_test.go. - Fix: Restore every file the commit deleted except
proxy/dash_test.go, and re-apply the #996 logic indash/capture.go,dash/prefixcause.go,dash/event.go,dash/query.go,dash/schema.go,dash/store.go,proxy/dashcapture.go,proxy/proxy.goand the docs. If a revert of #991/#996/#1009 is wanted, it needs its own PR that names the change at the top, per the repo rule that a behavior change needs a human developer's written yes (CLAUDE.md, RELEASING.md).
- What fails: The PR says "Test-only. No behavior change." The commit
-
dash/capture.go:770 — restart seeding counts failed requests again, so a
ttl_expiryreads asprefix_changeorunknown.- What fails: A thread writes cache at T, then a request fails at T+5 min, then the proxy restarts.
SeedSessionsseeds the thread's recency from the latest row of any status (line 770-774 has nostatus >= 200 AND status < 300filter). The failed request makes the entry look 5 minutes younger. The next request reportsprefix_changeorunknowninstead ofttl_expiry. This is the exact defect #996 fixed. - Proof: The diff removes
AND r.status >= 200 AND r.status < 300from both halves of the query at dash/capture.go:770. TestTestRestartSeedRecencyIgnoresAFailedRequest(deleteddash/restartseed_test.go) covered it and fails on this code. - Fix: Restore the 2xx filter in both the outer query and the
r2subquery, and restore the deleted test.
- What fails: A thread writes cache at T, then a request fails at T+5 min, then the proxy restarts.
-
dash/prefixcause.go:107 — the seeded one-hour tier is per thread again, so one model's tier leaks into another model's TTL, and a fork loses its parent's tier.
- What fails: A thread writes a 1-hour cache entry on model A, then works on model B. After a restart,
seedTieris keyed bythread.Key(session, thread)only (dash/capture.go:200-203, 815-820). Model B's first read-only turn inherits A's 1-hour tier, so a miss 20 minutes later is not reported asttl_expiry. Also, line 107 reads onlyr.seedTier[key]: a fork (hasFrom) no longer reads its parent's seeded tier, so the fork's first turn after a restart loses the parent's 1-hour tier and reportsttl_expiryat 5 minutes. - Proof:
seededTier := !same && !hadAny && r.seedTier[key]at dash/prefixcause.go:107. #996 hadr.seedTier[perModel(key)]plus theperModel(thread.Key(session, fromThread))fallback for forks. TestsTestRestartSeedTierIsPerModelandTestRestartSeedTierGoesToAFork(deleteddash/restartseed_test.go) covered both. - Fix: Restore the per-model key (
thread.Key + "\x00" + model), the fork fallback, and the two deleted tests.
- What fails: A thread writes a 1-hour cache entry on model A, then works on model B. After a restart,
-
dash/capture.go:204 —
seenModelis no longer seeded on restart, so the first request on a known model is again acold_start.- What fails: The proxy serves model A, restarts, then serves model A again.
SeedSessionsno longer callsseedModels(the function is deleted), sor.seenModelstarts empty. The first request on A after the restart is labeledfirst_on_model(cold_start) although the model was seen minutes earlier. The dashboard under-reports cache hits for every model in flight across a restart. - Proof: The diff deletes
seedModelsand ther.seenModel[mk] = trueloop fromSeedSessions. TestsTestRestartSeedsTheSeenModel,TestRestartSeedsNoModelFromFailedRowsandTestRestartSeedsNoModelFromAPing(deleteddash/restartseed_test.go) covered it. - Fix: Restore
seedModels(2xx, non-ping, distinct tenant+model) and the seeding loop, plus the deleted tests.
- What fails: The proxy serves model A, restarts, then serves model A again.
Non-blocking
- The best-of-3 guard now passes a regression that is over budget in only 1 or 2 of 3 rounds. The comment at proxy/dash_test.go:657 argues a real regression adds its full size to every round. That holds for a fixed per-request cost, not for an intermittent one (a flush every N requests, lock contention). The PR documents the tradeoff and mutation-tested a fixed cost, so this is a note, not a block.
- Existing databases keep the 8 limit columns and the 2 partial indexes forever (no
DROPruns). Mixed schema state is harmless at runtime, but the indexes stay as dead weight on databases created before this change. - The
round()closure and the 3-round loop in proxy/dash_test.go:603-678 are correct: budget recomputed per round, failure message reports the last round, early return on the first round within budget.
What I checked
- The full diff, 1699 lines, all 23 files, including every deleted file in full.
- Commit parentage: one commit on parent
68113b9e; the deletions are explicit in the commit, not a branch-point artifact. Verified withgit ls-treeat base and head. - The PR body and issue #1013 (the flaky latency guard).
- The new latency-guard test logic in proxy/dash_test.go, read in full at head.
- Grep at head for
me/limits,dash.Limits,LimitWindow,limit_seen,auth_subscription,seedModels,noteLimits,callerIsSubscription: no dangling references. The revert is self-consistent, so it compiles. - That no in-repo consumer calls
GET /api/me/limits(the mod's band from #981 reads/api/stats), so nothing inside the repo breaks at compile time when the route disappears. - No builds or tests were run; live tests are not approved for this review.
The guard failed on a slow CI runner with 45.29 ms added against a 45 ms budget, on a 759 ms baseline, with nothing wrong. Noise only adds time; a real regression adds its full size to every round. The test now passes on the first round within budget and fails only when all 3 rounds are over budget. Budget and cap are unchanged. Test-only, no behavior change. Closes #1013 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Both blocking findings are fixed. The head is rebuilt and contains only the test change.
|
c86ce3b to
2fbb429
Compare
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 2fbb429763b9 |
approve |
Verdict: approve
Findings
None. The head is rebuilt and now matches the PR description: one commit on current main, one test file changed.
Non-blocking
- The author found a blind spot older than this PR: under load (load average 9.3), a 50 ms sleep in
capture.finishdoes not fail this test, on main and on this head alike. I checked the reasoning and it holds: the defer's cost is charged to the next request on the same keep-alive connection, and when the pair-mate request on the other connection runs longer than the defer, the wait is absorbed. It is a limit of the guard on main, not a regression from this PR. The author will file it as its own issue — please make sure that issue is filed, so the blind spot is not forgotten. - The comment at
proxy/dash_test.go:661-663says the trade-off twice ("that is the price of not failing on one noisy round. One noisy round no longer fails the test"). Wording only.
What I checked
- Last review: round 1, c86ce3b, 2026-11-10T08:20:50Z
- New commits read: 1 (
2fbb4297test(proxy): measure the dashboard latency guard in up to 3 rounds).7fd26dcd(#999) also appears inc86ce3b8..HEAD; it is main's own commit, not part of this PR. - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files in my folder).
- New items since my last review: the rebuilt commit
2fbb4297and the author's comment of 2026-11-10T08:46:13Z. Both read in full. - My round-1 finding (the silent revert of #991, #996, #1009): fixed.
git diff 7fd26dcd..HEAD --statshows one file,proxy/dash_test.go(50 insertions, 32 deletions). The parent of2fbb4297is7fd26dcd, current main.dash/,proxy/limitheaders*, the schema, the docs and the README are untouched. The cause the author gives (git reset --softover a stale index) matches my round-1 diagnosis of a stale tree. - My round-1 non-blocking notes: both adopted. The failure message now joins every round's added/budget/baseline into the
t.Errorf(proxy/dash_test.go:665-680), so a-v-less CI run shows all rounds. The comment no longer claims noise only adds; it says a stall can land on either side and names the intermittent-cost trade-off. - Reviewer 2's findings 1-4: fixed or gone with the rebuild. I verified this myself: the diff no longer touches
dash/capture.go,dash/prefixcause.goor any #996/#991 file, so the 2xx seeding, the per-model tier,seedModelsandGET /api/me/limitsare all back to main's state. Their non-blocking note about dead indexes is moot: the schema does not change any more. - The new commit's own code, read at head: the loop uses
:=inside the round loop (nothing escapes that should), every variable is used, the format strings match their arguments (4 verbs, 4 args in the error),roundsis never empty when the error fires, andfmtandstringsare imported.latencyBudget, the 45 ms cap andTestLatencyBudgetStillCatchesTheRedactionRegressionstay unchanged. - The PR body still says "Test-only. No behavior change." — now true of the diff.
- The author reports
go test -race ./proxy/...passes on the box, withgo vetandgofmtclean. I did not run tests (not approved).
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 2fbb429763b9 |
approve |
Verdict: approve
Findings
None. The head is rebuilt on the new base and carries only the test change.
Earlier findings
- My finding 1 (hidden revert of #991, #996, #1009): fixed.
git diff 7fd26dcd..HEAD --statshows one file,proxy/dash_test.go(50 insertions, 32 deletions). The deleted files are back with their original blob ids:dash/limits.gof6aa6c4c,dash/limits_test.go6a9eba50,dash/restartseed_test.gof4d428ab,proxy/limitheaders.gobdcbad45,proxy/limitheaders_test.go4c79a28a,README.md611af8c0,docs/reference/pi-vs-claude-code.mdea6c4873.git diff 68113b9e..HEAD -- dash/capture.go dash/prefixcause.go dash/event.go dash/schema.go proxy/dashcapture.go proxy/proxy.gois empty: the #991 and #996 logic is byte-identical to pre-rebase main. - My findings 2, 3, 4 (the #996 regressions: 2xx filter, per-model tier, seenModel seeding): fixed, by the same restoration. I re-read
dash/capture.go:770-790(2xx filter in both halves),dash/prefixcause.go:107-112(per-model key and the fork fallback) anddash/capture.go(seedModelspresent, called fromSeedSessions). - Reviewer 1's finding 1 (silent revert): fixed. Agree with reviewer 1; I verified it myself, as above. The rebase also clears the
mergeable_state: dirtyreviewer 1 saw: the head now sits on7fd26dcd(#999), the current main. - Reviewer 1's non-blocking (failure message drops the earlier rounds): fixed.
proxy/dash_test.gonow builds aroundsslice, one line per failed round with its added, budget and baseline, and joins it into thet.Errorf. Format strings check out: 4 verbs, 4 args in the error; 8 verbs, 8 args in the per-roundt.Logf. - Both reviewers' non-blocking (the "noise only ever ADDS" comment): fixed. The comment now says a stall can land on either request, that the median is what makes the claim hold, and states the tradeoff: an intermittent cost can pass one round.
- My non-blocking (best-of-3 passes an intermittent regression): addressed as a documented tradeoff. The new comment names the exact case I raised (a flush every N requests). The design choice stands, and the PR's own mutation test covers a fixed cost. I accept it.
- My non-blocking (dead limit columns on old databases): moot. The feature is back, so the columns and indexes are live again.
Non-blocking
- The blind spot the author reported is not filed yet. The author's comment (2026-11-10T08:46:13Z) says a 50 ms sleep in
capture.finishpasses the guard under load, on main and on this PR alike, and "I will file this blind spot as its own issue." I checked the issue list: the newest issues (#1019 at 08:36, #1017 at 08:32) predate the comment, and #1017 is the false-positive flake, not this false negative. Please file the issue, so the guard's known limit is tracked. - The comment at
proxy/dash_test.go:657breaks one sentence across lines ("One noisy round / no longer fails the test"). Read as one sentence it is right. Comment-only.
What I checked
- Last review: round 1, c86ce3b, 2026-11-10T08:21:00Z
- New commits read: 2 (
7fd26dcdfeat(dash): store the accountant's tier tokens and serve them from /api/stats (#999) — the new base, merged from main;2fbb4297test(proxy): measure the dashboard latency guard in up to 3 rounds — the rebuilt PR head) - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt) - New items since my last review:
- The force-push to
2fbb4297: read the full range diffc86ce3b8..HEAD(2964 lines — the restoration, #999, and the test change) and the PR diff7fd26dcd..HEAD(108 lines, one file). - The author's comment at 08:46:13Z (cause:
git reset --softwith a stale index; fix: rebuild onorigin/main; two non-blocking fixes; box test results; the blind-spot report): checked every claim it makes against the head, as recorded above. - Reviewer 1's round-1 review at 08:20:50Z: read now that my round-1 review is posted. Its finding matches mine; its three non-blocking items are all addressed.
- The force-push to
- The PR's own change,
proxy/dash_test.go:603-678at head, read in full: theroundclosure keeps pairing, interleaving and medians; the budget is recomputed from each round's own baseline; the test returns on the first round within budget;latencyBudget, the 45 ms cap andTestLatencyBudgetStillCatchesTheRedactionRegressionare unchanged; no CI skip;fmtandstringsare imported. - The interaction of #999 with #991 in
dash/query.go,dash/store.goanddash/schema.goat the new base: read in the range diff. The head adds nothing on top of main there, and #999's own review covered that merge. - The issue list, for the blind-spot issue the author promised.
- No builds or tests were run; live tests are not approved for this review.
Clean merge, no conflict. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
At each Pi session start, the Pi extension now checks the local proxy with one GET /healthz (5-second limit). If the proxy does not answer, it restarts the proxy's user service once and checks again. If the proxy is still down, Pi shows one warning, not only a connection error on every routed request. Behavior change: Pi users who installed context-guru with /context-guru setup, and only when a Pi model goes to the proxy. Old: nothing checked the proxy, and a down proxy showed only connection errors. New: the check, one restart, and one warning. No switch; pi --no-extensions turns off the whole extension, and /context-guru uninstall removes the install record and so the check. Owner's yes, 2026-11-10, in the integrator session: "1011 behavior change approved". Data dependence: metadata only. A bare GET /healthz to localhost with no body. It reads the install record and the model URLs Pi knows. No change to stored data. Reviews: 2 offload reviews (GLM), round 3 (owner granted round 3), both approve at 655a6a9. Round 3 reviewed the merge of main after #1010, which changed the same 5 pi-package files. Two later merges of main (1077d80 after #1012, d4124cd after #1014) change no #1011 code: their remerge-diff outside docs/data-dependence.md is 0 lines; the one doc conflict kept both rows. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
#1031) The latency test compared whole-request wall time with the dashboard on and off. On a slow runner the baseline was 500-730 ms and the added time was 49-77 ms in every round, so best-of-3 (#1014) did not help. It also missed a 50 ms sleep in capture.finish under load. The test now sums the time of the dashboard's own calls on the request goroutine (newCapture, the note* methods, finish) through spendHook, a test-only hook. The hook is nil in production. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
#1031) The latency test compared whole-request wall time with the dashboard on and off. On a slow runner the baseline was 500-730 ms and the added time was 49-77 ms in every round, so best-of-3 (#1014) did not help. It also missed a 50 ms sleep in capture.finish under load. The test now sums the time of the dashboard's own calls on the request goroutine (newCapture, the note* methods, finish) through spendHook, a test-only hook. The hook is nil in production. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Closes #1013
Test-only. No behavior change.
Summary
The latency guard now measures up to 3 rounds. It fails only when all 3 are over budget.
What we found
added 45.29ms, budget 45ms, baseline 759 ms. Nothing was wrong.What changed
proxy/dash_test.go: the 40-pair measurement is now aroundclosure. The test runs it up to 3 times and returns on the first round within budget.TestLatencyBudgetStillCatchesTheRedactionRegressionare unchanged.How it was tested
All on the eval box,
-race, 4 busy-loop cores (killed by pid after). Box shared, so the load was higher than 4 cores at times.go test -v -race -count=14 -run ^TestDashboardAddsNoRequestLatencyWithContentCapture$ ./proxy/. The command timed out at 8 runs. 1 of 8 failed (45.79 ms vs 45 ms). Others added 30 to 38 ms.time.Sleep(50ms)at the top ofcapture.finish, no load,-count=1. Baseline 59 ms, budget 12 ms. Added 55 ms in all 3 rounds. The test fails.go test -race -count=1 ./proxy/...: ok.go vetandgofmt -l: clean.Not verified
-count=30run did not finish in 10 minutes under load. I used 8 runs each way. The sample is small.