Skip to content

impl(061): increment 2, host repeat reports in the library - #486

Merged
bartekus merged 1 commit into
mainfrom
impl/061-inc2
Nov 5, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/061-inc2

Conversation

@bartekus

@bartekus bartekus commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Spec 061 (host-scored repeat sets, A-77), increment 2: host repeat reports in the library. The CLI import (rustev eval repeat import) follows as increment 3; the plan in the spec record is revised accordingly.

Stacked on #484 (increment 1), which this depends on.

  • crates/rustev-eval/src/host_repeat.rs: rustev.host-repeat-report/1, import (3.2.3 cross-run checks: mixed-runs, duplicate-run; top-k-not-observed; 3.4 statistics, 3.5 labels; 3.8 held-out unknown) and reassemble (3.3.4, reconcile).
  • crates/rustev-eval/src/repeat.rs: spec 029's per-cohort loop moved, unchanged in behavior, into cohort_reports, which both Rustev and host sets call. Every existing 029 eval test passes unchanged.
  • Spec 061 record paragraph; archive-policy.json lists src/host_repeat.rs.
  • Tests: crates/rustev-eval/tests/host_repeat.rs, including the acceptance item that a host set's statistics equal 029's functions over the same measures, bit for bit.

Archive size: rustev-eval stays under the 786,432 bound of #480.

@bartekus bartekus added the statecraft:stacked-ci Run the full CI matrix on a stacked pull request label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for spec 061 increment 2: host_repeat.rs, the extracted cohort_reports/CohortPlan in repeat.rs, the new tests, the spec text update, and the archive-policy entry.


repeat.rs refactoring — the extraction of the cohort loop into cohort_reports and CohortPlan is mechanically faithful. The across closure in repeat now captures the !derived(m) guard that was previously inline, and the new (name == "all").then(|| (p.across)(m)).flatten() call site preserves the original semantics. No behavioral regression visible.

host_repeat.rs logic — the cross-run consistency checks in check_runs, the stable computation, the as_eval_cases adapter, the first_unknown attribution, the observed/unit labelling, and the HeldOut::Unknown on final_test all match the spec 061 §§3.2–3.5, 3.8 requirements stated in the increment text.

reassemble — concrete defect:

// host_repeat.rs, reassemble
let same_cases = again.cases.len() == cases.len()
    && again
        .cases
        .iter()
        .zip(cases)
        .all(|(a, b)| a.record_canonical().ok() == b.record_canonical().ok());

record_canonical().ok() converts a serialization error to None. If canonicalization fails for both a and b, the comparison becomes None == None → true, and same_cases is true even though the byte-level equivalence mandated by §3.3.4 was never verified. The report comparison immediately above this uses bytes(…)? and propagates errors correctly; the case comparison does not. The discrepancy means a reconciliation can silently succeed without detecting a difference, directly contradicting the "byte for byte" requirement.

{"head": "e1524a436e92bc77ed8b520e488d03d4202df6d0", "verdict": "findings", "findings": [{"path": "crates/rustev-eval/src/host_repeat.rs", "line": 497, "summary": "reassemble swallows canonicalization errors via `.ok()` when comparing case documents, so if record_canonical() fails on both sides the comparison returns None == None (true), silently bypassing the byte-for-byte reconciliation check required by spec 061 §3.3.4."}]}

Subject: f1dfc03...e1524a4, diff digest 7f223ef0e57d377590087423b89a70b447bdd1cfc282dcca6539b26fef46816a, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for host_repeat.rs, repeat.rs, the new tests, the spec increment, and the archive-policy update.

repeat.rs refactoring — The extraction of cohort_reports and CohortPlan is semantically equivalent to the original cohort loop. The across closure for the existing repeat path correctly gates on !derived(m) returning None, so the else if let Some(values) = (name == "all").then(|| (p.across)(m)).flatten() replacement is behaviorally identical. Run-ref construction and RepeatReport assembly stay in repeat(); the moved bootstrap creation inside cohort_reports reads the same config fields. No behavior change in the existing path.

host_repeat.rs correctness — Cross-run ordering (check_runs before stable computation is correct; stable uses first.cases only after check_runs confirms all runs share the same case list). first_unknown indexes cases[r].cases[i] where r is a run index and i is a member case index; both bounds are maintained by construction. The no_observation / host_cohort split (no observation at the cohort_reports level, HostObservation::Host added per metric in host_cohort) is consistent. NotChecked::NotChecked with rename_all = "snake_case" serialises to "not_checked", matching the spec. HeldOut::Unknown { reason: HOST_LEDGER_UNSUPPORTED } on SplitRole::HeldOut matches spec 3.8.

Concrete defect — check_runs returns Result<(), HostError>, but it uses .expect("bound") unconditionally on runs[0].views (line 184) and run.views (line 194). HostRunInputs.views is Option; if any caller supplies an unbound run, these calls panic rather than returning an Err. import is pub and the contract is Result<HostSet, HostError>, so a panic violates the error-return contract. The spec says a per-run failure must name its run as a "refusal"; a panic is not a refusal. The fix is ok_or_else(|| HostError::new(code::HOST_RUN, "views not bound").at(i)) (and similarly for runs[0]).

No other concrete defects found. The archive-policy addition, spec increment text, and test coverage are consistent with the implementation.

{"head": "a9acbc967a189d5fd90b25512d6cca19ac42a463", "verdict": "findings", "findings": [{"path": "crates/rustev-eval/src/host_repeat.rs", "line": 184, "summary": "check_runs calls .expect(\"bound\") on runs[0].views and run.views (line 194) rather than returning Err, so an HostRunInputs with views: None panics instead of producing the HostError the Result contract requires."}]}

Subject: f1dfc03...a9acbc9, diff digest 39ee8e0e609ae9d066a649bceef1920e095762ffee5d0dd6b8eceae9571cd82d, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception November 3, 2026 23:25 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/061-host-repeats branch from f1dfc03 to 8bab679 Compare November 4, 2026 10:28
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR, which adds host_repeat.rs for spec 061's host repeat sets, refactors repeat.rs to extract CohortPlan/cohort_reports, adds tests, and updates the archive policy.

host_repeat.rs logic

  • check_runs is correctly called after all runs are measured (the per-run errors name their run index), and before stable is computed. After check_runs guarantees uniform case lists, the r.record.cases[c] indexing in the stable filter is safe.
  • first_unknown correctly covers all metrics (not only latency), matching the spec note "a run figure that is unknown because of one case names it, for every metric."
  • The not_declared guard prevents "cost-not-declared" figures from being overwritten by a case-specific reason.
  • reassemble correctly short-circuits on canonicalization error (never comparing two non-canonical documents as equal).
  • HeldOut::Unknown { HOST_LEDGER_UNSUPPORTED } is emitted on SplitRole::HeldOut only; None otherwise. Test coverage confirms both branches.

repeat.rs refactor

The extraction of cohort_reports / CohortPlan moves the existing loop without changing its semantics. The across closure in the refactored repeat function preserves the original behavior (non-found metric → Figure::Unknown { "non-finite value" }). The host's own across closure uses ? inside the map lambda, so a missing or value: None metric causes the whole collect to return None rather than a Figure::Unknown for that run. In practice, this is unlikely to differ from the repeat path (host metrics with value: None vs MetricValue::Unknown are distinct states), but the resulting diagnostic would be "not-case-decomposable" instead of something more precise. This is a minor semantic gap, not a data integrity issue, and no test exercises that path.

Other items

  • archive-policy.json insertion is alphabetically ordered correctly.
  • Spec increment 2 narrative matches the implementation: stable cohort, assertion/source: host, seed: null, scorer_reproduction: not_checked, judge_runs for model scorers, held_out on final_test.
  • NotChecked with snake_case serialises to "not_checked". ✓

No concrete defects found.

{"head": "771c140164cc38a4d6731088e46aeb4947bc0474", "verdict": "no-findings", "findings": []}

Subject: 8bab679...771c140, diff digest 2efdc544f8e291628597db06c56a953c1fd8471a0c37bcd34559ffffde9a481b, 1 call(s). An AI comment is not an approval.

Base automatically changed from impl/061-host-repeats to main November 4, 2026 21:19
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR: new host_repeat.rs module for spec 061 host repeat sets, refactoring of repeat.rs to extract shared CohortPlan/cohort_reports, tests, spec doc update, and archive-policy entry.

crates/rustev-eval/src/host_repeat.rs

  • Order of operations in import: measure is called for each run, then check_runs, then stable is computed using r.record.cases[c]. The stable indexing is safe because check_runs has already verified case-list parity via ids(r) == ids(first) before stable is computed.
  • The across closure uses collect::<Option<Vec<Figure>>>() over closures that return Option<Figure> via ?. If any run is missing metric m or has value: None, the entire across returns None and the metric falls to unknown_metric. In contrast, repeat.rs's across always returns a Figure::Unknown per run. This asymmetry is intentional for host runs (metrics in names derive from measured[0]; with the same evaluator config all runs produce the same metric set).
  • check_runs calls .expect("bound") on run.views; this is an internal invariant, not a public API, and consistent with similar patterns in the codebase.
  • host_cohort recomputes members from subgroups by cohort name, matching what cohort_reports computed—consistent.
  • first_unknown correctly maps run index r to cases[r] (same ordering as the MetricReport.runs vector).
  • reassemble: canonical comparison for canonical(b)? on the supplied (possibly NaN) case document is correct per spec 3.3.4; the test confirms the expected reconcile error fires.
  • NotChecked::NotChecked with serde(rename_all = "snake_case") serializes to "not_checked", consistent with the spec text.

crates/rustev-eval/src/repeat.rs

  • The extraction of cohort_reports moves bootstrap construction and the cohort loop into the new function; the digest closure and RepeatReport assembly remain in repeat. All logic is preserved. The CohortPlan struct correctly captures all closures and slices needed by both repeat and host_repeat.
  • The across closure in repeat now uses (!derived(m)).then(|| ...) returning Option<Vec<Figure>> where every run always gets a Figure (no short-circuiting ?). Behavior is unchanged from original.

crates/rustev-eval/tests/host_repeat.rs and host_support/mod.rs

  • Tests cover all specified cases: assertion/source labels, unknown latency naming the case, cost-not-declared, bit-identical statistics against spec 029 primitives, N=1 k_sd band, mixed-runs, duplicate-run, top-k-not-observed, below-minimum slice, held-out set, and re-assembly including the NaN non-canonical rejection.

tools/rustev-release/archive-policy.json

  • "src/host_repeat.rs" inserted in correct alphabetical order between "src/holdout.rs" and "src/host_run.rs".

specs/061-host-scored-repeat-sets/spec.md

  • Increment 2 narrative accurately describes the implementation decisions (subgroup agreement for mixed-runs, host-first metric ordering, qwk as not-case-decomposable, case-naming for unknown figures, cost-not-declared, reconcile semantics).

No concrete defects found.

{"head": "2fadb8e71a1bc23275fbb959392ebb68d56239ba", "verdict": "no-findings", "findings": []}

Subject: 3ab57f8...2fadb8e, diff digest 2efdc544f8e291628597db06c56a953c1fd8471a0c37bcd34559ffffde9a481b, 1 call(s). An AI comment is not an approval.

@bartekus bartekus closed this Nov 4, 2026
@bartekus bartekus reopened this Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across all changed paths.

crates/rustev-eval/src/host_repeat.rs (new)

  • import checks n >= 1 before runs[0] is accessed — no index panic.
  • check_runs is called after the measurement loop, so per-run measurement errors carry .at(i) and cross-run consistency is checked only once all runs have been individually validated.
  • stable is computed from runs[0].record.cases.len(), which check_runs has already verified equals every other run's case count.
  • reassemble propagates canonicalization errors with ? before comparing bytes, so two non-canonical documents cannot be treated as equal.
  • first_unknown is bounded by members (global case indices), which are derived from subgroups.len() — same length as cases[r].cases — so no out-of-bounds access.
  • ScorerCheck.judge_runs is Some(NotChecked) only for ScorerKind::Model, matching the spec.
  • HeldOut::Unknown { reason: HOST_LEDGER_UNSUPPORTED } is emitted only on SplitRole::HeldOut; non-held-out sets get None. Correct.

crates/rustev-eval/src/repeat.rs (refactored)

  • The semantics of the cohort loop are preserved. subgroups, form, observation, and across are now passed through CohortPlan rather than captured. Each field maps 1-to-1 to the previous local.
  • The across closure for repeat retains the (!derived(m)).then(|| ...) guard. The host's across omits it, but host sets carry no derived metrics (no derived_names path is entered), so the guard is not needed there.
  • The subtle behavioral difference: in repeat's original across, a missing metric gives Figure::Unknown { reason: "non-finite value" }; in the host across, a missing metric causes collect::<Option<Vec<_>>>() to return None, falling through to unknown_metric("not-case-decomposable"). This divergence cannot cause incorrect output for the described fixtures, since check_runs aligns case lists and scorer configs align metric lists across all runs.
  • Moving run_refs / RepeatReport construction from after the cohort loop to after the new cohort_reports(...) call is semantically equivalent.
  • cohort_reports returns Ok(cohorts) and repeat assembles the final RepeatReport from them — no double-use or borrow issue.

crates/rustev-eval/tests/host_repeat.rs and tests/host_support/mod.rs

  • Tests cover the labeled outcomes stated in the spec increment: assertion/source, stable cohort, seed: null, scorer checks, observation flags, cost-not-declared, duplicate-run, top-k-not-observed, held-out unknown, below-minimum slice, and bit-exact statistics against spec 029 functions. No test fixture accesses out-of-bounds indices.

specs/061-host-scored-repeat-sets/spec.md

  • Increment 2 text is consistent with the implementation: assertion: host, source: host, seed: null, not_checked, host-ledger-unsupported, duplicate-run, top-k-not-observed, cost-not-declared, not-case-decomposable, and reconcile error codes all appear in the code.

tools/rustev-release/archive-policy.json

  • src/host_repeat.rs is inserted between src/holdout.rs and src/host_run.rs — correct alphabetical position.

No concrete defect found.

{"head": "2fadb8e71a1bc23275fbb959392ebb68d56239ba", "verdict": "no-findings", "findings": []}

Subject: 3ab57f8...2fadb8e, diff digest 2efdc544f8e291628597db06c56a953c1fd8471a0c37bcd34559ffffde9a481b, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for host_repeat.rs, the refactoring in repeat.rs, the new tests, and the spec update.

repeat.rs refactoring — CohortPlan / cohort_reports extraction

The original repeat function had name == "all" && !derived(m) as the guard for across-run statistics. After refactoring, the !derived(m) guard moved into the across closure supplied by the repeat caller:

let across = |m: &str| -> Option<Vec<Figure>> {
    (!derived(m)).then(|| { runs.iter().map(|r| { … }).collect() })
};

And cohort_reports uses (name == "all").then(|| (p.across)(m)).flatten(). The host's across never filters by derived (which doesn't exist for host metrics). Both call sites correctly adapt the semantics. ✓

host_repeat.rs — ordering of check_runs vs measure

import calls host_run::measure on every run in a loop, then calls check_runs. If runs are inconsistent (mismatched dataset, flow, etc.) but all measurements succeed, check_runs correctly catches it. If a run also fails measurement, the caller gets a measurement error rather than a mixed-runs error — a minor UX issue, not a correctness bug.

check_runs — expect("bound") on views

let views = runs[0].views.expect("bound");

If a caller supplies a HostRunInputs with views: None, this panics rather than returning a clean HostError. The expect("bound") documents an invariant, and host_run::measure (called before check_runs) presumably enforces it first. Absent the definition of HostRunInputs, this is an internal precondition risk but mitigated by call ordering.

stable computation

check_runs verifies case names and subgroups are identical across runs (via the ids Vec comparison, which is order-sensitive), so indexing r.record.cases[c] by the same c across all runs after check_runs returns is safe. ✓

host_cohort — members recomputed from same subgroups

host_cohort recomputes members from the same subgroups slice passed from import, consistent with what cohort_reports used internally. The first_unknown lookup uses the same indices to identify unknown case measures by run. ✓

NotChecked serialization

#[serde(rename_all = "snake_case")] enum NotChecked { NotChecked } → "not_checked". Matches the spec text. ✓

across in host_repeat.rs — collect::<Option<Vec<Figure>>>

The closure returns Option<Figure>, and collect() on the iterator yields None if any run is missing metric m. This is correct: missing data degrades to unknown rather than silently skipping. ✓

Spec text vs implementation

The spec describes assertion: "host", source: "host", seed: null per run, scorer_reproduction: "not_checked", judge_runs: "not_checked" for model scorers, stable cohort, held_out with HOST_LEDGER_UNSUPPORTED on final_test, and cost unit beside host/cost_per_1000. All are present and correct in the implementation. ✓

No concrete defects found.

{"head": "f45a5b569e3d18d57fc08c082ecce7f122c5644e", "verdict": "no-findings", "findings": []}

Subject: a3c1eab...f45a5b5, diff digest 2efdc544f8e291628597db06c56a953c1fd8471a0c37bcd34559ffffde9a481b, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit 630d5fc into main Nov 5, 2026
38 checks passed
@bartekus
bartekus deleted the impl/061-inc2 branch November 5, 2026 00:33
bartekus added a commit that referenced this pull request Nov 5, 2026
Spec 061 (host-scored repeat sets, A-77), increment 3: `rustev eval
repeat import` (3.2).

Stacked on #486 (increment 2), which this depends on.

- `crates/rustev-cli/src/host_sets.rs`: reads `--repeat-config`,
`--config` and each `--run` directory (`host-run.json`, `views.json`,
`scores/`), calls `host_repeat::import`, and writes the import output of
3.2.5 all or none through spec 029's staged, no-clobber publication.
Stdout `imported` labels every figure `host-asserted`.
- `crates/rustev-cli/src/args.rs`, `lib.rs`: the command path and help
line. `repeat.rs`: its session, directory listing and publication
helpers become crate-visible, unchanged.
- `crates/rustev-eval/src/host_repeat.rs`: an unknown pooled figure
caused by one case names the run and case.
- Spec 061 record paragraph; `archive-policy.json` lists `rustev-cli`'s
`src/host_sets.rs`.
- Tests: `crates/rustev-cli/tests/host_sets.rs`, goldens under
`crates/rustev-cli/tests/golden/host/` (outside the harvested
conformance goldens: no binding surface runs host commands, 3.10).
bartekus added a commit that referenced this pull request Nov 5, 2026
… in the library (#492)

Spec 061 (host-scored repeat sets, A-77), increment 4: host baselines,
the reproducibility check and selection, in the library (3.6 to 3.8).

Stacked on #488 (increment 3). It needs only #486's library, but
increment 5 (the CLI) needs both, so the chain stays linear.

- `crates/rustev-eval/src/host_select.rs`: `provenance` /
`one_provenance` (`mixed-provenance`, I-1), `rustev.host-baseline/1` and
`record`, `reproducibility` (3.7.2), `rustev.host-selection/1` and
`evaluate_selection` with the 3.7.4 preconditions (no stable-cohort
comparison, decision 4) and 3.7.5 coverage clauses.
- `crates/rustev-eval/src/selection.rs`: spec 029's clause, verdict and
ranking code moved into `judge` and `sort_ranks` over a `Side`, which
both selections call. `baseline.rs`: the 3.9 comparison moved into
`stability`. `comparison.rs`: `check_name_list`. No behavior change;
every existing selection, comparison and diff test passes unchanged.
- `crates/rustev-eval/mutation/seeds.py`: the "unknown selection
qualifies" anchor follows the moved line (indentation only).
- Spec 061 record paragraph; `archive-policy.json` lists
`src/host_select.rs`.
- Tests: `crates/rustev-eval/tests/host_select.rs`.

Archive size: `rustev-eval` packages to 782,692 unpacked and 193,712
compressed bytes, under #480's 786,432 and the 196,608 archive bound,
with little headroom.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

statecraft:stacked-ci Run the full CI matrix on a stacked pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant