Repository navigation
Cohort model comparison (Compare > Cohorts) over an explicit observation population - #1324
Merged
Merged
Conversation
compare --format cohort-json answers a facet query (models, canonical projects, activity categories) and, with --model-a/--model-b, a cohort comparison whose observation is one edit turn driven by exactly one behavioral model. Cost attributed to the owning model's own calls in the turn; turns mixing models are excluded, counted, and shown with their combined cost; $0 on a model without a free-rate rule is unknown cost, not zero. Percentiles use linear interpolation at (N-1)*p — [1,2,4,8] gives median 3 and P90 6.8, pinned in tests. The report carries the full observation list, so every statistic is reproducible from the payload. --from/--to and --category are additive on the compare command; the classic json/tui contracts are unchanged.
…ume band Desktop cohorts mode talks to the new cohort-json format through two typed bridge channels (facets + report) with argv validation for models, repeatable project patterns, and categories. The section keeps the classic mode side by side; the cohorts view shows the population before any metric (included observations, distinct sessions, excluded mixed- model turns with their combined cost, unknown-cost count), an Inspect samples list of the declared population through a minimal navigation adapter (sampleNavigation.ts), cost median/P90/mean with a compact histogram whose top bucket is open-ended, one-shot/retry rates over the declared population, and token volume with input + cache-read labeled as a context proxy. The volume band recomputes renderer-side over the report's own observation list (cohortStats.ts mirrors the core convention, pinned to the same test vector), excludes and counts observations without a token measure, and never reads missing data as small. CODEBURN_USER_DATA_DIR opts into an isolated Electron profile so parallel dev runs get their own userData/serve.pid.
…w flags Rebased on main, which since gained #1307, #1316 and #1319. - Delete app/renderer/lib/sampleNavigation.ts. It was a placeholder for a registry that never landed: #1316 ships drill-through as an onInvestigate callback prop plus NavState. The sample rows now call it, threaded from App.tsx through Compare, and open the owning session for real. - Give a CohortObservation the provider/project/session triple the sessions report keys rows by (inferSessionProvider, session.project || project.project), so a sample resolves to exactly one session row. Without it a cohort sample could not build sessionRowKey at all. - Carry projectArgs() on both cohort spawns, per #1307. The saved project filter now scopes the facet query and the report; --project-id still narrows within it. Extended the scopes-every-fetch test to cover both. - Allow --from, --to, --category and --project-id on compare in SERVE_OPTIONS. Verified over stdio: before, every cohort request but the bare facet query came back "command not served" and fell back to a spawn. - Catch the invalid-date throw on compare like report does, instead of an unhandled UsageQueryError stack trace. - Drop the unrelated CODEBURN_USER_DATA_DIR hunk in bootstrap().
iamtoruk
force-pushed
the
feat/compare-cohorts
branch
from
September 12, 2026 21:06
8cd1c94 to
029843c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #1292 by @ozymandiashh, rebased on main (which since gained #1307, #1316, #1319) and reviewed against real data. All of the original work is his; the last commit is review follow-up.
What it adds
compare --format cohort-jsonplus--from/--to/--category/--project-id, and a Compare > Cohorts sub-tab. An observation is one edit turn whose behavioral calls carry exactly one model; that model owns it, and only its own calls' cost is attributed. Turns mixing models go to a shared exclusion ledger with their combined cost, visible on screen.Review follow-up (last commit)
sampleNavigation.tsstub. It described aregisterSampleOpenerregistry that never landed. Add drill-through: from aggregates to the sessions that compose them #1316 ships drill-through as anonInvestigateprop plusNavState, so sample rows now call that, threaded fromApp.tsx. Rows open the owning session for real instead of a no-op.CohortObservationnow carriesproviderand usessession.project || project.project, the same tripleaggregateSessionskeys rows by. Without it a sample could not buildsessionRowKeyat all. Pinned by a test comparing the two directly.projectArgs()on both cohort spawns (feat(app): Projects pane that scopes the desktop app to chosen projects #1307). The saved project filter now scopes the facet query and the report;--project-idnarrows within it rather than replacing it. The scopes-every-fetch test covers both handlers.SERVE_OPTIONSgains--from,--to,--category,--project-idoncompare. Verified live over stdio: before, every cohort request except the bare facet query came backcommand not servedand fell back to a full spawn.--from/--toon compare printed a rawUsageQueryErrorstack. Now the same friendly errorreportgives, exit 1.CODEBURN_USER_DATA_DIRhunk.Verified on real data (frozen home snapshot, Fable 5.1 vs Opus 5, 30 days)
Excluded: 1 multi-model edit turn ($5.95), 0 turns without a behavioral model.
editTurnsin the classic aggregate for both models above. They diverge by exactly one forclaude-fable-5: 300 vs 301, the mixed fable-5 + opus-4-8 turn that classic attributes to its first behavioral call and cohorts exclude. That is the only divergence in 526 edit turns, it is disclosed on screen, and it is now written down in the doc.retries / edit turns, the same formula and the same "Retry rate" label the classic compare already uses, not a new one.retries > 0implieshasEditsincountRetries, so summing over edit turns only cannot differ.(N-1)*p, pinned in tests on both the core and the renderer mirror.kept + outsideBand + missingMeasure == totalevery time, histogram buckets sum to the cost-known count, and a null band reproduces the CLI stats field for field.compare --format jsonand the TUI are byte-identical to main on frozen data acrosstoday,week,month,30days,all,lifetime, and with no flags at all.compare-cohortsis imported only bysrc/main.ts.MenubarPayload, the only thing share/MCP/sync transmit, carries no cohort data and none of the observation session ids.Tests
Root
tsc --noEmitclean,npm test4048 passed / 5 skipped.apptypecheck clean,vitest run951 passed with the 27 known local usePolled/overviewSnapshot failures (localStorageunavailable in this node build), same set as on main.Mutation checks, each caught:
providerdropped from the observation identity: 1 test failsTiming and payload
Faster than the classic
compare --format json(4.7s), which runs the self-correction git scan. Facets are dominated by the project list (1,674 identities, 513 KB of the 602 KB) which the picker needs; worth a--toplater if it gets heavier.Adjacent, not from this PR
current.topSessions[].projectKeysurvivesredactProjectNames(payload, false)and reaches MCP clients that asked not to see project names. It comes from #1316 and is unrelated to cohorts, so it is left alone here.