tuieval 0.2.0.dev164__tar.gz → 0.2.0.dev166__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/CHANGELOG.md +1 -1
  2. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/PKG-INFO +1 -1
  3. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/writing-packs.md +5 -2
  4. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/_version.py +2 -2
  5. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/engine.py +1 -0
  6. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/insights.py +20 -11
  7. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/packs.py +9 -2
  8. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/tui.py +52 -13
  9. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/verdict.py +20 -2
  10. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/tests/test_tuieval.py +50 -0
  11. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/.gitignore +0 -0
  12. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/LICENSE +0 -0
  13. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/README.md +0 -0
  14. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/RELEASING.md +0 -0
  15. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/agent-packs.md +0 -0
  16. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/README.md +0 -0
  17. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/favicon.ico +0 -0
  18. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/readme-header.png +0 -0
  19. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/social-preview.png +0 -0
  20. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-1024.png +0 -0
  21. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-128.png +0 -0
  22. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-16.png +0 -0
  23. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-16.svg +0 -0
  24. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-256.png +0 -0
  25. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-32.png +0 -0
  26. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-48.png +0 -0
  27. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-512.png +0 -0
  28. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-64.png +0 -0
  29. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon-animated.svg +0 -0
  30. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/brand/tuieval-icon.svg +0 -0
  31. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/tui-answer-reasoning.png +0 -0
  32. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/tui-run-reasoning.png +0 -0
  33. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/images/tui-setup.png +0 -0
  34. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/docs/models.md +0 -0
  35. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/pyproject.toml +0 -0
  36. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/__init__.py +0 -0
  37. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/__main__.py +0 -0
  38. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/agents.py +0 -0
  39. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/builtin.toml +0 -0
  40. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/cli.py +0 -0
  41. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/client.py +0 -0
  42. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/compare.py +0 -0
  43. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/ctxbench.py +0 -0
  44. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/dates.py +0 -0
  45. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/doctor.py +0 -0
  46. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/export.py +0 -0
  47. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/graders/__init__.py +0 -0
  48. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/graders/answer.py +0 -0
  49. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/graders/code.py +0 -0
  50. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/graders/rag.py +0 -0
  51. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/graders/reply.py +0 -0
  52. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/graders/tool_call.py +0 -0
  53. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/logs.py +0 -0
  54. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/machines.py +0 -0
  55. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/onboard.py +0 -0
  56. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/profiles.py +0 -0
  57. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/pta.py +0 -0
  58. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/remove.py +0 -0
  59. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/run_evals.py +0 -0
  60. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/scaffold.py +0 -0
  61. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/selftest.py +0 -0
  62. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/models.toml +0 -0
  63. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/answer/pack.toml +0 -0
  64. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/answer/system.txt +0 -0
  65. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/answer/tests.yaml +0 -0
  66. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/code/pack.toml +0 -0
  67. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/code/system.txt +0 -0
  68. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/code/tests.yaml +0 -0
  69. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/rag/pack.toml +0 -0
  70. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/rag/system.txt +0 -0
  71. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/rag/tests.yaml +0 -0
  72. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/reply/pack.toml +0 -0
  73. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/reply/system.txt +0 -0
  74. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/reply/tests.yaml +0 -0
  75. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/tool_call/pack.toml +0 -0
  76. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/tool_call/system.txt +0 -0
  77. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/tool_call/tests.yaml +0 -0
  78. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/templates/packs/tool_call/tools.yaml +0 -0
  79. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/tune.py +0 -0
  80. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/watch_proxy.py +0 -0
  81. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/workspace.py +0 -0
  82. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/src/tuieval/yamlout.py +0 -0
  83. {tuieval-0.2.0.dev164 → tuieval-0.2.0.dev166}/tests/mock_server.py +0 -0
@@ -3,7 +3,7 @@
3
3
  ## Unreleased
4
4
 
5
5
  - `tuieval tune --ctx` starts where the model file says the limit is, instead of climbing from a small context: for a GGUF on a llama.cpp-style server it estimates the largest context that fits (weights, buffers, and the KV cache per token with sliding-window layers counted as llama.cpp keeps them), tries that first, and lets the first reading predict whether more fits. Typically 1 or 2 server starts, down from 3 to 6 (Gemma 4 31B: one, at its 262,144 limit, where it took five). The estimate is dropped when a try's memory is more than 25% off it; MLA models, models larger than memory and servers that size their own memory keep the doubling search. The saved measurement records where it started (`started_from`, `estimated_ctx`).
6
-
6
+ - Sections: pack.toml `use_case` (default: the pack's `group`) is what a pack's verdict counts toward, so a section (`group`) can hold several use cases. The model list's verdict codes, the Readiness tab and Insights' best model per use case show use cases section by section in pack order, with a divider or heading per section (the Readiness tab was alphabetical).
7
7
  - Drafter files: a model can name a separate drafter file (`draft = "…gguf"`), and tune options that use `{draft}` are offered only to models that have one. A server's `[servers.<name>.drafts]` table names kinds of drafter by GGUF metadata, for options that use `{draft_<kind>}`. See docs/models.md.
8
8
  - Fix: `tuieval tune --ctx` stopped early ("predicted to need more memory") on servers that fill memory to their own budget whatever the context. When the smallest context that passed already took more than the memory set aside, the prediction no longer caps the search.
9
9
  - Fix: `tuieval tune --ctx` found no working context for servers that fill memory to their own budget and run with macOS memory pressure at the warning level. When the first try reaches that level with nothing swapped, tries are judged by swapping, memory running out and critical pressure instead.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tuieval
3
- Version: 0.2.0.dev164
3
+ Version: 0.2.0.dev166
4
4
  Summary: Evaluate local and frontier LLMs on your own questions: accuracy, speed, tokens and PASS/FAIL verdicts, in the terminal.
5
5
  Project-URL: Homepage, https://github.com/ashe-wb/tuieval
6
6
  Project-URL: Issues, https://github.com/ashe-wb/tuieval/issues
@@ -27,7 +27,8 @@ Every pack has a fingerprint of what the model sees and what decides pass/fail (
27
27
 
28
28
  ```toml
29
29
  label = "Support bot" # shown in the TUI
30
- group = "Customer support" # the use case it counts toward (see below)
30
+ group = "Customer support" # the section it's listed under, and its use case unless use_case says otherwise
31
+ use_case = "Refunds" # optional: the use case its verdict counts toward (default: its group)
31
32
  description = "…"
32
33
  grader = "reply" # default grader for its tests (see Graders)
33
34
  system = "system.txt" # system prompt file (optional)
@@ -50,7 +51,9 @@ max_truncation = 0.01 # share of answers cut off by max_tokens
50
51
  min_consistency = 0.95 # share of variant groups where every variant passes
51
52
  ```
52
53
 
53
- `group` doubles as the **use case** in the readiness verdicts: all packs in a group must PASS for the use case to PASS. For example, a "Coding" use case could be a `coding` pack plus a `coding-sql` pack.
54
+ `group` is the **section** a pack is listed under, and its **use case** in the readiness verdicts unless `use_case` names another: all packs in a use case must PASS for the use case to PASS. For example, a "Coding" use case could be a `coding` pack plus a `coding-sql` pack.
55
+
56
+ Give packs a `use_case` when a section should hold several separately judged use cases. With `group = "Coding"` on all of them, `coding` and `coding-sql` (use case Coding) and `agentic-coding` (`use_case = "Agentic coding"`) are listed together, but a model that has never run the agentic pack still gets a Coding verdict. The model list, the Readiness tab and the Insights panel show use cases section by section, in pack order.
54
57
 
55
58
  `stop_early` suits packs a weak model fails quickly, like a regression set of routine cases: a run stops the pack at the first critical failure, or once the accuracy or truncation bar is out of reach even if every remaining answer passes, saves what it has (the verdict is FAIL) and moves on. It asks first the questions models have failed most often. `tuieval run --stop-early` (or **Stop a pack once it fails** in Setup) does this for every pack in the run. A later Certify fills in the rest.
56
59
 
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.2.0.dev164'
22
- __version_tuple__ = version_tuple = (0, 2, 0, 'dev164')
21
+ __version__ = version = '0.2.0.dev166'
22
+ __version_tuple__ = version_tuple = (0, 2, 0, 'dev166')
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -2716,6 +2716,7 @@ class Engine:
2716
2716
  "model": {**{k: m.get(k) for k in ("label", "served_name", "server", "model", "tags", "vision", "mmproj")},
2717
2717
  **{k: m[k] for k in ("tools", "max_context", "thinking") if k in m}},
2718
2718
  "pack": {"name": job.pack.name, "label": job.pack.label, "group": job.pack.group,
2719
+ "use_case": job.pack.use_case,
2719
2720
  "fingerprint": job.pack.fingerprint, "tests": len(job.pack.tests),
2720
2721
  **({"max_tokens": job.pack.max_tokens} if job.pack.max_tokens else {})},
2721
2722
  "settings": job.sampling,
@@ -25,7 +25,7 @@ import statistics
25
25
 
26
26
  from rich.markup import escape as rich_escape
27
27
 
28
- from . import compare
28
+ from . import compare, verdict
29
29
 
30
30
  MIN_SHARE = 0.5 # like the PTA index: models with fewer answers than this share of the most-answered are left out
31
31
  HALF = 15 # half width of a diverging bar
@@ -140,20 +140,18 @@ def _heat(acc):
140
140
 
141
141
 
142
142
  def use_cases(rows, models, packs):
143
- """packs: {name: Pack} (for groups and question counts)."""
143
+ """packs: {name: Pack} (for use cases, their sections and question counts)."""
144
144
  title = "Best model per use case"
145
- groups = []
146
- for name, p in packs.items():
147
- if p.group not in groups:
148
- groups.append(p.group)
149
- groups = [g for g in groups if any(packs.get(r["suite"]) and packs[r["suite"]].group == g for r in rows)]
145
+ section_of = {u: sec for sec, ucs in verdict.sections(packs) for u in ucs}
146
+ uc = {name: verdict.use_case_of(p) for name, p in packs.items()}
147
+ groups = [u for u in section_of if any(uc.get(r["suite"]) == u for r in rows)]
150
148
  if not groups:
151
149
  return {"title": title, "lines": ["[dim]No results yet.[/dim]"], "actions": []}
152
- size = {g: sum(len(p.tests) for p in packs.values() if p.group == g) for g in groups}
153
- per = collections.defaultdict(lambda: collections.defaultdict(list)) # (model, group) -> test -> oks
150
+ size = {g: sum(len(p.tests) for name, p in packs.items() if uc[name] == g) for g in groups}
151
+ per = collections.defaultdict(lambda: collections.defaultdict(list)) # (model, use case) -> test -> oks
154
152
  for r in rows:
155
153
  if r["suite"] in packs:
156
- per[r["model"], packs[r["suite"]].group][r["test"]].append(r["ok"])
154
+ per[r["model"], uc[r["suite"]]][r["test"]].append(r["ok"])
157
155
  cell = {}
158
156
  for m in models:
159
157
  for g in groups:
@@ -168,7 +166,18 @@ def use_cases(rows, models, packs):
168
166
  best[g] = (sorted((m for m, a in full.items() if a == top)), sorted(full.items(), key=lambda x: -x[1]))
169
167
  w = max(len(m) for m in models)
170
168
  short = {g: (g if len(g) <= CELL - 1 else f"{groups.index(g) + 1} {g[:CELL - 4]}…") for g in groups}
171
- lines = [" " * (w + 2) + "".join(f"[b]{short[g]:<{CELL}}[/b]" for g in groups)]
169
+ spans, prev = [], None # the section names over their use cases' columns
170
+ for g in groups:
171
+ if section_of[g] != prev:
172
+ spans.append([section_of[g], 0])
173
+ prev = section_of[g]
174
+ spans[-1][1] += 1
175
+ heading = ""
176
+ for sec, n in spans:
177
+ name = sec.upper()[:n * CELL - 2]
178
+ heading += f"[b underline]{_esc(name)}[/]" + " " * (n * CELL - len(name))
179
+ lines = [" " * (w + 2) + heading]
180
+ lines.append(" " * (w + 2) + "".join(f"[b]{short[g]:<{CELL}}[/b]" for g in groups))
172
181
  for m in models:
173
182
  cells = []
174
183
  for g in groups:
@@ -63,6 +63,11 @@ class Pack:
63
63
  agent: str = "" # agent packs: the [agents.<name>] that runs them ("" = [defaults] agent)
64
64
  python: str = "" # agent packs: the Python the tasks and their tests run with ("" = tuieval's)
65
65
  min_context: int = 0 # context the pack needs, when its prompts don't show it (agent packs)
66
+ use_case: str = "" # what its verdict counts toward (pack.toml use_case; "" = its group). The group is
67
+ # the section it's listed under: a section can hold several use cases.
68
+
69
+ def __post_init__(self):
70
+ self.use_case = self.use_case or self.group
66
71
 
67
72
  @property
68
73
  def modules(self):
@@ -238,7 +243,8 @@ def _load_agent_pack(name, path, meta, meta_path):
238
243
  raise PackError(f"{meta_path}: min_context must be a whole number above 0, not {min_context!r}")
239
244
  gate = {"min_accuracy": 0.8, **meta.get("gate", {})}
240
245
  return Pack(name=name, path=path, label=meta.get("label", name), group=meta.get("group", "Other"),
241
- description=meta.get("description", ""), grader="agent", system="", needs=[], tools=[],
246
+ use_case=meta.get("use_case", ""), description=meta.get("description", ""), grader="agent",
247
+ system="", needs=[], tools=[],
242
248
  tests=tests, fingerprint=_task_fingerprint(tests), gate=gate, screen=int(meta.get("screen", 10)),
243
249
  certify_repeat=int(meta.get("certify", {}).get("repeat", 0)),
244
250
  stop_early=bool(meta.get("stop_early", False)), kind="agent", agent=str(meta.get("agent", "")),
@@ -323,7 +329,8 @@ def load_pack(path):
323
329
  if "max_tokens" in meta and (isinstance(max_tokens, bool) or not isinstance(max_tokens, int) or max_tokens < 1):
324
330
  raise PackError(f"{meta_path}: max_tokens must be a whole number above 0, not {max_tokens!r}")
325
331
  return Pack(name=name, path=path, label=meta.get("label", name), group=meta.get("group", "Other"),
326
- description=meta.get("description", ""), grader=meta.get("grader", "answer"),
332
+ use_case=meta.get("use_case", ""), description=meta.get("description", ""),
333
+ grader=meta.get("grader", "answer"),
327
334
  system=system, needs=list(needs), tools=tools, tests=tests,
328
335
  fingerprint=_fingerprint(system, tools, meta.get("grader", "answer"), tests, images, max_tokens),
329
336
  gate=gate, screen=int(meta.get("screen", 10)),
@@ -65,7 +65,7 @@ def model_verdicts(e):
65
65
  results (when = None) or, failing that, the last recorded one (when = its date)."""
66
66
  current = verdict.readiness(e)
67
67
  last = verdict.latest(verdict.load_history(e))
68
- groups = list(dict.fromkeys(pk.group for pk in e.packs.values()))
68
+ groups = use_case_order(e)
69
69
  out = {}
70
70
  for m in e.cfg["models"]:
71
71
  label, rows = m["label"], []
@@ -82,10 +82,20 @@ def model_verdicts(e):
82
82
  VERDICT_MARK = {"PASS": "✓", "FAIL": "✗", "INCONCLUSIVE": "?"}
83
83
 
84
84
 
85
+ def use_case_order(e):
86
+ """Every use case, section by section in pack order (see verdict.sections)."""
87
+ return [u for _, ucs in verdict.sections(e.packs) for u in ucs]
88
+
89
+
90
+ def section_starts(e):
91
+ """The use cases that open a section after the first: the model list puts a divider before each."""
92
+ return {ucs[0] for _, ucs in verdict.sections(e.packs)[1:]}
93
+
94
+
85
95
  def group_codes(e):
86
96
  """{use case: short code}: its first letter, or its words' initials, or more letters, whichever
87
97
  is the shortest that keeps every code unique (Coding -> C; Demo answer, Demo code -> DA, DC)."""
88
- groups = list(dict.fromkeys(pk.group for pk in e.packs.values()))
98
+ groups = use_case_order(e)
89
99
 
90
100
  def initials(g, extra=0):
91
101
  words = g.split() or [g]
@@ -98,12 +108,15 @@ def group_codes(e):
98
108
  return {g: f"{g[:1].upper()}{i + 1}" for i, g in enumerate(groups)}
99
109
 
100
110
 
101
- def verdict_codes(rows, codes):
102
- """Compact markup, e.g. C✗ D? T✓ (colour = verdict, dim = from earlier results), one fixed
103
- column per use case so rows line up; blank where a use case has no verdict."""
111
+ def verdict_codes(rows, codes, starts=()):
112
+ """Compact markup, e.g. C✗ D? │ T✓ (colour = verdict, dim = from earlier results), one fixed
113
+ column per use case so rows line up; blank where a use case has no verdict. starts: use cases that
114
+ open a section (a divider goes before each)."""
104
115
  by_group = {g: (status, when) for g, status, when in rows}
105
116
  out = []
106
117
  for g in list(codes) + [g for g in by_group if g not in codes]:
118
+ if g in starts and out:
119
+ out.append("│")
107
120
  code = codes.get(g, g[:1].upper())
108
121
  if g not in by_group:
109
122
  out.append(" " * (len(code) + 1))
@@ -757,7 +770,7 @@ class SetupScreen(Screen):
757
770
  yield Header()
758
771
  yield Static(id="machine")
759
772
  with Horizontal(id="pickers"):
760
- with Vertical(classes="picker"):
773
+ with Vertical(classes="picker", id="packs-picker"):
761
774
  yield Label("[b]Eval packs[/b] (space to toggle · e picks tests)")
762
775
  yield SelectionList(id="suites")
763
776
  with Vertical(classes="picker"):
@@ -849,6 +862,21 @@ class SetupScreen(Screen):
849
862
  if not e.packs:
850
863
  for i, line in enumerate(NO_PACKS):
851
864
  packs.add_option(Selection(line, f"\x00nopacks:{i}", disabled=True))
865
+ self.fit_packs_panel()
866
+
867
+ def fit_packs_panel(self):
868
+ """Eval packs gets the width its longest line needs (at most 45% of the screen); the models
869
+ panel, whose lines are longer, gets the rest."""
870
+ packs = self.query_one("#suites", SelectionList)
871
+ if not self.size.width or not packs.option_count:
872
+ return
873
+ widest = max(Text.from_markup(str(packs.get_option_at_index(i).prompt)).cell_len
874
+ for i in range(packs.option_count))
875
+ need = max(widest, len("Eval packs (space to toggle · e picks tests)")) + 10 # tick box, scrollbar, padding
876
+ self.query_one("#packs-picker").styles.width = max(30, min(need, int(self.size.width * 0.45)))
877
+
878
+ def on_resize(self, event):
879
+ self.fit_packs_panel()
852
880
 
853
881
  def refresh_models(self, select=None):
854
882
  """Local models, then each hosted API's models tried so far, best verdicts first. Hidden
@@ -870,7 +898,7 @@ class SetupScreen(Screen):
870
898
  except Exception as err: # a broken results file must not hide the model list
871
899
  self.verdicts = {}
872
900
  self.app.log(f"verdicts failed: {err!r}")
873
- codes = group_codes(e)
901
+ codes, starts = group_codes(e), section_starts(e)
874
902
  self.legend_codes = codes
875
903
  n_hidden = sum(m["label"] in hidden for m in e.cfg["models"])
876
904
  self.query_one("#show-hidden", Checkbox).label = f"Show hidden ({n_hidden})"
@@ -897,7 +925,8 @@ class SetupScreen(Screen):
897
925
  (" [dim italic]hidden[/dim italic]" if label in hidden else "")
898
926
  where = "" if m.get("remote") else f" [dim]{m['server']}[/dim]{serving_badge(e, m, newcomer)}"
899
927
  rows = self.verdicts.get(label, [])
900
- vcodes = verdict_codes(rows, codes) if rows else f"[dim]{'not run':<{len(verdict_codes([], codes))}}[/dim]"
928
+ vcodes = (verdict_codes(rows, codes, starts) if rows
929
+ else f"[dim]{'not run':<{len(verdict_codes([], codes, starts))}}[/dim]")
901
930
  # a Selection shows one line only: keep it short, the detail line has the rest
902
931
  models.add_option(Selection(f"{label:<{width}} {vcodes}{flags}{where}{extra}",
903
932
  label, label in self.selected_models))
@@ -3660,9 +3689,18 @@ class ResultsScreen(Screen):
3660
3689
  short.append(" [dim]To run Certify: in Setup tick the model and pack, choose Certify, press s.[/dim]")
3661
3690
  self.query_one("#readiness-short", Static).update("\n".join(short) if table else
3662
3691
  "[dim]No verdicts yet: run something from Setup.[/dim]")
3663
- groups = sorted({g for t in table.values() for g in t})
3664
- matrix.add_columns("Model", *groups)
3665
- detail.add_columns("Model", "Use case", "Pack", "Verdict", "Answers right", "Answered", "Why")
3692
+ present = {g for t in table.values() for g in t}
3693
+ section_of = {u: sec for sec, ucs in verdict.sections(self.app.engine.packs) for u in ucs}
3694
+ groups = [u for u in use_case_order(self.app.engine) if u in present] + sorted(present - set(section_of))
3695
+ # two header lines: the section over its first use case, then the use case
3696
+ matrix.header_height = 2
3697
+ heads, prev = [], None
3698
+ for g in groups:
3699
+ sec = section_of.get(g, "")
3700
+ heads.append(Text(f"{sec.upper() if sec != prev else ''}\n{g}", style="bold"))
3701
+ prev = sec
3702
+ matrix.add_columns(Text("\nModel", style="bold"), *heads)
3703
+ detail.add_columns("Model", "Section", "Use case", "Pack", "Verdict", "Answers right", "Answered", "Why")
3666
3704
  right = collections.Counter((r["model"], r["suite"]) for r in self.rows if r["ok"])
3667
3705
  answered = collections.Counter((r["model"], r["suite"]) for r in self.rows)
3668
3706
  when = collections.defaultdict(list)
@@ -3681,11 +3719,12 @@ class ResultsScreen(Screen):
3681
3719
  for g in gs:
3682
3720
  row = lat.get(label, {}).get(g, {})
3683
3721
  lt.add_row(label, g, *[latency_cell(row.get(mid)) for mid in machine_ids])
3684
- for g, (_, packs) in gs.items():
3722
+ for g in sorted(gs, key=lambda u: groups.index(u) if u in groups else len(groups)):
3723
+ packs = gs[g][1]
3685
3724
  for name, pv in packs.items():
3686
3725
  if pv.status != "NO DATA":
3687
3726
  n = answered[(label, name)]
3688
- detail.add_row(label, g, name, f"[{style[pv.status]}]{pv.status}[/]",
3727
+ detail.add_row(label, section_of.get(g, ""), g, name, f"[{style[pv.status]}]{pv.status}[/]",
3689
3728
  f"{right[(label, name)]}/{n}" if n else "-", dates.span(when[(label, name)]),
3690
3729
  "; ".join(pv.reasons)[:160])
3691
3730
 
@@ -265,9 +265,27 @@ def latency_table(engine, labels=None, table=None, ran_on=None):
265
265
  return out
266
266
 
267
267
 
268
+ def sections(packs):
269
+ """[(section, [use case, ...])] in pack order: a section is a pack.toml `group`, a use case is a pack's
270
+ `use_case` (its group when it has none), listed in the section of its first pack."""
271
+ out, seen = {}, set()
272
+ for p in packs.values():
273
+ uc = use_case_of(p)
274
+ if uc not in seen:
275
+ seen.add(uc)
276
+ out.setdefault(p.group, []).append(uc)
277
+ return list(out.items())
278
+
279
+
280
+ def use_case_of(pack):
281
+ """A pack's use case: pack.toml use_case, or its group."""
282
+ return getattr(pack, "use_case", "") or pack.group
283
+
284
+
268
285
  def readiness(engine, labels=None, ran_on=None):
269
286
  """{label: {use_case: (verdict, {pack: verdict})}} for every model with results.
270
- A use case is a pack group (pack.toml `group`), e.g. Coding = the coding and coding-advanced packs.
287
+ A use case is a pack's `use_case` (pack.toml; its `group` when it has none), e.g. Coding = the coding and
288
+ coding-advanced packs.
271
289
  ran_on: (machine, hosted_any) judges only the answers that ran on that machine (see records)."""
272
290
  out = {}
273
291
  for m in engine.cfg["models"]:
@@ -278,7 +296,7 @@ def readiness(engine, labels=None, ran_on=None):
278
296
  recs = records(engine, m["label"], name, ran_on)
279
297
  if engine.result_status(m["label"], name) not in ("certified", "screened"):
280
298
  recs = [] # missing or outdated results don't count
281
- by_group.setdefault(pack.group, {})[name] = evaluate(pack, recs, engine.certify_repeat(pack))
299
+ by_group.setdefault(pack.use_case, {})[name] = evaluate(pack, recs, engine.certify_repeat(pack))
282
300
  groups = {g: (combine(v), v) for g, v in by_group.items()
283
301
  if any(x.status != "NO DATA" for x in v.values())}
284
302
  if groups:
@@ -3766,6 +3766,56 @@ class Insights(unittest.TestCase):
3766
3766
  self.assertEqual(p.stdout.split(), ["True", "True", "True", "True", "bad"], p.stderr[-2000:])
3767
3767
 
3768
3768
 
3769
+ class UseCaseSections(unittest.TestCase):
3770
+ """pack.toml `group` is the section a pack is listed under; `use_case` (default: the group) is what its
3771
+ verdict counts toward, so one section can hold several use cases."""
3772
+
3773
+ def test_use_case_and_sections(self):
3774
+ from tuieval import packs, verdict
3775
+ with tempfile.TemporaryDirectory() as tmp:
3776
+ spec = [("coding", "Coding", None, 1), ("agentic", "Coding", "Agentic coding", 2),
3777
+ ("trading", "Data", "Trading", 3), ("coding-max", "Coding", "Coding", 4)]
3778
+ for name, group, uc, order in spec:
3779
+ d = os.path.join(tmp, name)
3780
+ os.makedirs(d)
3781
+ write(os.path.join(d, "pack.toml"), f'label = "{name}"\ngroup = "{group}"\norder = {order}\n'
3782
+ + (f'use_case = "{uc}"\n' if uc else ""))
3783
+ write(os.path.join(d, "tests.yaml"), "- {input: hi, expected: 1}\n")
3784
+ ps = packs.load_packs(tmp)
3785
+ self.assertEqual({n: p.use_case for n, p in ps.items()},
3786
+ {"coding": "Coding", "agentic": "Agentic coding", "trading": "Trading", "coding-max": "Coding"})
3787
+ # a section's use cases in pack order; a section split by `order` is still listed once
3788
+ self.assertEqual(verdict.sections(ps), [("Coding", ["Coding", "Agentic coding"]), ("Data", ["Trading"])])
3789
+
3790
+ def test_verdict_codes_divide_sections(self):
3791
+ from rich.text import Text
3792
+ from tuieval import tui
3793
+ codes = {"Coding": "C", "Agentic coding": "A", "Trading": "T"}
3794
+ rows = [("Coding", "PASS", None), ("Trading", "FAIL", "2026-11-01")]
3795
+ text = Text.from_markup(tui.verdict_codes(rows, codes, {"Trading"})).plain
3796
+ self.assertEqual(text, "C✓ │ T✗")
3797
+ # an empty row is as wide as a full one, so the "not run" padding lines up
3798
+ self.assertEqual(len(tui.verdict_codes([], codes, {"Trading"})), len(text))
3799
+
3800
+ def test_use_case_panel_by_section(self):
3801
+ from types import SimpleNamespace
3802
+ from rich.text import Text
3803
+ from tuieval import insights
3804
+ rows = [{"model": m, "suite": s, "test": f"{s}{i}", "ok": ok, "tokens": 100, "secs": 1, "truncated": False,
3805
+ "reason": "", "severity": None, "raw": {}}
3806
+ for s in ("coding", "agentic", "trading") for i in range(4)
3807
+ for m, ok in (("a", True), ("b", i % 2 == 0))]
3808
+ ps = {"coding": SimpleNamespace(group="Coding", use_case="Coding", label="Coding", tests=[{}] * 4),
3809
+ "agentic": SimpleNamespace(group="Coding", use_case="Agentic coding", label="Agentic", tests=[{}] * 4),
3810
+ "trading": SimpleNamespace(group="Data", use_case="Trading", label="Trading", tests=[{}] * 4)}
3811
+ rows, models = insights.prepare(rows)
3812
+ p = insights.use_cases(rows, models, ps)
3813
+ lines = [Text.from_markup(l).plain for l in p["lines"]]
3814
+ self.assertTrue(lines[0].strip().startswith("CODING"), lines[0])
3815
+ self.assertIn("DATA", lines[0])
3816
+ self.assertEqual([a.split(":")[0] for a in p["actions"]], ["Coding", "Agentic coding", "Trading"])
3817
+
3818
+
3769
3819
  class ServerCrash(unittest.TestCase):
3770
3820
  """A server that crashes mid-request (the stream just ends) never judges the model: the run says the
3771
3821
  server stopped and records no answer."""
File without changes
File without changes