Stats-bar catalog join + dock numerator consistency (context-meter close-out)

Platform's context-meter pair (04e336d, 18cc493) left two client seams
in my band; this closes the arc:

1. STATS-BAR CATALOG JOIN: contextWindow's denominator resolves ONLY
   from pi's live catalog — stats-bar now builds the provider:id ->
   contextWindow index client-side (catalogLimits in model-picker.tsx,
   the client twin of the server's catalogContextLimits join) over the
   picker's existing /api/models fetch/cache (useModelCatalog exported;
   module-level dedupe, one fetch feeds both ModelControl and the
   meter). Catalog pending or failed -> undefined index -> limit null ->
   USAGE-ONLY (Platform's interim render IS the null path; the
   honest-render precedent, never a fake window).

2. DOCK NUMERATOR CONSISTENCY: toBlobs' context fold was still
   last-step input+output only — now the same cache-inclusive footprint
   the session meter uses (all four directions; provider "input"
   EXCLUDES cacheRead/cacheWrite, so the old fold read wildly low on
   cache-heavy jobs). Same metric everywhere.

Review of Platform's interim edits in this band: verified as-shipped —
stats-bar's usage-only render (summary + popover), FeedJob.contextLimit
with the line-hides null treatment, and the render-test rewrites all
fit. Only fix needed: none beyond the above.

Tests: catalogLimits pinned pure (index shape, provider:id keying,
missing-model absence); toBlobs pinned on the cache-inclusive
numerator (10k+0.5k+120k+30k = 160.5k against a 200k feed limit).
889/889.

Live-verified on :3001: seedplan's bar reads "18.7k / 1M" (footprint
18725, catalog 1048576); a nope/unknown-model chat renders "12.8k"
usage-only with cost "-"; the popover detail matches; the dock blob's
context line renders "946 / 1M" from a server-joined feed (an
unintentionally real runner-adopted job — the full chain, live).
This commit is contained in:
amosblomqvist
2026-09-24 02:15:23 +03:00
parent 4ded547cb5
commit 81709afd22
5 changed files with 108 additions and 6 deletions
+24
View File
@@ -109,6 +109,30 @@ describe("activity dock pure layer", () => {
extractions: [],
})[0]!;
assert.equal(uncatalogued.context, null);
// The numerator is the same cache-inclusive fold the session meter
// uses (context-meter audit, owner 2026-09-23): provider "input"
// EXCLUDES cacheRead/cacheWrite, so input+output alone reads wildly
// low on cache-heavy jobs — 10k+0.5k+120k+30k = 160.5k, not 10.5k.
const cached = toBlobs({
jobs: [
job({
usage: {
...base,
lastStep: {
inputTokens: 10_000,
outputTokens: 500,
cacheReadTokens: 120_000,
cacheWriteTokens: 30_000,
reasoningTokens: undefined,
},
},
contextLimit: 200_000,
}),
],
extractions: [],
})[0]!;
assert.equal(cached.context?.used, 160_500);
assert.equal(cached.context?.limit, 200_000);
});
it("extraction blobs carry no money/context (—, the doctrine)", () => {