Repository navigation
feat(repo): show result.json process counts in repo report and repo compare #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
napetrov
wants to merge
4
commits into
intel:main
Choose a base branch
from
napetrov:process-in-report
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
afea305
feat(repo): show result.json process counts in repo report and repo c…
napetrov 621c00e
fix(repo): a process count only one arm reports no longer floods comp…
napetrov f12b327
test(repo): pin compare's one-arm process guard for an older treatmen…
xaleryb d74b075
Merge intel/main into process-in-report
napetrov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
dokimi/changelog.d/20261021_160000_napetrov_process-in-report.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ### Added | ||
|
|
||
| - **`repo report` and `repo compare` show `result.json` `process` counts** — | ||
| `repo report` prints, under each (task, arm, model) row, the mean of each | ||
| `process` count over the cells that have one (`tool_calls`, `commands`, | ||
| `failed_commands`, `denied_commands`, `guidance_read` as a number of paths, | ||
| and `counter:<name>` for each `process_metrics` counter); the JSON row has | ||
| them under `process`. `repo compare` adds each count a compared cell | ||
| reports as a descriptive measure (`process:<key>`, `counter:<name>`): a | ||
| paired delta with a t interval and a raw p, outside Holm's family. Cells | ||
| whose `process` is absent or `null` are left out, so batches written before | ||
| `process` existed compare as before. |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Copyright (C) 2026 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """``result.json`` ``process`` counts (contract §4.1) as measures of ``repo report`` and ``repo compare``. | ||
|
|
||
| Each count is a number per cell: ``process:<key>`` for the framework's counts | ||
| (``guidance_read``, a list of paths, is counted) and ``counter:<name>`` for | ||
| each manifest ``process_metrics`` counter. A cell whose ``process`` is absent | ||
| (written before it existed) or ``null`` (its trace could not be read) has none | ||
| and is left out of a mean, not counted as zero; so is a value that is not a | ||
| finite number. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import math | ||
| from collections import defaultdict | ||
| from typing import Any | ||
|
|
||
|
|
||
| #: ``result.json`` ``process`` keys that are counts (``guidance_read`` is a list of paths, counted). | ||
| PROCESS_KEYS = ("tool_calls", "commands", "failed_commands", "denied_commands", "guidance_read") | ||
|
|
||
|
|
||
| def process_values(rec: dict[str, Any]) -> dict[str, float]: | ||
| """A cell's ``process`` counters as numbers: ``process:<key>`` and ``counter:<name>``; ``{}`` without one.""" | ||
| found = rec.get("process") | ||
| if not isinstance(found, dict): | ||
| return {} | ||
| out = {} | ||
| for key in PROCESS_KEYS: | ||
| value = found.get(key) | ||
| count = len(value) if key == "guidance_read" and isinstance(value, list) else value | ||
| if (num := _count(count)) is not None: | ||
| out[f"process:{key}"] = num | ||
| counters = found.get("counters") | ||
| for name, value in (counters.items() if isinstance(counters, dict) else ()): | ||
| if (num := _count(value)) is not None: | ||
| out[f"counter:{name}"] = num | ||
| return out | ||
|
|
||
|
|
||
| def process_means(recs: list[dict[str, Any]]) -> dict[str, float]: | ||
| """Per process measure, the mean over the cells that report it, in a stable order.""" | ||
| values: dict[str, list[float]] = defaultdict(list) | ||
| for rec in recs: | ||
| for key, value in process_values(rec).items(): | ||
| values[key].append(value) | ||
| return {key: round(sum(v) / len(v), 4) for key, v in sorted(values.items(), key=lambda kv: process_order(kv[0]))} | ||
|
|
||
|
|
||
| def process_order(key: str) -> tuple[int, str]: | ||
| """Sort key of process measures: the framework's counts in contract order, then the counters by name.""" | ||
| name = key.removeprefix("process:") | ||
| return (PROCESS_KEYS.index(name), "") if name in PROCESS_KEYS else (len(PROCESS_KEYS), key) | ||
|
|
||
|
|
||
| def _count(value: Any) -> float | None: | ||
| """A finite number as a float; ``None`` for anything else (a bool, a string, NaN).""" | ||
| ok = isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value) | ||
| return float(value) if ok else None | ||
|
|
||
|
|
||
| def process_line(means: dict[str, float] | None, width: int) -> list[str]: | ||
| """The row's process means on one indented line; none for a row without them.""" | ||
| if not means: | ||
| return [] | ||
| return [" " * (width + 4) + "process " + ", ".join(f"{k.removeprefix('process:')} {v:g}" for k, v in means.items())] |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.