internal/prior at 82dc300e39, reviewed by gemini-3.6-flash.
prior.Load fails when given a directory holding mutant-set JSON documents because it aborts on auditpush.ReadLedgerDir errors instead of ignoring missing ledger structures.
#!/bin/sh
set -e
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
cat << 'EOF' > "$TMPDIR/test_prior.go"
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/pdbethke/corralai/internal/adequacy"
"github.com/pdbethke/corralai/internal/lang"
"github.com/pdbethke/corralai/internal/prior"
)
func main() {
dir, err := os.MkdirTemp("", "prior_test_*")
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create temp dir: %v\n", err)
os.Exit(1)
}
defer os.RemoveAll(dir)
jsonPath := filepath.Join(dir, "mutants.json")
sha := "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
err = adequacy.WriteMutantSet(jsonPath, adequacy.MutantSetFile{
Format: adequacy.MutantSetFormat,
Files: map[string]adequacy.MutantSetEntry{
"main.py": {
ParentSHA256: sha,
Mutants: []adequacy.RecordedMutant{
{
ID: "m1",
Span: lang.LineRange{Start: 5, End: 5},
Search: "x = 1",
Replace: "x = 2",
},
},
},
},
})
if err != nil {
fmt.Fprintf(os.Stderr, "failed to write mutant set: %v\n", err)
os.Exit(1)
}
p, err := prior.Load(dir)
if err != nil {
fmt.Printf("DEFECT DEMONSTRATED: prior.Load failed on directory of json documents: %v\n", err)
os.Exit(0)
}
tried, err := p.For("main.py", sha)
if err != nil || len(tried) != 1 {
fmt.Printf("DEFECT DEMONSTRATED: prior.For returned err=%v, len=%d (expected 1)\n", err, len(tried))
os.Exit(0)
}
fmt.Println("prior.Load unexpectedly succeeded")
os.Exit(1)
}
EOF
go run "$TMPDIR/test_prior.go"[stderr] package command-line-arguments /tmp/tmp.MckfNTnYxt/test_prior.go:8:2: use of internal package github.com/pdbethke/corralai/internal/adequacy not allowed
refuted by pdbethke — ReadLedgerDir returns nil, nil for a directory with no scans/ subdir (ledgerdir.go: os.IsNotExist → nil), so Load never aborts on a directory of documents; the script also could not run — it imported internal packages from outside the module
ref 09c43b7c81f235f78e77c2f21f0b783547a851ad2e30c07c540df0e3bc3da5d5#R1
Recorded so that "found nothing here" can be told apart from "never looked here".
The internal/prior package implements prior run loading, merging, and rendering for mutant sets and ledgers. However, Load(source) fails when source is a directory containing mutant-set JSON documents without a ledger structure, because it treats errors from auditpush.ReadLedgerDir as fatal rather than non-fatal (finding 1).