Skip to content

Port the Lens dashboard, session detail and analyzer pages to the new design system - #699

Merged
anshss merged 45 commits into
mainfrom
lens-redesign
Aug 7, 2026
Merged

anshss merged 45 commits into
mainfrom
lens-redesign

Conversation

@anshss

@anshss anshss commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Ports the Lens dashboard, session-detail page, and all eleven analyzer detail pages to the new
design system. Net -674 lines across the UI, plus one small API field and one correctness fix.

Design system

  • Geist and Geist Mono are now actually loaded. The CSS has named Geist for a while with no
    @font-face and no font files, so it has been silently falling back to system fonts. Both are now
    vendored as variable woff2 under ui/vendor/fonts/ (SIL OFL, ~141KB total) and served through
    the existing /ui/vendor static mount. No CDN — the offline test still passes.
  • New :root tokens: a 7-step --tone-1..7 rank ramp, --radius-panel/control/pill, and an
    rgb-triplet + --tint-bg/--tint-border convention so tinted states stop being literal rgba
    tuples. Every one has a derived light-theme counterpart; the theme toggle keeps working.
  • --info collapsed into --brand (near-identical hex, four call sites).
  • New shared .section-band primitive for zone headings.

Dashboard

  • Restored the hero band: a "Recoverable now" figure, a one-line summary, and a CTA that names the
    biggest single opportunity.
  • The hero total is netted, not summed. It previously added the per-analyzer figures together
    client-side, which double-counts whenever two analyzers claim the same sessions. It now reads the
    server-netted past_overspend rollup from GET /relearn/cost-proposals, which already de-dupes
    overlapping claims. Hero and total tile are handed the same object, so they cannot drift apart.
    Verified on a seeded overlap corpus: an analyzer's raw ~$4.00 correctly nets to zero when a
    higher-priority analyzer has already claimed the same sessions.
  • The total tile's disclosure string no longer claims to be the sum of the visible analyzers — that
    claim is now false in both directions, since the netted figure can be lower on overlap and can
    include contributors that have no tile.
  • Opportunity tiles gained a rank-coloured share bar, driven off the same figure the total uses.
  • The stale-scan notice is now a tinted bordered banner rather than bare amber text.

Session detail

Rebuilt against the design, removing roughly 1,590 lines:

  • Removed the Map tab, the Loop tab, the Alerts tab, and the resume-command button. Backend
    endpoints are deliberately untouched — tj loop on the CLI still consumes them.
  • Tools used is now its own tab instead of being bundled under Models & context.
  • The Timeline tab's internal state key said story while its label said Timeline; renamed.
  • Kept the multi-trace list branch, which the design's single-waterfall mock never exercises but
    live per-call-ingest sessions routinely hit.
  • The Models & context tab rendered nothing at all — not even an empty state — for a session with
    zero LLM calls. It now says so.
  • GET /sessions/{id} returns active_seconds, reusing the helper /status already uses, so the
    compute-time tile isn't derived in the browser.

Analyzer detail pages

All eleven share one restyled shell, now with breadcrumb chip nav, a tj optimize <name> chip, a
mechanism badge, a three-tile stat row, and footer "next fix" navigation.

  • The Fix panel always renders. Nine of the eleven previously dead-ended in a number or a table,
    with an action shown only if an open proposal happened to exist — and nothing at all in its place
    otherwise. Each analyzer now states why no fix is available when none is, rather than rendering
    blank space.
  • "Disabled for this persona" is now a distinct state, checked before the generic fallback. A
    gated analyzer renders no stats and no figures, so a page can no longer imply an absence of waste
    that was never measured.
  • downsize and placement previously early-returned and bypassed the stat row and Fix panel
    entirely; they now fall through the shared shell.
  • Branches carrying richer evidence than the design's flat row shape kept it — trim's per-prompt
    excerpts and reuse's two separate dollar columns were not flattened.

Tests

test_ui_offline.py 15/15 (includes a real node --check parse of the module script, and pins that
no external host is referenced). test_api.py 162/162 with new active_seconds coverage. Lens UI,
optimize-route, cost-proposal and cross-analyzer invariant suites all pass. A new test seeds an
overlapping-claim fixture and asserts the wire total is strictly less than the naive sum.

Where existing tests pinned markup that legitimately changed, the assertions were rewritten to check
the same underlying invariant rather than deleted.

Known gaps

  • Seven of the eleven analyzer branches are persona-gated for the corpus used to verify this, so
    their populated evidence tables were code-reviewed rather than seen rendering. Their shell path is
    the same one the other four exercise.
  • The per-analyzer tiles below the hero still measure their share against the old client-side sum
    rather than the netted figure. Nothing on screen asserts a false relationship — the misleading
    disclosure string was removed — but the two do answer different questions. Tracked separately.
  • The mechanism badge is a static client-side classification; no server field expresses it today.

🤖 Generated with Claude Code

One knowingly-stale decision left in place

Session detail's landing tab moves from Traces to Models & context, following the design. The
existing code carried a recorded decision that Traces should be the landing tab, on the grounds that
Map, Approach and Timeline are drill-in evidence rather than a landing view. Map is removed here, so
half that rationale no longer applies, and the newer design supersedes the rest.

self-improve-loop SPEC.md §12 still records the old decision and now disagrees with the code. That
is deliberate and left for a separate pass rather than edited silently in a UI pull request — noted
here so the contradiction is discoverable instead of being found by whoever next trusts the spec.


The "Viewing as" picker now actually scopes the product

The picker was cosmetic on most of the product. Only three endpoints had ever taken a persona
parameter, so selecting SDK changed the label on the Dashboard, the Optimize page, every
Optimize analyzer sub-page and Traces while leaving every figure on them unchanged. Three layers
were wrong, and closing only the outer ones would have left the numbers wrong for a subtler reason.

The population, not just the analyzer set

The persona gate decided which analyzers ran and nothing more, so every analyzer that survived
it still aggregated the whole mixed corpus and published that figure under whichever persona the
reader had picked. A dispatch gate says nothing about what an analyzer runs over.

There is now a population scope alongside it: one SQL predicate generated from the same prefix
tuple is_interactive_coding_agent reads, a persona_scope on the analyzer context and the report,
and one clause in every cost analyzer's WHERE builder — including the window summary those
findings quote their share against, so numerator and denominator cover one population. relearn
scopes by lane instead, since its three lanes are already partitioned by persona;
budget-projection is exempt and says why in the code (a provider budget caps the whole account, so
a scoped burn under an unscoped ceiling would be two populations in one ratio).

A population cannot be unioned the way an analyzer set can. A set of names is separable, so
compute-the-union-and-slice-on-read is sound for the gate; one sum over two populations contains
both and no read-time filter can extract either. So the daemon runs one pass per persona and stores
each result whole.

The proposal ledger

GET /relearn/cost-proposals feeds the Dashboard hero band, the Total-opportunity tile and
every Optimize sub-page's inline fix cards, and served one whole-corpus list with nothing on it to
narrow by. The scan cycle now writes one proposal list per persona, plus that persona's own
lane-partitioned relearn finding — relearn reaches the headline through the inbox-contribution path
rather than the proposal list, so a scoped rollup needs it or it folds the corpus's money back on
top.

Ledgers already on disk have no per-persona block. They keep working for the question they can
answer; a persona request against one returns persona_unscoped with an empty list rather than the
corpus figures relabelled. An empty scoped list and an unanswerable request are different states,
and only the first may render an empty state.

Threading, and three stated exemptions

/traces, /cost, /cost/compare, /status, /alerts, /relearn/proposals and
/relearn/cost-proposals now take and apply the persona, each validating against PERSONAS the way
/sessions does. It goes on the filters wherever a total is published beside a list, so the
rows, the count and the outlier quartiles cannot describe different populations. /optimize and
/cost/components serve the persona's own scoped report instead of slicing the corpus-wide one's
analyzer set.

Exempt, each stated in the code: /traces/{id} addresses one trace, which already belongs to one
persona; the recommendations ledger records no agent, so there is nothing to bucket by; and a
provider budget caps the whole account. /drift keeps its existing SDK-only population but now
publishes persona_applicable, because an empty list read as "no drift detected" when the truth is
that drift is not measured for coding agents at all.

Traces gets the picker

Traces is persona-scoped now, so it renders the picker in its own header. The regression test that
pinned it as persona-blind is inverted, not deleted — it was a green test enforcing the defect,
and it now pins the picker as present and the three genuinely persona-blind views as still absent.

Two things found by dogfooding that tests could not see

  • The Optimize spend bar drew a persona-scoped ceiling over corpus-wide spend, rendering as
    "overspend ceiling exceeds measured spend" on a mixed corpus. /cost/components accepted a
    persona and scoped neither half.
  • A syntax error in ui/index.html's module script blanks every page while the whole UI suite stays
    green, because a broken file still contains every string those tests grep for. There is now a test
    that the module parses.

One recorded decision overturned

tests/integration/test_cost_components_recoverable_population.py asserted that the persona must
not scope the ceiling's denominator, backed by measurements on the real corpus. That was correct
under its stated premise — "every finding is computed over the whole corpus" — which is exactly what
this branch changes. With a scoped numerator the same reasoning inverts, so those assertions are
inverted to pin the two halves moving together. The window and agent_id axes are unchanged and
still must not touch the denominator: neither re-runs the analyzers, so the stored numerator cannot
follow them.

Deploying this

A daemon restart alone is not enough for the persona-scoped figures. The stored analyzer report and
the cost-proposal ledger both need rebuilding, not just re-reading: the per-persona reports and
the ledger's persona provenance are written by the scan cycle, and an artifact from before this
change carries neither. Until the first scan completes, persona-scoped surfaces correctly report
not-yet-known rather than showing corpus-wide figures.

anshss and others added 5 commits August 6, 2026 11:48
Adds the missing @font-face declarations (variable woff2, served from
/ui/vendor/fonts/, zero CDN) so the 'Geist'/'Geist Mono' family names
already referenced throughout the stylesheet actually resolve instead of
falling back to system fonts.

Extends the :root/light token layer with the pieces the redesign needs
that didn't exist yet: a 7-step rank/tone ramp for rank-ordered visuals,
three named radius tokens (panel/control/pill), and an rgb-triplet +
alpha convention for tinted badge/border colors, each with a derived
light-theme counterpart. Collapses --info into --brand (near-duplicate
value, far fewer call sites) and updates its four call sites. Adds a
reusable .section-band primitive for screens to adopt as they're
restyled.

Sidebar shell, brand mark, and typography-by-class were already at the
target values on this branch, so this pass is purely additive to the
token layer.

Co-Authored-By: Claude <[email protected]>
… section-band, stale banner

Ports the design system pass onto DashboardView only:
- Each actionable opportunity tile in the triage row now shows a
  share-of-recoverable bar sized by its dollar share and colored off the
  rank/tone ramp (--tone-1..7, biggest = whitest), matching the
  rank-ordered-by-tone convention used elsewhere in the redesign. Share is
  computed from the same rounded contributor sum TotalOpportunityTile
  already sums, so the two can never disagree.
- Dashboard's zone headings ("Opportunities to optimize...", "Health at a
  glance", "Spend exploration") now use the shared .section-band primitive
  from the token layer instead of a page-local .band-label/.band-window
  pair that was byte-for-byte the same rule under a different name.
- The stale-scan banner is now a bordered/tinted amber box matching the
  design's alert-bar treatment, not bare colored text.

Quiet/muted tiles, per-tile hrefs, and the honest scan-state machine
(scanning/cold/timeout/failed/stale/tiles/none) were already correct and
are untouched. Updated two existing tests whose literal-substring
assertions pinned the old class names / render structure.

Co-Authored-By: Claude <[email protected]>
…r-analyzer double-claims

Restores the past-overspend hero band above the Dashboard's opportunity
tiles on explicit founder direction (lead with one clubbed recoverable-$
figure, then the fix path), reversing an earlier "read as heavy at the top
of the page" removal. The removal note recorded exactly what would have to
be true for a re-add: a separate past-tense row from the forward-looking
triage tiles, and its number sourced from GET /relearn/cost-proposals'
past_overspend block rather than any client-side sum. Both hold here.

The Total opportunity tile in the six-tile row below now reads the same
netted, server-computed rollup instead of a plain JS sum of the six
sibling tiles' own figures. That plain sum was a deliberate, documented
scoping decision for a claude-code-only MVP, where the one analyzer whose
claims can overlap another's (script) was persona-disabled -- it stops
being safe once the persona toggle reaches sdk, where script and reuse are
both left enabled and cluster on the identical repeated-tool-sequence
shape. The server already nets that overlap
(_net_cross_analyzer_session_overlap); the hero and the Total tile now
share one fetch and one computed figure (rollupFigure()) so the two can
never disagree with each other or with the Review inbox headline reading
the same block. The six analyzer tiles' own displayed figures and their
row-internal share bars are unchanged.

Verified live against a real seeded corpus tripping reuse+script on the
same 20 sessions: script's raw ~$4.00 claim nets down to ~$0 once reuse
(higher priority) claims the overlap, and the hero/Total tile both render
the netted $6.57 rather than the naive $10.57 sum.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Rebuilds the session-detail screen: identity row (status dot, name, id
chip, status badge) + a 4-tile stat grid (cost, tool calls, active
compute time, elapsed wall clock) replace the old two-card overview,
and the tab bar becomes 6 tabs in the redesign's order: Models &
context, Subagents, Tools used, Traces, Approach, Timeline.

Cut: the Map tab (swimlane board + codebase-territory treemap) and its
~1400 lines of exclusive rendering/CSS, the Loop tab (annotate/promote
expectation/record rerun), the Alerts tab (session alerts + behavioral
drift), and the "restore session" clipboard button — none of these are
in the redesign. The /sessionmap, /annotations, and /expectations API
endpoints are untouched (tj loop CLI still uses them).

Tools used is promoted to its own top-level tab instead of being
bundled under Models & context. The Timeline tab's internal state key
changes from 'story' to 'timeline' to match its label. Every tab body
drops its redundant in-body heading (the active tab button already
carries the label) and gets a real empty state where one was missing
(Models & context previously rendered nothing at all for a session
with zero LLM calls).

Kept despite not being modeled in the mock: the Traces tab's >1-trace
list-table branch (the mock's static data never exercises it, but live
per-call-ingest sessions routinely have multiple traces), per-dollar
info tooltips, and the hand-rolled flex-bar context histogram (the
mock's own histogram is the same hand-rolled shape, not a uPlot
migration).

Adds `active_seconds` to GET /sessions/{id} (session_active_seconds,
already used by /status, wasn't wired into session detail) to back the
new "active (compute time)" stat tile.

Co-Authored-By: Claude <[email protected]>
Restyles the shared OptimizeFinding shell (11 analyzers, one component) to
the design: breadcrumb chip nav across all detail pages, a title row with a
CLI-command chip and a mech badge (apply/snippet/read), a 3-tile stat row,
a two-column Evidence/Fix body, caveat + basis boxes, and a "next biggest"
footer nav. The Fix panel is now always present — where no fix is available
it says so and names why, instead of a page silently stopping after a table.
Persona-disabled analyzers (no lever for the selected persona) render a
distinct third state at the OptimizeView route level, before the generic
"ran, found nothing" fallback ever sees them.

Per-analyzer branch content (tables, prose, empty states) is unchanged; the
downsize/placement early returns are converted to fall through the same
shared shell every other analyzer already used.

Co-Authored-By: Claude <[email protected]>
@anshss
anshss requested a review from anilmurty as a code owner August 6, 2026 09:18
@greptile-apps

greptile-apps Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR ports the Lens dashboard, session details, and analyzer pages to the new design system while adding end-to-end persona population scoping.

  • Adds persona-specific analyzer reports and proposal ledgers.
  • Threads persona filters through dashboard-facing API routes and UI requests.
  • Uses the server-netted overspend rollup for dashboard totals.
  • Adds session active-time data and vendored Geist fonts.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains within the eligible follow-up-review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
tokenjam/core/persona_scope.py Centralizes the agent-prefix predicate used to partition database populations by persona.
tokenjam/core/optimize/runner.py Runs analyzers for each population-scoping persona and serializes the resulting report blocks.
tokenjam/core/optimize/report_store.py Resolves stored reports by requested persona and rejects legacy artifacts that cannot answer scoped reads.
tokenjam/core/optimize/relearn_store.py Extends the proposal cache with persona-specific proposal and relearn sections.
tokenjam/api/routes/cost.py Applies persona scope consistently to measured cost and the recoverable-spend presentation.
tokenjam/api/routes/traces.py Threads persona filters into trace rows, counts, and outlier statistics.
tokenjam/api/routes/sessions.py Adds persona filtering to session lists and returns server-computed active time in session details.
tokenjam/ui/index.html Ports the Lens surfaces to the new design system and connects persona selection to scoped API reads.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Picker["Viewing as picker"] --> Requests["Persona-scoped UI requests"]
  Requests --> API["Dashboard API routes"]
  API --> Scope["Shared persona population predicate"]
  Scope --> DB[(Sessions and spans)]
  DB --> Scan["Per-persona analyzer passes"]
  Scan --> Reports["Persona-specific reports"]
  Reports --> Ledger["Persona proposal ledgers"]
  Reports --> API
  Ledger --> API
  API --> Views["Dashboard, Optimize, Traces, and analyzer views"]
Loading

Reviews (26): Last reviewed commit: "test: drop the recommendation field from..." | Re-trigger Greptile

anshss and others added 21 commits August 6, 2026 15:12
Summarize (#/optimize/summarize) has its own bespoke curate -> run ->
review lifecycle and was excluded from the analyzer-detail-page redesign
pass, so it never picked up the shared header chrome the 11 ported
analyzer pages now share. Adds the CLI chip + mechanism badge to its
landing header (tj optimize summarize, "writes the change" -- summarize
is a real apply-mechanism analyzer, same footing as downsize/subagent/
deadweight), a stat-tile row (candidates found, est. tok/call recoverable
across all candidates, already-staged count) gated on the scan having
actually resolved so it never paints a false "0 candidates" before the
scan lands, and a section-band label above both the candidates table and
the staged-review table to match the shared shell pattern. No behavior
change: same curate/run/manual/review state machine, same API calls.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The earlier session-detail pass rebuilt the shell, the stat tiles and the tab
bar but left the six tab BODIES as they were, so the page read as the new
design wrapped around the old one. This brings the bodies across.

Shared primitives, so any screen ported later gets the same shape for free:
a data table that sits inside a `.panel` drops its own outer chrome and its
header row becomes the panel's tinted head strip; `th.num`/`td.num` right-align
a numeric column in both header and cell; `td.dim` is the design's secondary
cell; `.tab-cap` / `.tab-foot` replace the caption and footer-note styles that
were re-written inline at every tab.

Per tab:

* Models & context, Subagents, Tools used, Traces — each table now sits in a
  panel with the head strip, numerics right-aligned, cost bold. The context
  histogram gets its own panel with the caption above the plot. The subagent
  right-sizing flag moves out of a column at the far edge of a wide table and
  becomes a tinted pill under the subagent's name, next to the row tint that
  is the same signal. Traces gains the caption and the note that a tool span
  carries no tokens, and stops printing "click a span for details" twice.

* Approach — the real change. The design leaves tables and tiles behind here
  for a structured-prose format, and the layout is what carries it: a 20px
  glyph gutter (• acted, ⑂ delegated, ✗ dead end, ✅ verified) beside a full
  prose column, rows separated by a divider. The old spine was a vertical rail
  of circular icon badges with an uppercase kind tag, a bold label and a
  colored source chip competing along one line. Provenance is now a caption in
  words under the prose, which also retires the legend that existed to decode
  the chips; the legend now decodes the gutter, the one thing a first-time
  reader cannot infer. A dead end is dimmed rather than struck through, since
  the line you most need to read to understand a wasted twenty minutes should
  not be the hardest line on the page. The outcome moves from the header to
  the foot, so the panel reads as what was attempted, then how, then how it
  ended. The delegation rail becomes a panel of bordered rows with the cost
  hard right; a name too long for it truncates rather than wrapping into a
  stack of fragments, and a completed main agent loses its badge for the same
  reason a plain ended sidechain already had none.

* Timeline — the unit is now the exchange: the design's labelled "Ask" callout
  over a bordered panel of flat rows, repeated per ask rather than pinned once
  at the top (a session gets many asks, and the first stops describing the work
  almost immediately). Rows follow the design's order, with the retry tag
  pushed hard right.

Loading, empty and error states are kept throughout: the static mock cannot
express them, so their absence there is not a decision. The honest-absence
state for Approach/Timeline is boxed so it reads as a resolved answer rather
than a caption that failed to load. Traces keeps its multi-trace list branch
and the interactive waterfall, which is richer than the mock's single one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Rules now wears the same shell as the eleven analyzer detail pages: head row
with the CLI chip and mechanism badge, blurb, and a three-tile stat grid. The
tiles are counts, never a summed dollar figure, because the rules on that page
come from four analyzers whose overspend populations overlap; relearn reaches
the rollup through its contribution path and this screen must not grow a second,
naive one. Each proposal is a card that shows the exact text it would append
instead of hiding it behind a Show/Hide toggle, with the primary action first
(stage, then write), a copy button, and the standing terms at the foot. Tabs
read Pending / In place. The detector stays unbounded and no aggregate
cost-proposal card comes back.

The analyzer label 'Relearn' becomes 'Rules' everywhere it is displayed. The
Dashboard tile and the sidebar entry named the same thing two ways, so the tile
was unfindable from the nav; the registry key is untouched and no route moves.

Optimize: the two-bar component chart becomes one horizontal rank-toned share
bar plus a legend, since its second bar stacked past overspend by analyzer,
which is exactly what the action list underneath states row by row. Recommended
actions moves into a section band + panel with quiet checks dimmed rather than
ranked against rows carrying money. Rules and Summarize leave the action list —
neither has a dollar for its figure column — and close the page as their own
cards beside an applied ledger. The now-unused chart component and its tooltip
are deleted rather than left dead.

Co-Authored-By: Claude <[email protected]>
The closed and stale sessions were behind a <details> drawer whose summary
strip read like a section header, so most of what the screen holds sat one
click away. They are now a zone head plus the standard panel table with the
tinted head strip, cost and tool counts right-aligned as numeric columns and
the derived cells dimmed, matching every other data grid in the app.

Co-Authored-By: Claude <[email protected]>
The rows sit in a panel with the shared tinted head strip instead of a bare
table, spans right-align as a numeric column, and Load more moves inside the
panel under the rows it extends. The trace count and the outlier rule become
one caption rather than two stacked notes held together by a negative margin,
and the token column's header says Tokens, which is what the cell contains.

Co-Authored-By: Claude <[email protected]>
Cost and Budget become the two tabs of one Spend screen, sharing a title and a
tab bar defined once, and the sidebar carries a single Spend entry that stays
lit on either tab. Two sibling money rows both marked $ sent readers looking
for a ceiling to the wrong page.

Every data grid on these screens moves into a panel with the shared tinted head
strip, with numeric columns right-aligned and derived cells dimmed.

Drift gets its baseline requirement stated on the page rather than only inside
the empty state, and each agent becomes a panel whose head carries the agent,
its baseline provenance and one overall verdict derived from the same
per-metric judgements the rows show, so the two cannot disagree.

FAQ splits into the two groups its own opening sentence promises: the checks
live for this setup as a card grid, and the ones gated off as a list of
reasons. Which names are gated is now data rather than a comment above the
order array.

Co-Authored-By: Claude <[email protected]>
Summarize prices what a filesystem scan of AGENT INSTRUCTION FILES found. Its
population is the catalog in `core/summarize/agent_files.toml`: `CLAUDE.md`,
`AGENTS.md`, `GEMINI.md`, the rules / skills / commands / agents markdown beside
them, and the `~/.claude`, `~/.codex`, `~/.gemini` equivalents. It has never read
application source, and the only widening it offers (the user-invoked
`tj summarize list --recursive`) admits more markdown, never the `.py`/`.ts` a
prompt template lives in.

So for an SDK/API-dominant window the scan has no input, and the analyzer can
only produce a card with no fix behind it. That is the same bar the `sdk` key
already applies to `deadweight` and `subagent`, so it joins them in
`PERSONA_DISABLED_ANALYZERS` rather than getting a second gating scheme: a true
skip before dispatch, mirrored automatically into the Review inbox's own
selection surface through `cost_analyzers_for_persona`.

Nothing changes for Claude Code or Codex users. An interactive coding agent
classifies as the `claude-code` persona, never `sdk`, and `tj summarize` stays a
command anyone can type; the gate drops the analyzer from optimize reports, not
the lifecycle.

Two `tj optimize` strings were asserting the wrong reason for an SDK reader and
are now persona-aware: the "Not run:" line hardcoded the claude-code
"no fix inside an interactive coding-agent session" wording, and the skipped-
filesystem-scan note hardcoded three analyzer names, blaming a scope skip for
absences the persona gate had already caused.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… unresolved persona read

Two defects the first screenshot pass caught. The Rules primary button read
'Approve &amp; write' literally: htm assigns text content and never parses
entities, a trap already commented at one call site in this file and now a
rule of its own so the next writer does not rediscover it.

The Optimize submenu gated its Rules child on `personaHasNoData === false`.
That read is null until /persona answers, and null is not false, so an
unresolved read HID the entry. Hiding a nav row asserts this persona has no
rules to write, which is exactly the claim a not-yet-known state may not make;
only a positive no-data answer hides it now.

Co-Authored-By: Claude <[email protected]>
…g three zeros

A scan that ran and found no candidate rendered '0 files over budget · ~0 est.
tokens per call · 0% avg prose reduction'. That is the known-empty truth, but a
row of zeros reads as a broken tile; empty-state copy is the only honest home
for that state.

Co-Authored-By: Claude <[email protected]>
…ty state

The new page-level blurb rendered in every branch, including the branch whose
empty state already states the baseline requirement at length. Same sentence
twice, on the one page a reader is least likely to skim.

Co-Authored-By: Claude <[email protected]>
Bundles the analyzer-side gate with the UI work so they land together: summarize
scans agent instruction files only, so an SDK-dominant window has no input for it
and never dispatches it.
The lens port renamed the Rules tabs Open/Applied -> Pending/In place, and
tests/unit/test_rule_presence.py asserts those labels as raw substrings of
index.html. I grepped tests/ for the rendered form ("Open (") and missed the
source form ("Open "), so the rename shipped red on CI.

Both guards keep the property they were written for — two tabs, each count
gated behind its own fetch — and now pin the new wording as present AND the old
wording as absent, so a drift back is a failure rather than a silent revert.
Adds the rule that would have caught it: grep the source form, and run every
test that reads the UI file.

Co-Authored-By: Claude <[email protected]>
Both filter bars on Summarize offered every option unconditionally, so a user
always saw All/Global/Repo/Project even when every candidate shared one scope.
Nothing looked at the data before drawing the control.

A new shared facet() decides per dimension: a population holding one distinct
value gets no control at all, because every button there either changes nothing
or empties the list, and the option list drops values no row carries. The basis
is the whole population the bar filters, never the currently-visible subset —
faceting on the visible subset makes a control vanish the instant it is used and
strands the reader with no way back to All. A retained selection the control can
no longer offer reverts to filtering nothing rather than silently emptying the
list.

That covers all three cases at once. Kind is binary and almost always uniform.
The review bar's applied/rejected/reverted states live only in this session's
fileStates overlay and nothing persists them, so on a fresh load every row is
staged and the whole State dimension disappears instead of offering three
buttons that cannot match; it comes back the moment an Apply or Reject actually
produces a second state. No server persistence was invented for those states.

Both empty states now separate three cases rather than two: nothing found, a
filter is hiding everything, or everything is hidden with no filter set — so a
control that is absent can never be mistaken for a result set that is empty.

Co-Authored-By: Claude <[email protected]>
…iles

Two defects found by looking at the running page.

The screen was "Relearn" in the analyzer registry and "Rules" in the nav, and
an earlier pass settled the collision the wrong way by renaming the Dashboard
tile to Rules. The user-visible label is Relearn everywhere now: the Dashboard
action tile, the sidebar nav-child, the Optimize card and its link, the page
title, the persona-empty header, and the FAQ entry. The route
(#/optimize/rules), the registry key (relearn) and the nav's data-param are
deliberately untouched, so existing links and the nav sync keep working. The
CLI chip stays `tj rules`: that group is what drives this surface, one
subcommand per button on the page, while `tj relearn` only emits an eval-case
artifact and reaches none of it.

The three stat tiles sat in the page head pinned to the pending population, so
standing on "In place (2)" you read three counts about the other tab. On the
founder's data all three were 0, directly above two real rules with real dollar
figures, which reads as a broken page. Each tab now renders its own strip
inside its own branch: Pending counts what is waiting, the files it would land
in and what is staged; In place counts what is done, split by the two routes
the rows are already labelled with (written by tokenjam, already in your files),
derived as a complement so the two cannot fail to add up to the population.
A known-empty tab renders no strip at all rather than a row of zeros, leaving
the empty-state sentence as the one honest statement, per the same rule the
Summarize card follows.

Guards: both changes pinned with the old state asserted absent, so a revert
fails rather than drifting back.

Co-Authored-By: Claude <[email protected]>
…he SDK-only views

The "Viewing as" picker was pure client-side state that never left the browser.
Every persona-looking affordance downstream keyed off the STORED report's own
dominant persona instead, so on a claude-code corpus viewed as SDK the Optimize
submenu, the analyzer cards, the gated-analyzer chip and the Dashboard tiles all
rendered the claude-code gate under an SDK label. The one reconciliation attempt
could only BLANK the submenu on a mismatch; there was no code path that computed
the right set for a non-dominant persona.

Persona now reaches the server. GET /optimize, GET /cost/components and
GET /sessions each take a `persona` parameter. No request path may run an
analyzer, so a per-selection recompute is not available: the daemon's background
pass instead gates on the INTERSECTION of every selectable persona's disabled set
(build_report's new `personas` argument) so ONE stored artifact can answer for
either side, and each read narrows to the persona asked for. Narrowing happens
server-side, so a surface that forgets the filter cannot render what it should
not. The report's own `persona` is untouched — it still records what the corpus
IS — and `computed_analyzers` / `computed_for_personas` record what the pass
actually dispatched, which is what lets a route publish
`persona_unanswered_analyzers`: a lever this persona HAS that nothing has
measured yet, kept strictly distinct from "ran and found nothing".

Widening what the stored report holds is a change to every blind reader of it, so
the three that walked findings unscoped are now explicit: the /cost/components
overlay, the `tj status` teaser, and the write budget's summarize denominator.

Second half: PERSONA_HIDDEN_VIEWS listed the SAME five views under both persona
keys, and those are the only two keys, so traces / cost / alerts / drift / budget
were reachable by nobody — five built, routed, populated screens behind a gate
that was simply wrong. Target state now implemented: Traces is SDK-only
(per-session traces still reach every persona through the session detail tab);
Alerts, Drift and Budget are SDK-only and RELOCATED into the Sessions page's
SDK-services zone as tabs, since none of the three is per-session; Spend stays
hidden for both personas deliberately and says so in PERSONA_HIDDEN_DELIBERATE,
so a view hidden everywhere on purpose is distinguishable from one hidden by this
defect. The persona fallback no longer resolves an unknown persona to a concrete
one: nothing is hidden until the persona is actually known, in the CSS half as
well as the JS half.

Also fixed while verifying against a real two-persona corpus: the Sessions header
published the coding-session count while the coding zone was hidden, and the
"biggest single cause" line named an analyzer the row list beside it had
correctly dropped — two figures rendered together over two different populations.

Tests: the guard that asserted the two personas' hidden lists were identical was
ENFORCING the defect, so its assertion is inverted rather than deleted — the
shared parts stay pinned present, the identical-lists state is pinned absent. New
pins: no view hidden under every persona key without a recorded reason; the
dispatch gate and COST_ANALYZERS agree for every persona the classifier can
produce; every gated name resolves to a registry entry or a named sub-check; and
the union pass, the read-side slice and both new query parameters end to end.

Co-Authored-By: Claude <[email protected]>
…eted binding freezing the page

Two defects, both on the SDK persona's Sessions page.

1. NO HISTORICAL SURFACE. The live-services panel is bounded by
SDK_DISCOVERY_WINDOW (7 days, api/routes/status.py), and that panel was the only
thing on the page. An SDK agent quiet for longer than the window dropped out of
it and, since this is that persona's only session surface, out of the product
entirely — the page rendered one sentence, "No SDK services live right now",
over a corpus holding real SDK sessions from twelve days earlier.

Deliberately NOT fixed by widening the window: live / went-quiet / long-dormant
are all defined against it, so widening changes what those three words mean and
only moves the cliff. An agent leaving the live window now degrades into
history, which is what the coding zone already does with its archive. The new
list is fed by GET /sessions?persona=sdk (a different question needs a different
source) and its rows are SESSIONS, mirroring the coding archive, so each row is
a real thing to drill into rather than a second aggregate free to disagree with
the panel above it. The column is Started, from started_at, kept to a single
basis because an SDK service never closes and a "last activity" column would
silently mean two different things per row.

The empty state now distinguishes three things, gated on the history read's OWN
resolved flag: not-yet-known renders a skeleton and makes no claim of any kind;
known-and-empty is the only place an absence claim lives, and it makes the claim
the reader actually needs rather than the narrower live-window one;
known-with-history keeps the live-window fact but never leaves it standing
alone. A failed read stays not-known rather than degrading into "empty".

2. A DELETED BINDING FROZE THE WHOLE PAGE. Relocating alerts into the
SDK-services zone removed a local that the active-agent card still referenced.
It only evaluates when there is an active coding card to draw, so a corpus with
no active session never reached it — and Preact swallows a re-render exception
into its rerender queue, so the page silently stopped updating with an empty
console and a permanent skeleton that reads as a slow fetch. The alerts row now
gates on whether the reader can OPEN alerts at all, which is the same question
as whether the SDK zone renders. Pinned by name, since a static grep cannot do
scope analysis; the durable lesson is recorded as a Critical Rule.

The existing discovery-window test is kept, not loosened — it pins a deliberate
bound. Its docstring now says where those agents surface instead, and names the
test holding the other half, because half this behaviour on its own IS the bug.

Co-Authored-By: Claude <[email protected]>
…h-overspend spend bar, project-name sessions, and a compute tile that falls back to tokens

Five founder-reported items in one pass, plus two defects found while verifying
them.

PERSONA PICKER — ONE POSITION. It had two placement mechanisms: an in-header
slot for four named views, and a floated fallback bar for every other view. The
fallback was `float: right`, so the same control sat beside the page title on
some pages and at the far right on others and moved as the reader navigated. The
fallback is deleted rather than restyled; a control positioned in two places
drifts in two places. It is also gone from Traces, FAQ, Relearn and Summarize
entirely: none of them reads the persona, so the picker there was a control that
changed nothing, which is worse than a misplaced one because it invites the
reader to believe the page responded. Verified in the browser: on all three
remaining views the select renders at the same offset beside the title.

BUDGETS ARE SDK-ONLY. The page was reachable under the SDK persona but still
rendered coding-tool caps, because relocating it never scoped its DATA — the
same defect class as the two already fixed in this PR. `GET /budget` now takes
`persona`, and the SDK scope empties the coding groups and restricts the legacy
flat agent map, so a client that forgets the filter cannot render a cap this
surface does not cover. The view drops its coding zone as the second half of the
same decision. Where the two agent classifiers disagree (`agent_kind` matches
codex on an exact id, the persona predicate on a prefix) this scope takes the
broader one for exclusion only: showing a coding agent breaks the decision,
hiding an SDK one does not.

SPEND IS ONE BAR. Total spend is the whole width, the overspend ceiling is a
shaded region inside it, and the segmented composition chart is replaced. The
trap that shapes the implementation: those estimates overlap, so the total is a
ceiling rather than a slice anyone could bank. The server's own overlap note
therefore travels directly under the bar, the legend says "ceiling", and the
largest single line stays one click away as the only standalone-honest figure.
Only the WIDTH clamps to the bar; when the ceiling exceeds measured spend the
real number is still shown and labelled, because that case is the clearest
evidence of how much the estimates overlap.

SESSION NAMES SHOW THE PROJECT. `claude-code-tokenjam` renders as `tokenjam`.
Display only: `agent_id` stays the identity for links, filters and dedup keys,
and every rendered name carries it on hover. The stripping rule lives beside the
prefix list that defines what a coding agent is, so it cannot drift from the
classifier. Degenerate cases are decided rather than left to fall out: a bare
tool id keeps the tool name, a trailing separator keeps the whole id, and
nothing ever renders empty. Two ids that shorten alike revert to full ids, which
is a list property and so resolved per rendered list.

THE COMPUTE TILE FALLS BACK TO TOKENS. It showed a dash whenever a session's
spans carry no recorded duration. Correcting the premise this was filed on:
measured on the real corpus this is NOT per-persona. SDK sessions carry
durations in full, but 38% of coding sessions carry them too, with the share
falling in recent months, which is why a twelve-session sample of recent
sessions found none. So the fallback is per SESSION. Zero is treated as absent
rather than shown as `0s`, since a zero sum means the spans recorded no
duration, not that the session did no work. Nothing derives a duration from
adjacent timestamps: that is wall clock, which the tile beside it already shows.

Also fixed, both found while verifying the above: the new bar's shaded region
had no width at all, so a 19% ceiling drew as the 6px CSS legibility floor and
the picture contradicted the legend beside it; and the ceiling figure was being
clamped to the total for display, printing a value the data never produced.

Deleted with the chart they served: `buildComponentWaste`, `dominantSplit` and
`WASTE_LEGEND_OVERRIDE`, none of which had another caller. The rules the last of
those encoded are still enforced where they are actually rendered.

Co-Authored-By: Claude <[email protected]>
…, and un-surface Drift

The Optimize spend bar drew a stored 30-day recoverable estimate as a shaded
share of whatever total the window picker happened to hold. Measured on a real
corpus: at 30d the pair read 19.3%, at 7d the numerator did not move by a cent
while the denominator fell from $13,518.97 to $3,575.29, so a week's view shaded
73.1% of spend as overspend. Narrower windows trend past 100%. The two figures
also had to agree on which agents they cover: the stored report is corpus-wide,
so any agent filter on the total recreated the same mismatch on the other axis.

/cost/components now publishes recoverable_basis_cost_usd, measured spend over
the report's OWN window across every agent, and the bar divides by that. The
requested window's total still answers the request and is no longer a valid
divisor for the ceiling. Null when the scan never recorded its bounds, never
zero. The window, the scope, and what the persona picker actually changes all
travel with the pair as recoverable_basis_note, beside the existing overlap
note.

The persona does NOT scope the denominator, and the note says so. The picker
selects which analyzers contribute (a lever set), not which traffic is measured;
every finding is computed over the whole corpus. On the real corpus, scoping the
denominator to the SDK persona's own traffic gives $1.37 of spend against a
$1,023.58 ceiling at 30d and $0.00 at 7d.

Drift is withdrawn from the UI by founder decision: no nav entry, no tab, no
health tile, no link, no copy, and #/drift aliases to Sessions rather than
resolving to the surface. DriftView, the route, the detector and the baselines
are all kept, so re-surfacing is a wiring change.

Tests: new integration coverage asserts numerator and denominator carry the same
window and the same agent population across two windows and both personas, on a
deliberately asymmetric corpus (the symmetric fixture this shipped past could not
see either defect). Three guards that were pinning the removed states are
inverted rather than deleted: the Drift tab, the Drift health tile, and the
shaded region's looser gate.

Co-Authored-By: Claude <[email protected]>
… not just the analyzer set

The persona gate decided WHICH ANALYZERS ran and nothing more, so every
analyzer that survived it still aggregated the whole mixed corpus and
published that figure under whichever persona the reader had picked. A
dispatch gate says nothing about what an analyzer runs over.

Adds a population scope alongside the dispatch gate: one SQL predicate
generated from the same prefix tuple is_interactive_coding_agent reads, a
persona_scope on the analyzer context and the report, and one clause in every
cost analyzer's WHERE builder — including the window summary those findings
quote their share against, so numerator and denominator cover one population.
relearn scopes by LANE instead, since its three lanes are already partitioned
by persona; budget-projection is exempt and says why in the code.

A population cannot be unioned the way an analyzer set can, so the daemon now
runs one pass per persona and stores each result whole rather than one widened
pass sliced on read.

Co-Authored-By: Claude <[email protected]>
…of persona-labelled

GET /relearn/cost-proposals served one whole-corpus proposal list and had
nothing on it to narrow by, so the Dashboard hero band, the Total-opportunity
tile and every Optimize sub-page's inline fix cards published corpus-wide
dollars under whichever persona the reader had selected.

A dollar total cannot be narrowed on read the way an analyzer set can, so the
scan cycle now writes one proposal list per persona, plus that persona's own
lane-partitioned relearn finding — relearn reaches the headline through the
inbox contribution path rather than the proposal list, so a scoped rollup
needs it or it folds the whole corpus's money back on top.

Ledgers already on disk have no per-persona block. They keep working for the
question they can answer, and a persona request against one returns
persona_unscoped with an empty list rather than the corpus figures relabelled
— an empty scoped list and an unanswerable request are different states, and
only the first may render an empty state.

Co-Authored-By: Claude <[email protected]>
anshss and others added 17 commits August 7, 2026 11:29
…ent fetch the picker reaches

Only three endpoints had ever taken a persona, so the picker changed the label
on the Dashboard, Optimize, every Optimize analyzer sub-page and Traces while
leaving every figure on them unchanged.

Server: /traces (list), /cost, /cost/compare, /status, /alerts,
/relearn/proposals and /relearn/cost-proposals now take and apply it, each
validating against PERSONAS the way /sessions does. It goes on the FILTERS
rather than the route wherever a total is published beside a list, so the rows,
the count and the outlier quartiles cannot describe different populations.
/optimize now serves the persona's own fully-scoped stored report instead of
slicing the corpus-wide one's analyzer set.

Three deliberate exemptions, each stated in the code: /traces/{id} addresses
one trace, which already belongs to one persona; the recommendations ledger
records no agent, so there is nothing to bucket by; and a provider budget caps
the whole account, so scoping the burn under an unscoped ceiling would be two
populations in one ratio. /drift keeps its existing SDK-only population but now
publishes persona_applicable, because an empty list read as 'no drift detected'
when the truth is that drift is not measured for coding agents at all.

Client: every Dashboard and Optimize fetch carries the persona AND names it as
a load dependency, TracesListView destructures and forwards it, and readStatus
treats an unscopable ledger as still-loading so a tile cannot render 0 for a
persona nothing was measured for.

Traces gains the picker, and the regression test that pinned it as
persona-blind is inverted rather than deleted: it was a green test enforcing the
defect, and it now pins the picker as present and the three genuinely
persona-blind views as still absent.

Co-Authored-By: Claude <[email protected]>
…persona not the corpus's

Three defects found by dogfooding the real UI, which the unit tests could not
see.

/cost/components accepted a persona and scoped neither its spend bar nor its
recoverable overlay: it read the corpus-wide stored report and an unscoped
component split, so the Optimize spend bar drew one persona's overspend ceiling
against everybody's spend and rendered "exceeds measured spend" on a corpus
where it did not. It now selects that persona's own scoped report and applies
the population predicate to the split AND to the ceiling's denominator, so the
two figures on that bar cover one population.

The placement sub-check and relearn's write gate keyed off the window's
dominant persona rather than the persona the pass was computing for. On a mixed
corpus that resolves to 'mixed', which disables nothing, so a claude-code-scoped
pass still attached a batch-lane card priced off Claude Code sessions. Both now
read an effective_persona that prefers the scope.

Adds a test that the dashboard's module script PARSES. Every other UI test
matches strings, and a file with a syntax error still contains all of them, so
the whole UI suite stayed green while the page rendered blank. That was not
hypothetical: an interpolating comment placed inside a ternary expression took
the entire module down and nothing caught it.

Also pins storage.path in the endpoint tests' config fixture. Without it the
proposal store resolves to the real ~/.tj, so the tests read the operator's
live ledger and their result depended on the machine.

Co-Authored-By: Claude <[email protected]>
# Conflicts:
#	CLAUDE.md
#	tokenjam/ui/index.html
…ecord the two lessons

The merge renamed DeadweightFinding.dead_servers to unused_servers, but the
Optimize stat-tile helper reading it lives only on this branch, so nothing
renamed it for us. Reading the old name does not throw — it returns no tile,
which renders as a finding with no figures.

Corrects the union-then-slice rule, which as written taught exactly the
mistake that produced the persona bug: a SET of analyzer names can be unioned
at compute time and sliced on read, a POPULATION cannot, and applying only the
set gate leaves every surviving analyzer measuring the whole corpus.

Files the string-matching lesson: a syntax error in the dashboard's module
script blanks every page while the whole UI suite stays green, because a broken
file still contains every string those tests grep for.

Co-Authored-By: Claude <[email protected]>
…na, and update the tests whose premise moved

The spend bar drew a persona-scoped ceiling over corpus-wide spend, which on a
mixed corpus rendered as an overspend ceiling larger than measured spend.

/cost/components now resolves the persona's own scoped report through a single
seam, stored_report_for_persona, which also owns the rule for an artifact
written before per-persona passes existed: it withholds the overlay and reports
not-yet-known rather than serving the corpus's figures under that persona's
label, or serving them as that persona's zero.

Three integration tests asserted the opposite, and they were correct when they
were written: while every finding was computed over the whole corpus, scoping
the denominator alone put a whole-corpus ceiling over a fraction of the spend it
came from. That premise is what this branch changed. The same reasoning now
requires the denominator to follow, so those assertions are INVERTED to pin the
two halves moving together, with the corpus-wide state pinned absent. The window
and agent_id axes are unchanged and still must not touch the denominator:
neither re-runs the analyzers, so the stored numerator cannot follow them.

Two seam repairs: the population fixture patched stored_report, which the route
no longer calls, and the overlap test patched build_report rather than
build_persona_reports, so neither was intercepting the code under test.

Co-Authored-By: Claude <[email protected]>
…o its seam

CI lints tokenjam/ only, and this was the one error there. Also clears two
unused imports in the new test modules, which CI does not lint but which are
noise all the same.

Co-Authored-By: Claude <[email protected]>
… Sessions heading

The lens switch was unreachable UI: CSS hid it for both personas, since
neither has an Observe nav. But the hide was keyed on the sidebar's
data-persona attribute, which syncNavState deliberately leaves empty
until the persona resolves, so the switch rendered during the loading
state and only then. Removes the whole mechanism rather than the
symptom: the switch, its CSS, the per-persona hides, the data-lens
attributes, VIEW_LENS, the route-sync lens computation and the pill
click handler.

Spend stays hidden for both personas: that gating lives in
PERSONA_HIDDEN_VIEWS, independent of the lens rules being removed.

On the Sessions page the SDK zone carried a second heading directly
under the page's own Sessions title, so that line goes and the first
tab now reads Sessions. The tab KEY stays 'services' because the routes
match on it; only the label was product copy.

Tests are inverted rather than deleted: what pinned the lens present
now pins it absent, so the concept cannot creep back.

Co-Authored-By: Claude <[email protected]>
The slice ended at a '// Two lenses, one router' comment. That comment
went with the dead Improve/Observe lens, so index() raised rather than
asserting: the test could not find its own anchor. An extractor anchored
on prose is only as durable as the prose, so bound it by the next
top-level declaration instead.

Co-Authored-By: Claude <[email protected]>
…hold the previous persona's figures

OptimizeView held its last answer across every reload (`loading: !s.opt`) and
carried no generation counter, so a persona switch left the previous persona's
analyzer rows, dollar figures, gated-analyzer set and scan-freshness line
rendered under the new persona's label for the whole read, with nothing on
screen indicating a read was in flight. Measured on an isolated instance with
the reads artificially slowed: 4.4s of a wrong-persona page carrying three
"No candidates" claims, zero skeletons.

Same contract DashboardView's recoverable-waste read and useTriageRead already
keep, factored into two pure functions:

- optQuestionKey/optPendingState: a changed question (persona, window, agent,
  comparison) DROPS the held answer and renders skeletons; an unchanged one
  (poll tick, Refresh, apply-a-fix reload) keeps it.
- a generation counter guards both settle paths and the effect cleanup, so a
  response for the persona the reader has left cannot write into the current
  view.
- the six reads run as one Promise.all instead of six sequential awaits: the
  not-yet-known window was the SUM of their latencies (4.4s measured), now the
  slowest single read (2.2s under the same delays).
- ScanBar gets the third state it lacked: a null payload was read as
  'scan state unavailable', a failure claim about a read merely in flight.
- OptimizeSkeleton is shaped like the page it stands in for, so resolution does
  not yank the scroll position the way one 200px shimmer did.
- the sidebar's analyzer submenu is a persona-specific set too: it kept naming
  the previous persona's analyzers, and now renders them visibly unsettled
  until its own read answers rather than either asserting or removing them.

Also repairs test_lens_dashboard_states' extractor, which was anchored on a
comment removed with the dead lens and had been silently taking four assertions
down with it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019SbVXUgJy7zjuAo8jh5mZD
… and pin the declaration/enforcement mirror

PERSONA_HIDDEN_VIEWS is the DECLARATION; the sidebar CSS is the ENFORCEMENT.
Spend was hidden for both personas by a pair of rules keyed on the nav attribute
the removed Improve/Observe lens carried. Deleting the lens deleted them and
left both 'cost' entries in the list, so the declaration read as intact while
nothing enforced it: the link rendered, the route stayed gated, and clicking
Spend landed on nothing.

Mirror audit: 'cost' under both personas was the only casualty. traces under
claude-code is the sole surviving rule and is correct; alerts/drift/budget are
in neither list by design (the Sessions SDK zone decides them).

test_lens_persona_hidden_mirror.py pins the mapping as a whole in BOTH
directions, since the failure was a rule disappearing rather than a rule being
wrong: every list entry needs a rule, and every rule needs a list entry (one
that outlives its entry hides a view nothing declares hidden). Verified it fails
with the two rules removed.

Also in this pass:

- Persona-gated analyzer chips no longer render in the Optimize breadcrumb strip
  (operator decision, overriding the 'distinct, never hidden' argument the
  comment made). The strip now iterates `order`, the same persona-filtered list
  the summary's row list uses, so the two surfaces cannot offer different sets.
  The PAGE is untouched: #/optimize/<gated> still routes and still lands on the
  persona-disabled explanation, verified in the browser under both personas.
  The dimmed-chip style and the prose arguing for it go with the behaviour.

- The Sessions SDK zone's separator is conditional on the zone above it having
  rendered. It was written to sit above an 'SDK services' zone-head since
  removed as a duplicate, and viewing as SDK, where the coding zone renders
  nothing, it opened a band of dead space between the page header and the tab
  row. Not deleted: with both zones on screen it is the only thing between the
  archived table and the tab strip. A hoisted `codingZoneShown` answers the question
  all three consumers were answering separately.

The 'Coding sessions' zone-head was checked and is correct as-is: it is nested
inside the coding zone and gated on the SDK zone, so it cannot render for a
persona with no coding sessions.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019SbVXUgJy7zjuAo8jh5mZD
…the traffic alone; it scopes both halves

`recoverable_basis_note` travels with the ceiling and its denominator as part
of the claim, and two of its three sentences were false:

  "Both figures cover every agent ... The persona picker changes which
   analyzers contribute to the ceiling, not which traffic is measured."

Both stopped being true when the daemon began storing a separately-scoped
analyzer pass per persona. `stored_report_for_persona` serves that persona's
own pass, and `_component_costs` takes the same persona, so the picker moves
the denominator too: on one real corpus the same bar reads 13733.55 under
claude-code and 1.37 under sdk. A disclosure that contradicts the payload it
ships with is worse than no disclosure, and this one asserted more than its
population supports, which is the defect class the whole surface exists to
prevent.

The middle sentence (this bar does not follow the range picker; the estimate
comes from the stored scan and is never recomputed per request) was and is
true, and is kept verbatim.

The note now has three branches:

- a selected persona names that persona's traffic and states that the picker
  scopes both halves;
- no persona over a corpus that resolves to one is a HYBRID, not a clean
  corpus total: every agent's spend under a ceiling still filtered by that
  dominant persona's lever set, because `_collect_recoverable` falls back to
  it. The note says so and offers the fix (select a persona);
- no persona over a mixed or unclassified corpus disables nothing, so every
  analyzer really does contribute, and it says that instead.

WHAT THE NOTE DELIBERATELY DOES NOT CLAIM: that the ceiling's POPULATION is
persona-scoped. The analyzer set is, and the spend beneath it is, but a
contributing analyzer may measure on a wider basis than this window: relearn
scans unbounded on-disk history by design and lands the same figure in a
scoped total as in an unscoped one. So the sentence says the ceiling counts
the analyzers that persona can act on, "each measured on its own basis", which
is true of every contributor. Naming which contributors are wider than the
window needs a per-analyzer disclosure this note cannot carry.

Also deletes the two comment sentences above `_recoverable_window_bounds`
asserting the denominator is not persona-scoped and that every finding is
computed over the whole corpus. Both were left behind by the change that
scoped it, and both contradict the code twelve lines below them.

Tests: the unit and integration assertions that pinned the old wording were
INVERTED rather than deleted, since a green suite was defending the defect by
matching the string instead of the claim. The old phrasing is now pinned
absent, each branch is pinned present, and a new test drives the real
denominator query over a two-persona corpus to assert the picker actually
moves it and that the two personas partition the corpus exactly. Verified
end-to-end against a scratch daemon in all three scopes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019SbVXUgJy7zjuAo8jh5mZD
…once

The previous fix corrected the sentence about what the persona picker does and
left the LEAD sentence still making one blanket coverage claim about both
figures ("Both figures cover Claude Code traffic"). That is the same over-claim
one layer down, because the two figures do not share a population.

Measured per-analyzer on a real corpus over one 30-day window:

  relearn    250.735256 scoped == 250.735256 unscoped
  deadweight   2.763760 scoped ==   2.763760 unscoped
  downsize   265.983515 + 0.000374 (sdk) == 265.983889 unscoped
  resend     429.120533 scoped !=  430.123459 unscoped
  subagent  1785.533959 scoped != 1790.156141 unscoped
  summarize   19.847401 scoped !=   19.865029 unscoped

The spend is exactly persona-scoped: the two personas partition the corpus to
the cent. The ceiling is a MIX. relearn and deadweight measure on an unbounded
corpus scan rather than this window, so they return byte-identical figures
scoped or not, roughly a tenth of the claude-code total sitting under a persona
label while not being persona-scoped at all.

So both obvious wordings are false, in opposite directions:

  "both figures cover every agent"           false for the spend when scoped
  "both cover this persona's traffic"        false for the corpus-wide ceiling

Each figure now states its own coverage. The spend gets a flat claim, which is
the only half that can carry one. The ceiling says only what holds for every
contributor: it counts the analyzers that persona can act on, each measured on
its own basis, and not every basis is scoped to the persona.

The bases are untouched. relearn's unbounded scan is deliberate and recorded as
such; the defect was the silence, not the basis.

Tests assert the note against the measurement rather than against itself. The
new invariant is a SHAPE, not a phrase, so a future rewrite cannot reintroduce
the collapse under different words: no branch may contain "Both figures", and
every branch must open with the spend's own claim. A second test drives
`_collect_recoverable` over two reports shaped like the scoped and unscoped
passes and asserts the mix survives, so if the corpus-wide analyzers ever
become window-scoped the hedge can be tightened deliberately rather than by
accident. The integration assertions that pinned the old wording are inverted
in place, not deleted.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019SbVXUgJy7zjuAo8jh5mZD
…he persona is unknown

The sidebar's persona hide rules key on `.sidebar[data-persona="..."]`, which
`syncNavState` leaves EMPTY until the persona read lands, so no rule matches and
the nav shows everything. That is deliberate for a view the read DECIDES: hiding
on a guess silently removes rows a reader may be entitled to, and the comment
and its regression test both say so.

It is wrong for a view every persona hides. `cost` is hidden under both keys
(PERSONA_HIDDEN_DELIBERATE records why), so no resolution of the persona read
brings it back. Showing it meanwhile advertised a live route beside a picker
already reading "Claude Code", and clicking it rendered nothing, because the
route stayed gated the whole time. A nav row is a claim of reachability, and
that one asserted more than the data supported.

Split into the three states the nav actually has:

* hidden under EVERY persona key: hidden immediately, independent of whether
  the persona is known, because there is no answer under which it returns. The
  set is DERIVED from PERSONA_HIDDEN_VIEWS, never transcribed, so moving an
  entry out of one list moves the view out of this category automatically;
* hidden under SOME persona: the read genuinely decides it, so it renders in
  the not-yet-known state instead. Present, so nothing a reader may be entitled
  to is removed on a guess; dimmed and aria-busy, so nothing is asserted either.
  Same third state, and the same treatment, the Optimize submenu already uses;
* not hidden anywhere: unchanged.

The anti-over-hiding property is preserved, not inverted. Its regression test is
narrowed rather than deleted, with a note on what it still guarantees, and the
mirror test gains the split: the derivation may contain no view-name literal,
the unknown-window hide is keyed on the derived flag, and a persona-dependent
view must never reach it.

Observed across the load transition on two seeded corpora, one resolving to
claude-code and one to sdk, with the persona read artificially delayed:

  claude-code   Spend absent from first paint. Traces pending 0 to 2.4s, then
                removed when the answer lands.
  sdk           Spend absent from first paint. Traces pending 0 to 2.4s, then
                settles IN PLACE; it never moves.

So the reported flash is gone outright, and the one remaining transition is a
row going from visibly-unsettled to resolved, which is the third state
rendering correctly rather than a claim being retracted.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019SbVXUgJy7zjuAo8jh5mZD
…ed coding-agent alerts

The endpoint filters correctly: /alerts?persona=sdk returns nothing on a
coding-agent corpus. The client simply never asked. AlertsView rendered as
a tab with EMPTY_PARAMS and no persona at all, so the SDK view showed the
unscoped result: claude-code and codex rows under an SDK label.

Hands the persona down from the render site, sends it, and makes it a load
dependency so a switch cannot leave the previous persona's alerts on screen.
Budget's own alert reads are scoped the same way its /budget read already
was, since those alerts are what its caps fire.

The test pins the RENDER SITE as well as the signature. A signature-only
assertion would not have caught this: the parent dropped the prop, the child
never had it.

Co-Authored-By: Claude <[email protected]>
…sured with never-measurable

Of the three action kinds the ledger records, exactly one has a measurement
path: downsize adoption, a real pre/post premium-usage rate comparison.
config_export and summarize_apply are written with measured=False and are
never re-measured. Both fed 0 into a tile labelled 'measured recovered',
which made 'never measured' arithmetically identical to 'measured, and
nothing came back'.

Removes the surface only. core/recommendations.py and GET /recommendations
are untouched: the adoption measurement is sound and a bounded verify design
will want it. The panel was the read's only consumer, so the fetch and its
cache prefix go with it rather than firing on every Optimize load for
nothing.

Co-Authored-By: Claude <[email protected]>
The nav now renders unsettled rows while the persona read is in flight, but
the picker beside it went on asserting the fallback for that whole window,
so on an SDK-dominant corpus it read 'Claude Code' and corrected itself a
moment later. Two controls answering the same unresolved question
differently is worse than either alone.

The picker now shows a neutral placeholder until the read lands, dimmed and
aria-busy to match a pending nav row. It stays enabled throughout: an
explicit pick is how a reader answers the question early, and that path
already marks the context settled.

Co-Authored-By: Claude <[email protected]>
optEmptyState() no longer carries `rec`: the field went with the
recommendation-outcome panel, its only consumer. The test asserts every held
figure is dropped across a persona switch, so it listed a field that no
longer exists and raised KeyError rather than failing an assertion.

Co-Authored-By: Claude <[email protected]>
@anshss
anshss merged commit bd4b208 into main Aug 7, 2026
6 checks passed
@anilmurty
anilmurty deleted the lens-redesign branch September 18, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant