Skip to content

feat(dash): show the top-level cache mark in the overview placement - #1285

Merged
amiddavid merged 10 commits into
mainfrom
fix/overview-root-slot
Nov 23, 2026
Merged

amiddavid merged 10 commits into
mainfrom
fix/overview-root-slot

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a dashboard figure; no other behavior change.

Fixes #1283

Summary

The overview placement panel now counts the top-level cache_control mark. A request whose only mark is the top-level one shows 1 in a new "top-level" slot. The placement sums add up to the breakpoint total.

Data dependence

Metadata only; it sums the existing cache_bp_root count column, so no data-dependence row changes.

What changed

  • BreakpointTotals has a new Root field (JSON root). The placement sums add cache_bp_root.

  • Modal placement. The grouping now includes the root column. The modal string ends with , top-level=N.

  • Overview UI (dash/ui/app.js). The panel shows a "top-level" slot next to system, tools, messages and blocks. The empty-state check counts it.

  • One name. The per-request placement breakdown (cache_bp_location) now says top-level=N, as the overview does.

  • Test. dash/overview_rootbp_test.go: a root-only request shows 1 in the top-level slot, the sums add up to 5, and the modal string has top-level=1.

  • Golden files. I edited 3 files by hand for the new root field and modal string:

    • dash/testdata/golden/stats.json
    • dash/testdata/golden/stats_lean.json
    • dash/testdata/golden/stats_windowed.json

    CG_GOLDEN_UPDATE=1 also rewrote unrelated goldens (kv_*, tools*, toolfilter) with float and ordering noise. I reverted that noise.

How it was tested

macOS, Go 1.27.4.

  • gofmt and go vet ./...: clean.
  • go test ./internal/timingguard: pass.
  • CGO_ENABLED=1 go test -race -timeout 30m ./dash/...: pass (689 s).
  • node --test dash/*.test.mjs: 51 pass, 0 fail.

Main is frozen until the v0.7.6 tag. This PR merges after it.

Assisted-By: Claude Opus 5.5 [email protected]

Anthropic automatic caching uses one top-level cache_control. No TTL
reader looked at it. Add one list of every mark on the wire, root
included (wireCacheControls). bodyAsksExtendedTTL and
AllBreakpointsAskExtendedTTL use it. schema.CountBreakpoints counts the
root mark (Breakpoints.Root), so the cap of four holds and ttlTier sees
the body as cached. RelabelAllTTL1h relabels the root mark too.

Fixes #1279

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
- dash: new column cache_bp_root (additive migration). Meta.CacheBreakpoints()
  now sums the root mark, so it matches schema.Breakpoints.Total().
- proxy: envelopeOps reports a root-only 5m to 1h relabel as a headttl
  operation, so the accountant can book the premium and the rescue.
- apply: fix two stale comments.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
- apply: say that schema.CountBreakpoints counts the cache_control
  spellings of the same set (it also counts cachePoint).
- dash: the cache_bp_location dim has five columns, not four.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Add a Root slot to BreakpointTotals, the placement sums, the modal
grouping and the modal string, and show it in the overview UI. A
request whose only mark is the top-level cache_control now shows 1 in
the top-level slot, and the placement sums add up to the total.

Refs #1283

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
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.330 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 80f87154af0a approve

Verdict: approve

Findings

None. The change reports an existing column; it stores nothing new.

Non-blocking

  • dash/overview.go:352 — the Breakpoints field comment says "These four columns" and its example lists four locations. The struct now has five. Commit dda06f fixed the same staleness in dash/query.go; this one was missed.
  • dash/ui/app.js:830-831 — the renderCacheDetail doc comment says "Four columns have recorded it per request". Same staleness as above.
  • Naming: the overview modal string says top-level=1 (dash/overview.go:1157), but the per-request breakdown dim says root=1 (dash/query.go:1710). Two names for one slot, both user-visible. Pick one.

What I checked

  • The net diff vs base is 6 files, all in dash/. The branch also carries apply/proxy commits, but the merge 80f87154 resolved them to what main already holds (#1281), so they cancel in the diff. I confirmed base is an ancestor of HEAD and the two-dot and three-dot diffs match.
  • The cache_bp_root column (dash/schema.go:396), the migration (dash/schema.go:949), the CacheBPRoot event field, and Meta.CacheBreakpoints() already include root. They landed before this PR. This PR only reads them.
  • First Overview query: the SELECT adds SUM(r.cache_bp_root) between blocks and the requests CASE (dash/overview.go:667), and the Scan adds &o.Breakpoints.Root at the same position (dash/overview.go:721). I read the full column list and the full Scan list; every position matches.
  • The requests denominator CASE already counted cache_bp_root before this PR, so its meaning ("requests that carried at least one") is unchanged.
  • Modal query: 10 columns selected, GROUP BY 1..9 covers the 9 non-count columns. Scan order matches. The sort tie-break gained the r field, and the winner assignment sets br. Modal prints top-level=%d.
  • The new test (dash/overview_rootbp_test.go) uses mkEvent with ModeActive, sets the bp fields directly, and insertBatch stores them verbatim (dash/store.go:677). The asserted totals (root 2, system 1, blocks 2, requests 2, sum 5) follow from the two events. The solo modal string matches the new format exactly.
  • The three golden files were regenerated in the same commit that changed the format, and TestGoldenEndpoints compares against them.
  • The UI adds bp.root to bpTotal and one row, so a window with only the top-level mark now shows the panel instead of the empty state.
  • Fail-open and reversibility: not in scope. The change touches only the dashboard's read path.
  • Data dependence: unchanged. The overview reads a count column that already exists; no row edit is needed. The PR adds no stored data.

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

Verdict: approve

Findings

None. I found no defect in this change.

Non-blocking

  • dash/ui/app.js:830 — the panel's docstring still says "Four columns have recorded it per request". The root column is the fifth, and this PR makes it first-class in this very panel. The wording was already stale in the base (the column landed with #1281), so it is not this PR's defect. Fix it in a follow-up or in this PR while touching the panel.
  • PR body — no data-dependence statement. CLAUDE.md asks every PR that changes a feature to state its data dependence. This change only sums an existing count column (cache_bp_root) that the dashboard-database row already covers as counts, so no row edit was needed and the top line "Adds a dashboard figure" says what changed. Say the dependence in one line if you re-edit the PR.

What I checked

  • Read CLAUDE.md and the relevant parts of docs/design.md, then the full diff 14545559..HEAD.
  • The big aggregate (dash/overview.go:667, 721). The new SUM(r.cache_bp_root) sits between the blocks sum and the requests count in the SELECT. The new &o.Breakpoints.Root sits at the same position in the Scan. The order matches. The requests count already included cache_bp_root in the base, so the denominator is unchanged.
  • The modal-placement query (dash/overview.go:957-1011). The SELECT lists 9 group keys plus COUNT(*); GROUP BY 1..9 matches. The bp struct, the Scan, the sort comparator and the modal assignment all gained the root field together. The tie-break "smallest key wins" now includes root, so the modal choice stays deterministic.
  • The modal string (dash/overview.go:1157). The new , top-level=%d matches the test's expectation and the three golden files.
  • The UI (dash/ui/app.js:857-868). bpTotal includes bp.root, so the empty state no longer shows for a window whose only mark is the root one. The new tile's note ("the provider marks the last block") matches the semantics in schema/breakpoints.go:43-44.
  • The write path. Event embeds Meta (dash/event.go:601), insertBatch persists cache_bp_root (dash/store.go:603), and the schema column exists with a default of 0 (dash/schema.go:396, 949). All of this is base code, unchanged here.
  • The new test (dash/overview_rootbp_test.go). It covers a root-only request, a mixed request, the sum-equals-total check, and the root-only modal string. mkEvent leaves every CacheBP field at 0, so the test sets exactly what it asserts.
  • The golden files. All three stats goldens carry the new root: 0 field and the new modal string. The fixture in golden_endpoints_test.go sets no CacheBP fields, so 0 and top-level=0 are the values the code produces. The test compares the JSON semantically after unmarshalling, so the hand edits are safe.
  • Behavior and data dependence. The change reads one existing metadata column and displays it. It changes no proxy or library behavior, so the human-permission rule for behavior changes does not apply.
  • I did not run the Go tests; live tests were not approved. I read the code only.

- The per-request placement breakdown says top-level, as the overview does.
- Two comments said four columns; now five.
- Add a test for the breakdown name.

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

Copy link
Copy Markdown
Collaborator Author

Round 1 notes are fixed. Head: see the latest commit on fix/overview-root-slot.

  • dash/overview.go field comment said "four columns": now five, and it names the top-level location.
  • dash/ui/app.js renderCacheDetail doc said "Four columns": now "Five".
  • One name for the slot. The per-request breakdown dim cache_bp_location said root=N. It now says top-level=N, like the overview modal string. No test or golden file pinned the old string, so no golden file changed. I added TestPlacementBreakdownNamesTheTopLevelSlot.
  • PR body: added the data-dependence line (metadata only; sums the existing cache_bp_root column; no row changes). I read the body back from the server.

Tests (macOS, Go 1.27.4): gofmt, go vet, CGO_ENABLED=1 go test -race ./dash/... (678 s) and node --test dash/*.test.mjs (51 pass) are clean.

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

Verdict: approve

Findings

None. Every round-1 note is fixed, and the fix commit introduces no defect.

Earlier findings

  • Mine, app.js "Four columns" docstring — fixed. dash/ui/app.js:830 now says "Five columns".
  • Mine, missing data-dependence statement in the PR body — fixed. The body now has a Data dependence section: "Metadata only; it sums the existing cache_bp_root count column, so no data-dependence row changes." I read the body back from the server. The statement is right.
  • Reviewer 1, dash/overview.go "four columns" field comment — fixed. The comment now says "These five columns" and names the fifth location (top-level).
  • Reviewer 1, app.js docstring — fixed. Same as my first item.
  • Reviewer 1, two names for one slot (top-level= vs root=) — fixed, and I checked it myself. dash/query.go:1710 now builds top-level=N, matching the overview modal string at dash/overview.go:1158. I grepped the repo: no Go test, .mjs test, JS file or golden file pins the old root= string, so no golden change was needed. The golden endpoint list (dash/golden_endpoints_test.go:158-187) has no dim=cache_bp_location URL, which confirms the rename cannot break a golden. The new test TestPlacementBreakdownNamesTheTopLevelSlot pins the new string.

New commit reviewed

b55ca7f "docs(dash): name the top-level slot the same everywhere" — 4 files, all verified:

  • dash/overview.go:351-352 — comment only. It now names top-level as the fifth location.
  • dash/ui/app.js:830 — comment only. "Four" → "Five".
  • dash/query.go:1708-1710 — the cache_bp_location breakdown key changes root= to top-level=. The observe-mode guard (CASE WHEN r.mode = observe THEN '') is kept, so observe rows still group under the empty key, which is what TestBreakdownCacheBreakpointsUnknownForObserve pins. This is a dashboard display string only; no proxy or library behavior changes.
  • dash/overview_rootbp_test.go:43-62 — new test. I traced it: one active-mode event with CacheBPRoot=1, Breakdown(Filter{}, "cache_bp_location") runs the SQL concat, SQLite casts the integer columns to text, and the key is exactly "system=0 tools=0 messages=0 blocks=0 top-level=1". The Breakdown signature (dash/query.go:1744) matches the call. One group is the right answer for one event.

Non-blocking

  • dash/overview.go:352-353 — "These five columns have existed since the placement work" is now slightly off for the fifth: cache_bp_root landed later, with #1281. Prose only; the sentence above it already says where the fifth location came from.

What I checked

  • Last review: round 1, 80f8715, 2026-11-22T18:09:50Z.
  • New commits read: 1 — b55ca7f "docs(dash): name the top-level slot the same everywhere". git log 80f87154..b55ca7fa lists only this commit.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files; the inline file is empty).
  • New items since my last review: the fix commit b55ca7f; the author's comment at 2026-11-22T18:23:09Z (fix list — each item verified above); reviewer 1's round-1 review at 18:09:35Z (read now for the first time, per the round-1 rule; all three of its notes are addressed by the same commit).
  • Checked out head b55ca7f in this worktree and read the full diff 80f87154..b55ca7fa, plus the code around each change (dash/query.go:1685-1723, dash/query.go:1744-1780, dash/overview.go:346-356, dash/overview_rootbp_test.go).
  • Grepped for stale copies of the old string: no root= remains in Go, JS, .mjs or testdata (minified vendor files excluded). No consumer parses the placement key format programmatically; dash/ui/tabs/usage.js:16 maps the dimension name only, and the per-request drawer builds its own labels.
  • Confirmed the PR body's data-dependence line by reading the body back from the server.
  • I did not run the Go tests; live tests were not approved. I read the code only.

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

Verdict: approve

Findings

None. The new commit fixes every round-1 note and adds a correct test.

Earlier findings

  • Mine, dash/overview.go:352 ("four columns" comment): fixed. The comment now says five and names the top-level location.
  • Mine, dash/ui/app.js:830 ("Four columns" doc): fixed. It now says "Five columns".
  • Mine, naming split top-level= vs root=: fixed. dash/query.go:1710 now says top-level=, same as the overview modal. The new test pins it.
  • Reviewer 2, dash/ui/app.js:830 docstring: same as my second note, fixed.
  • Reviewer 2, missing data-dependence statement in the PR body: fixed. I read the body back from the server; it has a "Data dependence" section that says "Metadata only; it sums the existing cache_bp_root count column, so no data-dependence row changes." That matches the code.

Non-blocking

  • dash/overview.go:352-353 — the comment now says "These five columns have existed since the placement work". The root column landed later, with the top-level capture (#1279/#1281), not with the placement work. The four older columns did. One word of history is off; the numbers and names are right.

What I checked

  • Last review: round 1, 80f87154af0a5d5dfd5028c3721cf812eafcdbe8, 2026-11-22T18:09:35Z.
  • New commits read: 1 — b55ca7fa "docs(dash): name the top-level slot the same everywhere" (4 files: overview.go, overview_rootbp_test.go, query.go, app.js).
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files).
  • New items since my last review: the author's comment at 2026-11-22T18:23:09Z (lists the four fixes; I verified each one, see above), and the commit b55ca7fa (reviewed below).
  • The rename root= → top-level= in the cache_bp_location dim (dash/query.go:1710). I looked for anything that pinned or parsed the old string: no Go or JS code parses the key, no golden file records the key values (the goldens only list the dim name, which did not change), and no doc references it. Safe rename.
  • The new test TestPlacementBreakdownNamesTheTopLevelSlot: mkEvent uses ModeActive, so the dim's observe-mode guard does not blank the key. Breakdown (dash/query.go:1744) groups one event into one row; the asserted key matches the SQL string concatenation exactly.
  • The full diff vs base is now 7 files, all in dash/, still read-only reporting of an existing column. Fail-open, storage, and data dependence are unchanged from round 1.
  • I did not run the Go or node tests; live tests were not approved. The author reports them clean (macOS, Go 1.27.4, ./dash/... with -race, 678 s).

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

Copy link
Copy Markdown
Collaborator Author

scripts/release/approval-still-valid.sh 1285 b55ca7fa at head e5ca6eb6 (a comment-only commit after both round-2 approvals):

approved: b55ca7fa (base 14545559a19c) patch-id 33bc37c31489
head:     e5ca6eb6f50a (base 14545559a19c) patch-id 129d42361d42
--- git range-diff
1:  394d15da = 1:  394d15da fix(apply): read the top-level cache_control in every cache-TTL reader
2:  63c97e3f = 2:  63c97e3f fix(dash,proxy): store the root mark and report its 1h relabel
3:  fdbe279d = 3:  fdbe279d docs(apply): name the root mark in the hasCacheBreakpoint doc
4:  e0393aa5 = 4:  e0393aa5 test(proxy): the library books the root-only premium and rescue
5:  dda06fce = 5:  dda06fce docs: fix two stale comments about the root mark
6:  a6c0357f = 6:  a6c0357f feat(dash): show the top-level cache mark in the overview placement
7:  b55ca7fa = 7:  b55ca7fa docs(dash): name the top-level slot the same everywhere
-:  -------- > 8:  e5ca6eb6 docs(dash): say when the fifth placement column came
COMMENTS ONLY: b55ca7fa..e5ca6eb6f50a changes only comment lines in .go and .sh files. The approval of b55ca7fa still counts. Say so on the PR.

@amiddavid
amiddavid merged commit 07afd6b into main Nov 23, 2026
10 of 11 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 23, 2026
amiddavid added a commit that referenced this pull request Nov 23, 2026
chore(plugins): bump the plugin versions for v0.7.7

- Pi package: 0.1.5 -> 0.1.6 (#1294, one-command installer).
- OpenCode plugin: pinned proxy v0.7.6 -> v0.7.7 (index.js, README,
  install how-to, commands and review1 tests).
- Claude Code plugin 0.7.8, Codex 0.2.14, Bob 0.1.3: unchanged, no
  file in them changed since v0.7.6 (#1285 is dash only).


Release owner (David Amid, 2026-11-23, integrator session): release v0.7.7 as a non-beta. The OpenCode CI job failed twice on failopen.test.mjs timing tests that this PR does not touch (5/5 pass locally); the owner chose to merge and report the flake (sent to flaky-tests, #1268).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[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.

fix(dash): the overview placement figures leave out the top-level cache mark

1 participant