Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions .claude/notes/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -933,17 +933,29 @@ Ungraded replicates — and ONLY those — drop out of a mean entirely: `or 0.0`
a clean `execute` run down to a real-looking zero, while dropping an ERRORED one would pay
it a bonus.

The rule lives once, in `result_metrics.measured_scores`, read by `VariantAggregate.average_score`
and run.md's Avg Reliability Score. run.md also hides that score whenever `nothing_was_measured`
holds, as the pass rate beside it does. Two known gaps remain. Closing either one changes a
serialized field that downstream consumers read, so each is a separate change:
The rule lives once: `result_metrics.measured_scores` picks the rows, and `measured_mean` takes
the headline mean, `None` when `nothing_was_measured` holds, as the pass rate beside it is.
`VariantAggregate.average_score` and run.md's Avg Reliability Score both read `measured_mean`.

The verdict evidence lives on the fold. `_fold_replicates` sets `VariantResult.measured` when
any replicate carries a verdict, because its score turns an errored replicate into 0.0 and
so cannot answer "was this measured". A variant where `nothing_was_measured` holds also loses
its per-task scores, so the fold's 0.0 for a crash cannot win a task, set a spread or feed
the replicate statistics. An `execute` run with a crash therefore has no `pass_rate` or
`average_score` in experiment.json and wins no task, as run.json has no `pass_rate` and run.md
shows no Avg Reliability Score. A graded run is unchanged: its errored rows still score 0.0
and can still lose.

Known gaps. Closing either changes a serialized value that downstream consumers read, so
each is a separate change:

- `SuiteRollup.average_weighted_score` (suite.json) still averages scored rows only, so an
errored row leaves it.
- `aggregate_results` counts `VariantAggregate.tasks_measured` after `_fold_replicates` has
turned an errored replicate's missing score into 0.0, so an `execute` run with a crash
reports `pass_rate` 0.0 and `average_score` 0.0 in experiment.json where run.json reports
`None`.
- A task whose replicates are a crash plus ungraded runs folds to ERROR (`_pick_worst_status`
ranks ungraded last). A variant made only of such tasks has no ungraded task, so
`nothing_was_measured` cannot hold and experiment.json shows 0.0 where run.json shows no
rate. Pinned by the strict xfail
`tests/test_ungraded_reporting.py::test_a_variant_of_only_crashed_and_ungraded_replicates_has_no_rate_or_score`.

Only graded variants can win or set a spread; including ungraded ones at 0.0 would name an
arbitrary "best" among scores that do not exist. When NOTHING was scored there is no
Expand All @@ -952,10 +964,10 @@ happened to list first, so swapping the inputs flipped the reported winner while
`is_tie=False` asserted it was a real result. It now sorts by `variant_id` for determinism
and marks a tie among all arms, which is what "no arm outscored another" means.

`tasks_measured` counts rows with a score, because a TIMEOUT lands in the `failed` bucket
without any criterion having run — so the buckets alone cannot answer "was this measured
at all". `average_score` is `None` rather than `0.000` when nothing was graded, since a
zero beside "Pass Rate: n/a" is indistinguishable from "scored zero".
`tasks_measured` counts evidence, not buckets, because a TIMEOUT lands in the `failed`
bucket without any criterion having run, so the buckets alone cannot answer "was this
measured at all". run.json counts replicate rows with a score; experiment.json counts tasks
with a measured replicate. Only the gate they feed is shared.

The status-priority map is annotated with the SAME `Literal` that `FinalStatus.category`
returns and indexed directly rather than via `.get(..., -1)`. Adding the fourth `ungraded`
Expand Down
30 changes: 19 additions & 11 deletions docs/REPORT_SCHEMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ run-level summary; full per-replicate detail lives in each `task.json`.
| `total_duration_seconds` | `float` | Wall-clock. |
| `tasks_run` | `int` | Total replicates executed. |
| `tasks_succeeded` / `tasks_failed` / `tasks_error` | `int` | Category counts. **Invariant:** these three plus `tasks_not_graded` sum to `tasks_run`. |
| `tasks_measured` | `int` | Rows carrying a criteria verdict (`weighted_score is not None`). NOT a bucket and not part of the task-count invariant: it is the evidence that gates `pass_rate` / `error_share`, because the four category buckets cannot tell a graded `FAILURE` from a `TIMEOUT` no criterion ever saw. Defaults to `0`, inert on pre-`execute` `run.json` (where `tasks_not_graded` is `0`). |
| `tasks_measured` | `int` | Replicate rows carrying a criteria verdict (`weighted_score is not None`); `variant.json` counts tasks instead. NOT a bucket and not part of the task-count invariant: it is the evidence that gates `pass_rate` / `error_share`, because the four category buckets cannot tell a graded `FAILURE` from a `TIMEOUT` no criterion ever saw. Defaults to `0`, inert on pre-`execute` `run.json` (where `tasks_not_graded` is `0`). |
| `tasks_not_graded` | `int` | Tasks run by `coder-eval execute` — executed, deliberately unscored. Excluded from **both** sides of `pass_rate`. Defaults to `0`, so pre-`execute` `run.json` still parses. |
| `tasks_token_budget_exceeded` / `tasks_cost_budget_exceeded` | `int` | Sub-counters of `tasks_failed` (not part of the invariant). |
| `skipped_tasks` | `list[{path, reason}]` | Load failures / `skip: true` opt-outs. |
Expand Down Expand Up @@ -291,10 +291,14 @@ the same weighted armed gate as a native fail),

A single aggregate (not wrapped): `variant_id`, `tasks_run`, `tasks_succeeded`,
`tasks_failed`, `tasks_error`, `tasks_not_graded` (same sum-to-`tasks_run` invariant),
`average_score` (`float | None` — the mean over **measured** rows: an errored row counts
as `0.0`, an ungraded one leaves both sides; `null` when nothing was measured),
`average_duration`, `total_tokens`, `replicate_count`, `tasks_token_budget_exceeded`,
`tasks_cost_budget_exceeded`.
`tasks_graded` (`tasks_run - tasks_not_graded`), `tasks_measured` (tasks with at least one
replicate that carries a criteria verdict, from `VariantResult.measured`; an errored
replicate's `0.0` is not a verdict), `pass_rate` (`tasks_succeeded / tasks_graded`; `null`
when `tasks_graded` is `0` or `nothing_was_measured` holds), `average_score`
(`float | None` — the mean over **measured** rows: an errored row counts as `0.0`, an
ungraded one leaves both sides; `null` when no row counts or `nothing_was_measured` holds,
the same gate as `pass_rate`), `average_duration`, `total_tokens`, `replicate_count`,
`tasks_token_budget_exceeded`, `tasks_cost_budget_exceeded`.

## `experiment.json` — `ExperimentResult`

Expand All @@ -303,17 +307,21 @@ The cross-variant summary:
- `experiment_id`, `description`, `variant_ids`.
- `task_summaries: list[TaskExperimentSummary]` — each
`{task_id, variant_results, best_variant, is_tie, score_spread, replicate_count}`,
where each `VariantResult` carries `{variant_id, task_id, weighted_score,
where each `VariantResult` carries `{variant_id, task_id, weighted_score, measured,
final_status, duration_seconds, total_tokens, iteration_count,
total_assistant_turns, reference_similarity, replicate_index, replicate_count}`.
`weighted_score` is `float | None`: `null` only when every replicate was
**ungraded**. An **errored** replicate counts as `0.0` — same rule as
`VariantAggregate.average_score` above. That is deliberate: dropping errored
`weighted_score` is `float | None`: `null` when every replicate was **ungraded**,
and for every task of a variant where `nothing_was_measured` holds (an `execute`
run with a crash). Otherwise an **errored** replicate counts as `0.0`, the same rule
as `VariantAggregate.average_score` above. That is deliberate: dropping errored
rows would let a nightly where one image build failed report a *higher*
headline score than a clean one.
headline score than a clean one. `measured` is `true` when at least one replicate
carries a criteria verdict. Only a non-`null` `weighted_score` can be
`best_variant` or count toward `score_spread`; a task with none is a tie.
- `variant_aggregates: dict[str, VariantAggregate]` — keyed by variant id.
- `total_duration_seconds`.
- `per_replicate_scores: dict[variant_id -> dict[task_id -> list[float]]]`.
- `per_replicate_scores: dict[variant_id -> dict[task_id -> list[float]]]` — empty lists for a
variant where `nothing_was_measured` holds.

> **Statistics are render-time only.** Bootstrap/Wilson confidence intervals and the
> Welch/paired mean-difference tests appear in `experiment.md` / HTML but are **not**
Expand Down
22 changes: 18 additions & 4 deletions src/coder_eval/models/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ class VariantResult(BaseModel): # noqa: CE009 -- persisted result model; round-
# None when nothing was graded. A plain float would launder that into 0.000.
# Rationale: .claude/notes/orchestration.md § Rates need verdict evidence, not bucket counts
weighted_score: float | None = None
measured: bool = Field(
default_factory=lambda data: data.get("weighted_score") is not None,
description=(
"At least one replicate carries a criteria verdict. An errored replicate's 0.0 is not one. "
"Defaults to `weighted_score is not None`."
),
)
final_status: FinalStatus
duration_seconds: float
total_tokens: int | None = None
Expand Down Expand Up @@ -232,9 +239,13 @@ class VariantAggregate(BaseModel): # noqa: CE009 -- persisted result model; rou
ge=0,
description="Tasks executed without grading (`coder-eval execute`). Excluded from pass_rate entirely.",
)
# None when nothing in this variant was graded: a 0.0 is indistinguishable from
# "measured and scored zero".
average_score: float | None
average_score: float | None = Field(
description=(
"Mean over measured rows: an errored row counts as 0.0, an ungraded one leaves. None when no "
"row counts, or when nothing_was_measured holds (aggregate_results applies it through "
"result_metrics.measured_mean)."
),
)
average_duration: float
total_tokens: int | None = None
replicate_count: int = Field(
Expand All @@ -258,7 +269,10 @@ class VariantAggregate(BaseModel): # noqa: CE009 -- persisted result model; rou
tasks_measured: int = Field(
default=0,
ge=0,
description="Rows carrying a criteria verdict (weighted_score is not None). Gates pass_rate.",
description=(
"Tasks with at least one replicate carrying a criteria verdict (VariantResult.measured). "
"Gates pass_rate here, and average_score in aggregate_results."
),
)

@model_validator(mode="after")
Expand Down
6 changes: 3 additions & 3 deletions src/coder_eval/models/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,14 +1175,14 @@ class RunSummary(BaseModel):
),
)

# Verdict evidence, NOT a bucket and NOT part of the invariant. Symmetric with
# VariantAggregate.tasks_measured so the three published rates read one input.
# Verdict evidence, NOT a bucket and NOT part of the invariant. The same gate input as
# VariantAggregate.tasks_measured, in a different unit: replicate rows here, tasks there.
# Rationale: .claude/notes/orchestration.md § Rates need verdict evidence, not bucket counts
tasks_measured: int = Field(
default=0,
ge=0,
description=(
"Rows carrying a criteria verdict (weighted_score is not None). "
"Replicate rows carrying a criteria verdict (weighted_score is not None). "
"Gates pass_rate / error_share: nothing measured means no rate, not a 0% one."
),
)
Expand Down
Loading