Skip to content

fix(keepalive): choose the keep-alive prefix floor by wait cause - #1040

Merged
amiddavid merged 8 commits into
mainfrom
feat/strategy-min-prefix
Nov 10, 2026
Merged

amiddavid merged 8 commits into
mainfrom
feat/strategy-min-prefix

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change

  • Who: every keep-alive user. That includes users on auto, 1-ping and 2-ping (Claude Code plugin and Pi plugin), and users who set no strategy.
  • Old: one floor for all waits. 80k for users with a strategy. 20k for users with no strategy (since feat(keepalive): choose the ping count from what the thread waits for #867).
  • New: the floor follows the wait cause.
    • 20k for a tool wait, a wait for background work and a wait for a teammate (main thread or subagent).
    • 20k for every wait of a subagent thread.
    • 80k for a main thread that waits for a person, or for an unknown cause.
    • OpenAI keeps the general floor.
  • Effect: subagent threads, tool waits, and main-thread waits for background work or a teammate with a prefix of 20k-80k now get pings. This costs money. A main thread that waits for a person keeps the 80k floor.
  • Owner decision (2026-11-10): tool waits get 20k. A main thread's wait for a person gets 80k. Main-thread waits for background work or a teammate get 20k. A main thread with an unknown cause keeps 80k. Subagents get 20k for every cause.
  • Turn off: set keepalive_tool_wait_min_prefix_tokens: 80000 (one floor), or set keepalive_wait_plan: false (one floor, keepalive_min_prefix_tokens, for every wait).
  • Approval: the owner chose "floor by wait cause" on 2026-11-10. It completes the feat(keepalive): choose the ping count from what the thread waits for #867 decision.
  • Why: for a main thread that waits for a person, a prefix under 50k never paid (0 of 274 came back within reach). For subagent tool waits, a 20k floor cut misses from 65 to 31 (keepalive: choose the ping count from what the thread waits for (measured on two sources) #858).

Summary

  • feat(keepalive): choose the ping count from what the thread waits for #867 lowered the one floor to 20k. The strategy table still wrote 80000. An explicit value beats the default, so the change never reached strategy users.
  • Now there are two floors. keepalive_min_prefix_tokens (default 80000) is the general floor. New keepalive_tool_wait_min_prefix_tokens (default 20000) is the lower floor.
  • The lower floor never raises the general one. The lower of the two applies.

What changed

  • config: new key keepalive_tool_wait_min_prefix_tokens. Default 20000. Wired into the form and main.go. DefaultKeepAliveMinPrefix is 80000 again.
  • keepalive: Policy.WaitMinPrefix(cause, subagent) sits next to WaitPings. pingable() reads it. With keepalive_wait_plan: false, one floor applies.
  • Dashboard replay (dash/keepalive.go) uses the same floors. Policy.SpanPrefixOK is the replay form of the keeper gate. A drift test still runs the keeper and the replay on the same cases.
  • Adapt replay (proxy/adaptcache.go) uses the same floors. A row has a stop reason, not a cause: a tool stop is a tool wait, any other stop is read as a wait for a person (80k). So it under-counts rows that waited for background work or a teammate. An OpenAI row gets the general floor.
  • Strategy table: keeps the literal 80000. It does not write the new key. A test pins the table floor to the default. The auto Desc text states the split.
  • Pi: no code change except one README line. The Pi strategy table already states 80000, the right general floor.
  • Docs and stale comments updated: docs/how-to/cache-keepalive.md, pi-package/README.md, docs/components/advanced-offload.md, extract_sweep_ping.go, kvcache/strategy.go.
  • Not changed: proxy/campaign.go. The main session tracks it in its own issue.

Existing user files

  • Claude Code plugin: files re-render at the next start (strategy sync). The file states keepalive_min_prefix_tokens: 80000. That is the right general floor. The file does not state the new key, so the proxy default (20000) applies at the next proxy start. strategy sync also runs before every start and re-renders the file from the table.
  • Pi: an existing Pi file needs no re-render for this change. It keeps 80000 as the general floor, and tool waits get 20000 from the proxy default. A re-render for later table changes is tracked in fix(pi): re-render the proxy config before each start, like strategy sync #1044.

How it was tested

On the shared box, with -race:

  • ./config/... ./keepalive/... ./cmd/... ./context-guru-plugin/... ./pi-package/...: pass.
  • ./dash/...: pass (own call). ./proxy/...: pass (own call, 599 s).
  • New tests: TestWaitMinPrefixByCause, TestPingableUsesTheFloorOfTheWait, TestSpanPrefixOKFollowsTheWaitCause, TestStrategiesPinTheGeneralFloorToTheDefault, TestToolWaitMinPrefixDefaultAndOverride, TestStrategyFileHasNoToolWaitFloor.
  • Also: TestRowFloorFollowsTheWaitAndTheProvider (adapt replay floor by wait and provider). Round 3 mutation: with the background case removed from WaitMinPrefix, the keeper, replay and floor tests fail.
  • Mutation: with the per-cause rule removed, WaitMinPrefix, pingable and SpanPrefixOK tests fail. With the table at 20000, the table test fails.
  • The dashboard golden fixture has prefixes of 20k-45k and no wait cause. Its API now sets a 20k general floor, so the replay columns stay non-empty. The golden files did not change.

Data dependence

Metadata only. The wait cause is already computed from tool names and the stop reason. The floor reads token counts. No row in docs/data-dependence.md changes.

🤖 Generated with Claude Code

#867 lowered the default keepalive_min_prefix_tokens to 20000. The
strategy table still wrote 80000 for auto, 1-ping and 2-ping. An
explicit value beats the default, so every user on those strategies
kept the 80k floor.

- config/strategy.go: the three entries use DefaultKeepAliveMinPrefix.
- settings.py and pi_plugin.py: 80000 becomes 20000. Desc text follows.
- Test: every strategy floor equals the default.
- Test: `strategy sync` rewrites an old 80000 file to 20000.
- Docs: two stale 80k statements fixed.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 6a9f29a7c453 blocking

Verdict: blocking

Findings

  1. pi-package/scripts/pi_plugin.py:335 — the fix never reaches an existing Pi install, and the PR says it does

    • What fails: a Pi user who armed auto, 1-ping or 2-ping before this change has
      keepalive_min_prefix_tokens: 80000 written literally in their config file. Nothing on the Pi
      side ever re-renders that file, so the floor stays 80000 indefinitely. The PR description says
      "Existing user files need no migration. strategy sync runs before every proxy start. An old
      file with 80000 becomes 20000 at the next start" — that is true for the Claude Code plugin
      only (start-proxy.sh:570 runs strategy sync), and false for Pi.
    • Proof: render_config (pi_plugin.py:320-332) writes the strategy's keys literally, with no
      strategy: name in the file, so the proxy cannot re-derive the row either.
      write_proxy_config (pi_plugin.py:335) is called only from setup (line 665, needs explicit
      consent) and configure (line 795, a user slash-command). update (lines 822-857) swaps the
      binary and restarts the service without touching the config; restart reuses the file as-is.
      There is no Pi equivalent of strategy sync.
    • Fix: re-render the owned config on update/restart the way start-proxy.sh syncs, or state
      in the PR and in pi-package/README.md that a Pi user must re-run setup or configure to get
      the 20k floor. Do not leave the "no migration" claim as written.
  2. config/strategy.go:28 — the table's rule comment now contradicts the code it sits on

    • What fails: lines 28-31 say "The numbers are written out here, not read from the Default*
      constants, on purpose: a later change to a default must not silently re-tune a strategy that an
      install already uses." This change does the exact opposite for keepalive_min_prefix_tokens
      (lines 79, 94, 109 now read DefaultKeepAliveMinPrefix). A reader who trusts the comment will
      either "fix" the constant back to a literal, or miss that a future change to the default now
      re-tunes every strategy — which is the approved intent here, and must be stated as the new rule.
    • Proof: config/strategy.go:28-31 against config/strategy.go:79.
    • Fix: rewrite the comment: the prefix floor tracks DefaultKeepAliveMinPrefix by owner decision
      (this PR, approved 2026-11-10); the other numbers stay literal so a default change cannot
      re-tune them.

Non-blocking

  • proxy/campaign.go:41-47 — pre-existing drift, same class this PR fixes. The comment says
    campaignDefaultMinPrefixTokens "mirrors config.DefaultKeepAliveMinPrefix", but the constant is
    80000 and the default has been 20000 since #867. It is outside this diff and the campaign arms
    have their own pinned tests, so per the repo rules it deserves its own issue, not a ride on this PR.
  • context-guru-plugin/preset_default_test.go:834 — the assertion rejects the substring "80000"
    anywhere in the synced file. Correct today (no other rendered value contains it), but a future key
    could trip it for an unrelated reason.

What I checked

  • The full diff (7 files) and the code around each change.
  • applyStrategy (config/strategy.go:165): a key the file sets itself always wins. So the PR's
    turn-off instruction (keepalive_min_prefix_tokens: 80000 in the config) is correct, and a
    hand-tuned file is not overridden.
  • TestStrategyTableMatchesPlugin still pins the Go table to settings.py key by key; both tables
    were changed together, so they stay pinned.
  • The sync path: strategy sync (settings.py:3973-4035) re-renders the whole file from the table,
    and start-proxy.sh:570 runs it before every proxy start. The new
    TestStrategySyncLowersAnOldPrefixFloor covers the 80000→20000 rewrite end to end.
  • Every remaining 80000 in the tree: the campaign arms (proxy/campaign.go, proxy/campaign_test.go)
    are measured A/B arms with the 80k evidence floor, deliberately unchanged; RELEASING.md and the
    dash tests already say 20000.
  • DefaultKeepAliveMinPrefix = 20000 since #867 (issue #858), config/config.go:263-265. The #858
    and #867 citations in the new comments and docs are the issue and the PR, both correct.
  • The behavior change is named at the top of the PR (who, old, new, turn-off) with owner approval on
    2026-11-10 — this meets the repo's behavior-change rule.
  • Data dependence: token counts only, metadata first; no row in docs/data-dependence.md changes.
    Agree.
  • No live tests were run (not approved for this review).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 6a9f29a7c453 blocking

Verdict: blocking

Findings

  1. pi-package/scripts/pi_plugin.py:335 — an existing Pi install never gets the 20k floor

    • What fails: a Pi user who armed auto, 1-ping or 2-ping before this change keeps
      keepalive_min_prefix_tokens: 80000 in their config file. The file is re-rendered only by
      setup and configure (write_proxy_config, line 335 and line 795). The session-start path
      runs pi_plugin.py restart, and restart_service never touches the config. update
      re-installs the binary and restarts with the old file. So the lower floor reaches that user
      only when they run configure again. The PR body says the opposite: "Existing user files need
      no migration. strategy sync runs before every proxy start. An old file with 80000 becomes
      20000 at the next start." That is true for the Claude Code plugin (start-proxy.sh:570) but
      not for Pi.
    • Proof: render_config writes the cache keys literally (pi_plugin.py:320-332). The extension
      runs only status and restart at session start (pi-package/extensions/context-guru.ts:136).
      restart_service and update call no config write. No sync op exists in the Pi package
      (main's parser list: setup, status, configure, update, restart, uninstall).
    • Fix: add a re-render before the service start in the Pi package (the same rule as
      start-proxy.sh), or correct the PR body: Pi files keep 80000 until the next configure,
      and the owner accepts that gap.
  2. config/strategy.go:28 — the table's rule comment now contradicts the code

    • What fails: the comment says "The numbers are written out here, not read from the Default*
      constants, on purpose: a later change to a default must not silently re-tune a strategy that
      an install already uses." This PR does the opposite for the floor: all three entries now read
      DefaultKeepAliveMinPrefix (lines 79, 94, 109), and the new TestStrategiesUseTheDefaultMinPrefix
      enforces that coupling. The file states two opposite rules. A future reader who trusts the
      comment will "fix" the code back, or follow the dead rule for the other keys.
    • Proof: git diff d407191b..HEAD -- config/strategy.go changes the three values; the comment
      block at lines 28-31 is untouched.
    • Fix: rewrite the sentence. Say the floor follows DefaultKeepAliveMinPrefix since this change
      (completing #867), and the other numbers stay literal.
  3. proxy/campaign.go:47 — the campaign mirror of the default is stale at 80000

    • What fails: campaignDefaultMinPrefixTokens = 80000, and its comment (line 41) says it
      "mirrors config.DefaultKeepAliveMinPrefix". That default has been 20000 since #867. So the
      comment is false, and the live campaign arms keepalive-5m and keepalive-5m-xK (K >= 2)
      still arm an 80k floor: campaignArmFor (lines 137, 165) passes it into the strategy rows the
      campaign writes (line 492). This PR fixes exactly this drift class in the strategy table but
      leaves the campaign mirror broken.
    • Proof: config/config.go:265 — DefaultKeepAliveMinPrefix = 20000 ("since #858", landed with
      the #867 series). proxy/campaign.go:41-47 unchanged by this PR and by #867.
    • Fix: per the repo rule, this defect in main gets its own issue and its own PR, not a change
      on this branch. The issue needs an owner decision: either the campaign arms follow the 20k
      default, or the value is kept for the K>=2 evidence (lines 49-52) and the comment drops the
      "mirrors" claim.

Non-blocking

  • components/offload/extract_sweep_ping.go:31 — the comment still says "a prompt under the
    keep-alive floor (80k tokens, #444) gets none". The matching sentence in
    docs/components/advanced-offload.md was updated to 20k in this PR. Update the comment too.
  • kvcache/strategy.go:506 — the comment says "the shipped config default is now 240 s / 80k
    floor". Stale since #867. Pre-existing, not touched by this PR.
  • config/strategy_test.go:87 hardcodes 20000 where the new test uses the constant. Fine as a
    pin; noted only so the duplication is known.

What I checked

  • The full diff (7 files) and the code around each change.
  • The value chain: config/strategy.go rows → CacheConfig fill (explicit key beats the row,
    row beats the default) → Resolved() at config/config.go:312.
  • The three-table drift chain stays closed: Go table ↔ settings.py
    (TestStrategyTableMatchesPlugin, desc strings compared exactly — both sides now say
    ">=20k-token prefix") ↔ pi_plugin.py (test_strategies_match_the_claude_code_plugin).
  • The new tests: TestStrategiesUseTheDefaultMinPrefix (compares against the constant, requires
    the floor in at least 3 rows) and TestStrategySyncLowersAnOldPrefixFloor (the sync path at
    settings.py:3973-4035 re-renders from the table; helpers settingsIn and readFileString
    exist; the armed auto file carries exactly one floor line, so the replace and the
    no-80000 assertion are sound).
  • The Claude Code upgrade story: start-proxy.sh:570 runs strategy sync before every launch.
  • Every other copy of the old floor: proxy/campaign.go (finding 3), two stale comments
    (non-blocking), and historical analysis docs (scripts/analysis/README.md,
    predictive/README.md) that record past measurements and are correctly untouched.
  • The PR body: it names the behavior change at the top, gives the old and new behavior, the
    turn-off switch, and the owner's approval date (2026-11-03 / 2026-11-10).
  • No tests were run. Live tests are not approved, and Go is not on this machine.

The owner chose a floor by wait cause. A tool wait (main or subagent)
gets 20k. A subagent thread gets 20k for every wait. A main thread
that waits for a person, background work, a teammate or an unknown
cause gets 80k.

- keepalive_min_prefix_tokens default is 80000 again (general floor).
- New keepalive_tool_wait_min_prefix_tokens, default 20000.
- Policy.WaitMinPrefix picks the floor. pingable() reads it.
- Dashboard replay and the adapt replay use the same floors.
- Strategy table keeps the literal 80000. A test pins it to the
  default. The table does not write the new key, so old files get
  the 20k tool-wait floor without a re-render.
- Pi re-renders the config it owns at restart and update.
- With keepalive_wait_plan: false, one floor applies.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid amiddavid changed the title fix(config): strategies use the 20k keep-alive prefix floor fix(keepalive): choose the keep-alive prefix floor by wait cause Nov 10, 2026
@amiddavid

amiddavid commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Reply to Reviewer 1, round 1. Head is now c0a99f8c.

  1. Pi never re-renders the config: moved to fix(pi): re-render the proxy config before each start, like strategy sync #1044. The owner gave it to another session. This PR has no Pi re-render code (removed in c0a99f8c). An existing Pi file keeps its old values until the user runs configure again. The PR body now says so.
  2. Also changed the claim. The scope changed to a floor by wait cause. The table keeps 80000 and does not write the new key keepalive_tool_wait_min_prefix_tokens. So an old Pi file and an old Claude Code file both get the 20k tool-wait floor from the proxy default, with no re-render. The PR body now says this for both plugins.
  3. campaign.go: out of scope here. The main session tracks it in its own issue.

@amiddavid

amiddavid commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Reply to Reviewer 2, round 1. Head is now c0a99f8c.

  1. Pi installs never re-render the config: moved to fix(pi): re-render the proxy config before each start, like strategy sync #1044. The owner gave it to another session. This PR has no Pi re-render code (removed in c0a99f8c). An existing Pi file keeps its old values until the user runs configure again.
  2. The claim "no migration" was false for Pi: corrected. The PR body now separates the Claude Code plugin (re-renders at start) from Pi (fix(pi): re-render the proxy config before each start, like strategy sync #1044).
  3. strategy.go:28 comment and code disagreed: fixed. The "use the constant" change is reverted. The table keeps literals, as its comment says. A new test pins the table floor to DefaultKeepAliveMinPrefix and fails if the table writes the tool-wait key.
  4. Non-blocking items: fixed. The stale 80k comments in extract_sweep_ping.go and kvcache/strategy.go now state the new rule. The Python sync test now checks the key line itself, not any 80000 substring.

The owner moved the Pi re-render to its own issue (#1044). The Pi
strategy table is unchanged by this PR.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

The Pi config re-render moved to #1044. This PR no longer has it (removed in c0a99f8c).

Finding 1 no longer applies to this change. The Pi table needs no new value: an old Pi file keeps 80000 as the general floor, and tool waits get 20000 from the proxy default.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 c0a99f8ce8b2 blocking

Verdict: blocking

Findings

  1. dash/ui/app.js:9664 — the keep-alive tab still tells the reader the gate is 20k; this change makes it 80k for a main thread's other waits

    • What fails: the calculator's PINGS note says pings are "gated as the request path gates (past
      the session's first request, cached prompt over 20k tokens)". After this change the request path
      gates a main thread's wait for a person, background work, a teammate or an unknown cause at
      80k. Only a tool wait or a subagent keeps 20k. The same stale 20k claim sits at app.js:9474
      ("the default 'only sessions with a large cached prompt' filter costs almost nothing" —
      measured at a 20k gate, no longer the shipped general floor) and app.js:9722. Two comments in
      dash/keepalive.go also state it: line 591 ("the shipped floor is 20k since #858") and line 611
      ("is the shipped floor again since #858"). The base's gate comment kept the page self-consistent
      on purpose ("the panel's copy names 20k so the page stays self-consistent"); this PR rewrote
      that comment and dropped the panel-copy clause without updating the panel.
    • Proof: WaitMinPrefix (keepalive/waitplan.go:86-94) returns MinPrefixTokens (default 80000,
      config/config.go:272) for every non-tool wait of a main thread; pingable reads it
      (keepalive/keeper.go:329). The three copy spots and the two comments are unchanged by the diff.
    • Fix: name both floors in the three copy spots and the two comments: "over 20k for a tool wait
      or a subagent, 80k otherwise".
  2. RELEASING.md:225 — the release traps list states the wrong default floor

    • What fails: "The default floor is keepalive_min_prefix_tokens: 20000 (it was 80000 before
      #858)". After this change the general default is 80000 again; 20000 is the tool-wait and
      subagent floor. A release checker who follows this list configures the wrong expectation, and
      check item 10 (line 220) tells them to verify the per-wait plan.
    • Proof: config/config.go:272 — DefaultKeepAliveMinPrefix = 80000; the PR updated
      docs/how-to/cache-keepalive.md, pi-package/README.md and two code comments, but not this file.
    • Fix: one line: the general floor is 80000, 20000 for a tool wait or a subagent
      (keepalive_tool_wait_min_prefix_tokens).

Earlier findings

  • Mine, round 1, finding 1 (Pi never re-renders): resolved, accepted. The redesign makes an old
    Pi file correct: it states 80000, which is now the right general floor, and the tool-wait floor
    (20000) reaches it from the proxy default with no re-render. The re-render itself moved to #1044,
    and the PR body now separates the two plugins honestly ("Existing user files" section). Verified:
    the diff against the base touches only pi-package/README.md; the Pi strategy table is byte-equal
    to base and its 80000 matches settings.py and the Go table.
  • Mine, round 1, finding 2 (strategy.go rule comment): fixed. The table keeps literals, as its
    comment says. The comment now also states the two new rules: a test pins the table floor to
    DefaultKeepAliveMinPrefix, and the table does not write the tool-wait key.
    TestStrategiesPinTheGeneralFloorToTheDefault enforces both.
  • Reviewer 1, round 1, findings 1 and 2: agree, and both are resolved the same way (checked
    myself above).
  • Reviewer 1, round 1, finding 3 (campaign mirror stale at 80000): moot, and I add new proof.
    This PR moves DefaultKeepAliveMinPrefix back to 80000, so campaignDefaultMinPrefixTokens = 80000 (proxy/campaign.go:47) mirrors the default again and the comment is true. The author's
    reply (own issue, not this branch) also matches the repo rule; nothing is left to do.
  • Non-blocking round 1: the stale 80k comments in extract_sweep_ping.go and
    kvcache/strategy.go are fixed (in the diff). The brittle no-"80000"-substring sync test is gone
    with the redesign; the new TestStrategyFileHasNoToolWaitFloor checks the key lines themselves.

Non-blocking

  • Keeper and replay disagree on the floor at Idle >= 300 s. The keeper sets the wait cause
    whenever the plan is on, with no Idle condition (keepalive/keeper.go:914-918), so a tool wait at
    Idle >= 300 s still gets the 20k floor in pingable. The calculator forces WaitPlan off at
    idleSeconds >= 300 (dash/keepalive.go:1664-1666), so its replay gates every span at the general
    floor. The docs say idle must be under 300 s, and the replay under-counts, so I leave this here.
  • SpanPrefixOK gives a subagent row with no stored cause the general floor (cause "" returns
    MinPrefixTokens, keepalive/waitplan.go:87-88), though a live keeper always classifies a cause
    and would use 20k. Old rows only, and the replay under-counts. Worth a line in the
    storedWait/SpanPrefixOK comment if the author keeps it.

What I checked

  • Last review: round 1, 6a9f29a, 2026-11-10T12:24:37Z.
  • New commits read: 6 in git log 6a9f29a7..HEAD. The PR's own: ee1e01dc (floor by wait cause)
    and c0a99f8c (drop the Pi re-render, moved to #1044) — both read in full, plus the merge
    54a7eaa9. From main through the merge: 407d9d1a (#483), 54a51b57 (#720), b57b2bda
    (#1046, the new base) — main's own merged PRs, outside this PR's diff; I read their messages and
    stats, not their thousands of lines, and the review diff b57b2bda..HEAD excludes them.
  • Read in full: 2 reviews, 3 comments, 0 inline comments (files .review-in-reviews.txt,
    .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review: the two PR commits (reviewed above), the merge of main, and the
    author's three comments (two replies at 14:13, one note at 14:14). Each reply claim was checked
    against the code: Pi re-render removed (diff vs base touches only the Pi README), PR body
    corrected (read in full), strategy.go comment fixed (read), stale comments fixed (read).
  • The new rule end to end: CacheConfig key and default → Resolved() → cachePolicy
    (cmd/context-guru-proxy/main.go:1214, uses c.Resolved()) → Policy.WaitMinPrefix →
    pingable. WaitMinPrefix never raises the general floor (min), returns one floor with the
    plan off or an unknown cause, and gives every subagent wait the tool-wait floor.
  • The replay side: gatePolicy fills zero floors with the shipped ones; pingSpansWithFacts gates
    SQL at LowestMinPrefix and each span at SpanPrefixOK; the SELECT/Scan column order matches;
    DefaultWaitPolicy carries both floors; DashWaitPolicy (proxy/keepalive.go:602) now threads
    both floors from the tenant config. The golden fixture pins its account floor at 20k, so the
    golden files stay valid.
  • The other floor readers: the session override sets WaitPlan = false, so one floor applies
    (proxy/keepaliveoverride.go:189); the predictive campaign zeroes the floor as before
    (predictive.go:455, unchanged behavior); adaptcache.go maps a tool stop to a tool wait and
    flags subagent rows (rowFacts has one producer, campaignauto.go:137, which sets it).
  • The strategy tables: Go, settings.py and pi_plugin.py agree at 80000; the drift tests
    (TestStrategyTableMatchesPlugin, pi's test_strategies_match_the_claude_code_plugin) compare
    values and the auto desc, both consistent; no table writes the new key.
  • The behavior change is named at the top of the PR body: who, old, new, the owner's choice of
    2026-11-10, and two turn-off switches. The extension to background/teammate/unknown causes is
    flagged as the author's reading of the owner's two rules. Data dependence: metadata only (stop
    reason, tool names, thread shape, token counts). Agree.
  • Remaining docs that name the floor: kv-cache-keepalive-budget.md and
    test-subscription-sandbox.md show example values, not defaults — fine. The two wrong spots are
    the findings above.
  • No tests were run. Live tests are not approved, and Go is not on this machine.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 c0a99f8ce8b2 blocking

Verdict: blocking

Findings

  1. proxy/adaptcache.go:157-161 — the adapt replay gives OpenAI rows the 20k tool-wait floor; the keeper and the dash replay do not

    • What fails: an OpenAI row whose stop reason is tool_calls or function_call (both in
      keepalive.ToolStopReasons) reads as a tool wait, and any OpenAI subagent row reads as a
      subagent wait. So the adapt report gates those rows at 20k. The request path does not: the
      keeper reads no wait cause for an OpenAI thread (keepalive/keeper.go:914,
      guard := ... && provider != bschemas.OpenAI), so e.wait stays "" and
      WaitMinPrefix returns the general floor. The dash replay agrees with the keeper
      (Policy.SpanPrefixOK: s.OpenAI → general floor). For OpenAI traffic with a 20k-80k
      prefix, the adapt report counts pings the policy never sends.
    • Proof: ToolStopReasons = {"tool_use", "tool_calls", "function_call"} (waitplan.go:148);
      tool_calls/function_call are OpenAI stop reasons. kvcache.Request has a Provider
      field (kvcache.go:226), and autoRowsX builds rowFacts from those requests without a
      provider filter, but rowFacts does not carry the provider, so the gate cannot see it.
    • Fix: copy the provider into rowFacts and apply the general floor on OpenAI rows, the same
      rule as SpanPrefixOK. The PR body says "Adapt replay uses the same floors" — today it does
      not, for OpenAI.
  2. RELEASING.md:225 — the release-check trap states a default this PR removes

    • What fails: the Part B trap says "The default floor is keepalive_min_prefix_tokens: 20000
      (it was 80000 before #858), so a small session needs a lower value in its own config." After
      this PR the default of keepalive_min_prefix_tokens is 80000 again, and 20000 is the default
      of a different key. The sentence sends the release checker wrong: a small session on a tool
      wait now gets pings at the 20k default, with no config change.
    • Proof: config.DefaultKeepAliveMinPrefix = 80000 and DefaultKeepAliveToolWaitMinPrefix = 20000 (config/config.go, this PR). RELEASING.md is not in the diff.
    • Fix: rewrite the line to the two floors and their keys.
  3. dash/keepalive.go:591 and 611 — comments still say the shipped floor is 20k

    • What fails: line 591 says "the shipped floor is 20k since #858" and line 611 says 20,000 "is
      the shipped floor again since #858 (80,000 in between)". Both are false after this PR: the
      shipped general floor is 80000 and 20k is the tool-wait floor. The same package now defines
      kaGateMinPrefix = 80000 (line 1299) and a pinning test asserts it, so the package states
      two opposite facts about the same policy.
    • Proof: the diff touches dash/keepalive.go around lines 1290-1400 but not 591/611; I read the
      current text of both lines.
    • Fix: reword both to the two-floor rule, as the gate comment at line 1293 already does.

Non-blocking

  • docs/how-to/kv-cache-keepalive-budget.md:33 — the example sets
    keepalive_min_prefix_tokens: 20000. That now lowers the general floor, which re-enables 20k
    pings for a main thread's wait for a person — the case the owner's 80k rule refuses (the PR
    body: under 50k, 0 of 274 came back). Drop the line or use the new key.
  • proxy/adaptcache.go:157 — a main-thread ask-a-person tool stop reads as a tool wait (20k)
    where the keeper reads a person (80k). A kvcache row has no tool names and no stored cause, so
    the replay cannot do better. The comment could state the exception, as dash's storedWait does.

Earlier findings

Mine, round 1:

  1. Pi never re-renders the config — fixed by scope change, accepted. The owner moved the
    re-render to issue #1044 (open, I checked). This PR has no Pi re-render code (removed in
    c0a99f8c). Under the new design an old Pi file needs no re-render for this change: it keeps
    80000 as the general floor and gets the 20k tool-wait floor from the proxy default, because
    the file does not state the new key. The PR body now says this for both plugins.
  2. strategy.go:28 comment contradicted the code — fixed. The table writes literals again
    (80000), the comment states the pinning rule, and TestStrategiesPinTheGeneralFloorToTheDefault
    fails when the table and the default drift. The table does not write the new key, and a test
    guards that too.
  3. campaign.go:47 stale mirror — resolved by the redesign. DefaultKeepAliveMinPrefix is
    80000 again, so campaignDefaultMinPrefixTokens = 80000 matches the default it claims to
    mirror. The author also says the main session tracks it in its own issue.

Reviewer 2, round 1 (read in full this round; it was posted before my round-1 review):

  • Finding 1 (Pi) and finding 2 (strategy.go comment) are the same as mine — both addressed as
    above. I checked both myself.
  • Non-blocking (campaign drift, the 80000 substring assertion): the campaign point is tracked;
    the substring assertion is gone — the new TestStrategyFileHasNoToolWaitFloor checks the key
    lines themselves.

What I checked

  • Last review: round 1, 6a9f29a, 2026-11-10T12:25:54Z.
  • New commits read: 3 — 54a7eaa9 (merge of origin/main: #1046, #720, #483), ee1e01dc
    (fix(keepalive): choose the prefix floor by wait cause), c0a99f8c (revert(pi): drop the Pi
    config re-render).
  • Read in full: 2 reviews, 3 comments, 0 inline comments (from the three files;
    .review-in-inline.txt is empty).
  • New items since my last review: the 3 commits above, the rewritten PR body, and 3 issue
    comments by the author (two replies to the round-1 reviews, one note on the Pi revert). I
    checked each reply against the code, and verified issue #1044 exists and is open.
  • The full net diff b57b2bda..c0a99f8c (27 files) and the code around each change. The merge
    brings main's own reviewed PRs; the net diff against the new base isolates this PR's change.
  • The new floor rule end to end: Policy.WaitMinPrefix (min of the two floors, plan-off and
    unknown-cause fall back to the general floor), pingable() (keeper.go:329), the keeper's wait
    assignment (keeper.go:914-921: no wait cause for OpenAI or 1-hour counts), ForOneHour
    (floor still applies on the 1h tier, and dash's SpanPrefixOK agrees — no drift there).
  • The dash replay: gatePolicy, LowestMinPrefix in SQL then SpanPrefixOK per span,
    scanFacts sets Subagent from the thread id, the SELECT/Scan column order matches, and the
    golden fixture pins its floor at 20k so the golden files stay unchanged.
  • The policy plumbing: cachePolicy in cmd/main.go carries ToolWaitMinPrefix on both return
    paths; proxy.CachePolicy is an alias of keepalive.Policy, so manager strategies
    (applyStrategyWindows) and overrides keep the account's plan fields; DashWaitPolicy passes
    both floors.
  • The strategy chain: the table writes 80000 and no tool-wait key; settings.py matches (desc
    strings equal on both sides); pi_plugin.py is byte-identical to base again; the round-1
    sync-lowers test is gone and the new file test matches the new design.
  • Docs and comments for stale floor claims: cache-keepalive.md and the two stale comments are
    fixed; RELEASING.md, the two dash comments, and the budget-doc example are not (findings 2 and
    3, non-blocking).
  • The PR body names the behavior change at the top (who, old, new, effect, turn-off, owner
    approval 2026-11-10) and states the data dependence (metadata only). No row in
    docs/data-dependence.md changes.
  • No tests were run. Live tests are not approved, and Go is not on this machine.

- The adapt replay gives an OpenAI row the general floor only, as the
  keeper does. rowFacts carries the provider. New test and mutation.
- RELEASING.md, dash comments, panel copy and the budget how-to state
  the two floors.
- Comments name the known gaps: tool stops that ask a person, old
  rows with no cause, and the calculator at idle 300 s or more.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Reply to Reviewer 1, round 2. Head is now 1ce76d25.

  1. adaptcache.go: OpenAI rows got the 20k floor: fixed. rowFacts now carries the provider. New rowFloor gives an OpenAI row the general floor only, as the keeper and SpanPrefixOK do. New test TestRowFloorFollowsTheWaitAndTheProvider fails when the OpenAI branch is removed.
  2. RELEASING.md:225: fixed. The trap line states both floors.
  3. dash/keepalive.go comments: fixed. Both comments state the two-floor rule.
  4. Non-blocking: fixed. Comments added for a tool stop that asks a person, an old row with no cause, and the calculator at idle 300 s or more.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Reply to Reviewer 2, round 2. Head is now 1ce76d25.

  1. RELEASING.md:225: fixed. The trap line states both floors.
  2. dash/keepalive.go comments: fixed. Both comments state the two-floor rule.
  3. dash/ui/app.js panel copy: fixed. The three texts now say "over 20k for a tool wait or a subagent, 80k otherwise". No dash test or golden file pins this text.
  4. Non-blocking: fixed. kv-cache-keepalive-budget.md shows both keys. Comments added for the old-row case and the calculator at idle 300 s or more. I did not change the calculator: the fix is not one line.

The owner decided: a main thread that waits for background work or a
teammate uses the 20k floor, like a tool wait. Only a main thread that
waits for a person, or for an unknown cause, keeps the 80k floor.
Subagents keep 20k for every cause. OpenAI keeps the general floor.

- Policy.WaitMinPrefix and its tests (keeper gate and dashboard replay).
- Adapt replay: a row has only a stop reason, so a non-tool stop reads
  as a person (80k). The comment says the replay under-counts.
- Docs, Desc texts, panel copy and RELEASING.md state the new rule.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 3 of 3 d01128ed3ded blocking

Verdict: blocking

Findings

  1. pi-package/README.md:121 — the floor sentence was updated for the round-2 rule and missed by the round-3 rule
    • What fails: the README says the proxy "pings only a session with a prefix of 80,000 tokens or
      more (20,000 while a tool runs, and on a subagent)". Commit d01128ed moved a main thread's
      waits for background work and for a teammate to the 20k floor, so the sentence now names only
      two of the four 20k causes. A Pi user whose main thread waits for background work at a 30k
      prefix is told the proxy never pings it, and it does — on the user's own credential. Every
      other copy states the new rule: the config comments, the strategy Desc (Go and
      settings.py), docs/how-to/cache-keepalive.md, RELEASING.md, and the three dash panel
      texts. This file was updated for the earlier rule in ee1e01dc and not re-read by d01128ed
      (no pi-package file is in its diff).
    • Proof: pi-package/README.md:121 (read after d01128ed); WaitMinPrefix
      (keepalive/waitplan.go:86-96) gives 20k to own_tool, background, teammate and every subagent
      wait; d01128ed's file list has no pi-package entry.
    • Fix: one clause: "(20,000 while a tool runs, for background work or a teammate, and on a
      subagent)".

Non-blocking

  • Several copies say "20k except for a main thread that waits for a person" and omit the unknown
    cause, which also keeps 80k: dash/keepalive.go:612, dash/ui/app.js:9664 and :9722,
    docs/components/advanced-offload.md:203, kvcache/strategy.go:506. The unknown cause is the
    rare classifier fallback, so this is precision only.
  • proxy/adaptcache.go:171-176 — the rowFloor comment says an ask-a-person tool stop "reads as
    a tool wait here, as dash's storedWait reads it". Dash's storedWait keeps a tool stop with a
    stored human cause as human; only a row with no stored cause reads as a tool wait. The adapt
    behavior is right and the PR body states it; the comparison with dash is imprecise.
  • The PR body's "How it was tested" list still names the round-2 test set and omits
    TestRowFloorFollowsTheWaitAndTheProvider (the reply comment does name it, with mutation).

Earlier findings

Mine, round 2:

  1. Adapt replay gave OpenAI rows the 20k floor — fixed. rowFacts carries openai
    (r.Provider == "openai", campaignauto.go:141), rowFloor returns the general floor for an
    OpenAI row, and TestRowFloorFollowsTheWaitAndTheProvider covers the main tool stop, end_turn,
    subagent, OpenAI tool stop and OpenAI subagent cases. I checked each against WaitMinPrefix.
  2. RELEASING.md:225 — fixed. The trap line now states both floors and both keys, including
    which waits use which.
  3. dash/keepalive.go:591 and 611 — fixed. Both comments state the two-floor rule; the
    prefix-edges comment names both edges.
  • Non-blocking then: the budget-doc example now shows both keys with the default values; the
    ask-a-person exception is stated in the rowFloor comment.

Reviewer 2, round 2 (read in full; posted just before my round-2 review):

  • Finding 1 (dash panel copy still said 20k) — fixed. I read all three spots (app.js:9474,
    :9664, :9722); they now state both floors.
  • Finding 2 (RELEASING.md) — same as my round-2 finding 2, fixed as above.
  • Non-blocking (keeper keeps the per-cause floor at Idle >= 300 s while the calculator turns the
    plan off; SpanPrefixOK gives an old no-cause subagent row the general floor) — the author
    documented both as known gaps in comments (dash/keepalive.go:1665-1668, waitplan.go:106-109)
    rather than fixing, and said the calculator fix "is not one line". I accept: both gaps
    under-count, the safe direction, the calculator's idle band is outside the config's allowed
    range (under 300 s), and old rows are the only case for the second.

What I checked

  • Last review: round 2, c0a99f8, 2026-11-10T14:23:56Z.
  • New commits read: 2 — 1ce76d25 (fix(keepalive): fix round-2 review findings on the floor by
    wait cause), d01128ed (fix(keepalive): main background and teammate waits use the 20k floor).
  • Read in full: 4 reviews, 5 comments, 0 inline comments (from the three files;
    .review-in-inline.txt is empty).
  • New items since my last review: the two commits above; reviewer 2's round-2 review; the
    author's two replies at 14:43 (to reviewer 1 and reviewer 2); the rewritten PR body. Each reply
    claim was checked against the code, including the new test and the OpenAI branch.
  • The round-3 rule change end to end: WaitMinPrefix's switch (own_tool, background, teammate,
    subagent → 20k; human, unknown, done, retry and "" → the general floor — I checked every
    waitcause constant against the switch), the keeper's pingable, the dash SpanPrefixOK and
    its new test cases (background, teammate, unknown), the adapt rowFloor, and the label string.
  • Consistency of every user-facing copy of the rule: config comments, DefaultKeepAliveMinPrefix
    comment, the strategy Desc in Go and settings.py (identical strings, pinned by the drift
    test), cache-keepalive.md, the budget how-to, RELEASING.md, app.js (three spots),
    extract_sweep_ping.go, kvcache/strategy.go, advanced-offload.md, and the Pi README — the
    README is the one straggler (finding 1).
  • The two commits' other changes: rowFloor's extraction and test; the known-gap comments; the
    openai flag has one producer (autoRowsX) and the test; nothing else reads it.
  • The PR body states the newest owner decision with its date, the turn-off switches, the adapt
    under-count honestly, and the data dependence (metadata only). No row in
    docs/data-dependence.md changes.
  • No tests were run. Live tests are not approved, and Go is not on this machine.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 3 of 3 d01128ed3ded blocking

Verdict: blocking

Findings

  1. pi-package/README.md:122 — the README states the rule that d01128ed superseded
    • What fails: "The proxy pings only a session with a prefix of 80,000 tokens or more (20,000
      while a tool runs, and on a subagent)". The owner's decision in d01128ed also gives a MAIN
      thread's wait for background work or a teammate the 20k floor (WaitMinPrefix,
      keepalive/waitplan.go:90-95). The sentence's "only" enumeration is now false: a main thread
      waiting on background work at a 30k prefix gets a ping, and the README says it does not. This
      is the paragraph that warns the user about their own quota, so the understated spend rule is
      the wrong half to get wrong. The PR updated this very sentence for the earlier rule
      (ee1e01dc) and missed it when the rule changed again. A second spot has the same staleness:
      docs/how-to/kv-cache-keepalive-budget.md:33-34 still glosses the keys as "a tool wait and for
      a subagent" / "a main thread that waits for a person" (written in 1ce76d25, not updated by
      d01128ed).
    • Proof: WaitMinPrefix returns the tool-wait floor for WaitingBackground and
      WaitingTeammate on a main thread (waitplan.go:91-93); the tests pin it
      (keepalive/waitminprefix_test.go:21-22, dash/keepaliveplan_test.go:417-418). Neither file is
      in d01128ed's change list; both are in ee1e01dc's and 1ce76d25's.
    • Fix: one line each. Pi README: "(20,000 while a tool runs, for background work or a teammate,
      and on a subagent)". Budget how-to: name background work and a teammate in the two comments.

Earlier findings

  • Mine, round 2, finding 1 (dash panel copy and comments said 20k): fixed. The three app.js
    spots (9474, 9664, 9722) and both dash/keepalive.go comments (591, 611) now state the two floors
    by cause. Verified in the diff of 1ce76d25 and d01128ed.
  • Mine, round 2, finding 2 (RELEASING.md wrong default): fixed. The trap line now states both
    keys and both floors, and it was updated again by d01128ed for the background/teammate change.
  • Mine, round 2, non-blocking (Idle >= 300 s replay gap): addressed, accepted. The author added
    a "Known gap" comment at dash/keepalive.go:1665-1667 and did not change the calculator ("the fix
    is not one line"). The reason is right: the band is off-spec (docs say idle must be under 300 s)
    and the replay under-counts.
  • Mine, round 2, non-blocking (old subagent rows get the general floor): addressed. The
    SpanPrefixOK comment now states the old-row rule and calls the under-count the safe direction
    (waitplan.go:106-108).
  • Reviewer 1, round 2, finding 1 (adapt replay gave OpenAI rows the 20k floor): fixed, and I
    checked it myself.
    rowFacts carries openai (campaignauto.go:140), rowFloor returns the
    general floor for an OpenAI row (adaptcache.go:172-174), matching the keeper (guard excludes
    OpenAI, keeper.go:914) and SpanPrefixOK (s.OpenAI). TestRowFloorFollowsTheWaitAndTheProvider
    covers it, including the two OpenAI cases.
  • Reviewer 1, round 2, findings 2 and 3: same as my round-2 findings — fixed (see above).
  • Reviewer 1, round 2, non-blocking (budget doc example, ask-a-person comment): addressed. The
    budget doc was fixed in 1ce76d25 (and is stale again only in the way my finding above says);
    the rowFloor comment states the ask-a-person exception in both directions.

Non-blocking

  • Several simplified statements name only "a main thread that waits for a person" for the 80k floor
    and omit the unknown cause (dash/keepalive.go:612, app.js:9475, RELEASING.md:225). The full rule —
    person or unknown cause — is in docs/how-to/cache-keepalive.md, the WaitMinPrefix doc comment
    and the PR body. The unknown cause is a fallback classification, so I leave this here.

What I checked

  • Last review: round 2, c0a99f8, 2026-11-10T14:23:24Z.
  • New commits read: 2 — 1ce76d25 (fix round-2 review findings on the floor by wait cause),
    d01128ed (main background and teammate waits use the 20k floor). Both diffs read in full, plus
    the code around each change.
  • Read in full: 4 reviews, 6 comments, 0 inline comments (the three files were saved again this
    round and read in full; .review-in-inline.txt is empty).
  • New items since my last review: the 2 commits above and the author's 2 comments at 14:43 (replies
    to both round-2 reviews). Each reply claim was checked against the code: rowFloor and the
    OpenAI flag (read), RELEASING.md (read), the dash comments (read), the app.js copy (read), the
    budget doc (read), the known-gap and old-row comments (read).
  • The rule change in d01128ed end to end: WaitMinPrefix's switch gives the tool-wait floor to
    a tool wait, background work, a teammate and any subagent wait, and the general floor to a
    person, an unknown cause, done and retry (waitplan.go:86-97). The keeper gate, the dash replay
    (SpanPrefixOK) and the adapt replay (rowFloor) all read the same function. The three test
    files were extended for the new causes (waitminprefix_test.go, keepaliveplan_test.go,
    adaptcache_test.go).
  • Every text that states the rule: config.go, strategy.go and settings.py Descs (Go and Python
    match), dash comments and app.js copy, cache-keepalive.md, advanced-offload.md,
    extract_sweep_ping.go, kvcache/strategy.go, RELEASING.md, kv-cache-keepalive-budget.md,
    pi-package/README.md — all read. All state the new rule except the two spots in the finding.
    Greps for the old wordings ("tool wait or a subagent", "while a tool runs") find nothing else.
  • The waitcause constants ("background", "teammate", "unknown") match the literals the new tests
    use, so the dash replay reads stored causes correctly.
  • The PR body names the behavior change at the top and states the owner's decision of 2026-11-10
    cause by cause, with two turn-off switches. Data dependence: metadata only, unchanged. Agree.
  • No tests were run. Live tests are not approved, and Go is not on this machine.

Round 3 found copy that named only a tool wait and a subagent, or that
left out an unknown cause from the 80k floor. Fix the README, the
how-tos, the panel copy and the comments. The adapt replay comment now
says a row has no stored cause, so every tool stop reads as a tool wait.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Reply to Reviewer 1, round 3. Head is now 07f448cb.

  1. README and budget how-to: fixed. pi-package/README.md and kv-cache-keepalive-budget.md name background work and a teammate.
  2. "80k only for a person" copy: fixed. Each place now says "or for an unknown cause": dash/keepalive.go, the three panel texts in app.js (still inside the 4000-character test window), advanced-offload.md and kvcache/strategy.go. I also fixed the same wording in config, keepalive and the form comments.
  3. adaptcache.go comment: fixed. It now says a row has no stored cause, so every tool stop reads as a tool wait, and that dash's storedWait keeps a stored human cause as human.
  4. PR body: updated with the new test and the round-3 mutation.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Reply to Reviewer 2, round 3. Head is now 07f448cb.

  1. README and budget how-to: fixed. pi-package/README.md and kv-cache-keepalive-budget.md name background work and a teammate.
  2. "80k only for a person" copy: fixed. Each place now says "or for an unknown cause": dash/keepalive.go, the three panel texts in app.js (still inside the 4000-character test window), advanced-offload.md and kvcache/strategy.go. I also fixed the same wording in config, keepalive and the form comments.
  3. adaptcache.go comment: fixed. It now says a row has no stored cause, so every tool stop reads as a tool wait, and that dash's storedWait keeps a stored human cause as human.
  4. PR body: updated with the new test and the round-3 mutation.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 4 of 4 07f448cb919e approve

Verdict: approve

Findings

None. My round-3 finding is fixed, and the new commit introduces no defect.

Earlier findings

  • Mine, round 3, finding 1 (pi README and budget how-to stated the superseded rule): fixed.
    pi-package/README.md:122 now reads "(20,000 while a tool runs, for background work or a
    teammate, and on a subagent)" — the exact fix I proposed. The budget how-to's two comments
    (kv-cache-keepalive-budget.md:33-34) now name background work and a teammate. Verified in the
    diff of 07f448cb.
  • Mine, round 3, non-blocking (person-only 80k copy): mostly fixed, remainder stays
    non-blocking.
    The commit adds "or for an unknown cause" to the dash comments, the three app.js
    texts, advanced-offload.md, kvcache/strategy.go and the config/keepalive/form comments. Three
    spots still name only a person — see Non-blocking.
  • Reviewer 1, round 3, finding 1: same as mine — fixed (checked myself, above).
  • Reviewer 1, round 3, non-blocking (unknown-cause copy, adaptcache comment, PR body test list):
    all three addressed
    , and I checked each: the copy spots listed are fixed; the rowFloor
    comment now states the no-stored-cause rule and the dash difference; the PR body's test list now
    names TestRowFloorFollowsTheWaitAndTheProvider with the round-3 mutation.

Non-blocking

  • Three copies still give the 80k floor as "a main thread that waits for a person" without the
    unknown cause: RELEASING.md:225, the adapt report label (proxy/adaptcache.go:159), and the
    auto strategy Desc (config/strategy.go:74, mirrored in settings.py). The unknown cause also
    gets 80k. The full rule is in docs/how-to/cache-keepalive.md, the WaitMinPrefix doc comment
    and the PR body. The unknown cause is a fallback classification, so precision only.

What I checked

  • Last review: round 3, d01128e, 2026-11-10T15:15:44Z.
  • New commits read: 1 — 07f448cb (docs: state the 20k and 80k floors the same way everywhere).
    Full diff read, plus the code around each change.
  • Read in full: 6 reviews, 7 comments, 0 inline comments (the three files were saved again this
    round and read in full; .review-in-inline.txt is empty).
  • New items since my last review: the commit above, the author's two replies at 15:23 (to both
    round-3 reviews), and the updated PR body. Each reply claim was checked against the code.
  • The commit changes comments and copy strings only. No code path changed: rowFloor's body, the
    config constants and the dash gates are byte-identical to d01128ed. So no new behavior to
    test, and the existing test set still covers the rule.
  • Every edited sentence checked against WaitMinPrefix's switch (waitplan.go:86-97): 20k for a
    tool wait, background work, a teammate and any subagent wait; 80k for a person or an unknown
    cause. All eleven edited spots state it correctly.
  • The rowFloor comment's new claim, checked myself: storedWait passes noNames = false for a
    stored human cause (waitplan.go:191-193), so toolStopWait keeps a tool stop stored as "human"
    as human. Dash's replay and the adapt replay do differ exactly as the comment says.
  • The author's "still inside the 4000-character test window" claim, checked with the real offsets:
    in loadKARecommend's window (uikeepalive_test.go:124), the pinned range regex matches, and
    rec.refused (offset 729) and "factor of two" (offset 2890) stay inside the 4000 characters.
    The other window (line 92, renderKADownside) is an unchanged function.
  • The PR body: the test list now names the adapt-replay test and the round-3 mutation; the
    behavior-change section still states the owner decision of 2026-11-10 cause by cause, with two
    turn-off switches. Data dependence: metadata only, unchanged. Agree.
  • Final greps: the old enumeration ("while a tool runs, and on a subagent") is gone everywhere;
    the only remaining person-only wordings are the three non-blocking spots above.
  • No tests were run. Live tests are not approved, and Go is not on this machine.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 4 of 4 07f448cb919e approve

Verdict: approve

Findings

None. The new commit is docs and comments only. I read every changed line and checked each
new sentence against Policy.WaitMinPrefix (keepalive/waitplan.go:86-97). All state the
shipped rule: 20k for a tool wait, background work, a teammate and any subagent wait; 80k
for a main thread that waits for a person or for an unknown cause. No code, test or
behavior changed.

Non-blocking

  • Four copies still name only "a person" for the 80k floor and omit the unknown cause, the
    same rare-fallback class I rated non-blocking in round 3:
    config/strategy.go:74 and settings.py:3699 (the strategy Desc, identical on both
    sides, so the drift test still passes), RELEASING.md:225 (a small-session example, not
    a rule statement), proxy/adaptcache.go:159 (the label says "(%d otherwise)", which
    reads an unknown cause as the lower floor), and the 80k half of the Pi README sentence.
  • The commit message says "the same way everywhere". The four spots above are not
    everywhere. The author's reply lists exactly what was fixed, so this is wording, not a
    hidden claim.

Earlier findings

Mine, round 3:

  1. pi-package/README.md:121 named only two of the four 20k causes — fixed. The
    sentence now reads "(20,000 while a tool runs, for background work or a teammate, and
    on a subagent)" — the clause I asked for. Verified against WaitMinPrefix.
  2. Non-blocking: five copies omitted the unknown cause — fixed. dash/keepalive.go
    (three spots), the three panel texts in app.js, advanced-offload.md,
    kvcache/strategy.go and kv-cache-keepalive-budget.md now all say "or for an
    unknown cause". The remaining four spots of the same class are in this round's
    non-blocking list.
  3. Non-blocking: the rowFloor comment compared dash imprecisely — fixed. It now
    says a row carries no stored cause, so every tool stop reads as a tool wait, and that
    dash's storedWait keeps a tool stop with a stored human cause as human. That matches
    what I verified in round 3.
  4. Non-blocking: the PR body's test list — fixed. It now names
    TestRowFloorFollowsTheWaitAndTheProvider and the round-3 mutation (checked in the
    body itself).

Reviewer 2, round 3 (read in full; posted just after my round-3 review):

  • Finding 1 (Pi README, plus the budget how-to's two glosses) — fixed. Both files are
    in 07f448cb; I read the diffs. The budget how-to now names background work and a
    teammate in both key comments.
  • Non-blocking (unknown-cause omissions) — two of the three spots fixed; RELEASING.md:225
    remains, as noted above. I accept it: the sentence is an example of a small session, not
    a statement of the rule.

What I checked

  • Last review: round 3, d01128e, 2026-11-10T15:14:17Z.
  • New commits read: 1 — 07f448cb (docs: state the 20k and 80k floors the same way
    everywhere). Full diff read: 11 files, +21/−19. Every change is a comment, a doc line or
    a panel string; no Go statement changed.
  • Read in full: 5 reviews, 7 comments, 0 inline comments (from the three files;
    .review-in-inline.txt is empty).
  • New items since my last review: the commit above, reviewer 2's round-3 review, and the
    author's two replies at 15:23. Each reply claim was checked against the code: the fixed
    copy (read), the app.js parse safety (the edits extend existing string literals in
    concatenations; dash/api_test.go:427 parses app.js and stays green), and the PR body
    (fetched and read).
  • The accuracy of every new sentence, against the switch in waitplan.go: config.go,
    form.go, types.go, waitplan.go (comments), dash/keepalive.go (three comments),
    the three app.js panel texts, advanced-offload.md, the budget how-to,
    kvcache/strategy.go, the Pi README, and the rewritten rowFloor comment.
  • Greps for the stale wordings ("a tool wait and a subagent", "while a tool runs" outside
    the fixed sentence, "is the shipped floor") find nothing else that misstates the rule.
  • No Go test pins the changed panel copy; the only copy-adjacent tests are the app.js
    parse test and the strategy-table drift tests, and the Desc is unchanged on both sides.
  • No tests were run. Live tests are not approved, and Go is not on this machine.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Merged origin/main into this branch (head c899242).

  • Merge: no conflicts. Remerge-diff: 0 lines.
  • Semantic check: the floor is chosen in the keeper by wait cause, before any substitute runs. The sweep ping, the warm path and the summary substitute all inherit it. No function is defined twice. Strategy table and config keys agree. go vet ./... clean.
  • Tests (box, -race): keepalive, config, components, kvcache, cmd/context-guru-proxy, dash, context-guru-plugin, proxy (two halves). All pass.
  • CI: CI, CodeQL, Docs, DCO green.

@amiddavid
amiddavid merged commit 1b63ffc into main Nov 10, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 10, 2026
amiddavid added a commit that referenced this pull request Nov 11, 2026
…0.2.12, Pi 0.1.1)

Claude Code plugin 0.6.7 -> 0.7.2:
- #981, #989, #1018, #1035: subscription band and savings show saved tokens.
- #1038: insights drop the finding that credits a user's own removal.
- #1039, #1040: dash and keep-alive fixes that touch the plugin files.

Codex plugin 0.2.11 -> 0.2.12:
- #1051: read the cache strategies and presets from the proxy.
- The vendored cg.py gets the same plugin changes.

Pi package 0.1.0 -> 0.1.1:
- #1010: chain the proxy in front of an existing base URL.
- #1011: check the proxy at session start and restart it once.
- #1049, #1058: write the cache strategy by name; review fixes.

OpenCode plugin (#483): new in v0.7.2, no version file, not changed.
Bob plugin 0.1.0: no change since v0.7.1, not changed.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 11, 2026
Add K9 (pings per long wait), K10 (no-ping misses by prefix band) and
X6 (savings share by thread type), each compared with the week before
and split by main or subagent thread. Add the #1040 case with a laptop
baseline, and gap G10 (the keep-alive settings in effect are not
recorded).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 11, 2026
A new test covers the sweep question at the keep-alive ping under the
per-cause prefix floors from #1040: 20k tokens for a subagent wait,
80k for a person or an unknown cause. Test only.

Mutation checks: the test fails when the 20k subagent floor is
removed, when the general floor is set to 120k, and when the unknown
cause gets the 20k floor.

Behavior change: none. Data dependence: none.

Reviews: 2 offload reviews (GLM), round 3 (granted by the owner), both
approve at 77909f3, which is the PR head.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
amiddavid added a commit that referenced this pull request Nov 11, 2026
Bump the plugin versions for v0.7.2.

- Claude Code plugin 0.6.7 -> 0.7.2: #981, #989, #1018, #1035 (savings
  in tokens on a subscription), #1038, #1039, #1040, #1055 (cache
  strategies read from the proxy).
- Codex plugin 0.2.11 -> 0.2.12: #1051 (cache strategies and presets
  read from the proxy), plus the vendored cg.py changes.
- Pi package 0.1.0 -> 0.1.1: #1010, #1011, #1049, #1058, and the #1040
  README line.
- OpenCode plugin: new in v0.7.2 (#483), no version file. Its first
  start now downloads proxy v0.7.2 (was v0.7.1). Nothing compares
  against PINNED_VERSION; the floor stays "v0.7.1 or later". The README
  lines, the install guide and 3 tests follow.
- Bob plugin: 0.1.0, no change since v0.7.1.

Behavior change: the OpenCode plugin's first download is proxy v0.7.2,
not v0.7.1. Owner's yes, 2026-11-11, in the integrator session: "option1
it is"; the version bumps: "I approve the version bumps for the
plugins".

Data dependence: none.

Reviews: 3 offload review rounds (GLM; round 3 pre-approved by the
owner). Both reviewers approve at 3cf6176, which is the PR head.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant