diff --git a/.ripr/traceability.toml b/.ripr/traceability.toml index c956854076d..d268f7f5af7 100644 --- a/.ripr/traceability.toml +++ b/.ripr/traceability.toml @@ -12599,6 +12599,9 @@ tests = [ "crates/ripr/tests/expect_test_owner_pins.rs::every_parsed_inline_expect_spelling_pins_the_owner", "crates/ripr/tests/expect_test_owner_pins.rs::other_expect_test_and_snapshot_shapes_keep_their_medium_grade", "crates/ripr/tests/expect_test_owner_pins.rs::a_captured_identifier_format_tail_propagates", + "crates/ripr/tests/expect_test_owner_pins.rs::a_verified_golden_file_comparison_pins_the_owner", + "crates/ripr/src/analysis/classify/owner_pin/tests/expect_test_pins.rs::a_test_that_may_write_files_lends_no_golden_pin", + "crates/ripr/src/analysis/classify/owner_pin/tests/expect_test_pins.rs::a_golden_path_stays_in_tree_and_fs_renames_refuse", "crates/ripr/src/analysis/classify/changed_span.rs::the_span_is_the_smallest_node_around_the_differing_text", "crates/ripr/src/analysis/classify/changed_span.rs::a_closure_is_seen_only_around_or_inside_the_change", "crates/ripr/src/analysis/classify/changed_span.rs::no_span_without_an_old_text_or_one_tail_expression", diff --git a/changelog.d/6578-expect-file-golden-pin.md b/changelog.d/6578-expect-file-golden-pin.md new file mode 100644 index 00000000000..335402cdf44 --- /dev/null +++ b/changelog.d/6578-expect-file-golden-pin.md @@ -0,0 +1,2 @@ + +- An expect-test golden-file comparison, `expect_file!["out.txt"].assert_eq(&owner(..))`, behind a manifest-verified `use expect_test::expect_file;` now pins the owner's return as the inline `expect![[..]]` comparison does, instead of reading as a medium snapshot. `assert_debug_eq`, a computed or out-of-tree file path, an unverified or shadowed import, tests that write files, run commands, make symlinks, rename `std::fs` imports or set `UPDATE_EXPECT`, and `#[should_panic]` tests still do not pin (#6578). diff --git a/crates/ripr/src/analysis/classify/owner_pin.rs b/crates/ripr/src/analysis/classify/owner_pin.rs index 90169c3b112..971c7109e55 100644 --- a/crates/ripr/src/analysis/classify/owner_pin.rs +++ b/crates/ripr/src/analysis/classify/owner_pin.rs @@ -2321,6 +2321,19 @@ impl OwnerReturnPin { // a mismatch, as `assert_eq!(render_row("alice", 41), "alice: 42")` // does. expect_operands = operands; + // #6578 review: a golden file the test itself writes (from the + // owner, say) before comparing fixes nothing, so a test that + // writes, copies or renames a file, or sets `UPDATE_EXPECT`, + // lends no golden-file pin. + if is_golden_file_comparison(&assertion.text) + && (test_may_write_files(&test.body) + || index + .files() + .get(&test.file) + .is_none_or(|facts| file_renames_fs_or_env_import(&facts.source))) + { + return false; + } let Some(call) = self.awaited_call_shape(&expect_operands[0], &self.name) else { return false; }; @@ -4181,11 +4194,11 @@ fn assertion_context_macros() -> Vec<&'static str> { } /// Trusted names whose trust is the test-side binding scan's alone (#6578). -/// `expect!` is no `std` macro: outside a test that verifies -/// `use expect_test::expect;`, a bare `expect!` is a crate's own (a try-style -/// `expect!(x)` may hide a `return`), so owner bodies and binding reads never -/// count it as bounded. -const TEST_SCOPED_TRUSTED_MACROS: &[&str] = &["expect"]; +/// `expect!` and `expect_file!` are no `std` macros: outside a test that +/// verifies `use expect_test::{expect, expect_file};`, a bare one is a +/// crate's own (a try-style `expect!(x)` may hide a `return`), so owner +/// bodies and binding reads never count it as bounded. +const TEST_SCOPED_TRUSTED_MACROS: &[&str] = &["expect", "expect_file"]; /// Whether a macro named `name` neither returns nor binds a name, whatever /// file it sits in. @@ -5895,8 +5908,16 @@ fn is_admission_gated_assert_eq(text: &str) -> bool { /// lines) and panics on a mismatch unless `UPDATE_EXPECT` is set. Only the /// bare `expect!` with one string literal (or none, the empty expectation) /// and one argument; a single leading `&` borrows the actual value and is -/// dropped. `assert_debug_eq`, `expect_file!` and a qualified -/// `expect_test::expect!` stay `snapshot` / medium (RIPR-SPEC-0231 step 6). +/// dropped. `assert_debug_eq` and a qualified `expect_test::expect!` stay +/// `snapshot` / medium (RIPR-SPEC-0231 step 6). +/// +/// `expect_file!["path"].assert_eq(actual)` compares `actual` with the +/// committed file's whole text (CRLF read as LF; a missing file reads as +/// "") and panics on a mismatch the same way, so it pins too. Its file is +/// not read: the second operand is the path literal, standing in for a +/// fixed text the analyzer does not inspect. Only a path gate that admits +/// any value of the owner's type (`ReturnPathGate::Any` and the like) +/// accepts that stand-in; a gate that checks the expected value refuses it. pub(in crate::analysis) fn inline_expect_operands(text: &str) -> Option<[String; 2]> { let statement = text.trim().trim_end_matches(';').trim_end(); let parse = parse_clean_source_file(&format!("fn ripr_expect() {{ {statement}; }}"))?; @@ -5923,9 +5944,15 @@ pub(in crate::analysis) fn inline_expect_operands(text: &str) -> Option<[String; return None; }; let receiver = receiver.macro_call()?; - if receiver.excl_token().is_none() || receiver.path()?.syntax().text() != "expect" { + receiver.excl_token()?; + let path = receiver.path()?.syntax().text(); + let golden_file = if path == "expect" { + false + } else if path == "expect_file" { + true + } else { return None; - } + }; let tokens: Vec<_> = receiver .token_tree()? .syntax() @@ -5936,6 +5963,14 @@ pub(in crate::analysis) fn inline_expect_operands(text: &str) -> Option<[String; .collect(); let texts: Vec<&str> = tokens.iter().map(|(_, text)| text.as_str()).collect(); let literal = match texts.as_slice() { + // `expect_file!["path"]`: one string literal naming the file. + ["[", path, "]"] if golden_file => { + if tokens[1].0 != ra_ap_syntax::SyntaxKind::STRING || !is_in_tree_relative_path(path) { + return None; + } + (*path).to_string() + } + _ if golden_file => return None, ["[", "[", _, "]", "]"] | ["[", _, "]"] => { let (kind, text) = &tokens[tokens.len() / 2]; // expect-test trims a multi-line literal's indentation before @@ -5965,6 +6000,109 @@ pub(in crate::analysis) fn inline_expect_operands(text: &str) -> Option<[String; Some([actual, literal]) } +/// #6578 review: `expect_file!` resolves its path against the test's own +/// source directory, so a relative path without `..` names a file under the +/// crate, which the commit fixes. An absolute path (`/tmp/x`, a drive-letter +/// path, a UNC `\\\\host`), a home-relative `~` or any `..` segment may name text +/// produced outside the commit, so it lends no pin. `path` is the literal's +/// source text, quotes and any raw-string hashes included. +fn is_in_tree_relative_path(path: &str) -> bool { + let inner = path + .trim_start_matches('r') + .trim_matches('#') + .trim_matches('"'); + let absolute = inner.starts_with(['/', '\\', '~']) || inner.as_bytes().get(1) == Some(&b':'); + // A non-raw literal's escapes (`\u{2e}\u{2e}/w.txt`) decode to segments + // this text check cannot see, so any escape refuses. + let escaped = !path.starts_with('r') && inner.contains('\\'); + !inner.is_empty() + && !absolute + && !escaped + && !inner.split(['/', '\\']).any(|segment| segment == "..") +} + +/// #6578 review: whether a test file renames an import from `std::fs` or +/// `std::env` (`use std::fs::write as save;`), which would let a bare +/// `save(..)` write the golden or set `UPDATE_EXPECT` unseen by +/// [`test_may_write_files`]. Fail-closed: any such rename refuses. +fn file_renames_fs_or_env_import(source: &str) -> bool { + let masked = mask_comments_and_strings(source); + // Word tokens rather than a statement prefix: a `use` may follow `{`, an + // item's `}`, an attribute or `pub(crate)` inside the same `;` fragment. + masked.split(';').any(|statement| { + let mut words = statement + .split(|c: char| !(c.is_alphanumeric() || c == '_')) + .filter(|word| !word.is_empty()) + .skip_while(|word| *word != "use"); + if words.next().is_none() { + return false; + } + let tree: Vec<&str> = words.collect(); + tree.iter().any(|word| matches!(*word, "fs" | "env")) && tree.contains(&"as") + }) +} + +/// Whether an expect-test comparison's receiver is `expect_file!`. +fn is_golden_file_comparison(text: &str) -> bool { + let masked = mask_comments_and_strings(text); + let compact: String = masked.chars().filter(|c| !c.is_whitespace()).collect(); + compact.starts_with("expect_file!") +} + +/// #6578 review: whether a test body may write the file a golden-file +/// comparison reads. Comments and strings are masked; anything that may +/// create, overwrite, copy or rename a file, or turn on expect-test's +/// `UPDATE_EXPECT` rewrite, counts. A bare `write(..)`/`create(..)` call +/// counts too, since `use std::fs::write;` makes it the file write. +/// Fail-closed: a test that writes some other file also lends no pin. +fn test_may_write_files(body: &str) -> bool { + let masked = mask_comments_and_strings(body); + let compact: String = masked.chars().filter(|c| !c.is_whitespace()).collect(); + const WRITERS: &[&str] = &[ + "fs::write", + "fs::copy", + "fs::rename", + "fs::hard_link", + "File::create", + "File::options", + "OpenOptions", + "UPDATE_EXPECT", + "set_var", + // A subprocess, a symlink or a persisted temp file may also produce it. + "Command", + "symlink", + "soft_link", + "persist", + ]; + WRITERS.iter().any(|writer| compact.contains(writer)) + || [ + "write(", + "create(", + "copy(", + "rename(", + "write::<", + "create::<", + "copy::<", + "rename::<", + ] + .iter() + .any(|call| { + // A turbofish (`write::<_, _>(..)`) is the same call. + compact.match_indices(call).any(|(at, _)| { + let before = &compact[..at]; + // A bare or path-qualified call (`save::write(`, `::create(`, + // `fs_err::write(`) may write; a method call or `io::copy(` + // between readers and writers does not. + if before.ends_with("::") { + return !before.ends_with("io::"); + } + before.chars().next_back().is_none_or(|previous| { + !(previous.is_alphanumeric() || matches!(previous, '_' | '.' | ':')) + }) + }) + }) +} + /// RIPR-SPEC-0197: the compared operands of a plain `assert!(lhs == rhs)` /// or of the assertion twin of a terminal Err-return guard /// `if lhs != rhs { return Err(..) }` (RIPR-SPEC-0154). The condition must diff --git a/crates/ripr/src/analysis/classify/owner_pin/tests/expect_test_pins.rs b/crates/ripr/src/analysis/classify/owner_pin/tests/expect_test_pins.rs index a51046295d3..5a2547126c2 100644 --- a/crates/ripr/src/analysis/classify/owner_pin/tests/expect_test_pins.rs +++ b/crates/ripr/src/analysis/classify/owner_pin/tests/expect_test_pins.rs @@ -1,7 +1,9 @@ //! #6578: an inline expect-test comparison, //! `expect![["text"]].assert_eq(&owner(..))`, pins the owner's return as //! `assert_eq!(owner(..), "text")` does, behind a manifest-verified -//! `use expect_test::expect;`. Every other expect-test spelling stays a +//! `use expect_test::expect;`; a golden-file +//! `expect_file!["path"].assert_eq(&owner(..))` pins behind a verified +//! `use expect_test::expect_file;`. Every other expect-test spelling stays a //! `snapshot` / medium oracle (RIPR-SPEC-0231 step 6). use super::*; @@ -54,10 +56,15 @@ fn an_inline_expect_comparison_pins_behind_a_verified_import() -> Result<(), Str "expect![[\"w12\"]].assert_eq(&render(4));", ); let grouped = render_admitted(&grouped, Some(&plain)).len(); - for body in [ - "expect![[\"w12\"]].assert_eq(&render(4));", - "expect![\"w12\"].assert_eq(&render(4));", - "expect![[\"w12\"]].assert_eq(render(4).as_ref());", + for (import, body) in [ + (import, "expect![[\"w12\"]].assert_eq(&render(4));"), + (import, "expect![\"w12\"].assert_eq(&render(4));"), + (import, "expect![[\"w12\"]].assert_eq(render(4).as_ref());"), + // #6578: the golden-file comparison pins the same way. + ( + "use expect_test::expect_file;", + "expect_file![\"w.txt\"].assert_eq(&render(4));", + ), ] { let tests = render_test(import, body); outcomes.push(( @@ -73,9 +80,36 @@ fn an_inline_expect_comparison_pins_behind_a_verified_import() -> Result<(), Str (import, "expect![[\"w12\"]].assert_debug_eq(&render(4));"), ( "use expect_test::expect_file;", - "expect_file![\"w.txt\"].assert_eq(&render(4));", + "expect_file![\"w.txt\"].assert_debug_eq(&render(4));", ), ("", "expect_test::expect![[\"w12\"]].assert_eq(&render(4));"), + ( + "", + "expect_test::expect_file![\"w.txt\"].assert_eq(&render(4));", + ), + // A computed or non-literal file path. + ( + "use expect_test::expect_file;", + "expect_file![concat!(\"w\", \".txt\")].assert_eq(&render(4));", + ), + ( + "use expect_test::expect_file;", + "expect_file![[\"w.txt\"]].assert_eq(&render(4));", + ), + // `expect_file!` imported from somewhere else, renamed onto + // `expect!`, or through a glob. + ( + "use other::expect_file;", + "expect_file![\"w.txt\"].assert_eq(&render(4));", + ), + ( + "use expect_test::expect_file as expect;", + "expect![\"w.txt\"].assert_eq(&render(4));", + ), + ( + "use expect_test::*;", + "expect_file![\"w.txt\"].assert_eq(&render(4));", + ), // A computed expectation, or none of the owner's value. ( import, @@ -143,11 +177,21 @@ fn inline_expect_operands_reads_one_literal_and_one_argument() { operands("expect![[]].assert_eq(&render(4));"), pair("render(4)", "\"\"") ); + // A golden file's operand is its path literal, standing in for the + // committed text. + assert_eq!( + operands("expect_file![\"w.txt\"].assert_eq(&render(4));"), + pair("render(4)", "\"w.txt\"") + ); for text in [ "expect![[\"w12\"]].assert_debug_eq(&render(4));", "expect![[\"w12\"]].assert_eq::(&render(4));", "expect_test::expect![[\"w12\"]].assert_eq(&render(4));", - "expect_file![\"w.txt\"].assert_eq(&render(4));", + "expect_test::expect_file![\"w.txt\"].assert_eq(&render(4));", + "expect_file![\"w.txt\"].assert_debug_eq(&render(4));", + "expect_file![[\"w.txt\"]].assert_eq(&render(4));", + "expect_file![w_txt].assert_eq(&render(4));", + "expect_file![\"w\", \"txt\"].assert_eq(&render(4));", "expect![[w12]].assert_eq(&render(4));", "expect![[\"w\", \"12\"]].assert_eq(&render(4));", "expect![[\"w12\"]].assert_eq(&mut render(4));", @@ -191,9 +235,10 @@ fn expect_test_comparisons_extract_as_one_snapshot_oracle() { ); } -/// #6578 review: `expect!` is trusted only where a test's verified -/// `use expect_test::expect;` binds it. In an owner body it is a crate's -/// own macro, which may hide a `return` before the changed tail. +/// #6578 review: `expect!` and `expect_file!` are trusted only where a +/// test's verified `use expect_test::{expect, expect_file};` binds them. In +/// an owner body either is a crate's own macro, which may hide a `return` +/// before the changed tail. #[test] fn an_owner_body_expect_macro_keeps_its_return_paths_open() { let try_style = "macro_rules! {name} {\n ($e:expr) => {\n match $e {\n Some(v) => v,\n None => return 0,\n }\n };\n}\n"; @@ -209,16 +254,25 @@ fn an_owner_body_expect_macro_keeps_its_return_paths_open() { .map(|pin| admitted_texts(&index, &pin)) .unwrap_or_default() }; - let score = |call: &str| { + let score = |name: &str, call: &str| { format!( "{}pub fn score(x: Option) -> u32 {{\n let v = {call};\n v + 1\n}}\n", - try_style.replace("{name}", "expect") + try_style.replace("{name}", name) ) }; - // `score(None)` leaves through the macro's hidden `return 0`. - assert!(admitted(&score("expect!(x)")).is_empty()); - // The control: a standard non-returning macro keeps the pin. - assert_eq!(admitted(&score("dbg!(x).unwrap_or(0)")).len(), 1); + for name in ["expect", "expect_file"] { + // `score(None)` leaves through the macro's hidden `return 0`. + assert!( + admitted(&score(name, &format!("{name}!(x)"))).is_empty(), + "{name}" + ); + // The control: a standard non-returning macro keeps the pin. + assert_eq!( + admitted(&score(name, "dbg!(x).unwrap_or(0)")).len(), + 1, + "{name}" + ); + } } /// #7856 review: the parsed `snapshot` / medium grade is a ceiling. A @@ -253,3 +307,98 @@ fn a_nested_expect_comparison_is_not_its_own_snapshot() { "{oracles:?}" ); } + +/// #6578 review: a test that may write the golden file lends no +/// golden-file pin; the inline comparison is unaffected. +#[test] +fn a_test_that_may_write_files_lends_no_golden_pin() { + for body in [ + "std::fs::write(\"w.txt\", render(4)).unwrap();", + "fs::write (\"w.txt\", x);", + "write(\"w.txt\", x).unwrap();", + "let f = File::create(\"w.txt\");", + "OpenOptions::new().write(true).open(\"w.txt\");", + "std::fs::copy(\"a\", \"w.txt\");", + "unsafe { std::env::set_var(\"UPDATE_EXPECT\", \"1\") };", + "Command :: new(\"cp\").args([\"g.txt\", \"w.txt\"]).status().unwrap();", + "std::os::unix::fs::symlink(\"/tmp/g.txt\", \"w.txt\").unwrap();", + "::create(\"w.txt\")?;", + "fs_err::write(\"w.txt\", x).unwrap();", + "F::create(\"w.txt\")?;", + "write::<_, _>(\"w.txt\", render(4)).unwrap();", + ] { + assert!(test_may_write_files(body), "{body}"); + } + for body in [ + "expect_file![\"w.txt\"].assert_eq(&render(4));", + "let s = format!(\"{}\", 1); write!(out, \"x\").unwrap();", + "buffer.write(&bytes);", + "std::io::copy(&mut a, &mut b);", + "// fs::write(\"w.txt\", x);", + "let note = \"fs::write\";", + "rewrite(x);", + ] { + assert!(!test_may_write_files(body), "{body}"); + } + assert!(is_golden_file_comparison( + "expect_file![\"w.txt\"].assert_eq(&render(4));" + )); + assert!(is_golden_file_comparison( + "expect_file! [\"w.txt\"].assert_eq(&render(4));" + )); + assert!(!is_golden_file_comparison( + "expect![[\"w12\"]].assert_eq(&render(4));" + )); +} + +/// #6578 review: a golden path must stay under the test's directory, and a +/// renamed `std::fs` / `std::env` import refuses the golden-file pin. +#[test] +fn a_golden_path_stays_in_tree_and_fs_renames_refuse() { + for path in [ + "\"w.txt\"", + "\"snapshots/w.txt\"", + "r#\"w.txt\"#", + "r\"a\\b.txt\"", + ] { + assert!(is_in_tree_relative_path(path), "{path}"); + } + for path in [ + "\"/tmp/w.txt\"", + "\"~/w.txt\"", + "\"C:w.txt\"", + "\"\\\\\\\\host\\\\w.txt\"", + "\"../w.txt\"", + "\"\\u{2e}\\u{2e}/w.txt\"", + "\"a\\x2e\\x2e/w.txt\"", + "\"a\\\\b.txt\"", + "\"a/../../w.txt\"", + "\"\"", + ] { + assert!(!is_in_tree_relative_path(path), "{path}"); + } + for source in [ + "use std::fs::write as save;", + "use std::{env::set_var as on, fs};", + "pub use std::fs as files;", + "mod tests { use std::fs::write as save; }", + "fn a() {}\nuse std::fs::write as save;", + "#[cfg(test)] use std::fs::write as save;", + "pub(crate) use std::fs::write as save;", + ] { + assert!(file_renames_fs_or_env_import(source), "{source}"); + } + for source in [ + "use std::fs;\nuse std::fs::write;", + "use crate::offsets as o;", + "use expect_test::expect_file as golden;", + "// use std::fs::write as save;", + "fn reuse() { let used = fs_count as u8; }", + ] { + assert!(!file_renames_fs_or_env_import(source), "{source}"); + } + assert_eq!( + inline_expect_operands("expect_file![\"/tmp/w.txt\"].assert_eq(&render(4));"), + None + ); +} diff --git a/crates/ripr/src/analysis/classify/reveal.rs b/crates/ripr/src/analysis/classify/reveal.rs index 2373c042768..9fa25930a45 100644 --- a/crates/ripr/src/analysis/classify/reveal.rs +++ b/crates/ripr/src/analysis/classify/reveal.rs @@ -4414,9 +4414,10 @@ fn pin_strength_admits(assertion: &OracleFact) -> bool { } /// #6578: a `snapshot` oracle the owner pin may raise is only the inline -/// `expect![[..]].assert_eq(..)` comparison it reads like `assert_eq!`; an -/// `insta` macro, `expect_file!`, `assert_debug_eq` or any other text the -/// classifier grades `snapshot` keeps its medium strength. +/// `expect![[..]].assert_eq(..)` or golden-file `expect_file![..].assert_eq(..)` +/// comparison it reads like `assert_eq!`; an `insta` macro, `assert_debug_eq` +/// or any other text the classifier grades `snapshot` keeps its medium +/// strength. fn is_inline_expect_snapshot(assertion: &OracleFact) -> bool { matches!(assertion.kind, OracleKind::Snapshot) && super::owner_pin::inline_expect_operands(&assertion.text).is_some() @@ -6712,17 +6713,21 @@ return Err(\"typed pin\".into()); OracleKind::RelationalCheck, OracleStrength::Weak, ))); - // #6578: of the medium snapshots, only the inline expect-test - // comparison the owner pin reads like `assert_eq!`. - assert!(pin_strength_admits(&oracle( + // #6578: of the medium snapshots, only the inline and golden-file + // expect-test comparisons the owner pin reads like `assert_eq!`. + for text in [ "expect![[\"w12\"]].assert_eq(&render(4));", - OracleKind::Snapshot, - OracleStrength::Medium, - ))); + "expect_file![\"w.txt\"].assert_eq(&render(4));", + ] { + assert!( + pin_strength_admits(&oracle(text, OracleKind::Snapshot, OracleStrength::Medium)), + "{text}" + ); + } for text in [ "insta::assert_snapshot!(render(4));", "expect![[\"w12\"]].assert_debug_eq(&render(4));", - "expect_file![\"w.txt\"].assert_eq(&render(4));", + "expect_file![\"w.txt\"].assert_debug_eq(&render(4));", ] { assert!( !pin_strength_admits(&oracle(text, OracleKind::Snapshot, OracleStrength::Medium)), diff --git a/crates/ripr/src/analysis/seam_cache.rs b/crates/ripr/src/analysis/seam_cache.rs index 8bb13069849..32efa39267c 100644 --- a/crates/ripr/src/analysis/seam_cache.rs +++ b/crates/ripr/src/analysis/seam_cache.rs @@ -456,7 +456,9 @@ pub(crate) struct CachedSeamLimitInfo { /// panic-assertion helper loans (#7818); neither standalone `1.75` is reusable. /// `1.77`: a whole same-line comparison tail reaches its owner's return /// (#8042). Old entries can keep a predicate's propagation unknown. -pub(crate) const CACHE_SCHEMA_VERSION: &str = "1.77"; +/// `1.78`: a verified `expect_file![..].assert_eq(..)` golden comparison +/// pins the owner's return (#6578). Old entries keep it a medium snapshot. +pub(crate) const CACHE_SCHEMA_VERSION: &str = "1.78"; /// `0.2` → `0.3`: same semantic transition as the outer cache (#3273 / /// #3286) — sharded entries derive from the same facts and cannot bypass /// the outer generation bump. @@ -578,7 +580,8 @@ pub(crate) const CACHE_SCHEMA_VERSION: &str = "1.77"; /// `0.81`: same variant-field pattern evidence as full `1.75`. /// `0.82`: same composed helper/pattern evidence as full `1.76`. /// `0.83`: same returned-comparison transition as full `1.77` (#8042). -const SHARDED_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION: &str = "0.83"; +/// `0.84`: same golden-file pin evidence as full `1.78`. +const SHARDED_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION: &str = "0.84"; /// Compact-classified seam cache schema. This cache stores the same /// `ClassifiedSeam` envelope shape as the full repo exposure cache, but @@ -702,7 +705,8 @@ const SHARDED_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION: &str = "0.83"; /// `0.81`: same variant-field pattern evidence as full `1.75`. /// `0.82`: same composed helper/pattern evidence as full `1.76`. /// `0.83`: same returned-comparison transition as full `1.77` (#8042). -pub(crate) const COMPACT_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION: &str = "0.83"; +/// `0.84`: same golden-file pin evidence as full `1.78`. +pub(crate) const COMPACT_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION: &str = "0.84"; /// Compact class-count cache used by repo badge rendering. It keys off /// the same workspace state as the full fact cache, but stores only @@ -878,7 +882,9 @@ pub(crate) const COUNT_CACHE_SCHEMA_VERSION: &str = "0.2"; /// form; `1.38` facts lack it. /// `1.40`: single-line `self.` assignments mint a parser-owned /// `field_construction` shape (RIPR-SPEC-0228, #6485). `1.39` facts lack it. -pub(crate) const FILE_FACT_CACHE_SCHEMA_VERSION: &str = "1.40"; +/// `1.41`: `expect_file` joins the trusted macro names a binding site may +/// report (#6578); `1.40` candidates never record it. +pub(crate) const FILE_FACT_CACHE_SCHEMA_VERSION: &str = "1.41"; /// Keep the best-effort classified-seam cache from turning a successful live /// analysis into an unbounded post-analysis stall on large repos. Larger live @@ -4367,7 +4373,8 @@ mod tests { // 1.36 -> 1.37: combine expect-test facts and JSON binding candidates. // 1.38 -> 1.39: accepted-Err guarded-match form (RIPR-SPEC-0175). // 1.39 -> 1.40: field-assignment probe shapes (RIPR-SPEC-0228). - assert_eq!(FILE_FACT_CACHE_SCHEMA_VERSION, "1.40"); + // 1.40 -> 1.41: trusted `expect_file` binding candidates (#6578). + assert_eq!(FILE_FACT_CACHE_SCHEMA_VERSION, "1.41"); // 1.4 -> 1.5: metadata-sourced harness validation (#3634) flips // verdicts for workspaces the manifest emulation approximated. // 1.5 -> 1.6: the #3636 reachability authority excludes @@ -4469,7 +4476,8 @@ mod tests { // 1.74 -> 1.75: literal variant-field patterns pin the field (#6578). // 1.75 -> 1.76: compose both independently allocated 1.75 semantics (#7818). // 1.76 -> 1.77: same-line returned comparisons gain a real sink (#8042). - assert_eq!(CACHE_SCHEMA_VERSION, "1.77"); + // 1.77 -> 1.78: verified expect_file golden comparisons pin (#6578). + assert_eq!(CACHE_SCHEMA_VERSION, "1.78"); // 0.12 -> 0.13 through 0.14 / 0.15 / 0.16 / 0.17 / 0.18: same // #3731 semantic transition as the outer classified-seam cache, // for the sharded and compact envelopes. @@ -4539,8 +4547,9 @@ mod tests { // 0.80 -> 0.81: same evidence as full 1.75. // 0.81 -> 0.82: same composed evidence as full 1.76 (#7818). // 0.82 -> 0.83: same returned-comparison evidence as full 1.77. - assert_eq!(SHARDED_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION, "0.83"); - assert_eq!(COMPACT_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION, "0.83"); + // 0.83 -> 0.84: same evidence as full 1.78. + assert_eq!(SHARDED_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION, "0.84"); + assert_eq!(COMPACT_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION, "0.84"); } #[test] diff --git a/crates/ripr/src/analysis/syntax/owner_pin.rs b/crates/ripr/src/analysis/syntax/owner_pin.rs index 0513d9606b8..75b10939584 100644 --- a/crates/ripr/src/analysis/syntax/owner_pin.rs +++ b/crates/ripr/src/analysis/syntax/owner_pin.rs @@ -381,9 +381,11 @@ pub(crate) const TRUSTED_MACRO_NAMES: &[&str] = &[ "debug_assert_ne", "eprint", "eprintln", - // expect-test's `expect!` builds a value and cannot return; only its - // manifest-verified `use expect_test::expect` import keeps it trusted. + // expect-test's `expect!` and `expect_file!` build a value and cannot + // return; only a manifest-verified `use expect_test::{expect, + // expect_file}` import keeps either trusted. "expect", + "expect_file", "file", "format", "format_args", @@ -834,15 +836,15 @@ fn macro_binding_ambiguities( /// the assertion's meaning. Renaming one onto another trusted name does not. const DROP_IN_ASSERTION_CRATES: &[&str] = &["pretty_assertions"]; -/// #6578: `expect_test` exports `expect!`, which only builds an `Expect` -/// value; importing it under its own name is the one binding that makes a -/// bare `expect!` expect-test's. +/// #6578: `expect_test` exports `expect!` and `expect_file!`, which only +/// build an `Expect` / `ExpectFile` value; importing one under its own name +/// is the one binding that makes the bare macro expect-test's. const EXPECT_TEST_CRATES: &[&str] = &["expect_test"]; fn is_drop_in_assertion(item: &ast::UseTree, name: &str) -> bool { let crates = match name { "assert_eq" | "assert_ne" => DROP_IN_ASSERTION_CRATES, - "expect" => EXPECT_TEST_CRATES, + "expect" | "expect_file" => EXPECT_TEST_CRATES, "json" => &["serde_json"], _ => return false, }; @@ -1468,16 +1470,20 @@ pub(crate) fn owner_pin_assertions(source: &str, trusted: &[&str]) -> OwnerPinAs .push(call.syntax().clone()); } // #6578: an inline expect-test comparison - // (`expect![["alice: 42"]].assert_eq(&render_row("alice", 41))`) is - // a method call on the bare `expect!` value; the classify side - // decides which spelling pins. + // (`expect![["alice: 42"]].assert_eq(&render_row("alice", 41))`) or + // golden-file one (`expect_file!["out.txt"].assert_eq(..)`) is a + // method call on the bare macro's value; the classify side decides + // which spelling pins. for call in function .syntax() .descendants() .filter_map(ast::MethodCallExpr::cast) { if !is_expect_test_comparison(&call) - || expect_test_receiver(&call).as_deref() != Some("expect") + || !matches!( + expect_test_receiver(&call).as_deref(), + Some("expect" | "expect_file") + ) || call .name_ref() .is_none_or(|name| name.text() != "assert_eq") diff --git a/crates/ripr/tests/cli_smoke/structural_workspace_markers.rs b/crates/ripr/tests/cli_smoke/structural_workspace_markers.rs index ff7f92cfb10..3ebc6faf435 100644 --- a/crates/ripr/tests/cli_smoke/structural_workspace_markers.rs +++ b/crates/ripr/tests/cli_smoke/structural_workspace_markers.rs @@ -179,6 +179,19 @@ fn scalar_marker_preserves_cargo_uv_git_and_unmarked_root_boundaries() -> TestRe ], &[("RIPR_CACHE_DIR", "")], )?; + // Without `lang-python`, the uv root still resolves, but its Python + // markers make the run refuse instead of analysing (#8131 follow-up). + if label == "uv" && !cfg!(feature = "lang-python") { + let stderr = String::from_utf8_lossy(&output.stderr); + fs::remove_dir_all(sandbox)?; + assert!(!output.status.success(), "{label}: {output:?}"); + assert!( + stderr.contains("pyproject.toml contains [tool.uv.workspace]") + && stderr.contains("built without Cargo feature `lang-python`"), + "{label}: {stderr}" + ); + continue; + } assert!(output.status.success(), "{label}: {output:?}"); let report: Value = serde_json::from_slice(&output.stdout)?; fs::remove_dir_all(sandbox)?; diff --git a/crates/ripr/tests/expect_test_owner_pins.rs b/crates/ripr/tests/expect_test_owner_pins.rs index f49ccd5a57b..e0a37414ce3 100644 --- a/crates/ripr/tests/expect_test_owner_pins.rs +++ b/crates/ripr/tests/expect_test_owner_pins.rs @@ -1,8 +1,10 @@ -//! Public-API controls for inline expect-test owner pins (#6578, #7856 -//! review): an `expect![..].assert_eq(&owner(..))` comparison behind a +//! Public-API controls for expect-test owner pins (#6578, #7856 review): +//! an `expect![..].assert_eq(&owner(..))` comparison behind a //! manifest-verified `use expect_test::expect;` pins the owner's return in -//! every spelling the parser accepts, and every other expect-test or -//! snapshot shape keeps its medium snapshot grade. Each case writes a small +//! every spelling the parser accepts, as does a golden-file +//! `expect_file!["path"].assert_eq(&owner(..))` behind a verified +//! `use expect_test::expect_file;`, and every other expect-test or snapshot +//! shape keeps its medium snapshot grade. Each case writes a small //! crate, changes the owner's `format!` tail, and reads the return-value //! finding through `check_workspace`. @@ -150,7 +152,7 @@ fn other_expect_test_and_snapshot_shapes_keep_their_medium_grade() -> Result<(), "", "let _ok = render(1).is_empty() || { expect![[\"w12\"]].assert_eq(&render(4)); true };", ), - // The Debug comparison, a file expectation and an insta snapshot. + // The Debug comparisons and an insta snapshot. ( EXPECT_TEST, IMPORT, @@ -159,9 +161,9 @@ fn other_expect_test_and_snapshot_shapes_keep_their_medium_grade() -> Result<(), ), ( EXPECT_TEST, - "use expect_test::expect_file;", + FILE_IMPORT, "", - "expect_file![\"w.txt\"].assert_eq(&render(4));", + "expect_file![\"w.txt\"].assert_debug_eq(&render(4));", ), ( INSTA, @@ -186,6 +188,127 @@ fn other_expect_test_and_snapshot_shapes_keep_their_medium_grade() -> Result<(), Ok(()) } +const FILE_IMPORT: &str = "use expect_test::expect_file;"; +const GOLDEN: &str = "expect_file![\"w.txt\"].assert_eq(&render(4));"; + +/// #6578: `ExpectFile::assert_eq` compares the actual text with the whole +/// committed file and panics on a mismatch, so a verified golden-file +/// comparison pins the owner's return as the inline one does. The file is +/// never read; whatever it holds, a changed return fails the comparison. +#[test] +fn a_verified_golden_file_comparison_pins_the_owner() -> Result<(), String> { + for (imports, test) in [ + (FILE_IMPORT, GOLDEN), + ("use expect_test::{expect, expect_file};", GOLDEN), + ( + FILE_IMPORT, + "expect_file![\"w.txt\"]\n .assert_eq(&render(4));", + ), + ] { + let finding = render_finding(OLD, NEW, EXPECT_TEST, imports, "", test)?; + assert_eq!( + finding["classification"], "exposed", + "{imports} {test}: {finding}" + ); + } + for (dev, imports, attributes, test) in [ + // No manifest dependency verifies the import. + ("", FILE_IMPORT, "", GOLDEN), + // A renamed package behind the `expect_test` name. + ( + "[dev-dependencies]\nexpect-test = { package = \"fake-expect\", version = \"1\" }\n", + FILE_IMPORT, + "", + GOLDEN, + ), + // Some other crate's `expect_file!`. + ( + "[dev-dependencies]\nexpect-test = \"1\"\nother = \"1\"\n", + "use other::expect_file;", + "", + GOLDEN, + ), + // A path-qualified macro without the verified import. + ( + EXPECT_TEST, + "", + "", + "expect_test::expect_file![\"w.txt\"].assert_eq(&render(4));", + ), + // A renamed import, and a glob. + ( + EXPECT_TEST, + "use expect_test::expect_file as golden;", + "", + "golden![\"w.txt\"].assert_eq(&render(4));", + ), + (EXPECT_TEST, "use expect_test::*;", "", GOLDEN), + // A test-file macro shadows the import. + ( + EXPECT_TEST, + "use expect_test::expect_file;\nmacro_rules! expect_file { ($($t:tt)*) => { expect_test::expect_file!($($t)*) }; }", + "", + GOLDEN, + ), + // A test that passes by panicking. + (EXPECT_TEST, FILE_IMPORT, "#[should_panic]\n", GOLDEN), + // A computed path. + ( + EXPECT_TEST, + FILE_IMPORT, + "", + "expect_file![concat!(\"w\", \".txt\")].assert_eq(&render(4));", + ), + // #6578 review: a golden the test writes from the owner first, or + // lets expect-test rewrite, fixes nothing. + ( + EXPECT_TEST, + FILE_IMPORT, + "", + "std::fs::write(\"tests/w.txt\", render(4)).unwrap();\n expect_file![\"w.txt\"].assert_eq(&render(4));", + ), + ( + EXPECT_TEST, + "use expect_test::expect_file;\nuse std::fs::write;", + "", + "write(\"tests/w.txt\", render(4)).unwrap();\n expect_file![\"w.txt\"].assert_eq(&render(4));", + ), + ( + EXPECT_TEST, + FILE_IMPORT, + "", + "unsafe { std::env::set_var(\"UPDATE_EXPECT\", \"1\") };\n expect_file![\"w.txt\"].assert_eq(&render(4));", + ), + // A renamed file writer, and a golden outside the crate. + ( + EXPECT_TEST, + "use expect_test::expect_file;\nuse std::fs::write as save;", + "", + "save(\"tests/w.txt\", render(4)).unwrap();\n expect_file![\"w.txt\"].assert_eq(&render(4));", + ), + ( + EXPECT_TEST, + FILE_IMPORT, + "", + "expect_file![\"/tmp/w.txt\"].assert_eq(&render(4));", + ), + ] { + let finding = render_finding(OLD, NEW, dev, imports, attributes, test)?; + // A renamed macro is not recognized as an expect-test comparison + // at all, so it earns no snapshot grade either. + let expected = if test.starts_with("golden!") { + "reachable_unrevealed" + } else { + "weakly_exposed" + }; + assert_eq!( + finding["classification"], expected, + "{imports} {attributes}{test}: {finding}" + ); + } + Ok(()) +} + /// #7856 review: a lone format string with a captured identifier is a /// plain `format!` owner tail, as a tuple of arguments is. #[test] diff --git a/crates/ripr/tests/lsp_lifecycle/gap_corpus_currentness.rs b/crates/ripr/tests/lsp_lifecycle/gap_corpus_currentness.rs index ff2b2f951d3..cc088d0bff5 100644 --- a/crates/ripr/tests/lsp_lifecycle/gap_corpus_currentness.rs +++ b/crates/ripr/tests/lsp_lifecycle/gap_corpus_currentness.rs @@ -618,7 +618,7 @@ fn captured_corpus(captured: &Value) -> ProofResult<&Value> { .ok_or("analysis producer omitted source_subject.corpus")?; require( corpus["scope"] == "rust_workspace" - && corpus["cache_schema_version"] == "1.77" + && corpus["cache_schema_version"] == "1.78" && corpus["files_content_hash"].as_str().is_some_and(|hash| { hash.len() == 16 && hash diff --git a/docs/OUTPUT_SCHEMA.md b/docs/OUTPUT_SCHEMA.md index 0d98c18f43c..6e283348d95 100644 --- a/docs/OUTPUT_SCHEMA.md +++ b/docs/OUTPUT_SCHEMA.md @@ -17828,7 +17828,7 @@ top-level `source_subject`: - `digest_algorithm`: always `"sha256"`. - `corpus` (additive, full Rust inventory only): the analysis-owned - `{ "scope": "rust_workspace", "cache_schema_version": "1.77", + `{ "scope": "rust_workspace", "cache_schema_version": "1.78", "files_content_hash": "<16 lowercase hex digits>" }` from the actual classified inventory cache key, including both production and test Rust files after the existing generated-file exclusions. This is the existing @@ -18528,7 +18528,7 @@ targeted-rerun receipt shape: "direct_call_names": ["discounted_total"] }, "cache": { - "schema_version": "1.40", + "schema_version": "1.41", "reuse_state": "reused_file_facts", "file_fact_status": "hits_2_misses_0_corrupt_0_store_errors_0", "hits": 2, @@ -18539,7 +18539,7 @@ targeted-rerun receipt shape: "recomputation_reasons": ["selected_test_scope_recomputed"], "invalidation_status": "not_available", "input_fingerprint": { - "schema_version": "1.77", + "schema_version": "1.78", "analyzer_version": "0.11.0+0123456789abcdef0123456789abcdef01234567", "workspace_root_hash": "…", "files_content_hash": "…", diff --git a/docs/specs/RIPR-SPEC-0197-owner-return-pins.md b/docs/specs/RIPR-SPEC-0197-owner-return-pins.md index b05b6ec4a4b..e7054ad24d0 100644 --- a/docs/specs/RIPR-SPEC-0197-owner-return-pins.md +++ b/docs/specs/RIPR-SPEC-0197-owner-return-pins.md @@ -1407,9 +1407,56 @@ call grades as the canonical spelling does. A weaker reading of the compared value (a tautology, a broad `is_err()`) is kept. The oracle keeps RIPR-SPEC-0231's step-6 `snapshot` kind; as for the bool-owner pin, only its probe-relative strength rises once the pin admits -it. `assert_debug_eq` (which compares the `Debug` text), `expect_file!`, a -qualified `expect_test::expect!`, and every `insta` macro stay -`snapshot` / medium. +it. `assert_debug_eq` (which compares the `Debug` text), a qualified +`expect_test::expect!` or `expect_test::expect_file!`, and every `insta` +macro stay `snapshot` / medium. + +### Golden-file expect-test comparisons (#6578) + +`expect_file!["path"].assert_eq(&owner(..))` pins as the inline comparison +does. `ExpectFile::assert_eq` reads the committed file (CRLF as LF; a missing +file as the empty text), compares it with the actual text, and panics on a +mismatch unless `UPDATE_EXPECT` is set, the same escape the inline form has. +The rules above apply with four differences: + +1. The macro's one argument is a single string literal naming the file. A + computed path (`concat!(..)`, a binding) or the inline form's double + brackets refuses. `expect_file!` resolves the path against the test + source's directory, so the literal must be relative and stay in the + tree: an absolute path (`/tmp/x`, a drive-letter path, `\\host\x`), a `~` path or + any `..` segment may name text the commit does not fix, and refuses. A + non-raw literal with any escape (`"\u{2e}\u{2e}/x"`) refuses too, since + its decoded segments are not the source text. +2. The bare `expect_file!` must be expect-test's under rule 2: its file + imports `use expect_test::expect_file;` (alone or grouped) under its own + name, verified against the manifest, and nothing else binds + `expect_file`. In an owner body it stays an unknown macro. +3. The file is never read. The pin needs only that the compared text is + fixed by the commit; its content does not decide whether a changed + return fails. So the expected side is a stand-in that only a return-path + gate admitting any value of the owner's type accepts; a gate that checks + the expected value (an exact bool, a constructor head, a whole-value + field literal) refuses it. +4. The test must not be able to write the file first. A test body that + writes, creates, copies or renames a file (`fs::write`, a bare `write(..)` + under `use std::fs::write`, `File::create`, `OpenOptions`, `fs::copy`, + `fs::rename`, any path-qualified `write(..)` or `create(..)` such as + `::create` or `fs_err::write`), runs a `Command`, makes a symlink, + persists a temp file, or calls `set_var` / names `UPDATE_EXPECT`, lends no + golden-file pin, and neither does a test whose file renames an import + from `std::fs` or `std::env` (`use std::fs::write as save;`), which would + hide the write behind another name: it could derive the golden from the owner and compare + the owner with itself. Read from the test's masked body text, so it also + refuses a test that writes some unrelated file; a write hidden in a + helper the test calls is not seen (#8097 tracks the same hole for + `assert_eq!` against a file read back). + +Rejected: reading the golden file into the expected literal. The seam cache +keys on Rust sources, so a golden edit would not invalidate the reading, and +no gate the stand-in passes depends on the text. Rejected: keeping +`expect_file!` at `snapshot` / medium. It compares the whole value exactly, +as the inline form does; the corpus row +`lib-expect-test-expect-file-golden` kills both mutants at runtime. ### Short-circuit tails (#7969) diff --git a/docs/specs/RIPR-SPEC-0231-rust-oracle-kind-admission.md b/docs/specs/RIPR-SPEC-0231-rust-oracle-kind-admission.md index c357b17a6c8..df4d4987d6f 100644 --- a/docs/specs/RIPR-SPEC-0231-rust-oracle-kind-admission.md +++ b/docs/specs/RIPR-SPEC-0231-rust-oracle-kind-admission.md @@ -589,11 +589,12 @@ rejected alternative. Any can be reversed later without touching the rest. its probe-relative strength, because the assert fixes the owner's whole two-valued result. `owner_pin` is the authority for that shape and its runtime controls (`bool_owner_assert_pin_matched_static_and_runtime_controls`) - back it. The same holds for RIPR-SPEC-0197's inline expect-test pin - (`expect![["text"]].assert_eq(&owner(..))`, #6578): the oracle keeps + back it. The same holds for RIPR-SPEC-0197's inline and golden-file + expect-test pins (`expect![["text"]].assert_eq(&owner(..))` and + `expect_file!["path"].assert_eq(&owner(..))`, #6578): the oracle keeps step 6's `snapshot` / medium kind, and only an owner pin that admits that - exact spelling raises its probe-relative strength; `insta`, - `expect_file!` and `assert_debug_eq` snapshots never pin + exact spelling raises its probe-relative strength; `insta` and + `assert_debug_eq` snapshots never pin (`pin_strength_gate_keeps_exact_pins_strong_and_defers_bool_pins_to_owner_pin`). Rejected: requiring the classifier to read that shape as `exact_value` / strong, which would duplicate the owner-identity gates @@ -654,7 +655,7 @@ rejected alternative. Any can be reversed later without touching the rest. assertions). - No change to reveal's token or owner-pin confirmation, except that an exact owner pin needs a strong oracle, apart from the bool-owner and - inline expect-test pins (decision 4). + inline and golden-file expect-test pins (decision 4). - No change to TypeScript or Python oracle classification. ## Acceptance Examples diff --git a/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/after.repo-exposure.json b/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/after.repo-exposure.json index cc62955fde1..3b2dccc1ca4 100644 --- a/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/after.repo-exposure.json +++ b/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/after.repo-exposure.json @@ -10,7 +10,7 @@ "worktree": "dirty" }, "canonicalization": "raw_json_placeholder_v1", - "content_sha256": "sha256:110a8822455d85032e3e18dbed0b7147c12adb27d3a76bb1831f2018d8e09fcf", + "content_sha256": "sha256:7edb5864692fd2135335be0a203a3cebd271fdb3598ce86e602547cf33335114", "kind": "repo_exposure", "producer": { "tool": "ripr", @@ -402,7 +402,7 @@ ], "source_subject": { "corpus": { - "cache_schema_version": "1.77", + "cache_schema_version": "1.78", "files_content_hash": "16ab297ea99e68bf", "scope": "rust_workspace" }, diff --git a/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-receipt.json b/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-receipt.json index 7d819cf6175..2db9767e24e 100644 --- a/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-receipt.json +++ b/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-receipt.json @@ -10,12 +10,12 @@ "provenance": { "after_artifact": { "path": "fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/after.repo-exposure.json", - "sha256": "sha256:564086804b38b083257ae51ed942a21b8d6bc7c2b34581420fe8c2163e22b2f9" + "sha256": "sha256:bb2ce3e568c49ab04ad07a64702b0d30875c612e8ea30ccff62850f84dbf01cd" }, "after_class": "weakly_gripped", "before_artifact": { "path": "fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/before.repo-exposure.json", - "sha256": "sha256:564086804b38b083257ae51ed942a21b8d6bc7c2b34581420fe8c2163e22b2f9" + "sha256": "sha256:bb2ce3e568c49ab04ad07a64702b0d30875c612e8ea30ccff62850f84dbf01cd" }, "before_class": "weakly_gripped", "command_template_version": "0.1", @@ -32,7 +32,7 @@ "seam_id": "67fc764ba37d77bd", "verify_artifact": { "path": "fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-verify.json", - "sha256": "sha256:4cdb204f7a7b4712aa67ae404c826107eb57789b700c5d3ae04142d6d784b3b3" + "sha256": "sha256:ec5ce03655a5dba614656eb1d707859f1dc7e91385877d34d00f120acd4391d3" }, "workflow_artifact": null }, diff --git a/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-verify.json b/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-verify.json index 994518426ad..e2cf7e1b704 100644 --- a/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-verify.json +++ b/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/agent-verify.json @@ -3,9 +3,9 @@ "changed_seams": [], "inputs": { "after": "fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/after.repo-exposure.json", - "after_content_sha256": "sha256:110a8822455d85032e3e18dbed0b7147c12adb27d3a76bb1831f2018d8e09fcf", + "after_content_sha256": "sha256:7edb5864692fd2135335be0a203a3cebd271fdb3598ce86e602547cf33335114", "before": "fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/before.repo-exposure.json", - "before_content_sha256": "sha256:110a8822455d85032e3e18dbed0b7147c12adb27d3a76bb1831f2018d8e09fcf" + "before_content_sha256": "sha256:7edb5864692fd2135335be0a203a3cebd271fdb3598ce86e602547cf33335114" }, "new_gaps": [], "resolved_gaps": [], diff --git a/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/before.repo-exposure.json b/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/before.repo-exposure.json index cc62955fde1..3b2dccc1ca4 100644 --- a/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/before.repo-exposure.json +++ b/fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/before.repo-exposure.json @@ -10,7 +10,7 @@ "worktree": "dirty" }, "canonicalization": "raw_json_placeholder_v1", - "content_sha256": "sha256:110a8822455d85032e3e18dbed0b7147c12adb27d3a76bb1831f2018d8e09fcf", + "content_sha256": "sha256:7edb5864692fd2135335be0a203a3cebd271fdb3598ce86e602547cf33335114", "kind": "repo_exposure", "producer": { "tool": "ripr", @@ -402,7 +402,7 @@ ], "source_subject": { "corpus": { - "cache_schema_version": "1.77", + "cache_schema_version": "1.78", "files_content_hash": "16ab297ea99e68bf", "scope": "rust_workspace" }, diff --git a/fixtures/rust-verdict-corpus/cases/lib-expect-test-expect-file-golden.json b/fixtures/rust-verdict-corpus/cases/lib-expect-test-expect-file-golden.json index 649ece701e5..024b611ec37 100644 --- a/fixtures/rust-verdict-corpus/cases/lib-expect-test-expect-file-golden.json +++ b/fixtures/rust-verdict-corpus/cases/lib-expect-test-expect-file-golden.json @@ -9,7 +9,7 @@ "edit_kind": "behavior_preserving_rewrite", "behavior_family": "return_value_arithmetic", "test_shape": "expect_test_expect_file_golden", - "hard_case": "The expected text is in src/expect/summary.txt via `expect_file![..]`; ripr reads snapshot/medium and reports weakly_exposed.", + "hard_case": "The expected text is in src/expect/summary.txt via `expect_file![..]`; ripr must credit the verified golden comparison as an owner-return pin without reading the file, and must not credit a test that could write the golden itself.", "truth": { "state": "discriminated", "method": "runtime_mutant_kill", diff --git a/fixtures/rust-verdict-corpus/expected/rows/lib-expect-test-expect-file-golden.json b/fixtures/rust-verdict-corpus/expected/rows/lib-expect-test-expect-file-golden.json index a0d3eb87900..1291fd6b597 100644 --- a/fixtures/rust-verdict-corpus/expected/rows/lib-expect-test-expect-file-golden.json +++ b/fixtures/rust-verdict-corpus/expected/rows/lib-expect-test-expect-file-golden.json @@ -8,13 +8,13 @@ "hard_case": true, "truth": "discriminated", "ideal_verdict": "credited", - "observed_verdict": "gap", + "observed_verdict": "credited", "followed_retarget": false, - "changed_since_labeling": false, + "changed_since_labeling": true, "observed_classifications": [ - "weakly_exposed" + "exposed" ], - "outcome": "false_actionable", + "outcome": "ideal", "contradictions": [], "findings_scored": 1, "findings_contradicted": 0, diff --git a/xtask/src/tests/rust_corpus_projection.rs b/xtask/src/tests/rust_corpus_projection.rs index fc8a3fa0ddd..66fccac95aa 100644 --- a/xtask/src/tests/rust_corpus_projection.rs +++ b/xtask/src/tests/rust_corpus_projection.rs @@ -126,7 +126,7 @@ fn genuine_rust_capture(root: &Path) -> ProofResult { let corpus = &value["source_subject"]["corpus"]; require( corpus["scope"] == "rust_workspace" - && corpus["cache_schema_version"] == "1.77" + && corpus["cache_schema_version"] == "1.78" && corpus["files_content_hash"].as_str().is_some_and(|hash| { hash.len() == 16 && hash