From a317d4cf269f1b74bb1f34291fb1e21bd71957d5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 15 Sep 2026 23:11:46 +0200 Subject: [PATCH] Isolate the marker rule and the enclosing-repo case The first attempt at these two tests still failed no mutation, because in both cases another check answered first. A test that only passes is not evidence; it has to be the thing that fails when its own rule is removed. The marker rule. `cut-3a.h1` and `cut-3a.s1` cite the wrong kind's marker, but `h1` and `s1` are not digits, so the digits rule refuses them whether or not the marker is required. `cut-3a.1` is the case that isolates it: a well-formed number with no marker at all, which only the marker rule refuses. The enclosing-repo case. A separate git dir in its own temp directory is refused even without the `.git` check, because the parent is not a work tree and the toplevel verification fails anyway. The case the check actually exists for is a clone whose git dir sits inside *another* repo's working tree: there the common dir's parent is a real, valid work tree, so without the check `main_work_tree` resolves to the enclosing repo and the store lands in a tree that does not own it. The test now builds exactly that, and asserts the enclosing repo's store is never created. Builds clean with no warnings; `cargo test -p epiphany-core --lib` passes 180/180. Co-Authored-By: Claude Opus 5 --- epiphany-core/src/pipeline_store.rs | 31 +++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/epiphany-core/src/pipeline_store.rs b/epiphany-core/src/pipeline_store.rs index be961f30..c27c58c7 100644 --- a/epiphany-core/src/pipeline_store.rs +++ b/epiphany-core/src/pipeline_store.rs @@ -786,6 +786,9 @@ mod tests { // another kind: the marker rule is pinned on its own. refused(&format!("{CAMPAIGN}:cut_spec:cut-3a.h1")); refused(&format!("{CAMPAIGN}:cut_spec:cut-3a.s1")); + // A well-formed number with no marker at all. Only the marker rule + // refuses this one: the digits rule is satisfied either way. + refused(&format!("{CAMPAIGN}:cut_spec:cut-3a.1")); refused(&format!("{CAMPAIGN}:CUT_SPEC:cut-3a.r1")); refused(&format!("EUREKA-STATE:cut_spec:cut-3a.r1")); refused(&format!("{CAMPAIGN}:cut_spec:cut-3a.r1:")); @@ -1137,23 +1140,31 @@ mod tests { Ok(()) } - /// Ruling 10's odd-layout arm: a work-tree top level whose git dir is not a - /// sibling `.git` has no main working tree to resolve, and refuses typed. + /// Ruling 10's odd-layout arm. A work-tree top level whose git dir is not a + /// sibling `.git` has no main working tree to resolve. The clone here sits + /// inside another campaign repo's working tree, which is the case that + /// matters: without the `.git` check, its common dir's parent is the + /// *enclosing* repo, and the store would silently land in someone else's + /// tree instead of refusing. #[test] fn a_separate_git_dir_has_no_main_work_tree() -> Result<()> { - let temp = tempdir()?; - let root = temp.path().join("repo"); - let git_dir = temp.path().join("elsewhere.git"); - std::fs::create_dir_all(&root)?; - git_ok(&root, &["init", "-q", "-b", "main", "--separate-git-dir", &git_dir.to_string_lossy()])?; + let (_temp, outer) = campaign_repo(true, true)?; + let inner = outer.join("inner"); + let git_dir = outer.join("innergit.git"); + std::fs::create_dir_all(&inner)?; + git_ok(&inner, &["init", "-q", "-b", "main", "--separate-git-dir", &git_dir.to_string_lossy()])?; assert!( - matches!(attach(&root, "separate").err(), Some(PipelineRefusal::NoMainWorkTree { .. })), - "a separate git dir refuses typed, with no worktree-only mode" + matches!(attach(&inner, "separate").err(), Some(PipelineRefusal::NoMainWorkTree { .. })), + "a separate git dir refuses typed, and never resolves to the enclosing repo" ); assert!( - matches!(PipelineStore::open(&root).err(), Some(PipelineRefusal::NoMainWorkTree { .. })), + matches!(PipelineStore::open(&inner).err(), Some(PipelineRefusal::NoMainWorkTree { .. })), "and the read path refuses it the same way" ); + assert!( + !outer.join(PIPELINE_STORE_PATH).exists(), + "the enclosing repo's store is never created on its behalf" + ); Ok(()) }