Skip to content

feat(dash): tool deferral's dashboard, net-saving panel and save-more tools (#869) - #877

Merged
amiddavid merged 12 commits into
mainfrom
feat/deferral-dash-869
Nov 3, 2026
Merged

amiddavid merged 12 commits into
mainfrom
feat/deferral-dash-869

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change (the owner approved it)

  • Who it affects: every dashboard and plugin user. The new parts reach only accounts on the ultrahigh preset.
  • Old: tool_declarations held only deferred mcp__ tools. tool_uses held only tool_use calls.
  • New:
    • The built-ins Claude Code defers (Monitor, WebFetch, the Cron tools, and others) are recorded with 0 tokens.
    • A tool loaded through search counts as one use.
    • So the "unused" figures in remove-mcp-and-skills, save-more and the Tools tab can drop: a tool that was only loaded is now "used". Token and dollar totals do not change, because built-ins stay out of every total.
    • Tool deferral's history (seeded from these tables) now sees these tools. This is what Tool deferral follow-ups from the #861 review (N1–N10, N12) #866 N9 asks for.
    • save-more gets a tools part. The Tools tab gets a net-saving panel. It shows only when deferral changed a request.
  • How to turn it off: no switch for the recording. The new panel and save-more tools show nothing new on an account without deferral.
  • Not done: remove-mcp-and-skills is not removed (dash: tool deferral's dashboard, net-saving panel and save-more tools (#485 follow-up) #869 item 5). That waits for the owner's yes. Its skill and doc now point to save-more tools.

Data dependence

Metadata only. No change of level. It uses tool names, counts, token weights and prices. At each storage level:

  • Off: nothing (the dashboard is off).
  • Metadata only: works.
  • Everything: works the same.

docs/data-dependence.md (Dashboard database row) names the 8 new request columns and the 2 inventory changes.

Summary

The dashboard and save-more part of tool deferral (#869, items 1 to 4, and #866 N9).

What changed

  1. Deferred built-ins are recorded (dash/toolinventory.go). Each name in Claude Code's "deferred tools" block that is not mcp__ becomes a tool row with deferred = 1 and 0 tokens. MCP token shares do not change.
  2. A search load is a use (usedFrom). Two forms count:
    • a tool_search_tool_result in the last tool-using turn;
    • tool_reference blocks in the tool result right after it (Claude Code's ToolSearch).
      A load counts as 1 call, or 0 more if the turn also called the tool. A turn with only a search load is a tool-using turn, so the fingerprint dedupes it.
  3. Net-saving panel:
    • Each request deferral changed now stores 8 numbers on its row: tokens deferred, list tokens, searches, dropped searches, tools loaded, wrong guesses, gross USD and net USD. The row takes them from the same tooldefer.Request that the /stats ledger books, so the two cannot disagree.
    • A wrong guess is counted by fix(tooldefer): the follow-ups to tool deferral from #866 #874's tooldefer.WrongGuesses: a tool this request deferred, that a search in its response loaded, and that no earlier message loaded. A dropped search is fix(tooldefer): the follow-ups to tool deferral from #866 #874's SearchRead.Dropped(): a search with no result.
    • GET /api/tool-defer sums the numbers per account and UTC day.
    • The Tools tab shows tiles and a per-day table.
  4. save-more tools (toolfilter: defer unused tool declarations at session start, by history (was: remove at cold moments) #485 D3):
    • GET /api/save-more/tools returns one row per tool, MCP server and skill: state (loaded, deferred_cg, deferred_client, removed), use, carry cost and reason. tooldefer.Explain gives the rule's answer for one tool.
    • "Always defer" is shown as not available yet (not_yet, with tooldefer: an always-defer list (toolfilter.always_defer) for save-more tools #878). toolfilter has no list for it, and tooldefer.Decide is not touched here.
    • POST /api/save-more/tools/apply takes keep:<name>, unkeep:<name>, search_on, search_off or revert. It writes toolfilter's keep and defer through the shared adapt path (adaptWrite and adaptRevert), so hosted and local both work. It writes only options that the caller's own report offered.
    • Plugin: /context-guru:save-more tools prints the rows. The change commands are apply deferral … and revert deferral. The removal report keeps the tools kind, so apply tools and revert tools work as before. The Codex copy of cg.py and both skills are updated.
  5. Docs: docs/plugin/save-more.md (a new Tools section) and docs/plugin/remove-mcp-and-skills.md (a pointer).

How it was tested

On the eval box (~/cgssh2), CGO_ENABLED=1 go test -race -count=1:

Package Result
./dash/... ok (595 s)
./proxy/... ok (488 s)
./tooldefer/... ok (3 s)
./context-guru-plugin/... ok (346 s)

These are the results at the final head, rebased on main after #874 merged.
| plugin Python (unittest, both plugins) | 83 and 43 tests OK |

New tests: the parser on the dash/testdata/deferred fixtures (21 built-ins, 0 tokens, one row when loaded), the use recording (server search, ToolSearch, call and load in one turn, an older load, a pasted reference), the panel query (per account and day, scope, unpriced rows), the proxy row facts against the ledger, wrongGuesses, Explain, the save-more rows and options, a local keep, search_on and revert round trip, and 6 plugin goldens.

Mutations (each one made a test fail, then the code was restored):

  • drop built-ins;
  • charge built-ins a token share;
  • skip ToolSearch references;
  • skip server search results;
  • do not treat a search-only turn as a tool-using turn;
  • add a call on load plus call;
  • the row ignores the ledger's wrong guesses;
  • the row ignores the ledger's dropped searches;
  • read requests that deferral did not change in the panel.

No paid live runs.

Open questions

  1. Item 5: remove remove-mcp-and-skills now that save-more tools exists? Owner's call.

"Always defer" moved to #878: a new field toolfilter.always_defer, which changes tooldefer.Decide, so it needs the owner's yes.

Technical notes

  • The 8 columns are additive (additiveColumns) with a 0 default, so no version bump. A row deferral did not change keeps 0. The panel reads only defer_tokens > 0.
  • deferLedger now takes the capture and calls cp.noteDefer(r, price, distinct loads) with the same r it books in the ledger.
  • Explain checks only the user rule (3 sessions, keep list, never-defer list). The project veto, thread uses, tool_choice and the 200-token floor depend on the request, so the reason text says "Context Guru defers it" only when the user rule holds.
  • Skills get no deferral action: feat(plugin): keep Context Guru's own skills light in the model's skills listing #823 owns the skills listing.

Refs #869, #866 (N9), #485, #874, #878.

🤖 Generated with Claude Code

@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.317 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 a335fdda053e blocking

Verdict: blocking

Findings

  1. context-guru-plugin/scripts/cg.py:1211 (same line in codex-marketplace/plugins/context-guru/scripts/cg.py) — the deferral report's headline cost sums rows the report itself calls unpriced
    • What fails: an account whose window has a row with carry_priced: false gets a headline "Carrying all of them cost $X" that includes that row's partial carry_usd, while the table prints n/a for the same row (line 1222). The total cannot be reconciled with the rows, and it presents a lower bound as an exact figure.
    • Proof: the golden pair ships the inconsistency. save-more-tools.golden prints the headline $16.93 and n/a for the dataviz row. save_more_tools.json gives dataviz carry_usd: 0.31 with carry_priced: false, and 9.12 + 6.40 + 1.10 + 0 + 0.31 = 16.93. Dash documents CarryPriced as "false when some request had no known rates", so the 0.31 covers only the priced part. The plugin's own rule is "missing is not zero" (money(), line 983), and the removal report prints n/a per item (line 1265) for the same state.
    • Fix: sum only rows with carry_priced true, and say so when rows were left out ("at least $X; n items had no price"), or print n/a for the headline when any row is unpriced.

Non-blocking

  • dash/ui/tools.js (renderDeferNet): the tiles show dollars when only some requests are priced (priced = t.requests > t.unpriced_requests). A day with 9 priced and 1 unpriced request shows a net that covers 9 requests, with no note. The panel tracks unpriced_requests for exactly this; only the all-unpriced case is labeled. Same family as finding 1.
  • dash/toolinventory.go (usedFrom): the last tool-using turn is found by a substring test on the raw message. A user message whose text contains the quoted string "tool_search_tool_result" (a tool that printed a transcript, say) is now taken for the turn, so that request records no uses. Under-count only, the next request with a real tool turn recovers, and the same looseness already existed for "tool_use". A content-block scan would close it.
  • dash/savemoretools.go: rows past the 200-row limit lose their keep/unkeep options, and a keep-list entry whose tool no longer appears in the inventory gets no row and so no unkeep option. A user cannot clean a stale keep entry from this report.
  • dash/savemoretools.go: the report ignores rep.DeferredState ("unknown"). When a session's deferred list could not be read, a server Claude Code defers shows as loaded.
  • dash/tooldeferpanel.go: the defer_tokens > 0 gate drops a request whose deferral changed only the names list (every deferred tool already loaded earlier in the thread), while the /stats ledger books its list cost. The two figures the PR says match can diverge in that edge.
  • codex-marketplace/.../skills/save-more/SKILL.md: the Codex copy got the tools argument line but not the "no Apply it? line, ask nothing, run the printed line on a yes" guidance the Claude plugin copy got. A Codex agent that meets a keep request has no instruction for it.

What I checked

  • Read the full diff (39 files) and the code around each change: dash/savemoretools.go, tooldeferpanel.go, toolinventory.go, query.go, store.go, schema.go, toolapi.go, event.go, ui/tools.js; proxy/savemoretools.go, tooldefer.go, dashcapture.go, proxy.go; tooldefer/explain.go; both cg.py copies and all four skills; the docs and both data-dependence rows.
  • Traced the keep/unkeep/search/revert write path end to end: adaptPrincipal → AdaptOffer (basis and option id must come from the caller's own fresh report) → adaptWrite → editDefer (mirrors editRemoved, PipelineKnown pinned, own names refused twice) → adaptRevert (undoes only the last change of this kind). The local and hosted paths both work; the test covers the round trip.
  • Verified the store insert: 88 columns, 88 placeholders, the 7 new scan targets in the same order as requestCols.
  • Verified Filter.where() never returns an empty condition, so the panel's WHERE ... AND r.defer_tokens > 0 is well formed; pings stay excluded, as on every other panel.
  • Traced the usedFrom change (search loads count as uses) against the writer's fingerprint skip: a ToolSearch result always arrives in the same resent transcript as its turn, so a load is counted exactly once; call-plus-load in one turn counts once; an older load is not recounted; a pasted tool_reference in user text is not counted.
  • Verified wrongGuesses (distinct loads, deferred-only, first-time-only) and that noteDefer runs before cp.finish on the same goroutine, with a nil-capture guard.
  • Verified the CLI routing: save-more tools → deferral, insights tools apply and cg.py tools → the removal report, apply deferral / revert deferral reach the new routes, a stale basis re-renders the report.
  • Checked the two cg.py copies are identical, and the save-more tools behavior change is named at the top of the PR with its data-dependence statement.
  • Fail open: no new code runs on the request path before the response; the report and apply paths return errors without touching the pipeline; deferral itself is unchanged.
  • Live tests were not run (not approved). Test claims are taken from the PR description.

@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.317 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 a335fdda053e approve

Verdict: approve

Findings

None blocking. I read every changed line and the code around each change. I could not
run tests (live tests are not approved), so all proofs below are line-level traces.

Non-blocking

  1. tooldefer/explain.go:11-40 / dash/savemoretools.go:105 — a row can read deferred_cg for a tool Decide keeps loaded.
    Explain skips the 200-token floor (MinTokens, tooldefer/tooldefer.go:172) and the project
    veto (ProjectUsed, tooldefer/tooldefer.go:174). So an MCP server whose tools sum under
    200 tokens, or a tool the project used, shows "Context Guru defers it" while the proxy sends
    it in full. The code comment says this is deliberate ("a 'yes' means 'the user rule holds'"),
    but docs/plugin/save-more.md's state column promises "its state under tool deferral" with
    no caveat, and the reason string shown ("declared and not used in your last 3 sessions") is
    true while the state label is not. Display only; no wrong action follows from it (keep and
    search switches stay valid). Suggest one caveat sentence in the docs, or reuse the loaded
    state with the history reason.

  2. dash/savemoretools.go:152-155 — one client-deferred MCP tool marks the whole server row deferred_client.
    deferredServer[t.Server] is set when ANY tool of the server is deferred. Claude Code defers
    tools one by one, so a server with 1 of 5 tools deferred reads "Claude Code defers it" for
    all of it. Direction is right, magnitude is overstated.

  3. dash/savemoretools.go:160-163 — the removed override for server rows is dead code.
    state() already checks removed[name] first (line 109), so the second if removed[name]
    after the call can never change anything. Harmless.

  4. dash/savemoretools.go:108-110 — a client-deferred tool also on the removal list reads "the proxy does not send it", which is false for it.
    The removal filter removes only tools elements; a client-deferred tool lives in the
    deferred listing, so the proxy keeps sending its name. Reachable only when a name was put on
    the removal list before Claude Code started deferring it. Wrong reason text, no wrong action.

  5. context-guru-plugin/scripts/cg.py:1219-1221 — the card's "Carrying all of them cost $X" sums carry_usd of rows the table itself prints n/a.
    A row with carry_priced: false (some request had no rates) shows "n/a" in the cost column,
    but its partial carry_usd still lands in the card total. The headline can then quote
    dollars the table calls unknown. The Go report flags this (CarryPriced); the card ignores it.

  6. dash/toolinventory.go:495-502 — the deferredDeclsFrom doc comment is tangled by the insertion.
    The new sentences about built-ins split the old "The shares are APPROXIMATE" sentence, and
    the real doc line ("deferredDeclsFrom parses the lists in texts...") now reads as a
    continuation of the shares paragraph. Comment only.

  7. Coverage gaps. The hosted (registry) apply path for /api/save-more/tools/apply and the
    200-row truncation in buildSaveMoreTools have no test; the local-proxy test covers keep,
    search_on, refusal of an unoffered option, and revert. unkeep is built in tests but never
    applied. All fail-safe paths (bad name, broken config) return errors rather than writing.

What I checked

  • Every changed file, in full, plus the code around each change: proxy/savemoretools.go,
    proxy/tooldefer.go, proxy/dashcapture.go, proxy/proxy.go, dash/savemoretools.go,
    dash/tooldeferpanel.go, dash/toolinventory.go, dash/event.go, dash/query.go,
    dash/schema.go, dash/store.go, dash/toolapi.go, dash/ui/tools.js,
    tooldefer/explain.go, both plugin copies of cg.py, both SKILL.md sets, the docs, and
    every new test and golden.
  • The two plugin copies of cg.py are byte-identical; the SKILL.md differences are the two
    formats' own styles, and both carry the new tools guidance.
  • Explain against Decide (tooldefer/tooldefer.go:117-181): same history, same thresholds,
    same server-unit keying (mcp__<server>__), same keep-list veto shapes. The name rewrite
    (TrimSuffix(name,"__")+"__") resolves both mcp__pw and mcp__pw__click to the unit key.
  • editDefer against editRemoved (proxy/toolfilterctl.go:182): same parse/edit/write shape,
    same withComponent/PipelineKnown claims, so a save never reorders or drops a stored
    pipeline. docDefers and the running pipeline's Defers() agree on defer: auto.
  • The apply path: options come only from OfferAdapt/AdaptOffer (basis-checked, TTL'd,
    per-account), ownDecl is re-checked server-side, and Registry.Update validates the config
    before storing (tenant/tenant.go:703), so a name toolfilter rejects fails with a 400 and no
    write. Audit kind save-more-tools matches adaptRevert's prefix rule.
  • usedFrom's new next window: traced message orders for both search forms (server-side
    result inside the turn; Claude Code's tool_reference blocks in the following tool_result).
    The lastIdx/next logic picks the message right after the last matching turn and resets on
    each new match; string content and pasted tool_reference text are ignored (covered by
    tests). The marker hijack (a user message quoting "tool_use" or
    "tool_search_tool_result") is pre-existing behavior, only widened by one string.
  • wrongGuesses: distinct-count and first-load logic traced against
    tooldefer.Loaded(di.original); deferred is per-request, matching the documented meaning.
  • deferLedger ordering in serve: it runs at proxy.go:1833, before cp.finish at :1899, so
    the defer facts reach the dashboard row. noteDefer handles a nil capture (dashboard off).
  • The store round-trip: the INSERT's 88 columns match its 88 placeholders and the 88 Exec
    args; requestCols and scanRequest append the 7 new columns in the same order; the
    additive-column migrations mirror the CREATE TABLE columns.
  • The panel SQL: Filter.where prefixes with r., GROUP BY day bucket is UTC-aligned
    (DayMs divides the epoch), SUM cannot be NULL inside a group, and defer_tokens > 0
    excludes requests deferral did not change. The days: [] empty case is golden-tested.
  • The golden endpoint fixture seeds inventories directly, so the new built-in deferred rows and
    search-load uses cannot change the existing tools/insights goldens; the new
    tool_defer golden is added.
  • Data dependence: all new stored fields are counts and prices; tool names only;
    docs/data-dependence.md's dashboard row is updated in the same (metadata) direction.
  • The plugin routing: save-more tools → deferral, cg.py tools / insights tools → the
    removal report, apply tools X → the removal apply; save-more tools apply X is refused
    with the exact apply deferral command. All four new goldens match the stubbed routes.

@amiddavid
amiddavid force-pushed the feat/deferral-dash-869 branch from a335fdd to b43100a Compare November 3, 2026 21:53
Claude Code sends the built-in tools it defers (Monitor, WebFetch, the
Cron tools, ...) only as names in its "deferred tools" text block. The
parser kept the mcp__ names and dropped the rest, so tool_declarations
never held them and the history that seeds tool deferral missed the very
tools deferral targets (#866 N9).

Each deferred built-in is now a kind 'tool' row with deferred = 1 and
0 tokens. The token shares of the MCP tools do not change, built-ins stay
out of every total (they are "aside"), and nothing new is offered for
removal (the reports skip built-ins and 0-token rows).

Refs #869, #866.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Tool deferral's rule says "a load counts as a use", and its history is
seeded from tool_uses. But tool_uses held only tool_use calls, so a tool
the model loaded through search and then did not call read as unused
(#866 N9).

usedFrom now also reads, next to the last tool-using turn:
- tool_search_tool_result blocks in that turn (the server-side search);
- tool_reference blocks in the tool results of the message right after
  it (Claude Code's own ToolSearch).

Each loaded tool counts as one call, unless the same turn called it. A
turn with only a search load is a tool-using turn, so its fingerprint
dedupes it like any other.

Refs #869, #866.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
The proxy's deferral ledger lived only in /stats: one process total, no
account, no day, gone at a restart (#869 item 3).

- deferLedger now also puts the request's facts on its dashboard row:
  tokens deferred, the names list's tokens, searches, tools loaded,
  wrong guesses, and the ledger's gross and net dollars. Seven new
  request columns, additive, 0 on every earlier row.
- A wrong guess is a tool this request deferred that a search in its
  response loaded and no earlier search in the transcript had loaded.
  This matches the name #866 N8 uses (wrong_guesses).
- GET /api/tool-defer sums them per account and UTC day, with a total.
  Net is gross minus the names list and the search costs, the same
  figure /stats shows.
- The Tools tab shows the panel when deferral changed a request in the
  window, and nothing otherwise.

Metadata only: counts and prices.

Refs #869, #866, #485.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
#485 decision D3: one row per tool, MCP server and skill, with its
state, its use, what carrying it cost, and why (#869 item 4).

- GET /api/save-more/tools: the rows come from the same inventory as
  /api/tools. The state is loaded, deferred_cg (Context Guru's history
  rule defers it), deferred_client (Claude Code defers it) or removed.
  tooldefer.Explain gives the rule's answer and reason for one tool,
  from the same history and thresholds as Decide.
- POST /api/save-more/tools/apply: keep or unkeep a name on toolfilter's
  keep list, search_on or search_off (toolfilter defer: auto or off),
  or revert. It writes only an option the caller's own report offered,
  through the shared adapt path, so a hosted account and a local proxy
  both work. A change reaches new threads only.
- "Always defer" is not built: toolfilter has no such list. That needs
  a new field and a change to the rule (open question in the PR).

Refs #869, #485.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
`/context-guru:save-more tools` prints the per-tool report: state, use
and cost of each tool, MCP server and skill, and the reason with
`details`. It recommends nothing. The changes are printed as commands to
run after a yes:

- `apply deferral keep:<name>@<basis>` (and unkeep);
- `apply deferral search_on|search_off@<basis>`;
- `revert deferral`.

The removal report keeps the `tools` kind, so `apply tools` and
`revert tools` from remove-mcp-and-skills work as before.
remove-mcp-and-skills stays (#869 item 5 needs the owner's yes); its
skill and doc now point to save-more tools. The Codex copy of cg.py and
of both skills is updated too.

Refs #869, #485.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Metadata only: tool names, counts and prices.

Refs #869.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
save-more tools lists the D3 action it does not offer yet, with its
issue, so the reader sees it as missing rather than absent.

Refs #869, #878.

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

The lead decided one wrong-guess rule, in tooldefer.WrongGuesses (#874):
a tool this request deferred, that a search in its response loaded, and
that no earlier message had loaded. deferLedger already computes it on
the tooldefer.Request it books, so the dashboard row now takes
r.WrongGuesses from there. The second copy (proxy's wrongGuesses) is
gone, so /stats and the panel cannot disagree.

The row and the panel also carry r.DroppedSearches (#866 N8): searches
with no result, because the client drops a search sent beside another
tool call. One more additive column, defer_dropped_searches.

Rebased on #874 (feat/tooldefer-866), which merges first.

Refs #869, #866.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Review round 1 on #877: the headline "Carrying all of them cost $X"
added carry_usd of rows with carry_priced false, while the table prints
n/a for the same rows. The golden showed $16.93, with dataviz's partial
$0.31 inside it.

The headline now sums priced rows only. When any row is unpriced it
says "at least $X; N items had no price" (missing is not zero). Golden
now reads $16.62. Codex copy updated.

Refs #869, #877.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid
amiddavid force-pushed the feat/deferral-dash-869 branch from b43100a to b8dc2df Compare November 3, 2026 22:22
…tes)

- deferred_cg says what it checks: the user rule, in new threads. A
  thread still sends the tool in full when the project used it or it is
  under 200 tokens; the reason now says so, and so does the doc.
- An MCP server reads deferred_client only when every tool of it is
  client-deferred. Claude Code defers tools one by one.
- A client-deferred tool on the removal list reads deferred_client: the
  filter removes only `tools` elements, so its name is still sent.
- The dead removed override on server rows is gone.
- The deferredDeclsFrom doc comment is untangled.
- Tests: unkeep through the local apply path, server and removed edges,
  and the 200-row cut.

Refs #869, #877.

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

Copy link
Copy Markdown
Collaborator Author

Replies to review round 1 (head a335fdda). New head: 22dd975d, rebased on main after #874 merged.

Reviewer 2, blocking: the save-more tools headline adds unpriced rows. Fixed in b8dc2dfa.

  • The headline now sums only rows with carry_priced: true.
  • When any row is unpriced, it says "cost at least $X; N items had no price" (missing is not zero).
  • The golden now reads "at least $16.62; 1 item had no price" (it was $16.93, with dataviz's partial $0.31).
  • New Python test SaveMoreToolsHeadline covers the unpriced and all-priced cases. A mutation (sum all rows again) makes it fail.
  • The Codex copy of cg.py has the same fix.

Reviewer 1, non-blocking notes. Taken in 22dd975d:

  1. deferred_cg now says it checks the user rule only, in new threads. The reason adds "unless this project used it or it is under 200 tokens", and docs/plugin/save-more.md says the same.
  2. A server reads deferred_client only when all of its tools are client-deferred.
  3. The dead removed override on server rows is gone.
  4. A client-deferred tool on the removal list now reads deferred_client, because the filter cannot remove it.
  5. This is the same finding as reviewer 2's (see above).
  6. The deferredDeclsFrom doc comment is untangled.
  7. Added tests: unkeep through the local apply path, the server and removal edges, and the 200-row cut. The hosted apply path shares adaptWrite with the tools apply, whose hosted test already exists. It has no test of its own here.

Also on this head: the dashboard row takes r.WrongGuesses (tooldefer.WrongGuesses, #874) and r.DroppedSearches from the same tooldefer.Request the /stats ledger books. Nothing is computed twice. "Always defer" is #878, and the screen shows it as not available yet.

Tests at 22dd975d (~/cgssh2, CGO_ENABLED=1 go test -race -count=1):

Package Result
./tooldefer/... ok
./proxy/... ok (483 s)
./dash/... ok (593 s)
./context-guru-plugin/... ok (349 s)
plugin Python 85 tests OK

@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.317 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 22dd975d4b4a approve

Verdict: approve

Findings

None blocking. My round-1 finding is fixed. The four fix commits introduce no new defect
I could prove, and the rebase changed no reviewed line.

Earlier findings

Mine, blocking (cg.py:1211 — the headline summed unpriced rows). Fixed in b8dc2dfa.

  • The headline now sums only rows with carry_priced: true. When a row is unpriced it says
    "cost at least $X; N item(s) had no price". This is the fix I asked for.
  • The goldens read "at least $16.62; 1 item had no price". That is $16.93 less dataviz's
    partial $0.31. The arithmetic checks out.
  • New test SaveMoreToolsHeadline covers the unpriced and the all-priced case. The two
    cg.py copies are byte-identical at the new head.

Reviewer 1's notes, all checked against 22dd975d:

  1. deferred_cg reason — fixed. The reason now says "in new threads ... unless this
    project used it or it is under 200 tokens", and docs/plugin/save-more.md says the same.
  2. Server reads deferred_client only when every tool of it is — fixed.
    deferredTools[s] == serverTools[s] gates the state. A server with no tool rows cannot
    read deferred_client.
  3. Dead removed override on server rows — fixed. Gone.
  4. Client-deferred tool on the removal list — fixed. state() checks clientDeferred
    before removed, so it reads deferred_client. The removal filter cannot remove it, so
    the text is now true.
  5. Same finding as mine — fixed, see above.
  6. deferredDeclsFrom doc comment — fixed. The built-in sentences are their own
    paragraph now.
  7. Coverage — taken in part, and I agree with the rest. unkeep now runs through the
    local apply path, and the revert after it undoes the unkeep and leaves search on, which
    matches the kind-scoped revert. New tests cover the server edge, the removal edge and
    the 200-row cut. The hosted apply path shares adaptWrite with the tools apply, which
    has a hosted test. I checked that sharing in round 1 and accept it.

My round-1 non-blocking notes — status. None was taken, and none blocks:

  1. renderDeferNet tiles show dollars when only some requests are priced — still open.
  2. usedFrom substring markers — still open (pre-existing looseness).
  3. The 200-row cut is now tested. A keep-list entry whose tool has no row still offers no
    unkeep — still open.
  4. The report ignores rep.DeferredState — still open.
  5. The defer_tokens > 0 gate can drop a list-only request the ledger books — still
    open.
    The refactor below does not change the gate.
  6. The Codex save-more SKILL.md still lacks the keep-request guidance the Claude copy
    has — still open.

New commits

I read all five in full, with the code around each change.

  • af895400 + 25eb78ff (always-defer as not available yet). The report carries a
    not_yet list with the issue number, and cg.py prints "Not available yet: ..." inside
    the fitted block, before the act lines. The goldens show the line. The test asserts the
    report offers no defer option. No defect.
  • 3819f1a0 (wrong guesses and dropped searches from the ledger). deferLedger sets
    r.WrongGuesses and r.DroppedSearches once, then hands the same r to ledger.Add
    and cp.noteDefer, so /stats and the panel cannot disagree. The tooldefer logic
    (distinct, deferred-only, first-load-only) matches the proxy copy it replaces, and
    tooldefer has its own test for it in the base. I counted the store insert: 89
    columns, 89 placeholders
    , and requestCols and scanRequest append the new column in
    the same position. The additive migration, the panel SUM, tools.js and the golden
    all carry defer_dropped_searches. The data-dependence row now says eight columns. No
    defect.
  • b8dc2dfa — my fix, checked above.
  • 22dd975d — reviewer 1's fixes, checked above.

What I checked

  • Last review (round 1, a335fdda053ea973d7a5a97c91575105cbfc58cd, 2026-11-03T21:36:44Z).
  • New commits read (5: af895400 always-defer not-yet, 25eb78ff its goldens,
    3819f1a0 ledger refactor, b8dc2dfa headline fix, 22dd975d state fixes). The range
    a335fdda..HEAD holds 14 commits: the 5 above, 7 rebased copies of round-1 commits, and
    2 base commits (0022f45a #874, 75c52f2c #873).
  • Read in full (2 reviews, 1 comment, 0 inline comments).
  • New items since my last review:
    • The author's reply (2026-11-03T22:50:44Z): each claim checked against the code. All
      claims hold.
    • The rebase onto 0022f45a: I compared patch-ids of all 7 round-1 commits against
      their rebased copies. All 7 are identical patches, so no reviewed line changed in
      the rebase. The tooldefer/*, proxy/proxy.go, proxy/usage.go and
      proxy/tooldefer_866_test.go changes in the tree diff come from #874 in the base and
      are out of scope here.
    • The two cg.py copies: diffed at the new head, byte-identical.
  • Verified the store round-trip again at the new head: insert 89/89, scan order matches
    requestCols, the additive column list carries defer_dropped_searches.
  • Verified the new tests read what they claim: the server/removal edges, the 200-row cut
    (cheapest kept, Truncated 3), the unkeep round trip and its revert.
  • Live tests were not run (not approved). Test claims are taken from the author's reply.

@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.317 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 22dd975d4b4a approve

Verdict: approve

No new findings. Every fix the author claims is in the code, and I traced each one.
I could not run tests (live tests are not approved), so all proofs are line-level traces.

My round-1 findings

  1. A row could read deferred_cg for a tool Decide keeps loaded — fixed in 22dd975d.
    dash/savemoretools.go:144-146 now says "defers it in new threads (...), unless this
    project used it or it is under 200 tokens", and docs/plugin/save-more.md states the same
    limits. The state label is still deferred_cg, but the reason now carries the caveat, so a
    reader is no longer told an unqualified false thing.
  2. One client-deferred MCP tool marked the whole server deferred_client — fixed.
    dash/savemoretools.go:181-200 counts deferredTools against serverTools per server and
    passes deferredTools == serverTools. TestSaveMoreToolsServerAndRemovedEdges covers the
    half-deferred and all-deferred servers.
  3. The dead removed override on server rows — fixed. It is gone
    (dash/savemoretools.go:195-203); state() already checks removed.
  4. A client-deferred tool on the removal list read "the proxy does not send it" — fixed.
    state() now checks clientDeferred before removed (dash/savemoretools.go:129-136),
    with a comment saying why: the removal filter removes only tools elements. The new test
    puts Monitor on the removal list and wants deferred_client.
  5. The card's headline summed unpriced rows — fixed in b8dc2dfa. This was reviewer 2's
    blocking finding; see below.
  6. The tangled deferredDeclsFrom comment — fixed. The built-in sentences are now their
    own paragraph and deferredDeclsFrom's line stands alone (dash/toolinventory.go:493-506).
  7. Coverage gaps — mostly fixed. unkeep now runs through the local apply path
    (proxy/adapttoolsctl_test.go:289-295), and the server, removal and 200-row edges have a
    test. The hosted apply path still has no test of its own; it goes through the same
    adaptWrite as the tools apply, whose hosted test exists, so I accept the author's
    reasoning.

Reviewer 2's round-1 findings (I checked each myself)

  • Blocking, the headline summing unpriced rows — fixed in b8dc2dfa, verified in both
    cg.py copies (byte-identical). The headline now sums only carry_priced rows and says
    "cost at least $X; N items had no price" when any row is unpriced. The golden reads
    $16.62 = 9.12 + 6.40 + 1.10 + 0, with dataviz's partial $0.31 left out and named. The new
    Python test SaveMoreToolsHeadline covers both cases.
  • The six non-blocking notes are all still open: the tiles still show dollars when only
    some requests are priced (renderDeferNet is unchanged apart from the dropped count);
    usedFrom still substring-matches the raw message; rows past the 200 limit still lose their
    keep options and a stale keep entry still gets no row; buildSaveMoreTools still never reads
    rep.DeferredState; the panel SQL still gates on defer_tokens > 0, so a list-only change
    the ledger books stays off the panel; and the Codex SKILL.md still lacks the keep-request
    guidance the Claude copy has (I diffed both). I agree with reviewer 2 on each, and none
    blocks this PR.

The new work

I reviewed the five new commits as a first review. No findings.

  • af895400 + 25eb78ff (always-defer shown as not available yet). SaveMoreToolsNotYet
    is a fixed list holding one entry, defer with issue 878. I checked that 878 is an open
    issue ("an always-defer list for save-more tools"), not a merged PR, so the pointer is
    right. The option list never offers defer, the test asserts that, and the goldens and
    docs/plugin/save-more.md carry the same sentence. cg.py renders not_yet after the
    window line, and treats a missing issue safely.
  • 3819f1a0 (wrong guesses and dropped searches from the ledger). deferLedger
    (proxy/tooldefer.go:534-553) sets r.WrongGuesses and r.DroppedSearches from the same
    sources the ledger books, then passes that one r to noteDefer, so /stats and the panel
    cannot disagree. tooldefer.WrongGuesses (from #874) has the same semantics the proxy's
    deleted local function had: deferred by this request, loaded by this response's search, not
    loaded earlier in the transcript, once per tool — and #874's own tests cover it
    (tooldefer/support_test.go:828, TestReadSearchesCountsDropped), so the deleted proxy test
    is redundant, not lost. distinctLoads counts non-empty distinct names, as the old
    distinct did.
  • The new defer_dropped_searches column. I counted the round-trip: 89 INSERT columns,
    89 placeholders, 89 Exec args (the last line carries a trailing comma);
    requestCols and scanRequest append the column in the same, last place; the panel's
    SELECT, its Scan order, and the totals fold match; additiveColumns mirrors the CREATE
    TABLE column. The golden and docs/data-dependence.md (seven → eight columns) are updated.
  • b8dc2dfa and 22dd975d — covered above.

What I checked

  • Last review: round 1, sha a335fdda053ea973d7a5a97c91575105cbfc58cd, 2026-11-03T21:39:48Z.
  • The PR was rebased onto main after #874 merged, so my round-1 SHA is no longer in the
    history. I found the rebased equivalent by tree-diffing: git diff --stat a335fdda cca39a28
    holds only #874/#873 content, so cca39a28 is where my last review stands, and
    git diff cca39a28..HEAD is the new work. New base: 0022f45a.
  • New commits read: 5 — af89540 feat(dash,plugin): show always-defer as not available yet;
    25eb78f test(plugin): goldens show always-defer as not available yet; 3819f1a
    refactor(proxy,dash): take wrong guesses and dropped searches from the ledger; b8dc2df
    fix(plugin): save-more tools totals only priced rows; 22dd975 fix(dash): save-more tools
    states, from review round 1.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (the author's reply of
    2026-11-03T22:50:44Z; no inline comments exist on this PR).
  • The whole new diff (24 files, +326/−114) and the code around each change: both cg.py
    copies, test_costly.py, the four deferral goldens and save_more_tools.json,
    dash/event.go, query.go, savemoretools.go, savemoretools_test.go, schema.go,
    store.go, tool_defer.json, tooldeferpanel.go, tooldeferpanel_test.go,
    toolinventory.go, ui/tools.js, docs/data-dependence.md, docs/plugin/save-more.md,
    proxy/adapttoolsctl_test.go, dashcapture.go, tooldefer.go,
    tooldefer_ledger_test.go, plus tooldefer/ledger.go from #874 for the semantics the
    refactor leans on.
  • The unkeep-then-revert sequence in the local apply test: revert restores the document before
    the unkeep, so the keep list comes back and search stays on — the new expectations match.
  • The save_more_tools.json rewrite is a reformat plus not_yet; every other value is
    unchanged. The basis stays 9d4e2a7c because OfferAdapt hashes the options, and not_yet
    adds no option.
  • Fail open: unchanged. The new code is report-side only; the request path gains one field
    copied from the ledger's own Request.

@amiddavid
amiddavid merged commit cc0839d into main Nov 3, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 3, 2026
amiddavid added a commit that referenced this pull request Nov 4, 2026
…0.2.11) (#921)

Claude Code plugin 0.6.6 -> 0.6.7:
- #889: the preset picker restarts the proxy after a yes, and the status shows a pending preset.
- #891: insights and the status show tool deferral as its own saving lever.
- #877, #885: save-more tools (keep, unkeep, defer, undefer, search on/off, revert).
- #882: ultrahigh is marked experimental in the picker.

Codex plugin 0.2.10 -> 0.2.11:
- #889, #891: the same cg.py changes (vendored copy).
- #882: ultrahigh is marked experimental in the picker.


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