Skip to content

impl(061): increment 3, rustev eval repeat import - #488

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

bartekus merged 1 commit into
mainfrom
impl/061-inc3

Conversation

@bartekus

@bartekus bartekus commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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 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 (no-findings)

Reviewing the diff for bugs, security issues, and inconsistencies.

crates/rustev-cli/src/host_sets.rs — import function structure

The closure begins with an early-exit absence check on three files (repeat-config.json, config.json, repeat.json), then after all computation builds the full written list and re-checks every entry before calling publish_outputs. The second check is authoritative and covers all output paths. The first check is a valid optimization (avoids reading inputs when the main outputs already exist). No correctness issue here.

The zip of files.iter() with &set.cases would silently truncate if the library returned fewer cases than runs, but this is guarded by a library invariant (import_set must return one cases document per run), and the golden confirms the correct count for 3 runs.

The dirs.len() > 64 check only enforces the upper bound; run is listed in required in args.rs, which should enforce at least one at the parsing layer, and the library rejects an empty run list in any case.

crates/rustev-eval/src/host_repeat.rs — pooled figure fix

The if-let chain (FigureDoc::Unknown already set, metric declared, first unknown case found) correctly propagates "run R: case C: ..." context into the pooled figure. The mut pooled destructuring and later struct-literal use are sound. The golden (import.repeat.json) confirms the fix produces the right output ("run 1: case c2: latency unknown: clock_skew").

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

The increment description says "at most 16" scores files per run; the code passes MAX_SCORES from rustev_eval::host_run to dependency_files. The value of MAX_SCORES is not shown in the diff, so consistency with the spec's "16" cannot be confirmed from the supplied evidence.

crates/rustev-cli/src/args.rs

The 3-segment path ["eval", "repeat", "import"] dispatches before the 2-segment ["eval", "candidates"] could match (different slice length, no overlap). The help text lists the new command. import_is_its_own_command_path test verifies the path is matched independently.

Golden files

import.repeat.json has "assertion":"host" (the library's internal form), while import.stdout has "host-asserted" (the CLI display label). This distinction is intentional per 3.5.3. All cohort-level metrics in stdout carry "assertion":"host-asserted", and the test asserts this.

tools/rustev-release/archive-policy.json

host_sets.rs is correctly added to the archive policy alongside the other CLI source files.

No concrete bugs or security defects found. The spec-vs-code discrepancy on the MAX_SCORES value is unverifiable from the supplied evidence.

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

Subject: e1524a4...7eb1a08, diff digest d85528e3368913210fc8b2e7d605a4d7f4589480e862f88e6316d51c3f96459f, 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 bugs, security problems, and inconsistencies against the governance context and existing code patterns.

host_sets.rs — views.json read limit off-by-one (line ~44)

The optional views.json file is read with REPLAY_V1.max_bytes.saturating_add(1) as the size bound:

let views = match s
    .reads
    .read_bounded(&views_path, REPLAY_V1.max_bytes.saturating_add(1))

Every other document in this module — including host-run.json and all scores files — goes through read_doc, which calls s.reads.read(path, REPLAY_V1.max_bytes) (no + 1). If read_bounded enforces its size argument as an upper bound (the natural interpretation), views.json is permitted to be one byte larger than the declared per-document limit, inconsistent with every other input. If read_bounded returns None on "too large" rather than Err, the + 1 also means a file of exactly max_bytes + 1 bytes is silently treated as absent rather than producing a "file too large" diagnostic, which would manifest as a confusing host-binding refusal from the library instead.

Everything else reviewed and no additional findings:

  • The host_repeat.rs pooled-figure enrichment (mut pooled + if let FigureDoc::Unknown block) is correct and consistent with the goldens ("run 1: case c2: latency unknown: clock_skew").
  • The double absence check (early 3-file sentinel check then full written loop) is correct; both paths produce io_error (exit 3), and publish_outputs via hard_link provides the actual no-clobber guarantee per spec 006.
  • Scorer IDs are embedded in output filenames, but these come from documents the caller supplies and hard-links are within the caller-specified out directory, so this is not a meaningful security boundary.
  • The repeat.rs visibility widening to pub(crate) is mechanical and correct.
  • The spec 061 increment 3 prose is consistent with the implementation (command path, sentinel files, refusal semantics, stdout shape, HOST_ASSERTED label, test coverage).
  • The archive-policy.json addition of src/host_sets.rs is correct.
{"head": "470ec4a1113c7452a830bc72535cce057761e7f8", "verdict": "findings", "findings": [{"path": "crates/rustev-cli/src/host_sets.rs", "line": 44, "summary": "views.json is read with REPLAY_V1.max_bytes.saturating_add(1) instead of REPLAY_V1.max_bytes, giving it a one-byte larger effective size limit than every other input document and risking a confusing host-binding refusal instead of a size-exceeded error if the implementation returns None for oversized files."}]}

Subject: a9acbc9...470ec4a, diff digest 66eb5757b0b47e85944602ab6f8c498ce138687d38afe042b6086b3dcc3f087f, 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 correctness, security, and consistency with governance rules.

crates/rustev-cli/src/host_sets.rs — new file

The two-phase absent check is intentional: a fast pre-computation check on the three fixed-name outputs (repeat-config.json, config.json, repeat.json), then a full check over all written entries before publication. The per-run files (whose names depend on scorer IDs, which are only known after reading inputs) are only checked in the second pass. This is consistent with the no-clobber, staged publication pattern from spec 006 — computation is wasted if a per-run conflict exists, but nothing is ever written incorrectly. The final hard_link provides the atomic safety net regardless.

The read_bounded(..., REPLAY_V1.max_bytes.saturating_add(1)) for the optional views.json is correct: +1 avoids a false-absent result for a file whose size is exactly max_bytes, distinguishing "absent" from "right at the limit."

The refused helper correctly resolves a HostError::run index into a directory path, falling back to "import" for out-of-bounds or absent indices.

The scorer-ID filename construction (run-{r}.scores-{}.json) relies on doc.scorer.id being a validated identifier (not containing path separators), which is a contract invariant, not a local sanitization concern.

The --run lower bound of 1 is enforced by required: &[..., "run", ...] in the args spec; the runtime only guards the upper bound of 64.

crates/rustev-eval/src/host_repeat.rs

The new block correctly restricts pooled-figure annotation to declared metrics (!not_declared) and only fires when pooled is already Unknown and a case-level unknown exists in some run. If no run contributes a case-level unknown, find_map returns None and the original pooled message is preserved. The golden confirms the intended output ("run 1: case c2: latency unknown: clock_skew").

crates/rustev-cli/src/args.rs

The new CommandSpec is inserted before eval reproducibility, consistent with the requirement that eval repeat import is matched before the shorter eval paths (spec 029 §3.13). Help text is updated to match.

tools/rustev-release/archive-policy.json

src/host_sets.rs is inserted in correct alphabetical order between host.rs and io.rs.

Spec 061

Increment 3 description matches the implementation: command path, helper visibility changes, library behaviour change, golden placement rationale, and test coverage are all accurately described.

No bugs, security issues, or governance inconsistencies found.

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

Subject: 771c140...808f0eb, diff digest a5b9532b2e9d83369161248dadebdd7e1671d695506f005fe74a726e9ed12d99, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/061-inc2 branch 2 times, most recently from 2fadb8e to f45a5b5 Compare November 4, 2026 23:35
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (findings)

Review

crates/rustev-cli/src/host_sets.rs — unsanitized scorer ID used in output path

In the loop that builds the written vec inside import, the scorer ID from a parsed user-supplied Scores document is embedded directly into a file path:

for (doc, bytes) in &f.scores {
    written.push((
        join(out, &format!("run-{r}.scores-{}.json", doc.scorer.id)),
        bytes.clone(),
    ));
}

doc.scorer.id is read from an input file that the caller supplies. If that ID contains a path separator (e.g. "foo/../../secret"), format! produces a string with / components that, when passed to join, can resolve to a path outside the intended output directory. For instance, scorer.id = "foo/../../secret" yields the format string run-0.scores-foo/../../secret.json; joined onto out, path resolution by the OS traverses up two levels from out/run-0.scores-foo. Exploitation requires a pre-existing directory named run-0.scores-foo inside out, but the s.absent pre-flight only checks whether the destination path is absent — it does not verify the destination is inside out.

The other changed files look correct: the double-preflight pattern matches existing spec-006 practice (the second check plus the hard_link atomicity is the actual no-clobber guarantee), the host_repeat.rs pooled-figure enrichment (run N: case c2: …) is consistent with the goldens, and the repeat.rs visibility changes are mechanical.

{"head": "74be48105ddd933820fad347d7f79000c278828c", "verdict": "findings", "findings": [{"path": "crates/rustev-cli/src/host_sets.rs", "line": 183, "summary": "doc.scorer.id from a user-supplied scores file is embedded in a filesystem path without sanitizing path-separator characters, allowing a crafted scorer ID to construct an output path outside the intended output directory."}]}

Subject: f45a5b5...74be481, diff digest a5b9532b2e9d83369161248dadebdd7e1671d695506f005fe74a726e9ed12d99, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 4, 2026 23:40 — with GitHub Actions Inactive
@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-cli/src/host_sets.rs (new)

The scorer-id-to-filename construction is:

written.push((
    join(out, &format!("run-{r}.scores-{}.json", doc.scorer.id)),
    bytes.clone(),
));

This uses doc.scorer.id (from a parsed document) directly in a file path. The guard rustev_eval::measures::declared_name(&doc.scorer.id) is in place and the library's import_set has already validated this. Without evidence that declared_name admits path-unsafe characters, this cannot be called a defect; the double-check with an explicit comment is defensive and appropriate.

The initial three-file preflight (repeat-config.json, config.json, repeat.json) before the expensive computation, followed by a full-set preflight before publish_outputs, is consistent with the existing no-clobber publication pattern and is not a race-condition bug.

The read_bounded call for views.json uses REPLAY_V1.max_bytes.saturating_add(1), which correctly handles the boundary case (a file of exactly max_bytes should not be treated as too-large if read_bounded is strict-less-than).

crates/rustev-eval/src/host_repeat.rs

The let … && let … chain is Rust 2024 syntax (stabilised in 1.88). It correctly narrows the override to declared metrics (!not_declared) and to cases where at least one run has a case-level unknown, so the error propagation is sound and matches the golden at import.repeat.json.

crates/rustev-cli/src/args.rs

The new CommandSpec is inserted before eval reproducibility and before eval candidates in dispatch (lib.rs), consistent with the 029 §3.13 requirement that the three-segment path be matched first. The usage line is consistent with the flag spec.

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

Increment 3 accurately describes the new CLI command, the library fix, the helper promotions, and the test locations. No contradiction with governance documents.

tools/rustev-release/archive-policy.json

src/host_sets.rs correctly added alongside the other src/ files for rustev-cli.

No concrete defects found.

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

Subject: f45a5b5...36cc344, diff digest b532fd212b4c980c0af887372275e902a76ef6b8695a00e8d27729513cf9625d, 1 call(s). An AI comment is not an approval.

Base automatically changed from impl/061-inc2 to main November 5, 2026 00:33
@bartekus
bartekus merged commit 9fc59f6 into main Nov 5, 2026
3 checks passed
@bartekus
bartekus deleted the impl/061-inc3 branch November 5, 2026 00:37
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.
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for correctness, security, and consistency with the governance documents.

crates/rustev-cli/src/host_sets.rs — scorer id used as filename component (line ~153):

if !rustev_eval::measures::declared_name(&doc.scorer.id) {
    return Err(s.invalid("scores", "a scorer id is not a declared name"));
}
written.push((
    join(out, &format!("run-{r}.scores-{}.json", doc.scorer.id)),
    bytes.clone(),
));

The scorer id is interpolated directly into a filesystem path. The comment says "Import bound each scorer to a declared one, whose id is a declared name; checked again here, where it names a file." The library's import_set already performed this binding, so a problematic id would have been rejected before this point. The redundant declared_name guard is belt-and-suspenders. No concrete path-traversal defect is confirmable from the diff.

crates/rustev-eval/src/host_repeat.rs — pooled figure update:

The mut pooled extraction and the if-let chain are correct. The new block only updates pooled when it is already Unknown, the metric is declared (!not_declared), and a per-run case unknown exists. The golden import.repeat.json and the stdout golden both confirm "run 1: case c2: latency unknown: clock_skew" which is exactly the new format. No defect.

crates/rustev-cli/src/host_sets.rs — double preflight:

Three output files (repeat-config.json, config.json, repeat.json) are checked for absence early (fast-fail before expensive IO) and again in the full preflight loop over written. Redundant but harmless; consistent with the no-clobber publication contract.

crates/rustev-cli/src/args.rs — --run lower bound:

required: &[..., "run", ...] with Many presumably enforces ≥1 at the args layer; the code only checks dirs.len() > 64. The test import_is_its_own_command_path verifies 65 runs are rejected with code 2. The minimum-1 enforcement is delegated to the args parser, consistent with every other Many required flag in COMMANDS.

specs/061-host-scored-repeat-sets/spec.md — Increment 3 description:

Claims match the implementation: host_sets.rs reads/writes exactly the files described, repeat.rs helpers are made pub(crate), stdout format and golden files are consistent.

tools/rustev-release/archive-policy.json:

src/host_sets.rs correctly added to the archive list.

No concrete defects found.

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

Subject: 630d5fc...d4336a0, diff digest b532fd212b4c980c0af887372275e902a76ef6b8695a00e8d27729513cf9625d, 1 call(s). An AI comment is not an approval.

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