Skip to content

impl(029): held-out ledgers, baselines and reproducibility checks - #169

Merged
bartekus merged 1 commit into
mainfrom
impl/029-baselines
Oct 22, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/029-baselines

Conversation

@bartekus

@bartekus bartekus commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Adds the held-out ledger, baseline records and reproducibility checks from spec 029 sections 3.7 to 3.9. The ledger verifies its hash chain and bounded entries; baseline creation reproduces and checks the supplied repeat report; reproducibility reports exceedances and unknown evidence explicitly.

Tests cover ledger counts and tampering, bounds and round trips, baseline bindings, exact band boundaries and unknown evidence.

This is the first part of increment 4. Section 3.10's diff document and rendering are still to follow before candidate comparison and selection gates. Spec 029 remains in progress. Brier per-case measures remain absent and their interval unknown pending a concrete compatibility decision on D-029-1.

Validation: make gate and pinned spec-spine coupling pass. AI review reports no findings on 50e8d04. CI code hit the existing runtime_batch deadline race, addressed separately in #170; rebase and fresh checks follow that merge. Local code validation is queued behind the current shared-target run; pushed before it completes at the owner's request.

Merge order: after #168 and the runtime batch race fix #170. Auto-merge stays off pending that order, a current-head no-findings AI review and required checks.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the two new modules (holdout.rs, baseline.rs), the updated spec, and the archive-policy change.

holdout.rs

HoldoutLedger::verify admits a ledger of exactly MAX_ENTRIES (uses >); append then refuses it (uses >=). That layering is correct. The chain walk, entry_digest, and immutability guarantee are all sound. The plan_count semantics (all entries with this plan, not scoped to this lineage) match both the spec text and the test assertions. The TooManyEntries error in append reports self.entries.len() + 1, the would-be count, which is accurate.

baseline.rs — misleading error string

In record, the branch that validates a HeldOut::Counted record:

if let Some(HeldOut::Counted(r)) = &report.held_out
    && (r.count == 0
        || r.plan_count == 0
        || r.count > r.dataset_count
        || r.plan_count > r.dataset_count)
{
    return Err(BaselineError::Binding(
        "the held-out record is not a count".into(),
    ));
}

The if let arm only fires when the variant is HeldOut::Counted. The error string "the held-out record is not a count" therefore fires precisely when the data is a Counted record, but with invalid field values (zero count or count exceeding dataset_count). The message would misdirect an operator toward thinking the wrong enum variant was supplied, rather than pointing at the invariant that is violated. A string such as "held-out count is zero or exceeds the dataset count" is accurate.

reproducibility

The double-push risk (both config.id() mismatch and run.repeat_config mismatch append separate reasons) produces a slightly redundant Unknown message, but both reasons are truthful and the early return is correct; not a bug.

repeat_held_out and binding check in record

Masking held_out before comparing masked == again correctly isolates the one field that only the ledger can determine. The binding check is structurally sound.

Spec increment text and archive-policy

Both match the implementation. The archive-policy additions for src/baseline.rs and src/holdout.rs are correct.

{"head": "5a2e17bd7d2554502f3effdba7c47ca03b92cd37", "verdict": "findings", "findings": [{"path": "crates/rustev-eval/src/baseline.rs", "line": 117, "summary": "The error string 'the held-out record is not a count' is semantically inverted: the if-let arm matches only when the variant IS HeldOut::Counted, so the message fires when the variant is correct but the count values are invalid (zero or exceeding dataset_count), misleading operators into diagnosing the wrong problem."}]}

Subject: ed1d191...5a2e17b, diff digest c5f905f2b35f654bac7a99d254bb678bf1886206a3179772d25a1b6077d4bdfc, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 22, 2026 16:46 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reading through each changed file carefully.

crates/rustev-eval/src/holdout.rs

Chain verification in verify checks TooManyEntries before the chain loop, so over.verify in the test correctly returns TooManyEntries rather than BrokenChain. The double-guard between verify (> MAX_ENTRIES) and append (>= MAX_ENTRIES) is intentional: verify allows a full ledger, append refuses adding to one. The count closure in append counts against next (post-push), so all three tallies include the new entry, matching the spec's "each including the new entry." The truncated-ledger test correctly documents the known limitation (consistency, not completeness).

crates/rustev-eval/src/baseline.rs

The held-out masking (masked.held_out = again.held_out.clone()) correctly excludes the ledger-backed count from the reproducibility check, since repeat without a ledger would produce Unknown. The subsequent structural validation of HeldOut::Counted (count > 0, plan_count > 0, both ≤ dataset_count) is a sound defense-in-depth check. dataset_count == 0 is implicitly caught because count > 0 would violate count <= dataset_count.

crates/rustev-eval/src/baseline.rs – reproducibility

The early return on config/dataset/split/evaluator_config/repeat_config/plan mismatch is before the exceedances loop. The spec says NotReproducible wins "whatever else is unknown," but that priority only applies within the metric loop (the closing if !exceedances.is_empty() block). When fundamental comparators don't match, comparing per-metric pooled values against a different configuration's bands is meaningless, so the early return is defensible and consistent with the tests.

crates/rustev-eval/src/repeat.rs

repeat_held_out correctly rejects a non-held-out split before touching the ledger. The fresh ledger lifetime is properly scoped so the borrow of &fresh is valid for the ledger reference used in append.

Tests

holdout.rs covers all boundary conditions. reports.rs integration tests cover ledger counting, baseline binding, round-trip, name rules, tampered reports/seeds, and reproducibility edge cases (one ulp beyond zero band, exactly at band, unknown band with and without exceedance, config mismatch).

Spec and archive policy

Increment list renumbering and increment 4 narrative are internally consistent. baseline.rs and holdout.rs are correctly added to the eval crate's archive list.

No concrete defects found.

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

Subject: f66e2cb...50e8d04, diff digest 313b0e50c4bcd88a8203924f184ccadfb18f290c26829e1b747c105190a5a53f, 1 call(s). An AI comment is not an approval.

bartekus added a commit that referenced this pull request Oct 22, 2026
Runtime-planned batch members with equal remaining budgets previously
received slightly different deadlines because each member started its
budget during preparation. When the earliest deadline ended the shared
transport, a later member could receive a transient transport failure
while its siblings expired. This is the runtime_batch CI failure seen on
#169.

Implements the owner-authorized fix under spec 020's existing
dispatch-budget and no-replenishment requirements: capture one monotonic
instant at batch entry and derive all member deadlines from it.
Preparation consumes the budget, and distinct remaining budgets stay
distinct. A paused-clock regression covers preparation time and expiry;
the existing batch-versus-independent loopback test is unchanged.

Validation: make gate, cargo fmt and git diff --check pass. Hosted code
and binding checks pass, including the new paused-clock regression and
the unchanged runtime_batch differential test. The rebased review
identified an in-place normative amendment. The approved normative text
is now unchanged; the implementation record explains how this fix
enforces the existing requirements. AI review reports no findings on
current head 9ebf3de. CI is running;
auto-merge is enabled. Pushed before local workspace tests at the
owner's request.

Rebased onto merged #168. Rebase #169 onto this fix after it merges.
Requires current-head no-findings AI review and green CI.
@bartekus
bartekus enabled auto-merge (squash) October 22, 2026 19:49
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff across baseline.rs, holdout.rs, repeat.rs, the tests, and the spec update.


holdout.rs — chain logic and bounds

verify accepts a ledger with exactly MAX_ENTRIES entries (> MAX_ENTRIES), while append refuses at >= MAX_ENTRIES. This allows a full ledger to round-trip verification but blocks further appending, which matches the spec and the tests. No defect.

holdout.rs — append counting

count, plan_count, and dataset_count are all derived from next.entries (after the push), so every field includes the new entry, as spec 3.7.4 requires. Tests confirm the (1,1,1)→(2,1,2)→(1,2,3) progression. Correct.

repeat.rs — repeat_held_out fresh-ledger path

When held.ledger is None, a new HoldoutLedger is constructed with report.dataset and immediately passed to append(&report.dataset, …). append calls verify which rechecks the dataset. No mismatch is possible. Correct.

baseline.rs — binding check

record re-runs repeat(inputs), masks the held_out field (which only the ledger can supply), and does a full equality comparison. This catches every other computed field at once. The held-out count validation on Counted entries (count/plan_count zero or exceeding dataset_count) is a sound sanity gate on externally supplied data. Correct.

baseline.rs — reproducibility priority ordering (defect)

The spec (added text in specs/029-evaluation-repeatability/spec.md) states:

not_reproducible with every exceedance … whatever else is unknown; otherwise unknown … when … the configuration … is not the baseline's

NotReproducible must take priority over Unknown. In the implementation, however, the configuration/dataset/plan checks run first and return Unknown before the exceedance loop is ever entered:

// baseline.rs ~lines 224–237
if config.id().ok().as_ref() != Some(&baseline.repeat_config) {
    reasons.push(…);
}
if run.dataset != baseline.dataset || … || run.plan != baseline.plan {
    reasons.push(…);
}
if !reasons.is_empty() {
    return Reproducibility::Unknown { reasons };   // ← exits before exceedance loop
}

When a configuration mismatch co-occurs with a metric exceedance that would trigger NotReproducible, the function incorrectly returns Unknown. The test suite does not exercise this combination (it tests config-mismatch alone and exceedance alone, but never together), so the discrepancy is undetected.

The fix is to compute exceedances before the final verdict, then apply the spec's priority: if any exceedances were found, return NotReproducible; if only reasons remain, return Unknown.


{"head": "e2d2ff993cec36886a30c8a60f3d307e0426565e", "verdict": "findings", "findings": [{"path": "crates/rustev-eval/src/baseline.rs", "line": 235, "summary": "reproducibility returns Unknown early on a config/dataset/plan mismatch before computing exceedances, violating the spec's ordering that NotReproducible takes priority over Unknown regardless of what else is unknown."}]}

Subject: bee731c...e2d2ff9, diff digest 313b0e50c4bcd88a8203924f184ccadfb18f290c26829e1b747c105190a5a53f, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception October 22, 2026 19:53 — with GitHub Actions Inactive
@bartekus
bartekus merged commit bb83627 into main Oct 22, 2026
31 checks passed
@bartekus
bartekus deleted the impl/029-baselines branch October 22, 2026 20:02
bartekus added a commit that referenced this pull request Oct 22, 2026
A configuration or report binding mismatch combined with a metric
exceedance returned `Unknown` before computing the exceedance. Compute
all exceedances first and apply spec 029's existing priority:
`NotReproducible`, then `Unknown`, then `Reproducible`.

This follows up the unresolved structured AI finding on PR #169, which
already merged at bb83627. Regression coverage combines drift with
configuration and split mismatches, verifies the complete exceedance
remains intact, and checks that a split mismatch without drift remains
unknown. The spec edit records coverage only; its contract is unchanged.
Baseline diff and increments 5/6 remain outside this repair.

Validation: the regression failed against the original implementation
and passes with the fix. `make gate`, pinned spec-spine 0.31.0 coupling,
`cargo fmt --all --check`, and `git diff --check` pass. Full `make code`
runs concurrently with hosted CI. This PR requires an explicit
structured no-findings verdict on its latest head and green required CI;
no owner exception should bypass findings.

This branch was previously deployed

1 inactive deployment
statecraft-review-exception — e2d2ff99 Deployed Oct 22, 2026 by bartekus via review-exception #1175
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.

1 participant