Skip to content

impl(043): increment 11, comparison with the source - #427

Merged
bartekus merged 1 commit into
mainfrom
impl/043-compare-source
Oct 31, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/043-compare-source

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Summary

Spec 043, increment 11: comparison with the source (3.2.1 compare_with_source, 3.9.3).

  • With compare_with_source, a retained bundle input passes its HistoricalLink to reexecute_live_with_gate. After the live result, spec 026's own rustev_eval::live::compare_live and with_comparison complete the case's live document's comparison: a changed proposal is live-diverged, and the item is still completed.
  • The comparison context (adapter, agreement, replay configuration and resolver) is a new optional RunSpec member. prepare refuses live-config when the flag is set without it, when a bundle's stated identity differs from its recomputed link, or when an input is not a retained bundle.
  • Without the flag nothing changes, and a bundle's run and supplies are never read as the new judgment (section 5).

rustev-live is publish = false; no published type changes.

Spec: a dated increment 11 paragraph in the 043 implementation record.

Verification

  • cargo test -p rustev-live --locked (full), clippy -D warnings on rustev-live with and without --features fault-injection, cargo fmt --all --check, make gate, scripts/check-authored-content.sh.

@github-actions

Copy link
Copy Markdown

AI review (findings)

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

Structural review

The PR wires in spec 026's compare_live/with_comparison into the live run path. I verified:

  • The HistoricalLink::of double-call (once in prepare, once during execution) is safe because the bundle is immutable between those two points.
  • The expect("checked bundle") / expect("checked historical link") panics at execution time are only reachable for CaseInput::Available { source: ReplayBundle, bundle: Some(...) } cases — the only kind that pass validation.
  • Comparison output is written into r.document before save_case, so the saved file includes the comparison result. That's consistent with the test assertions.
  • Validation correctly bounds name, version, and each param string against MAX_TEXT_BYTES, and bounds params.len() against MAX_NOTES.

Concrete defect

In prepare(), the validation loop over cases when compare_with_source is set contains:

CaseInput::Unavailable { .. } => {}

This arm silently accepts unavailable cases instead of refusing them. The spec text added by this same PR (increment 11, specs/043-live-re-execution-at-scale/spec.md) states explicitly that prepare refuses live-config "when an input is not a retained bundle." An Unavailable case is not a retained bundle. The _ catch-all arm (which returns LiveError::invalid) correctly rejects DatasetCase and bundle-without-retained inputs, but Unavailable is exempted by the explicit arm before _ is reached.

The test source_comparison_requires_context_and_retained_bundle_before_output covers bundle: None (defect 2) and DatasetCase inputs (defect 1) but has no case for CaseInput::Unavailable, so the gap is untested.

The practical consequence: a caller that sets compare_with_source = true with a mix of unavailable cases passes prepare without error; those cases are silently excluded from comparison at runtime, but the run completes as EvaluatedLive with no signal that comparison was incomplete.

{"head": "0ac57447b0ebad6124a4ba38e644dd02878e4b37", "verdict": "findings", "findings": [{"path": "crates/rustev-live/src/run.rs", "line": null, "summary": "CaseInput::Unavailable is silently accepted in the compare_with_source validation loop instead of being refused, contradicting the spec text (increment 11) which states prepare must refuse live-config when any input is not a retained bundle."}]}

Subject: f94b716...0ac5744, diff digest 332ff5901e0977d100f87bc7b6937a192593af25563c56225a28dfdcab0c83e6, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 30, 2026 23:58 — with GitHub Actions Error
With compare_with_source, a retained bundle input is linked as the
historical case and spec 026's comparison completes each case's live
document; a changed proposal is live-diverged.
@bartekus
bartekus force-pushed the impl/043-compare-source branch from 0ac5744 to a4affdc Compare October 31, 2026 00:00
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR, which wires source-bundle comparison (spec 026's compare_live/with_comparison) into the live re-execution path (spec 043), controlled by a new compare_with_source flag.

Validation in prepare()

The three-way identity check (bundle_digest, decision_id, snapshot_id) in the loop correctly cross-references the recomputed HistoricalLink against both the CaseOrigin::ReplayBundle fields and the outer Available::snapshot_id. The wildcard _ arm correctly rejects Available cases with a non-ReplayBundle source or a missing bundle. Unavailable cases are explicitly permitted and do not refuse the run, consistent with spec 015.

String-length validation: [&name, &version].into_iter().chain(&params) yields &String from both sides of the chain, and s.len() resolves correctly on &String. No type mismatch.

Execution path

The expect("checked bundle") and expect("checked historical link") calls in execute() are justified by prepare() invariants; bundle is only Some when the validation already verified HistoricalLink::of succeeds for that bundle. The unreachable!("checked bundle") in the post-result comparison block is equally sound: any Available case reaching that point with compare_with_source = true had bundle: Some(...) established by prepare(), and spec ownership was moved into PreparedRun at that point, preventing mutation.

Flag guard

The if self.spec.config.compare_with_source guards in both reexecute_live_with_gate and the post-result block ensure that when the flag is false, neither the replay closure nor resolver nor any bundle bytes are accessed. This is independently confirmed by the comparison_observes_retention_after_execution_and_is_unused_without_flag test, which injects corrupted retention bytes and asserts the replay closure is never called when the flag is off.

Spec consistency

The spec.md increment 11 description matches the code: comparison context validated in prepare, HistoricalLink passed to the gated entry point, compare_live/with_comparison applied post-result, unavailable-bundle cases pass through, and the result is that without the flag no bundle fields are read.

No bugs, security problems, or spec inconsistencies found.

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

Subject: f94b716...a4affdc, diff digest b5e97e4d1efee10299001fc24bb3bf3820251f99d6e89411b8a04eb03265b0b9, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 31, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 31, 2026
@bartekus
bartekus added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 2db7c94 Oct 31, 2026
30 checks passed
@bartekus
bartekus deleted the impl/043-compare-source branch October 31, 2026 01:41
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