Skip to content

Add cohort model comparison (Compare → Cohorts) over an explicit observation population - #1292

Closed
ozymandiashh wants to merge 3 commits into
getagentseal:mainfrom
ozymandiashh:zcode/goal-4-model-cohorts
Closed

ozymandiashh wants to merge 3 commits into
getagentseal:mainfrom
ozymandiashh:zcode/goal-4-model-cohorts

Conversation

@ozymandiashh

@ozymandiashh ozymandiashh commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Add Compare → Cohorts alongside the classic comparison. Users choose two models, a period, a project and an activity category, then inspect the observations behind cost percentiles, retry rates and token-volume statistics. A volume band recomputes the statistics over the selected observations.

An observation is an edit turn owned by exactly one behavioral model. Mixed-model turns are excluded and disclosed. The owning model retains all its recorded cost and tokens, including supplementary accounting, without counting supplementary rows as requests or giving them behavioral ownership. Unknown prices stay distinct from free models.

Project facets expose canonical ids. The desktop passes these as repeatable --project-id=<id> arguments to compare --format cohort-json, preventing prefix-similar projects from entering the selection. Existing loose --project matching remains available. A selected project with no activity for one of the chosen models produces an empty cohort for that model.

Validation: full root suite compared with upstream/main a1805393 (3,962 passed; the same four Node 26 DEP0205 stderr failures as main); full app suite (902 passed, four skipped); root/app typechecks and CLI/Electron/renderer builds. All 33 core/CLI cohort tests passed again after the final empty-cohort adjustment. Bridge and component tests verify exact project ids, including leading-hyphen fallback ids. Concrete fixtures retain $1 + $9 supplementary spend as $10 and select alpha without alpha-backend; the real CLI also returns a zero-observation second cohort for a one-model project. The main project-filter suite passes all nine tests on Node 24.

Sample rows expose their full data here; wiring their navigation adapter to the separate drill-through feature remains part of cross-feature integration. Details: docs/compare-cohorts.md.

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.
@iamtoruk

Copy link
Copy Markdown
Member

Landed as #1324 (e024758) with your commits and authorship intact, rebased onto current main, plus fixes found on real data: the stub sampleNavigation is deleted and sample rows open the real session through the drill-through navigation; observations now carry provider and the session's own project so the row key actually resolves; both new fetches carry the Projects-pane filter; serve --stdio allowlists the new compare options (they were refused before); invalid dates get the friendly error; an unrelated CODEBURN_USER_DATA_DIR hunk was dropped. Verified on frozen data: 172 and 301 observations for the two models in use here, histograms sum exactly, retry rate is the existing formula, percentiles pinned, band recomputation exact, compare --format json and the TUI byte-identical across every period. One divergence disclosed in the docs: a turn touched by two models is excluded here and given to the first model by the classic view, one turn in 526 on this corpus. Thank you.

@iamtoruk iamtoruk closed this Sep 12, 2026
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.

2 participants