From 39f8f9e556b3bdae705b4169353930257a7bece3 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:03:21 +0200 Subject: [PATCH 01/15] test(cli): pin one JSON value on stdout for next, record, and report --- cmd/verdict/stdout_contract_test.go | 99 +++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 cmd/verdict/stdout_contract_test.go diff --git a/cmd/verdict/stdout_contract_test.go b/cmd/verdict/stdout_contract_test.go new file mode 100644 index 00000000..671fc501 --- /dev/null +++ b/cmd/verdict/stdout_contract_test.go @@ -0,0 +1,99 @@ +package main + +import ( + "encoding/json" + "errors" + "io" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" +) + +// TestJSONVerbsWriteOneEnvelopeToStdout pins the --json contract on the three +// verbs a dogfood loop pipes into jq: stdout carries exactly one JSON value and +// every human line stays on stderr. The fixture is produced by fetch-local, so +// the bundle is the shape record and report read in a real loop. +func TestJSONVerbsWriteOneEnvelopeToStdout(t *testing.T) { + hermeticEnv(t) + root := t.TempDir() + t.Chdir(root) + base, head := gitRangeFixture(t, root) + if got := runOne(t, "fetch-local", "acme/app", "stdout", "--range", base+".."+head, "--json"); got.code != 0 { + t.Fatalf("fetch-local exit = %d\nstdout: %s\nstderr: %s", got.code, got.out, got.err) + } + writeReviewJSON(t, ".verdict/state/local-stdout/review.json") + for _, args := range [][]string{ + {"next", "acme/app", "local-stdout", "--coverage", "--json"}, + {"record", "acme/app", "local-stdout", "--json"}, + {"report", "acme/app", "local-stdout", "--check", "important", "--max-risk", "medium", "--json"}, + } { + got := runOne(t, args...) + if got.code != 0 { + t.Fatalf("%v exit = %d\nstderr: %s", args, got.code, got.err) + } + assertOneJSONValue(t, args[0], got.out) + } +} + +// assertOneJSONValue decodes stdout once and requires the rest to be +// whitespace: a human line before or after the envelope leaves a second value. +func assertOneJSONValue(t *testing.T, verb, out string) { + t.Helper() + dec := json.NewDecoder(strings.NewReader(out)) + var first any + if err := dec.Decode(&first); err != nil { + t.Fatalf("%s stdout is not a JSON value: %v\n%s", verb, err, out) + } + var extra any + if err := dec.Decode(&extra); !errors.Is(err, io.EOF) { + t.Fatalf("%s stdout carries more than one JSON value: %v\n%s", verb, err, out) + } +} + +func writeReviewJSON(t *testing.T, path string) { + t.Helper() + body := `{"schema_version":"1","body":"## Summary\nA clean review body with enough text and no quote lead.","approved":false,"comments":[]}` + if err := os.WriteFile(path, []byte(body), 0o644); err != nil { + t.Fatal(err) + } +} + +// gitRangeFixture seeds a two-commit repository and returns the range the +// bundle covers. +func gitRangeFixture(t *testing.T, dir string) (base, head string) { + t.Helper() + git := func(args ...string) string { + cmd := exec.CommandContext(t.Context(), "git", args...) + cmd.Dir = dir + cmd.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1") + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("git %v: %v\n%s", args, err, out) + } + return string(out) + } + git("init", "-q") + notes := filepath.Join(dir, "notes.txt") + if err := os.WriteFile(notes, []byte("one\ntwo\nthree\n"), 0o644); err != nil { + t.Fatal(err) + } + git("add", "notes.txt") + git("-c", "user.name=t", "-c", "user.email=t@example.com", "commit", "-qm", "one") + base = git("rev-parse", "HEAD") + if err := os.WriteFile(notes, []byte("one\nTWO\nthree\n"), 0o644); err != nil { + t.Fatal(err) + } + git("add", "notes.txt") + git("-c", "user.name=t", "-c", "user.email=t@example.com", "commit", "-qm", "two") + head = git("rev-parse", "HEAD") + return trimNewline(base), trimNewline(head) +} + +func trimNewline(s string) string { + for len(s) > 0 && (s[len(s)-1] == '\n' || s[len(s)-1] == '\r') { + s = s[:len(s)-1] + } + return s +} From 9da8f28c4701c2de052caa5b404b03041ed330ea Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:06:30 +0200 Subject: [PATCH 02/15] fix(coverage): refuse an array-valued ranges like record does --- .changeset/sta-425-coverage-ranges.md | 7 ++ docs/manual.md | 7 +- internal/core/coverage/coverage.go | 90 ++++++++++++++------- internal/core/record/store_contract_test.go | 1 + internal/core/report/coverage_next_test.go | 25 ++++++ 5 files changed, 100 insertions(+), 30 deletions(-) create mode 100644 .changeset/sta-425-coverage-ranges.md diff --git a/.changeset/sta-425-coverage-ranges.md b/.changeset/sta-425-coverage-ranges.md new file mode 100644 index 00000000..87392bc7 --- /dev/null +++ b/.changeset/sta-425-coverage-ranges.md @@ -0,0 +1,7 @@ +--- +"@stainless-code/verdict": patch +--- + +**Coverage range shape** — `next --coverage` refuses an array-valued +`coverage[].ranges` with the same `bad-review-input` problem `record` reports, +instead of printing a silent 0% attestation. diff --git a/docs/manual.md b/docs/manual.md index fe27e5b4..db1240f4 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -1075,8 +1075,11 @@ the bundle's own hunk snapshot: a comma-separated list of 1-based inclusive source-line intervals, and it is side-agnostic — the evaluator unions the file's `OLD` and `NEW` hunk intervals, so one interval covers a hunk on either side. Duplicate `file` entries union -rather than count twice. A malformed range warns and makes that entry count as -unattested; it never silently attests the file. +rather than count twice. A malformed range string warns and makes that entry +count as unattested; it never silently attests the file. A `ranges` value that +is neither a string nor `null` — an array, number, or object — refuses +`bad-review-input` naming `$.coverage[N].ranges` on `record`, `post`, and +`next --coverage`, so it can never measure as an unattested 0%. Coverage is computed from `hunks.tsv`, the snapshot `fetch` already writes — never from a second diff parse and never from `toc.txt` line counts. Paths the diff --git a/internal/core/coverage/coverage.go b/internal/core/coverage/coverage.go index ea908047..5ddf05c0 100644 --- a/internal/core/coverage/coverage.go +++ b/internal/core/coverage/coverage.go @@ -54,8 +54,14 @@ const ( // Codes and messages. const ( - // CodeIncomplete is the one refusal this package raises. + // CodeIncomplete is the coverage gate's refusal. CodeIncomplete = "coverage-incomplete" + // CodeBadReviewInput is the review-input refusal record's checker raises. + CodeBadReviewInput = "bad-review-input" + + msgReviewProblem = "review.json has %d problem(s); fix every one, then re-run" + msgRangesWrongType = "value must be a string" + msgRangesWrongTypeFix = `use "1-240,300-320", "all", or omit it` msgHunksUnreadable = "hunks.tsv unreadable: %v" msgEntryNotObject = "coverage: entry %d is not an object — ignored" @@ -163,7 +169,14 @@ func Evaluate(dir string, review *jq.Obj, generated func(string) bool) (Summary, } files := intervalsByFile(rows) var warns []string - claims, present := parseClaims(review, &warns) + claims, present, problems := parseClaims(review, &warns) + if len(problems) > 0 { + return Summary{}, warns, &core.RefusalError{ + Code: CodeBadReviewInput, + Message: fmt.Sprintf(msgReviewProblem, len(problems)), + Problems: problems, + } + } warns = append(warns, unknownClaims(claims, files)...) sum := summarize(files, claims, generated) sum.Present = present @@ -233,63 +246,82 @@ func attestation(files map[string][]Range, claims []claim) map[string][]Range { // parseClaims reads coverage[] and reports whether the key was present. Every // malformed entry warns; none of them silently attests a file. -func parseClaims(review *jq.Obj, warns *[]string) ([]claim, bool) { +func parseClaims(review *jq.Obj, warns *[]string) ([]claim, bool, []core.Problem) { if review == nil { - return nil, false + return nil, false, nil } raw, ok := review.Get(Field) if !ok { - return nil, false + return nil, false, nil } items, isArr := raw.([]any) if !isArr { *warns = append(*warns, msgNotArray) - return nil, true + return nil, true, nil } out := make([]claim, 0, len(items)) + var problems []core.Problem for i, item := range items { - if c, ok := claimAt(item, i, warns); ok { + c, ok, p := claimAt(item, i, warns) + if p != nil { + problems = append(problems, *p) + } + if ok { out = append(out, c) } } - return out, true + return out, true, problems } // claimAt reads one coverage[] entry, warning and reporting false for an entry // that cannot name a file. A malformed range still yields a claim, marked bad, // so the merge warns about it and never counts it as attested. -func claimAt(item any, i int, warns *[]string) (claim, bool) { +func claimAt(item any, i int, warns *[]string) (claim, bool, *core.Problem) { obj, isObj := item.(*jq.Obj) if !isObj || obj == nil { *warns = append(*warns, fmt.Sprintf(msgEntryNotObject, i)) - return claim{}, false + return claim{}, false, nil } file := strings.TrimSpace(jq.Str(fieldOf(obj, FieldFile))) if file == "" { *warns = append(*warns, fmt.Sprintf(msgEntryNoFile, i)) - return claim{}, false + return claim{}, false, nil } - ranges, whole, bad := claimRanges(obj, file, warns) - return claim{file: file, ranges: ranges, whole: whole, bad: bad}, true + ranges, whole, bad, problem := claimRanges(obj, file, i, warns) + return claim{file: file, ranges: ranges, whole: whole, bad: bad}, true, problem } // claimRanges resolves one entry's ranges field: a whole-file claim, a parsed // range list, or a claim marked bad when the field is present but unreadable. -func claimRanges(obj *jq.Obj, file string, warns *[]string) ([]Range, bool, bool) { - ranges, ok := rangeField(obj) +func claimRanges(obj *jq.Obj, file string, i int, warns *[]string) ([]Range, bool, bool, *core.Problem) { + ranges, present, wrongType := rangeField(obj) switch { - case !ok: + case wrongType: + return nil, false, true, rangesWrongType(i) + case !present: *warns = append(*warns, fmt.Sprintf(msgBadRanges, file, jq.Str(mustField(obj, FieldRanges)))) - return nil, false, true + return nil, false, true, nil case ranges == "" || ranges == RangesAll: - return nil, true, false + return nil, true, false, nil default: parsed, err := ParseRanges(ranges) if err != nil { *warns = append(*warns, fmt.Sprintf(msgBadRanges, file, ranges)) - return nil, false, true + return nil, false, true, nil } - return parsed, false, false + return parsed, false, false, nil + } +} + +// rangesWrongType is the problem record's checker reports for a ranges value +// that is neither a string nor null: one shape, one refusal on every verb. +func rangesWrongType(i int) *core.Problem { + return &core.Problem{ + Path: fmt.Sprintf("$.coverage[%d].ranges", i), + Code: core.ProblemCodeWrongType, + Level: core.ProblemLevelError, + Message: msgRangesWrongType, + Fix: msgRangesWrongTypeFix, } } @@ -301,20 +333,22 @@ func fieldOf(o *jq.Obj, key string) any { func mustField(o *jq.Obj, key string) any { return fieldOf(o, key) } -// rangeField reads ranges as a trimmed string. A key that is present but not a -// string — `null` included — is a malformed attestation, not a whole-file -// claim: attesting more than was written is the one error this package must -// never make, and a claim only widens by saying `all` or omitting the key. -func rangeField(o *jq.Obj) (string, bool) { +// rangeField reads ranges as a trimmed string. A key present as null stays a +// malformed attestation warning; any other non-string refuses with record's +// bad-review-input problem, so an array never measures as a silent 0%. +func rangeField(o *jq.Obj) (value string, present, wrongType bool) { raw, ok := o.Get(FieldRanges) if !ok { - return "", true + return "", true, false } s, isStr := raw.(string) if !isStr { - return "", false + if raw == nil { + return "", false, false + } + return "", true, true } - return strings.TrimSpace(s), true + return strings.TrimSpace(s), true, false } // loadRows reads the fetch-time snapshot, rebuilding it in memory from diff --git a/internal/core/record/store_contract_test.go b/internal/core/record/store_contract_test.go index f1452196..4c5fd6cd 100644 --- a/internal/core/record/store_contract_test.go +++ b/internal/core/record/store_contract_test.go @@ -129,6 +129,7 @@ func TestRunRecordInputShapeRefusals(t *testing.T) { {"triage-not-object", `,"triage":[42]`, "bad-review-input", "triage entry must be an object"}, {"sections-not-array", `,"sections":1`, "bad-review-input", "sections must be an array"}, {"section-not-object", `,"sections":[42]`, "bad-review-input", "section must be an object"}, + {"coverage-ranges-array", `,"coverage":[{"file":"notes.txt","ranges":["1-2"]}]`, "bad-review-input", "value must be a string"}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { diff --git a/internal/core/report/coverage_next_test.go b/internal/core/report/coverage_next_test.go index 2d83ee5c..76118467 100644 --- a/internal/core/report/coverage_next_test.go +++ b/internal/core/report/coverage_next_test.go @@ -116,6 +116,31 @@ func TestRunNextCoverageRefusesCorruptReview(t *testing.T) { // TestRunNextCoverageChunked pins criterion 9's chunked leg: a chunked bundle // reports its chunk count and is not evaluated, because chunks[] is its // attestation. +// TestRunNextCoverageRefusesArrayRanges pins one input contract for +// coverage[].ranges: an array is not a range string, and next must report the +// same bad-review-input problem record does instead of measuring a silent 0%. +func TestRunNextCoverageRefusesArrayRanges(t *testing.T) { + req := coverageNextRequest(t, coverageFiles(coverageReview("notes.txt", `"coverage":[{"file":"notes.txt","ranges":["1-2"]}],`))) + resp, ref := reportcore.RunNextCoverage(req) + if ref == nil { + t.Fatalf("RunNextCoverage = %+v; want a bad-review-input refusal", resp.Coverage) + } + if ref.Code != "bad-review-input" { + t.Fatalf("refusal code = %q, want bad-review-input", ref.Code) + } + if want := "review.json has 1 problem(s); fix every one, then re-run"; ref.Message != want { + t.Errorf("refusal message = %q, want %q", ref.Message, want) + } + if len(ref.Problems) != 1 { + t.Fatalf("problems = %+v, want exactly one", ref.Problems) + } + p := ref.Problems[0] + if p.Path != "$.coverage[0].ranges" || p.Code != core.ProblemCodeWrongType || + p.Message != "value must be a string" { + t.Errorf("problem = %+v, want the record checker's wrong-type problem", p) + } +} + func TestRunNextCoverageChunked(t *testing.T) { files := coverageFiles(coverageReview("notes.txt", `"coverage":[{"file":"notes.txt","ranges":"all"}],`)) files["chunks/manifest.json"] = `{"chunks":[{"name":"chunks/01.diff"},{"name":"chunks/02.diff"}]}` From f77f233613cc1dda6768b6570c4c0b2bfa181720 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:10:00 +0200 Subject: [PATCH 03/15] fix(roles): exempt *.gen.* and zz_generated.* paths as generated --- .changeset/sta-425-generated-exemption.md | 7 +++++ docs/manual.md | 5 +-- internal/core/record/coverage_exempt_test.go | 26 ++++++++++++++++ internal/core/report/coverage_next_test.go | 32 ++++++++++++++++++-- internal/readcommon/roles.go | 2 +- internal/readcommon/roles_test.go | 3 ++ 6 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 .changeset/sta-425-generated-exemption.md diff --git a/.changeset/sta-425-generated-exemption.md b/.changeset/sta-425-generated-exemption.md new file mode 100644 index 00000000..a1932ee9 --- /dev/null +++ b/.changeset/sta-425-generated-exemption.md @@ -0,0 +1,7 @@ +--- +"@stainless-code/verdict": patch +--- + +**Generated-path coverage exemption** — `*.gen.*` and `zz_generated.*` paths +now count as generated in the shared role heuristic, so `next --coverage` and +the risk floor exempt them exactly as the review prompt promises. diff --git a/docs/manual.md b/docs/manual.md index db1240f4..43a45b9c 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -1084,8 +1084,9 @@ is neither a string nor `null` — an array, number, or object — refuses Coverage is computed from `hunks.tsv`, the snapshot `fetch` already writes — never from a second diff parse and never from `toc.txt` line counts. Paths the shared role heuristic classifies as generated or vendored are exempt -automatically; no sentinel is required. `percent` is `null`, never `0`, when no -changed line was measured. +automatically — `*.pb.go`, `*.gen.*`, `zz_generated.*`, lockfiles, minified +assets, and `dist/`, `build/`, or `vendor/` trees — so no sentinel is required. +`percent` is `null`, never `0`, when no changed line was measured. The default posture is a warning plus one machine-built body line on a partial attestation. A partial one warns once and adds one machine-built body line; diff --git a/internal/core/record/coverage_exempt_test.go b/internal/core/record/coverage_exempt_test.go index ba97c034..7a2744d8 100644 --- a/internal/core/record/coverage_exempt_test.go +++ b/internal/core/record/coverage_exempt_test.go @@ -5,6 +5,32 @@ import ( "testing" ) +// generatedTypeScriptDiff changes notes.txt plus a `.gen.ts` path the review +// never names: the shared role heuristic must exempt the second file, so the +// stored receipt risk reads carries no gap for it. +const generatedTypeScriptDiff = "diff --git a/notes.txt b/notes.txt\nindex 1111111..2222222 100644\n" + + "--- a/notes.txt\n+++ b/notes.txt\n@@ -1,3 +1,3 @@\n top\n-old line\n+new line\n bottom\n" + + "diff --git a/clients/ts/src/refusal-codes.gen.ts b/clients/ts/src/refusal-codes.gen.ts\n" + + "index 3333333..4444444 100644\n--- a/clients/ts/src/refusal-codes.gen.ts\n" + + "+++ b/clients/ts/src/refusal-codes.gen.ts\n@@ -1,3 +1,3 @@\n top\n-old line\n+new line\n bottom\n" + +// TestMergeCoverageExemptsGeneratedTypeScript pins the receipt risk reads: +// a `.gen.ts` file left out of coverage[] is exempt, not unattested, so the +// stored gaps stay zero and `unreviewed-files` cannot raise the risk floor. +func TestMergeCoverageExemptsGeneratedTypeScript(t *testing.T) { + coverageBundle(t, generatedTypeScriptDiff, coverageReview("notes.txt", `"coverage":[{"file":"notes.txt","ranges":"all"}],`)) + if ref := runCoverage(t, false, false); ref != nil { + t.Fatalf("record refused: %+v", ref) + } + cov, ok := decodeObject(t, ".verdict/state/"+coverageSlug+"/record.json")["coverage"].(map[string]any) + if !ok { + t.Fatalf("record.json carries no coverage receipt") + } + if cov["percent"] != float64(100) || cov["gaps"] != float64(0) || cov["exempt"] != float64(1) { + t.Errorf("coverage receipt = %+v, want percent 100, gaps 0, exempt 1", cov) + } +} + // A bundle whose every changed file is generated has nothing to attest, so // --require-coverage must pass rather than refuse on a 0/0 denominator: the // exemption is automatic and needs no sentinel. The gate is the one place the diff --git a/internal/core/report/coverage_next_test.go b/internal/core/report/coverage_next_test.go index 76118467..b465cf24 100644 --- a/internal/core/report/coverage_next_test.go +++ b/internal/core/report/coverage_next_test.go @@ -20,6 +20,13 @@ const coverageDiff = "diff --git a/notes.txt b/notes.txt\nindex 1111111..2222222 const generatedDiff = "diff --git a/dist/app.min.js b/dist/app.min.js\nindex 3333333..4444444 100644\n" + "--- a/dist/app.min.js\n+++ b/dist/app.min.js\n@@ -1,3 +1,3 @@\n top\n-old line\n+new line\n bottom\n" +// generatedTypeScriptDiff adds a `.gen.ts` path the review never attests: the +// shared generated predicate must exempt it instead of scoring it unattested. +const generatedTypeScriptDiff = coverageDiff + + "diff --git a/clients/ts/src/refusal-codes.gen.ts b/clients/ts/src/refusal-codes.gen.ts\n" + + "index 3333333..4444444 100644\n--- a/clients/ts/src/refusal-codes.gen.ts\n" + + "+++ b/clients/ts/src/refusal-codes.gen.ts\n@@ -1,3 +1,3 @@\n top\n-old line\n+new line\n bottom\n" + // coverageReview builds a review over path whose body clears the degenerate // floor, with extra as the top-level fragment carrying coverage[]. func coverageReview(path, extra string) string { @@ -113,9 +120,25 @@ func TestRunNextCoverageRefusesCorruptReview(t *testing.T) { } } -// TestRunNextCoverageChunked pins criterion 9's chunked leg: a chunked bundle -// reports its chunk count and is not evaluated, because chunks[] is its -// attestation. +// TestRunNextCoverageExemptsGeneratedTypeScript pins the prompt's promise on +// the read verb: a `.gen.ts` path omitted from coverage[] is exempt, so it +// neither drags the percentage down nor appears in the unattested list. +func TestRunNextCoverageExemptsGeneratedTypeScript(t *testing.T) { + req := coverageNextRequest(t, map[string]string{ + "full.diff": generatedTypeScriptDiff, + "hunks.tsv": hunks.Format(hunks.Parse(generatedTypeScriptDiff)), + "review.json": coverageReview("notes.txt", `"coverage":[{"file":"notes.txt","ranges":"all"}],`), + }) + resp, ref := reportcore.RunNextCoverage(req) + if ref != nil { + t.Fatalf("RunNextCoverage refusal: %v", ref) + } + cov := resp.Coverage + if cov == nil || cov.Percent == nil || *cov.Percent != 100 || cov.Exempt != 1 || len(cov.Unattested) != 0 { + t.Fatalf("coverage = %+v, want 100%% with one generated exempt and no gaps", cov) + } +} + // TestRunNextCoverageRefusesArrayRanges pins one input contract for // coverage[].ranges: an array is not a range string, and next must report the // same bad-review-input problem record does instead of measuring a silent 0%. @@ -141,6 +164,9 @@ func TestRunNextCoverageRefusesArrayRanges(t *testing.T) { } } +// TestRunNextCoverageChunked pins criterion 9's chunked leg: a chunked bundle +// reports its chunk count and is not evaluated, because chunks[] is its +// attestation. func TestRunNextCoverageChunked(t *testing.T) { files := coverageFiles(coverageReview("notes.txt", `"coverage":[{"file":"notes.txt","ranges":"all"}],`)) files["chunks/manifest.json"] = `{"chunks":[{"name":"chunks/01.diff"},{"name":"chunks/02.diff"}]}` diff --git a/internal/readcommon/roles.go b/internal/readcommon/roles.go index 31f8f247..5eec3e9a 100644 --- a/internal/readcommon/roles.go +++ b/internal/readcommon/roles.go @@ -51,7 +51,7 @@ var ( var generatedSubstrings = []string{ "package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lock", "Cargo.lock", "Gemfile.lock", "poetry.lock", ".min.js", ".min.css", - "__snapshots__/", ".snap", ".pb.go", ".g.dart", ".generated.", + "__snapshots__/", ".snap", ".pb.go", ".g.dart", ".generated.", ".gen.", "zz_generated.", } // isGeneratedPath owns the generated branch, including the start-anchored diff --git a/internal/readcommon/roles_test.go b/internal/readcommon/roles_test.go index 95d2ac78..120c3222 100644 --- a/internal/readcommon/roles_test.go +++ b/internal/readcommon/roles_test.go @@ -19,6 +19,9 @@ func TestPathRole(t *testing.T) { {"package-lock.json", "generated"}, {"vendor/github.com/x/y.go", "generated"}, {"web/app.min.js", "generated"}, + {"clients/ts/src/refusal-codes.gen.ts", "generated"}, + {"internal/core/types.gen.go", "generated"}, + {"pkg/apis/zz_generated.deepcopy.go", "generated"}, {"docs/manual.md", "docs"}, {"README.md", "docs"}, {"go.mod", "config"}, From f0a4497ef87ef50a4b2b7679a1224dc69b5c5a9f Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:12:25 +0200 Subject: [PATCH 04/15] fix(report): name the merge when the check gate passes --- .changeset/sta-425-gate-next.md | 8 ++++++ docs/manual.md | 4 ++- internal/core/report/gate_test.go | 41 +++++++++++++++++++++++++++++++ internal/core/report/render.go | 34 ++++++++++++++++++------- internal/core/report/service.go | 1 + 5 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 .changeset/sta-425-gate-next.md diff --git a/.changeset/sta-425-gate-next.md b/.changeset/sta-425-gate-next.md new file mode 100644 index 00000000..6239b5cd --- /dev/null +++ b/.changeset/sta-425-gate-next.md @@ -0,0 +1,8 @@ +--- +"@stainless-code/verdict": patch +--- + +**Gate-passing `next`** — when `report --check ` passes, the envelope's +`next` and the human footer now say `merge — gate passes` instead of +`address open threads`. Findings below the tier's floor no longer read as the +next step. diff --git a/docs/manual.md b/docs/manual.md index 43a45b9c..fe2d619f 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -1348,7 +1348,9 @@ esac Compose it after the expensive step: gate the merge on `--check critical`, keep `post`'s preflight as the fail-closed backstop — the gate advises, -the human still merges. +the human still merges. A passing gate names that merge in the envelope's +`next` (`merge — gate passes`) and in the human footer, so open findings below +the tier's floor never read as the next step. `report --category ` filters the ranked findings to one finding kind (`logic`, `edge-case`, `security`, `performance`, `accidental-commit`, diff --git a/internal/core/report/gate_test.go b/internal/core/report/gate_test.go index 33630c0e..8df4e5df 100644 --- a/internal/core/report/gate_test.go +++ b/internal/core/report/gate_test.go @@ -91,6 +91,47 @@ func TestRunReportCheckTierGate(t *testing.T) { } } +// TestRunReportGatePassNextNamesMerge pins item 6: a passing --check gate +// names the merge as the next step instead of sending the reviewer to open +// threads that sit below the gate's floor. A failing gate keeps the old line. +func TestRunReportGatePassNextNamesMerge(t *testing.T) { + run := func(t *testing.T, findings, check string) *core.ReportResponse { + t.Helper() + resp, ref := reportcore.Run(context.Background(), &core.ReportRequest{ + ReadRequest: fixture(t, findings), + Flags: core.ReportFlags{Check: check}, + }) + if ref != nil { + t.Fatalf("Run refusal: %v", ref) + } + return resp + } + + below := "[" + entryJSON("1111111111111111111111111111111111111111", "inline", "open", `"informational"`, "true") + "]" + passed := run(t, below, "important") + if passed.GateFailed { + t.Fatalf("GateFailed = true, want a passing gate") + } + if want := "merge — gate passes"; passed.Next != want { + t.Errorf("Next = %q, want %q", passed.Next, want) + } + if got, want := passed.Human[len(passed.Human)-1], "next: merge — gate passes"; got != want { + t.Errorf("human footer = %q, want %q", got, want) + } + + atFloor := "[" + entryJSON("2222222222222222222222222222222222222222", "inline", "open", `"important"`, "true") + "]" + failed := run(t, atFloor, "important") + if !failed.GateFailed { + t.Fatalf("GateFailed = false, want a failing gate") + } + if want := "address open threads"; failed.Next != want { + t.Errorf("Next = %q, want %q", failed.Next, want) + } + if got, want := failed.Human[len(failed.Human)-1], "next: address open threads"; got != want { + t.Errorf("human footer = %q, want %q", got, want) + } +} + // TestRunReportCompletenessGate pins the HEAD-reviewed dimension: a matching // post passes, and a missing, head-less, or stale post fails with its typed // line naming the re-fetch command. The combined case proves one run fails on diff --git a/internal/core/report/render.go b/internal/core/report/render.go index b691540a..34e538a8 100644 --- a/internal/core/report/render.go +++ b/internal/core/report/render.go @@ -16,6 +16,15 @@ import ( ) func buildResponse(st *state) *core.ReportResponse { + // The gate runs first: next and the human footer name the merge when the + // requested check passes, so both surfaces read the same result. + var gateFailed bool + var checkLines []string + var gate *core.ReportGate + if st.gate { + gateFailed, checkLines, gate = gateTail(st) + st.gatePassed = !gateFailed + } resp := &core.ReportResponse{ Repo: st.req.Repo, Pr: st.req.Pr, @@ -32,21 +41,31 @@ func buildResponse(st *state) *core.ReportResponse { resp.Data.ProvenanceTruncated = provenance.MergeTruncated(st.provenance, readcommon.BundleTruncation(st.dir)) } if st.gate { - resp.GateFailed, resp.CheckLines, resp.Data.Gate = gateTail(st) + resp.GateFailed, resp.CheckLines, resp.Data.Gate = gateFailed, checkLines, gate } return resp } -func reportNext(st *state) string { - if st.flags.Output != "" { - return "wrote " + st.flags.Output +// nextStep names the next action from the open count, overridden by a passing +// --check gate: findings below the tier's floor do not stand between the run +// and a merge. +func nextStep(st *state, open int) string { + if st.flags.Check != "" && st.gatePassed { + return "merge — gate passes" } - if viewOpen(viewRanked(st)) > 0 { + if open > 0 { return "address open threads" } return "none open — nothing to address" } +func reportNext(st *state) string { + if st.flags.Output != "" { + return "wrote " + st.flags.Output + } + return nextStep(st, viewOpen(viewRanked(st))) +} + func buildData(st *state) *core.ReportData { data := &core.ReportData{ Verification: panelcore.Summarize(st.entries), @@ -289,10 +308,7 @@ func finalizeHuman(st *state, view []readcommon.Ranked, lines []string) []string // The footer follows the view the header reports: with a display floor the // rendered list can be empty while the store still holds open findings, and // "address open threads" beside "(0 shown) open=0" read as a contradiction. - if viewOpen(view) > 0 { - return append(lines, "next: address open threads") - } - return append(lines, "next: none open — nothing to address") + return append(lines, "next: "+nextStep(st, viewOpen(view))) } func appendHumanTail(st *state, lines []string) []string { diff --git a/internal/core/report/service.go b/internal/core/report/service.go index bc1c78b0..f478c128 100644 --- a/internal/core/report/service.go +++ b/internal/core/report/service.go @@ -92,6 +92,7 @@ type state struct { // field grouping documents the loaded dimensions; alignment nOpen int nAllOpen int gate bool + gatePassed bool liveGate bool compOK bool } From d459edcdca33c54c8a5c89eed80de8244c9f2be9 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:15:51 +0200 Subject: [PATCH 05/15] fix(provenance): leave a body with no quote lead alone --- .changeset/sta-425-basis-plain-body.md | 8 +++++ docs/manual.md | 46 ++++++++++++++------------ internal/core/record/basis_test.go | 28 ++++++++++++++++ internal/provenance/basis.go | 7 +++- internal/provenance/provenance_test.go | 11 ++++++ 5 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 .changeset/sta-425-basis-plain-body.md create mode 100644 internal/core/record/basis_test.go diff --git a/.changeset/sta-425-basis-plain-body.md b/.changeset/sta-425-basis-plain-body.md new file mode 100644 index 00000000..ea9fb084 --- /dev/null +++ b/.changeset/sta-425-basis-plain-body.md @@ -0,0 +1,8 @@ +--- +"@stainless-code/verdict": patch +--- + +**No false `basis-replaced` warning** — a `review.json` body with no leading +quote block has no confidence lead to insert a Basis line under, so `record` +leaves it byte-identical and reports nothing instead of warning that it +inserted a line it did not insert. diff --git a/docs/manual.md b/docs/manual.md index fe2d619f..cc9459f2 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -239,28 +239,30 @@ an unparsable or non-object document, a comment with no recoverable string coverage still refuses. `record --dry-run` adds `data.normalized` (the exact object the checker read) and `data.repairs`; verdict never rewrites `review.json` on disk. The CLI also owns the body's `> Basis:` line: it -replaces a disagreeing line, or inserts a missing one, with the counts computed -from the review and reports `basis-replaced`. - -| Code | Level | Meaning | -| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ | -| `invalid-json` | error | The file is not one JSON document; the message carries line:col, and the fix is to emit only the object. | -| `wrong-type` | mixed | Error for a wrong type; warning for a non-numeric line/start_line or a fenced suggestion. | -| `missing-field` | mixed | Error for a required field; warning for missing schema_version, comments, or line/start_line. | -| `bad-enum` | mixed | Error for an unknown closed-set value; warning for a malformed KB id or unknown chunk name. | -| `out-of-range` | error | A length or numeric bound is outside its published range (confidence, brief approach/question, caps). | -| `path-not-in-diff` | mixed | Error for a comment path; warning for a brief site outside the diff. | -| `unknown-field` | warning | A key is not in the published shape; the fix names the nearest known key. | -| `risk-stale-head` | warning | `review.json.risk.assessed_head` disagrees with the bundle's current HEAD SHA; the stored claim is marked `stale: true`. | -| `anchor-outside-hunk` | warning | The line is provably outside every hunk; `record` moves the comment into the body. | -| `rigor-unset` | warning | A comment carries no evidence rung; it records as `said` with `rigor_source: default`. | -| `normalized-fence` | warning | One whole-document code fence was unwrapped. | -| `normalized-extracted` | warning | Prose around exactly one balanced JSON object was dropped. | -| `scalar-to-array` | warning | A scalar where a string array belongs was wrapped in a one-element array. | -| `key-alias` | warning | A known alias (`inBounds`, `in_bounds`, `rung`, `file`) was renamed to its canonical key. | -| `enum-synonym` | warning | A rigor synonym or a case-folded enum value was rewritten to the published value. | -| `normalized-trivia` | warning | A BOM, an explicit null on an optional key, or an exact-duplicate comment was removed. | -| `basis-replaced` | warning | The body's `> Basis:` line disagreed with the computed counts, or was missing from the leading quote block, and the CLI replaced it. | +replaces a disagreeing line, or inserts a missing one under the leading quote +block's confidence lead, with the counts computed from the review and reports +`basis-replaced`. A body with no leading quote block has no lead to insert +under, so it stays byte-identical and reports nothing. + +| Code | Level | Meaning | +| ---------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| `invalid-json` | error | The file is not one JSON document; the message carries line:col, and the fix is to emit only the object. | +| `wrong-type` | mixed | Error for a wrong type; warning for a non-numeric line/start_line or a fenced suggestion. | +| `missing-field` | mixed | Error for a required field; warning for missing schema_version, comments, or line/start_line. | +| `bad-enum` | mixed | Error for an unknown closed-set value; warning for a malformed KB id or unknown chunk name. | +| `out-of-range` | error | A length or numeric bound is outside its published range (confidence, brief approach/question, caps). | +| `path-not-in-diff` | mixed | Error for a comment path; warning for a brief site outside the diff. | +| `unknown-field` | warning | A key is not in the published shape; the fix names the nearest known key. | +| `risk-stale-head` | warning | `review.json.risk.assessed_head` disagrees with the bundle's current HEAD SHA; the stored claim is marked `stale: true`. | +| `anchor-outside-hunk` | warning | The line is provably outside every hunk; `record` moves the comment into the body. | +| `rigor-unset` | warning | A comment carries no evidence rung; it records as `said` with `rigor_source: default`. | +| `normalized-fence` | warning | One whole-document code fence was unwrapped. | +| `normalized-extracted` | warning | Prose around exactly one balanced JSON object was dropped. | +| `scalar-to-array` | warning | A scalar where a string array belongs was wrapped in a one-element array. | +| `key-alias` | warning | A known alias (`inBounds`, `in_bounds`, `rung`, `file`) was renamed to its canonical key. | +| `enum-synonym` | warning | A rigor synonym or a case-folded enum value was rewritten to the published value. | +| `normalized-trivia` | warning | A BOM, an explicit null on an optional key, or an exact-duplicate comment was removed. | +| `basis-replaced` | warning | The body's `> Basis:` line disagreed with the computed counts and was replaced, or was missing from the leading quote block and was inserted. | ### Sig contract (sig_version 1) diff --git a/internal/core/record/basis_test.go b/internal/core/record/basis_test.go new file mode 100644 index 00000000..d901b7ac --- /dev/null +++ b/internal/core/record/basis_test.go @@ -0,0 +1,28 @@ +package recordcore_test + +import ( + "context" + "strings" + "testing" + + recordcore "github.com/stainless-code/verdict/internal/core/record" +) + +// TestRecordPlainBodySkipsBasisWarning pins item 7: a body with no leading +// quote block has no confidence lead to insert a Basis line under, so record +// leaves the body alone and no warning claims an edit it did not make. +func TestRecordPlainBodySkipsBasisWarning(t *testing.T) { + plain := `{"schema_version":"1","body":"A plain body with enough length to pass the guard, no quote lead.",` + + `"approved":false,"comments":[]}` + bundle(t, "local-plainbody", plain) + c := &collector{} + resp, ref := recordcore.Run(context.Background(), recordRequest(t, c, "local-plainbody")) + if ref != nil { + t.Fatalf("Run refusal: %v", ref) + } + for _, w := range resp.Warnings { + if strings.Contains(w, "Basis line") { + t.Errorf("warnings = %q, want no basis-insertion warning", resp.Warnings) + } + } +} diff --git a/internal/provenance/basis.go b/internal/provenance/basis.go index 38a0e2c5..a008a04c 100644 --- a/internal/provenance/basis.go +++ b/internal/provenance/basis.go @@ -274,9 +274,14 @@ func replaceBasisLine(body string, lines []string, i int, computed, expected str } // insertBasisLine adds the computed Basis line under the confidence lead, -// keeping a blank line before a following heading. +// keeping a blank line before a following heading. A body with no leading quote +// block has no lead to insert under: it stays byte-identical, because a line +// prepended above the verdict callout would break the marker the gate reads. func insertBasisLine(lines []string, computed string) (string, *core.Problem) { at := leadEnd(lines) + if at == 0 { + return strings.Join(lines, newline), nil + } insert := []string{computed} if at < len(lines) { if trimmed := strings.TrimSpace(lines[at]); trimmed != "" && strings.HasPrefix(trimmed, "#") { diff --git a/internal/provenance/provenance_test.go b/internal/provenance/provenance_test.go index 6f185e95..9591fe5e 100644 --- a/internal/provenance/provenance_test.go +++ b/internal/provenance/provenance_test.go @@ -323,6 +323,17 @@ func TestApplyBasisLineInsertsBlankBeforeHeading(t *testing.T) { } } +// TestApplyBasisLineSkipsPlainBody pins item 7: with no leading quote block +// there is no confidence lead to insert under, so the body stays byte-identical +// and no warning claims an edit record did not make. +func TestApplyBasisLineSkipsPlainBody(t *testing.T) { + t.Parallel() + const body = "A plain review body with no quote lead.\n\n## Summary\nReviewed." + if got, p := provenance.ApplyBasisLine("0 0 0 1 0 0 0", body); got != body || p != nil { + t.Fatalf("plain body = %q, %+v; want unchanged without a warning", got, p) + } +} + // TestPlainBasisBelowConfidence accepts matching plain Basis text. func TestPlainBasisBelowConfidence(t *testing.T) { const body = "> Confidence: 3/5\nBasis: 0 0 0 1 0 0 0\n\n## Summary\nReviewed." From e24567b2abb7ecbfe9ba88ce790afaa024392b10 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:24:27 +0200 Subject: [PATCH 06/15] fix(report): demote the local-bundle live skip to an info line A local bundle always skips the live read; warning about it made a clean local report look degraded. The skip stays in the typed gate dimension, and a failed remote read still warns. --- .changeset/sta-425-local-skip-info.md | 8 ++++ apps/docs/pages/_home/HowItWorks.astro | 4 +- docs/manual.md | 11 ++--- evals/cases/live-offline-contract.sh | 3 +- evals/cases/live-recheck-report.sh | 3 +- internal/core/report/gate_test.go | 45 ++++++++++++++++--- internal/core/report/live.go | 2 +- .../testdata/report/local-check-json.golden | 7 ++- 8 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 .changeset/sta-425-local-skip-info.md diff --git a/.changeset/sta-425-local-skip-info.md b/.changeset/sta-425-local-skip-info.md new file mode 100644 index 00000000..76bab2a1 --- /dev/null +++ b/.changeset/sta-425-local-skip-info.md @@ -0,0 +1,8 @@ +--- +"@stainless-code/verdict": patch +--- + +**Quiet local `report`** — a local bundle's live recheck is a structural skip, +so `report` now prints one `info:` line on the human stream instead of warning +about it. The skip stays out of `--json` `warnings[]`; a failed live read on a +remote bundle still warns. diff --git a/apps/docs/pages/_home/HowItWorks.astro b/apps/docs/pages/_home/HowItWorks.astro index 729835ed..99131e02 100644 --- a/apps/docs/pages/_home/HowItWorks.astro +++ b/apps/docs/pages/_home/HowItWorks.astro @@ -24,8 +24,8 @@ const sample = [ { kind: "out", text: " 878a93e0 open true src/retry.ts" }, { kind: "cmd", text: "verdict report acme/app local-work --check important" }, { - kind: "dim", - text: "warn: live recheck skipped: local bundle threads unreadable here (gating on local dimensions only)", + kind: "out", + text: "info: live recheck skipped: local bundle threads unreadable here (gating on local dimensions only)", }, { kind: "out", text: "report: .verdict/state/local-work (1 shown) open=1 head=" }, { kind: "out", text: "1. [open] src/retry.ts:3 (878a93e0)" }, diff --git a/docs/manual.md b/docs/manual.md index cc9459f2..525e6e10 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -1388,11 +1388,12 @@ a read that stopped before the host's last page, both leave the surface unread rather than clean: each warns (`live thread recheck unreachable`) and, under the default `--live auto` posture, leaves the dimension neutral: the gate reflects local dimensions only, and the run never exits 3 over the -network. Only local bundles skip the lookup with a warn (`live recheck -skipped: ...`), paying zero network; plain `report` without a gate flag -never calls the network. There is no `--force` on report: fetch + triage + -re-check is the recovery, and advisory `report` without `--check` is the -escape hatch. +network. Only local bundles skip the lookup, paying zero network; they say +so with an `info: live recheck skipped: ...` line on the human stream, never +a warning or a `--json` `warnings[]` entry. Plain `report` without a gate +flag never calls the network. There is no `--force` on report: fetch + +triage + re-check is the recovery, and advisory `report` without `--check` +is the escape hatch. Offline posture (`--live auto|strict|skip`, gate runs only) is always an explicit operator choice — automation never inherits it silently. `auto` diff --git a/evals/cases/live-offline-contract.sh b/evals/cases/live-offline-contract.sh index 8a9fcf06..5d583189 100755 --- a/evals/cases/live-offline-contract.sh +++ b/evals/cases/live-offline-contract.sh @@ -138,7 +138,8 @@ if [ "$EVAL_STATUS" -eq 0 ]; then else bad "strict local exits $EVAL_STATUS, want 0" fi -assert_file_grep "local skip warns structurally" "$EVAL_ERR" "live recheck skipped" +assert_file_grep "local skip notes the structural skip on the human stream" "$EVAL_OUT" "info: live recheck skipped" +assert_stream_nogrep "local skip adds no structural warning" "$EVAL_ERR" "live recheck skipped" assert_stream_nogrep "local skip prints no fail-closed line" "$EVAL_ERR" "offline posture is strict" assert_eq "local skip pays zero graphql calls" "0" "$(graphql_since "$m")" diff --git a/evals/cases/live-recheck-report.sh b/evals/cases/live-recheck-report.sh index a65f442d..bcf263d5 100755 --- a/evals/cases/live-recheck-report.sh +++ b/evals/cases/live-recheck-report.sh @@ -273,7 +273,8 @@ if [ "$EVAL_STATUS" -eq 0 ]; then else bad "local skip exits $EVAL_STATUS, want 0" fi -assert_file_grep "local run warn-skips" "$EVAL_ERR" "live recheck skipped" +assert_file_grep "local run notes the skip on the human stream" "$EVAL_OUT" "info: live recheck skipped" +assert_stream_nogrep "local run adds no skip warning" "$EVAL_ERR" "live recheck skipped" assert_stream_nogrep "local run prints no fetch-local noise" "$EVAL_ERR" "fetch-local" "-i" assert_stream_nogrep "local run prints no live open line" "$EVAL_ERR" "live open" assert_eq "local run makes zero recheck calls" "0" "$(graphql_since "$m")" diff --git a/internal/core/report/gate_test.go b/internal/core/report/gate_test.go index 8df4e5df..f09c4d69 100644 --- a/internal/core/report/gate_test.go +++ b/internal/core/report/gate_test.go @@ -439,9 +439,19 @@ func TestRunReportLiveGate(t *testing.T) { } } +type liveProgress struct { + human []string + warnings []string +} + +func (p *liveProgress) Human(line string) { p.human = append(p.human, line) } +func (p *liveProgress) Warn(msg string) { p.warnings = append(p.warnings, msg) } +func (p *liveProgress) Diag(_ string) {} + // TestRunReportLocalBundleLiveSkip pins the structural skip: a local bundle -// has no live threads to verify, so every posture reads neutral with a warn -// and zero network. +// has no live threads to verify, so every posture reads neutral with zero +// network and no warning — a step report always takes is not noise. The typed +// gate dimension still records the skip. func TestRunReportLocalBundleLiveSkip(t *testing.T) { dir := t.TempDir() t.Chdir(dir) @@ -450,8 +460,9 @@ func TestRunReportLocalBundleLiveSkip(t *testing.T) { writeFile(t, ".verdict/state/local-gate/findings.json", "["+ entryJSON("1111111111111111111111111111111111111111", "inline", "open", `"important"`, "true")+"]") cmd := &threadCommander{stdout: threadsPage(4, 0)} + progress := &liveProgress{} req := core.ReadRequest{ - Runtime: &core.Runtime{Now: func() time.Time { return fixedNow }, Commander: cmd}, + Runtime: &core.Runtime{Now: func() time.Time { return fixedNow }, Commander: cmd, Progress: progress}, Repo: "acme/app", Pr: "local-gate", } resp, ref := reportcore.Run(context.Background(), &core.ReportRequest{ @@ -464,12 +475,36 @@ func TestRunReportLocalBundleLiveSkip(t *testing.T) { if cmd.calls != 0 { t.Errorf("commander calls = %d; a local bundle pays zero network", cmd.calls) } - if !containsLine(resp.Warnings, "live recheck skipped: local bundle threads unreadable here (gating on local dimensions only)") { - t.Errorf("Warnings = %q, want the local-bundle skip notice", resp.Warnings) + wantInfo := "info: live recheck skipped: local bundle threads unreadable here (gating on local dimensions only)" + if !containsLine(progress.human, wantInfo) { + t.Errorf("human stream = %q, want %q", progress.human, wantInfo) + } + if containsLine(resp.Warnings, "live recheck skipped") { + t.Errorf("Warnings = %q, want no warning for the structural local-bundle skip", resp.Warnings) + } + if containsLine(progress.warnings, "live recheck skipped") { + t.Errorf("warning stream = %q, want no structural skip warning", progress.warnings) } if containsLine(resp.CheckLines, "live open thread(s)") { t.Errorf("CheckLines = %q, want no live-thread verdict line", resp.CheckLines) } + if got := liveDimensionStatus(resp); got != "skip" { + t.Errorf("live dimension status = %q, want skip", got) + } +} + +// liveDimensionStatus reads the typed live_threads dimension's status, empty +// when the gate carries none. +func liveDimensionStatus(resp *core.ReportResponse) string { + if resp.Data.Gate == nil { + return "" + } + for _, d := range resp.Data.Gate.Dimensions { + if d.ID == "live_threads" { + return d.Status + } + } + return "" } func containsLine(lines []string, want string) bool { diff --git a/internal/core/report/live.go b/internal/core/report/live.go index 66baad15..b6e5d3be 100644 --- a/internal/core/report/live.go +++ b/internal/core/report/live.go @@ -36,7 +36,7 @@ func runLiveProbe(ctx context.Context, st *state) { st.warn("live recheck skipped (--live skip requested — gating on local dimensions only)") st.live.status = liveSkipExplicit case isLocalDir(st.dir): - st.warn("live recheck skipped: local bundle threads unreadable here (gating on local dimensions only)") + st.req.Human("info: live recheck skipped: local bundle threads unreadable here (gating on local dimensions only)") st.live.status = liveSkip default: probeLiveCount(ctx, st) diff --git a/internal/readgolden/testdata/report/local-check-json.golden b/internal/readgolden/testdata/report/local-check-json.golden index 0b4a6e72..641ffcb4 100644 --- a/internal/readgolden/testdata/report/local-check-json.golden +++ b/internal/readgolden/testdata/report/local-check-json.golden @@ -6,10 +6,9 @@ exit: 0 "repo": "acme/app", "pr": null, "at": "0000-00-00T00:00:00Z", - "next": "address open threads", + "next": "merge — gate passes", "warnings": [ - "run bundle has no typed evidence (pre-typed bundle?) — rendering without policy floors", - "live recheck skipped: local bundle threads unreadable here (gating on local dimensions only)" + "run bundle has no typed evidence (pre-typed bundle?) — rendering without policy floors" ], "data": { "generated_at": "0000-00-00T00:00:00Z", @@ -105,6 +104,6 @@ exit: 0 } --- stderr --- warn: run bundle has no typed evidence (pre-typed bundle?) — rendering without policy floors -warn: live recheck skipped: local bundle threads unreadable here (gating on local dimensions only) +info: live recheck skipped: local bundle threads unreadable here (gating on local dimensions only) check: no open findings at-or-above critical — gate passes --- files --- From c3b8560ecb60acccc8d490b83971c281c6e751f8 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:25:11 +0200 Subject: [PATCH 07/15] test(golden): refresh passing gate next lines The three sibling report goldens still held the pre-f0a4497 next line; -update regenerated them when the local-skip golden moved. --- internal/readgolden/testdata/report/check-critical-pass.golden | 2 +- .../readgolden/testdata/report/live-auto-unreachable.golden | 2 +- internal/readgolden/testdata/report/live-skip.golden | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/readgolden/testdata/report/check-critical-pass.golden b/internal/readgolden/testdata/report/check-critical-pass.golden index be908846..3779e7b2 100644 --- a/internal/readgolden/testdata/report/check-critical-pass.golden +++ b/internal/readgolden/testdata/report/check-critical-pass.golden @@ -3,7 +3,7 @@ exit: 0 report: .verdict/state/5102 (1 shown) open=1 head=aaaaaaa 1. [open] notes.txt:2 (a3333333) by category: untagged 1 -next: address open threads +next: merge — gate passes --- stderr --- warn: patch identity unavailable — completeness compares heads warn: run bundle has no typed evidence (pre-typed bundle?) — rendering without policy floors diff --git a/internal/readgolden/testdata/report/live-auto-unreachable.golden b/internal/readgolden/testdata/report/live-auto-unreachable.golden index dcaa1350..6623a000 100644 --- a/internal/readgolden/testdata/report/live-auto-unreachable.golden +++ b/internal/readgolden/testdata/report/live-auto-unreachable.golden @@ -3,7 +3,7 @@ exit: 0 report: .verdict/state/5102 (1 shown) open=1 head=aaaaaaa 1. [open] notes.txt:2 (a3333333) by category: untagged 1 -next: address open threads +next: merge — gate passes --- stderr --- warn: run bundle has no typed evidence (pre-typed bundle?) — rendering without policy floors warn: live thread recheck unreachable (evals-stub-gh: network disabled (api graphql --paginate -F owner=acme -F name=app -F pr=5102 -f query= query($owne — gating on local dimensions only) diff --git a/internal/readgolden/testdata/report/live-skip.golden b/internal/readgolden/testdata/report/live-skip.golden index e50d087a..c6493a34 100644 --- a/internal/readgolden/testdata/report/live-skip.golden +++ b/internal/readgolden/testdata/report/live-skip.golden @@ -3,7 +3,7 @@ exit: 0 report: .verdict/state/5102 (1 shown) open=1 head=aaaaaaa 1. [open] notes.txt:2 (a3333333) by category: untagged 1 -next: address open threads +next: merge — gate passes --- stderr --- warn: run bundle has no typed evidence (pre-typed bundle?) — rendering without policy floors warn: live recheck skipped (--live skip requested — gating on local dimensions only) From 009852192d299510cfa4e1532e039eff55bc7fc0 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:28:31 +0200 Subject: [PATCH 08/15] fix(record): stop warning on omitted schema_version The key is optional and reads as 1, so a valid review.json that leaves it out now records quietly. A present value other than "1" still refuses, including a non-string one. --- .changeset/sta-425-optional-schema-version.md | 7 +++++ docs/manual.md | 7 ++--- internal/core/record/checkreview.go | 12 +++------ internal/core/record/checkreview_test.go | 20 ++++++++++++-- internal/core/record/merge.go | 10 ++++--- internal/core/record/schemaversion_test.go | 27 +++++++++++++++++++ internal/schemagen/overlay.json | 4 +-- internal/schemagen/semantics_test.go | 4 ++- .../testdata/baseline/review.schema.json | 4 +-- pkg/verdict/check_example_test.go | 1 - skills/verdict/schemas/review.schema.json | 4 +-- 11 files changed, 74 insertions(+), 26 deletions(-) create mode 100644 .changeset/sta-425-optional-schema-version.md create mode 100644 internal/core/record/schemaversion_test.go diff --git a/.changeset/sta-425-optional-schema-version.md b/.changeset/sta-425-optional-schema-version.md new file mode 100644 index 00000000..ff299f17 --- /dev/null +++ b/.changeset/sta-425-optional-schema-version.md @@ -0,0 +1,7 @@ +--- +"@stainless-code/verdict": patch +--- + +**Optional `schema_version`** — `record` no longer warns that a valid +`review.json` omits `schema_version`, which it reads as version 1. A present +value other than `"1"` still refuses. diff --git a/docs/manual.md b/docs/manual.md index 525e6e10..29ec74ef 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -248,7 +248,7 @@ under, so it stays byte-identical and reports nothing. | ---------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | `invalid-json` | error | The file is not one JSON document; the message carries line:col, and the fix is to emit only the object. | | `wrong-type` | mixed | Error for a wrong type; warning for a non-numeric line/start_line or a fenced suggestion. | -| `missing-field` | mixed | Error for a required field; warning for missing schema_version, comments, or line/start_line. | +| `missing-field` | mixed | Error for a required field; warning for missing comments or line/start_line. | | `bad-enum` | mixed | Error for an unknown closed-set value; warning for a malformed KB id or unknown chunk name. | | `out-of-range` | error | A length or numeric bound is outside its published range (confidence, brief approach/question, caps). | | `path-not-in-diff` | mixed | Error for a comment path; warning for a brief site outside the diff. | @@ -279,8 +279,9 @@ previous merge filled a missing rung with `pointed`, and every other recognized reads as `model`. A review that explicitly wrote `pointed` is indistinguishable from a default-filled one, so those entries read as `default` either way. Changing the normalization orphans history — that ships as a new `sig_version`, never silently. -`review.json` inputs stamp `schema_version: "1"` (`post`/`record` refuse unknown -versions, warn-and-proceed when the stamp is missing); every bundle carries +`review.json` inputs stamp `schema_version: "1"` (`post`/`record` refuse a +present value other than `"1"`; an absent key reads as 1 without a warning); +every bundle carries `.verdict/state/N/store.json` (`{"schema_version":"1"}`) marking the generation of the whole store — plugins read it instead of sniffing shapes. GitHub bundles keep `PR.json`/`reviews.json`/`inline.json` as raw API output (GitHub's schema, diff --git a/internal/core/record/checkreview.go b/internal/core/record/checkreview.go index 0daa8611..cd238fc3 100644 --- a/internal/core/record/checkreview.go +++ b/internal/core/record/checkreview.go @@ -248,11 +248,6 @@ func (c *checker) checkReview(obj *jq.Obj) { "write \"comments\": []", []any{})) } c.checkBodyQuality(obj) - if _, ok := obj.Get("schema_version"); !ok { - c.add(c.problem(problemSchemaVersion, core.ProblemCodeMissingField, core.ProblemLevelWarning, - "schema_version is missing; assuming 1", - "write \"schema_version\": \"1\"", schemaVersion1)) - } if c.hasChunks { if _, ok := obj.Get(fieldChunks); !ok { c.unattestedChunks() @@ -261,10 +256,9 @@ func (c *checker) checkReview(obj *jq.Obj) { } func (c *checker) checkSchemaVersion(v any) { - if v == nil || v == false { - c.add(c.problem(problemSchemaVersion, core.ProblemCodeMissingField, core.ProblemLevelWarning, - "schema_version is missing; assuming 1", - "write \"schema_version\": \"1\"", schemaVersion1)) + // An absent key reads as 1, the assumption record already makes after the + // checker; a present value has to say 1 explicitly. + if v == nil { return } s, ok := v.(string) diff --git a/internal/core/record/checkreview_test.go b/internal/core/record/checkreview_test.go index af6ce32c..40a6dcc2 100644 --- a/internal/core/record/checkreview_test.go +++ b/internal/core/record/checkreview_test.go @@ -199,8 +199,14 @@ func TestCheckReviewCoversBundleInputs(t *testing.T) { path string }{ { - name: "schema-missing", json: `{"body":"` + checkBody + `","approved":false}`, - code: core.ProblemCodeMissingField, level: core.ProblemLevelWarning, path: "$.schema_version", + name: "schema-version-wrong-type", + json: `{"schema_version":false,"body":"` + checkBody + `","approved":false,"comments":[]}`, + code: core.ProblemCodeWrongType, level: core.ProblemLevelError, path: "$.schema_version", + }, + { + name: "schema-version-wrong-value", + json: `{"schema_version":"2","body":"` + checkBody + `","approved":false,"comments":[]}`, + code: core.ProblemCodeBadEnum, level: core.ProblemLevelError, path: "$.schema_version", }, { name: "brief-outcome-missing", json: comment(`,"brief":{"sites":[]}`), @@ -320,6 +326,16 @@ func TestCheckReviewCountsTruncatedLevels(t *testing.T) { } } +// TestCheckReviewAcceptsMissingSchemaVersion pins item 5: schema_version is +// optional and assumed 1, so omitting it is not a warning. +func TestCheckReviewAcceptsMissingSchemaVersion(t *testing.T) { + t.Parallel() + res := recordcore.CheckReview([]byte(`{"body":"`+checkBody+`","approved":false,"comments":[]}`), checkDiff) + if len(res.Problems) != 0 || res.Warnings != 0 { + t.Fatalf("problems = %+v (warnings %d), want none for an omitted optional key", res.Problems, res.Warnings) + } +} + // TestCheckReviewMissingComments proves the schema-required comments key is // reported instead of silently accepted. func TestCheckReviewMissingComments(t *testing.T) { diff --git a/internal/core/record/merge.go b/internal/core/record/merge.go index b826a714..f878cee2 100644 --- a/internal/core/record/merge.go +++ b/internal/core/record/merge.go @@ -122,7 +122,7 @@ func (st *state) validateAndMerge(body string) (string, diagram.Status, error) { st.loadKB() readcommon.WarnContextSources(st.dir, st.review, st.warn) st.kb.Staged = []map[string]any{} - if err := checkReviewSchema(st.warnInput, st.review); err != nil { + if err := checkReviewSchema(st.review); err != nil { return "", diagram.Status{}, err } if err := st.validateInputs(); err != nil { @@ -296,10 +296,12 @@ func validJSON(raw []byte) bool { return err == nil } -func checkReviewSchema(warn func(string), review *jq.Obj) error { +func checkReviewSchema(review *jq.Obj) error { + if review == nil { + return nil + } rv, has := review.Get("schema_version") - if review == nil || !has || rv == nil || rv == false { - warn("review.json carries no schema_version — assuming 1 (agents: write \"schema_version\":\"1\")") + if !has || rv == nil { return nil } if s := jq.R(rv); s == schemaVersion1 { diff --git a/internal/core/record/schemaversion_test.go b/internal/core/record/schemaversion_test.go new file mode 100644 index 00000000..b0d17188 --- /dev/null +++ b/internal/core/record/schemaversion_test.go @@ -0,0 +1,27 @@ +package recordcore_test + +import ( + "context" + "strings" + "testing" + + recordcore "github.com/stainless-code/verdict/internal/core/record" +) + +// TestRecordOmitsSchemaVersionWarning pins item 5 at the verb: a valid +// review.json without the optional schema_version records cleanly, with no +// warning about the key the CLI assumes. +func TestRecordOmitsSchemaVersionWarning(t *testing.T) { + review := `{"body":"> [!IMPORTANT]\n> Record service check with enough length.","approved":false,"comments":[]}` + bundle(t, "local-noschema", review) + c := &collector{} + resp, ref := recordcore.Run(context.Background(), recordRequest(t, c, "local-noschema")) + if ref != nil { + t.Fatalf("Run refusal: %v", ref) + } + for _, w := range resp.Warnings { + if strings.Contains(w, "schema_version") { + t.Errorf("warnings = %q, want none about the optional schema_version", resp.Warnings) + } + } +} diff --git a/internal/schemagen/overlay.json b/internal/schemagen/overlay.json index 898da93c..946cab64 100644 --- a/internal/schemagen/overlay.json +++ b/internal/schemagen/overlay.json @@ -453,8 +453,8 @@ }, "review": { "descriptions": { - "": "What the agent writes and post/record validate. One checker reports every problem: error refuses; warning lets record proceed and is promoted by --strict/strict_input. Errors: schema_version other than 1, missing/non-string/degenerate body, non-boolean approved, non-array comments or non-object items, comment path missing/non-string/not in diff, line/start_line wrong type, side wrong type or not RIGHT/LEFT, missing body, non-string suggestion, brief outcome/site/approach/question shape or range failures, rigor/severity wrong type or unknown, non-boolean in-bounds, kb non-array/non-string, resolved/triage/sections shape and enums, confidence non-integer or outside 1-5, non-string security_summary, malformed or partial chunks, and malformed verification claims. Warnings: missing schema_version, missing comments, no line/start_line, anchor outside hunks, unknown fields, unset rigor, an unknown or non-string category (warns once, stores null), brief site outside hunks, fenced suggestion, malformed kb id, and unknown or unattested chunks. Unknown top-level keys are allowed by the schema but still warn.", - "/properties/schema_version": "Agents stamp \"1\"; missing warns, any other value refuses.", + "": "What the agent writes and post/record validate. One checker reports every problem: error refuses; warning lets record proceed and is promoted by --strict/strict_input. An absent schema_version reads as 1; any other value refuses. Errors: schema_version other than 1, missing/non-string/degenerate body, non-boolean approved, non-array comments or non-object items, comment path missing/non-string/not in diff, line/start_line wrong type, side wrong type or not RIGHT/LEFT, missing body, non-string suggestion, brief outcome/site/approach/question shape or range failures, rigor/severity wrong type or unknown, non-boolean in-bounds, kb non-array/non-string, resolved/triage/sections shape and enums, confidence non-integer or outside 1-5, non-string security_summary, malformed or partial chunks, and malformed verification claims. Warnings: missing comments, no line/start_line, anchor outside hunks, unknown fields, unset rigor, an unknown or non-string category (warns once, stores null), brief site outside hunks, fenced suggestion, malformed kb id, and unknown or unattested chunks. Unknown top-level keys are allowed by the schema but still warn.", + "/properties/schema_version": "Agents stamp \"1\"; an absent key reads as 1, any other value refuses.", "/properties/body": "Full review text, verdict marker first line. Missing, non-string, or degenerate text (<20 chars with no verdict marker, or a short placeholder) refuses.", "/properties/approved": "Binding ask; the CLI --bind/--request-changes flags win over this. A non-boolean refuses.", "/properties/comments": "Inline findings; one per anchor. Missing warns as an empty list; a non-array or non-object item refuses.", diff --git a/internal/schemagen/semantics_test.go b/internal/schemagen/semantics_test.go index e154878e..f8f8dff5 100644 --- a/internal/schemagen/semantics_test.go +++ b/internal/schemagen/semantics_test.go @@ -421,7 +421,9 @@ var publishedSemantics = map[string]string{ // or type changed. // risk score: additive optional nullable risk claim ($defs/riskClaim). No // existing property, required key, enum, or type changed. - "review.schema.json": "58b8cafc67abfc6fe394f0cd7dff77182def6cd6652851e037ded38dc57defbe", + // schema_version optional: descriptions drop the missing-key warning. No + // property, required key, enum, or type changed. + "review.schema.json": "76232c7a9f815c81f2e2115778ebba6f55cc3bdfb9548b6f734effb0ef0cd768", // additive selected.schema.json (new bundle document: the reaction-scoped // fix selection fetch writes and fix --selected reads). A new document // only: no existing schema property, required key, enum, or type changed. diff --git a/internal/schemagen/testdata/baseline/review.schema.json b/internal/schemagen/testdata/baseline/review.schema.json index 295d61d1..55a7d5a5 100644 --- a/internal/schemagen/testdata/baseline/review.schema.json +++ b/internal/schemagen/testdata/baseline/review.schema.json @@ -2,11 +2,11 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://github.com/stainless-code/verdict/blob/main/skills/verdict/schemas/review.schema.json", "title": "review.json — agent-written review input", - "description": "What the agent writes and post/record validate. One checker reports every problem: error refuses; warning lets record proceed and is promoted by --strict/strict_input. Errors: schema_version other than 1, missing/non-string/degenerate body, non-boolean approved, non-array comments or non-object items, comment path missing/non-string/not in diff, line/start_line wrong type, side wrong type or not RIGHT/LEFT, missing body, non-string suggestion, brief outcome/site/approach/question shape or range failures, rigor/severity wrong type or unknown, non-boolean in-bounds, kb non-array/non-string, resolved/triage/sections shape and enums, confidence non-integer or outside 1-5, non-string security_summary, malformed or partial chunks, and malformed verification claims. Warnings: missing schema_version, missing comments, no line/start_line, anchor outside hunks, unknown fields, unset rigor, an unknown or non-string category (warns once, stores null), brief site outside hunks, fenced suggestion, malformed kb id, and unknown or unattested chunks. Unknown top-level keys are allowed by the schema but still warn.", + "description": "What the agent writes and post/record validate. One checker reports every problem: error refuses; warning lets record proceed and is promoted by --strict/strict_input. An absent schema_version reads as 1; any other value refuses. Errors: schema_version other than 1, missing/non-string/degenerate body, non-boolean approved, non-array comments or non-object items, comment path missing/non-string/not in diff, line/start_line wrong type, side wrong type or not RIGHT/LEFT, missing body, non-string suggestion, brief outcome/site/approach/question shape or range failures, rigor/severity wrong type or unknown, non-boolean in-bounds, kb non-array/non-string, resolved/triage/sections shape and enums, confidence non-integer or outside 1-5, non-string security_summary, malformed or partial chunks, and malformed verification claims. Warnings: missing comments, no line/start_line, anchor outside hunks, unknown fields, unset rigor, an unknown or non-string category (warns once, stores null), brief site outside hunks, fenced suggestion, malformed kb id, and unknown or unattested chunks. Unknown top-level keys are allowed by the schema but still warn.", "type": "object", "properties": { "schema_version": { - "description": "Agents stamp \"1\"; missing warns, any other value refuses.", + "description": "Agents stamp \"1\"; an absent key reads as 1, any other value refuses.", "const": "1" }, "body": { diff --git a/pkg/verdict/check_example_test.go b/pkg/verdict/check_example_test.go index 8bbb13de..1817590d 100644 --- a/pkg/verdict/check_example_test.go +++ b/pkg/verdict/check_example_test.go @@ -20,5 +20,4 @@ func ExampleCheckReview() { // error missing-field $.comments[0].brief.outcome // error wrong-type $.comments[0].brief.questions // warning rigor-unset $.comments[0].rigor - // warning missing-field $.schema_version } diff --git a/skills/verdict/schemas/review.schema.json b/skills/verdict/schemas/review.schema.json index 295d61d1..55a7d5a5 100644 --- a/skills/verdict/schemas/review.schema.json +++ b/skills/verdict/schemas/review.schema.json @@ -2,11 +2,11 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://github.com/stainless-code/verdict/blob/main/skills/verdict/schemas/review.schema.json", "title": "review.json — agent-written review input", - "description": "What the agent writes and post/record validate. One checker reports every problem: error refuses; warning lets record proceed and is promoted by --strict/strict_input. Errors: schema_version other than 1, missing/non-string/degenerate body, non-boolean approved, non-array comments or non-object items, comment path missing/non-string/not in diff, line/start_line wrong type, side wrong type or not RIGHT/LEFT, missing body, non-string suggestion, brief outcome/site/approach/question shape or range failures, rigor/severity wrong type or unknown, non-boolean in-bounds, kb non-array/non-string, resolved/triage/sections shape and enums, confidence non-integer or outside 1-5, non-string security_summary, malformed or partial chunks, and malformed verification claims. Warnings: missing schema_version, missing comments, no line/start_line, anchor outside hunks, unknown fields, unset rigor, an unknown or non-string category (warns once, stores null), brief site outside hunks, fenced suggestion, malformed kb id, and unknown or unattested chunks. Unknown top-level keys are allowed by the schema but still warn.", + "description": "What the agent writes and post/record validate. One checker reports every problem: error refuses; warning lets record proceed and is promoted by --strict/strict_input. An absent schema_version reads as 1; any other value refuses. Errors: schema_version other than 1, missing/non-string/degenerate body, non-boolean approved, non-array comments or non-object items, comment path missing/non-string/not in diff, line/start_line wrong type, side wrong type or not RIGHT/LEFT, missing body, non-string suggestion, brief outcome/site/approach/question shape or range failures, rigor/severity wrong type or unknown, non-boolean in-bounds, kb non-array/non-string, resolved/triage/sections shape and enums, confidence non-integer or outside 1-5, non-string security_summary, malformed or partial chunks, and malformed verification claims. Warnings: missing comments, no line/start_line, anchor outside hunks, unknown fields, unset rigor, an unknown or non-string category (warns once, stores null), brief site outside hunks, fenced suggestion, malformed kb id, and unknown or unattested chunks. Unknown top-level keys are allowed by the schema but still warn.", "type": "object", "properties": { "schema_version": { - "description": "Agents stamp \"1\"; missing warns, any other value refuses.", + "description": "Agents stamp \"1\"; an absent key reads as 1, any other value refuses.", "const": "1" }, "body": { From a5765bd006f488db335351eb1883a8670eea3552 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:31:51 +0200 Subject: [PATCH 09/15] test(golden): drop the stale basis-replaced warning The d459edcdc plain-body fix stopped emitting basis-replaced, but this golden was never regenerated; -update removed the two lines that no longer occur. --- internal/record/testdata/degenerate/missing-marker-ok.golden | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/record/testdata/degenerate/missing-marker-ok.golden b/internal/record/testdata/degenerate/missing-marker-ok.golden index 729dd648..8bb4e87a 100644 --- a/internal/record/testdata/degenerate/missing-marker-ok.golden +++ b/internal/record/testdata/degenerate/missing-marker-ok.golden @@ -8,8 +8,7 @@ exit: 0 "at": "0000-00-00T00:00:00Z", "next": "report or triage the local bundle; post stays refused (no PR target)", "warnings": [ - "no fetch-time hunk snapshot (.verdict/state/local-dg/hunks.tsv missing) — rebuilding from full.diff, validation is best-effort (re-fetch to pin the snapshot)", - "$.body: no Basis line in the leading quote block — inserted the computed counts (basis-replaced)" + "no fetch-time hunk snapshot (.verdict/state/local-dg/hunks.tsv missing) — rebuilding from full.diff, validation is best-effort (re-fetch to pin the snapshot)" ], "data": { "dir": ".verdict/state/local-dg", @@ -32,7 +31,6 @@ exit: 0 --- stderr --- warn: no fetch-time hunk snapshot (.verdict/state/local-dg/hunks.tsv missing) — rebuilding from full.diff, validation is best-effort (re-fetch to pin the snapshot) » anchors: 0 inline, 0 moved to body -warn: $.body: no Basis line in the leading quote block — inserted the computed counts (basis-replaced) » findings: 0 sigs -> .verdict/state/local-dg/findings.json recorded: .verdict/state/local-dg/findings.json (0 open) + .verdict/state/local-dg/record.json — report/triage read it; post stays refused (no PR target) --- files --- From c25ea675f73e6d4e6f5fcb8313e4282ec4e2ea5a Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:34:43 +0200 Subject: [PATCH 10/15] chore(lint): scope two cognitive-complexity exemptions revive flags the coverage claim walk and the item-6 gate next test; both keep one pass so every malformed row or both gate legs stay visible together. --- internal/core/coverage/coverage.go | 2 ++ internal/core/report/gate_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/internal/core/coverage/coverage.go b/internal/core/coverage/coverage.go index 5ddf05c0..3e9a6c8e 100644 --- a/internal/core/coverage/coverage.go +++ b/internal/core/coverage/coverage.go @@ -246,6 +246,8 @@ func attestation(files map[string][]Range, claims []claim) map[string][]Range { // parseClaims reads coverage[] and reports whether the key was present. Every // malformed entry warns; none of them silently attests a file. +// +//nolint:revive // one pass reports every malformed entry without splitting the warning tally func parseClaims(review *jq.Obj, warns *[]string) ([]claim, bool, []core.Problem) { if review == nil { return nil, false, nil diff --git a/internal/core/report/gate_test.go b/internal/core/report/gate_test.go index f09c4d69..99a9f1fe 100644 --- a/internal/core/report/gate_test.go +++ b/internal/core/report/gate_test.go @@ -94,6 +94,8 @@ func TestRunReportCheckTierGate(t *testing.T) { // TestRunReportGatePassNextNamesMerge pins item 6: a passing --check gate // names the merge as the next step instead of sending the reviewer to open // threads that sit below the gate's floor. A failing gate keeps the old line. +// +//nolint:revive // the pass and fail legs assert next and footer side by side func TestRunReportGatePassNextNamesMerge(t *testing.T) { run := func(t *testing.T, findings, check string) *core.ReportResponse { t.Helper() From 0b008d1670f5f392b496450d728d8a8d2a4fe446 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:47:10 +0200 Subject: [PATCH 11/15] refactor(coverage): extract claim collection from parseClaims The loop now lives in collectClaims, so revive cognitive complexity passes without a suppression. The ranges field keeps its original over-attestation rationale; the added helper narration is gone. --- internal/core/coverage/coverage.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/core/coverage/coverage.go b/internal/core/coverage/coverage.go index 3e9a6c8e..8706d45d 100644 --- a/internal/core/coverage/coverage.go +++ b/internal/core/coverage/coverage.go @@ -246,8 +246,6 @@ func attestation(files map[string][]Range, claims []claim) map[string][]Range { // parseClaims reads coverage[] and reports whether the key was present. Every // malformed entry warns; none of them silently attests a file. -// -//nolint:revive // one pass reports every malformed entry without splitting the warning tally func parseClaims(review *jq.Obj, warns *[]string) ([]claim, bool, []core.Problem) { if review == nil { return nil, false, nil @@ -261,6 +259,11 @@ func parseClaims(review *jq.Obj, warns *[]string) ([]claim, bool, []core.Problem *warns = append(*warns, msgNotArray) return nil, true, nil } + out, problems := collectClaims(items, warns) + return out, true, problems +} + +func collectClaims(items []any, warns *[]string) ([]claim, []core.Problem) { out := make([]claim, 0, len(items)) var problems []core.Problem for i, item := range items { @@ -272,7 +275,7 @@ func parseClaims(review *jq.Obj, warns *[]string) ([]claim, bool, []core.Problem out = append(out, c) } } - return out, true, problems + return out, problems } // claimAt reads one coverage[] entry, warning and reporting false for an entry @@ -315,8 +318,6 @@ func claimRanges(obj *jq.Obj, file string, i int, warns *[]string) ([]Range, boo } } -// rangesWrongType is the problem record's checker reports for a ranges value -// that is neither a string nor null: one shape, one refusal on every verb. func rangesWrongType(i int) *core.Problem { return &core.Problem{ Path: fmt.Sprintf("$.coverage[%d].ranges", i), @@ -335,9 +336,10 @@ func fieldOf(o *jq.Obj, key string) any { func mustField(o *jq.Obj, key string) any { return fieldOf(o, key) } -// rangeField reads ranges as a trimmed string. A key present as null stays a -// malformed attestation warning; any other non-string refuses with record's -// bad-review-input problem, so an array never measures as a silent 0%. +// rangeField reads ranges as a trimmed string. A key that is present but not a +// string — `null` included — is a malformed attestation, not a whole-file +// claim: attesting more than was written is the one error this package must +// never make, and a claim only widens by saying `all` or omitting the key. func rangeField(o *jq.Obj) (value string, present, wrongType bool) { raw, ok := o.Get(FieldRanges) if !ok { From a91034bd6d0b218a3d69825d4f45d89b7506199d Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:47:52 +0200 Subject: [PATCH 12/15] refactor(report): table the gate-next test legs The pass and fail legs share one table and one assertion helper, so revive cognitive complexity passes without a suppression and both surfaces stay asserted together. --- internal/core/report/gate_test.go | 60 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/internal/core/report/gate_test.go b/internal/core/report/gate_test.go index 99a9f1fe..57e82229 100644 --- a/internal/core/report/gate_test.go +++ b/internal/core/report/gate_test.go @@ -91,45 +91,41 @@ func TestRunReportCheckTierGate(t *testing.T) { } } -// TestRunReportGatePassNextNamesMerge pins item 6: a passing --check gate -// names the merge as the next step instead of sending the reviewer to open -// threads that sit below the gate's floor. A failing gate keeps the old line. -// -//nolint:revive // the pass and fail legs assert next and footer side by side func TestRunReportGatePassNextNamesMerge(t *testing.T) { - run := func(t *testing.T, findings, check string) *core.ReportResponse { - t.Helper() - resp, ref := reportcore.Run(context.Background(), &core.ReportRequest{ - ReadRequest: fixture(t, findings), - Flags: core.ReportFlags{Check: check}, - }) - if ref != nil { - t.Fatalf("Run refusal: %v", ref) - } - return resp - } - below := "[" + entryJSON("1111111111111111111111111111111111111111", "inline", "open", `"informational"`, "true") + "]" - passed := run(t, below, "important") - if passed.GateFailed { - t.Fatalf("GateFailed = true, want a passing gate") - } - if want := "merge — gate passes"; passed.Next != want { - t.Errorf("Next = %q, want %q", passed.Next, want) + atFloor := "[" + entryJSON("2222222222222222222222222222222222222222", "inline", "open", `"important"`, "true") + "]" + tests := []struct { + name string + findings string + wantNext string + gateFailed bool + }{ + {name: "pass", findings: below, wantNext: "merge — gate passes", gateFailed: false}, + {name: "fail", findings: atFloor, wantNext: "address open threads", gateFailed: true}, } - if got, want := passed.Human[len(passed.Human)-1], "next: merge — gate passes"; got != want { - t.Errorf("human footer = %q, want %q", got, want) + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + resp, ref := reportcore.Run(context.Background(), &core.ReportRequest{ + ReadRequest: fixture(t, tc.findings), + Flags: core.ReportFlags{Check: "important"}, + }) + if ref != nil { + t.Fatalf("Run refusal: %v", ref) + } + assertGateNext(t, resp, tc.gateFailed, tc.wantNext) + }) } +} - atFloor := "[" + entryJSON("2222222222222222222222222222222222222222", "inline", "open", `"important"`, "true") + "]" - failed := run(t, atFloor, "important") - if !failed.GateFailed { - t.Fatalf("GateFailed = false, want a failing gate") +func assertGateNext(t *testing.T, resp *core.ReportResponse, gateFailed bool, wantNext string) { + t.Helper() + if resp.GateFailed != gateFailed { + t.Errorf("GateFailed = %v, want %v", resp.GateFailed, gateFailed) } - if want := "address open threads"; failed.Next != want { - t.Errorf("Next = %q, want %q", failed.Next, want) + if resp.Next != wantNext { + t.Errorf("Next = %q, want %q", resp.Next, wantNext) } - if got, want := failed.Human[len(failed.Human)-1], "next: address open threads"; got != want { + if got, want := resp.Human[len(resp.Human)-1], "next: "+wantNext; got != want { t.Errorf("human footer = %q, want %q", got, want) } } From 4b78cc261f67e1c24c72444ed55d748bdfa2030f Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:48:59 +0200 Subject: [PATCH 13/15] chore(comments): drop branch narration The flagged test and helper comments restate what the code says. The published-semantics rationale and the range-field over-attestation why stay. --- cmd/verdict/stdout_contract_test.go | 8 -------- internal/core/record/basis_test.go | 3 --- internal/core/record/checkreview.go | 2 -- internal/core/record/checkreview_test.go | 2 -- internal/core/record/coverage_exempt_test.go | 6 ------ internal/core/record/schemaversion_test.go | 3 --- internal/core/report/coverage_next_test.go | 8 -------- internal/core/report/gate_test.go | 6 ------ internal/core/report/render.go | 5 ----- internal/provenance/basis.go | 4 ---- internal/provenance/provenance_test.go | 3 --- 11 files changed, 50 deletions(-) diff --git a/cmd/verdict/stdout_contract_test.go b/cmd/verdict/stdout_contract_test.go index 671fc501..dc6c70f3 100644 --- a/cmd/verdict/stdout_contract_test.go +++ b/cmd/verdict/stdout_contract_test.go @@ -11,10 +11,6 @@ import ( "testing" ) -// TestJSONVerbsWriteOneEnvelopeToStdout pins the --json contract on the three -// verbs a dogfood loop pipes into jq: stdout carries exactly one JSON value and -// every human line stays on stderr. The fixture is produced by fetch-local, so -// the bundle is the shape record and report read in a real loop. func TestJSONVerbsWriteOneEnvelopeToStdout(t *testing.T) { hermeticEnv(t) root := t.TempDir() @@ -37,8 +33,6 @@ func TestJSONVerbsWriteOneEnvelopeToStdout(t *testing.T) { } } -// assertOneJSONValue decodes stdout once and requires the rest to be -// whitespace: a human line before or after the envelope leaves a second value. func assertOneJSONValue(t *testing.T, verb, out string) { t.Helper() dec := json.NewDecoder(strings.NewReader(out)) @@ -60,8 +54,6 @@ func writeReviewJSON(t *testing.T, path string) { } } -// gitRangeFixture seeds a two-commit repository and returns the range the -// bundle covers. func gitRangeFixture(t *testing.T, dir string) (base, head string) { t.Helper() git := func(args ...string) string { diff --git a/internal/core/record/basis_test.go b/internal/core/record/basis_test.go index d901b7ac..9afc926e 100644 --- a/internal/core/record/basis_test.go +++ b/internal/core/record/basis_test.go @@ -8,9 +8,6 @@ import ( recordcore "github.com/stainless-code/verdict/internal/core/record" ) -// TestRecordPlainBodySkipsBasisWarning pins item 7: a body with no leading -// quote block has no confidence lead to insert a Basis line under, so record -// leaves the body alone and no warning claims an edit it did not make. func TestRecordPlainBodySkipsBasisWarning(t *testing.T) { plain := `{"schema_version":"1","body":"A plain body with enough length to pass the guard, no quote lead.",` + `"approved":false,"comments":[]}` diff --git a/internal/core/record/checkreview.go b/internal/core/record/checkreview.go index cd238fc3..cefae3a6 100644 --- a/internal/core/record/checkreview.go +++ b/internal/core/record/checkreview.go @@ -256,8 +256,6 @@ func (c *checker) checkReview(obj *jq.Obj) { } func (c *checker) checkSchemaVersion(v any) { - // An absent key reads as 1, the assumption record already makes after the - // checker; a present value has to say 1 explicitly. if v == nil { return } diff --git a/internal/core/record/checkreview_test.go b/internal/core/record/checkreview_test.go index 40a6dcc2..062f6220 100644 --- a/internal/core/record/checkreview_test.go +++ b/internal/core/record/checkreview_test.go @@ -326,8 +326,6 @@ func TestCheckReviewCountsTruncatedLevels(t *testing.T) { } } -// TestCheckReviewAcceptsMissingSchemaVersion pins item 5: schema_version is -// optional and assumed 1, so omitting it is not a warning. func TestCheckReviewAcceptsMissingSchemaVersion(t *testing.T) { t.Parallel() res := recordcore.CheckReview([]byte(`{"body":"`+checkBody+`","approved":false,"comments":[]}`), checkDiff) diff --git a/internal/core/record/coverage_exempt_test.go b/internal/core/record/coverage_exempt_test.go index 7a2744d8..cfa2c3e1 100644 --- a/internal/core/record/coverage_exempt_test.go +++ b/internal/core/record/coverage_exempt_test.go @@ -5,18 +5,12 @@ import ( "testing" ) -// generatedTypeScriptDiff changes notes.txt plus a `.gen.ts` path the review -// never names: the shared role heuristic must exempt the second file, so the -// stored receipt risk reads carries no gap for it. const generatedTypeScriptDiff = "diff --git a/notes.txt b/notes.txt\nindex 1111111..2222222 100644\n" + "--- a/notes.txt\n+++ b/notes.txt\n@@ -1,3 +1,3 @@\n top\n-old line\n+new line\n bottom\n" + "diff --git a/clients/ts/src/refusal-codes.gen.ts b/clients/ts/src/refusal-codes.gen.ts\n" + "index 3333333..4444444 100644\n--- a/clients/ts/src/refusal-codes.gen.ts\n" + "+++ b/clients/ts/src/refusal-codes.gen.ts\n@@ -1,3 +1,3 @@\n top\n-old line\n+new line\n bottom\n" -// TestMergeCoverageExemptsGeneratedTypeScript pins the receipt risk reads: -// a `.gen.ts` file left out of coverage[] is exempt, not unattested, so the -// stored gaps stay zero and `unreviewed-files` cannot raise the risk floor. func TestMergeCoverageExemptsGeneratedTypeScript(t *testing.T) { coverageBundle(t, generatedTypeScriptDiff, coverageReview("notes.txt", `"coverage":[{"file":"notes.txt","ranges":"all"}],`)) if ref := runCoverage(t, false, false); ref != nil { diff --git a/internal/core/record/schemaversion_test.go b/internal/core/record/schemaversion_test.go index b0d17188..cffda3ac 100644 --- a/internal/core/record/schemaversion_test.go +++ b/internal/core/record/schemaversion_test.go @@ -8,9 +8,6 @@ import ( recordcore "github.com/stainless-code/verdict/internal/core/record" ) -// TestRecordOmitsSchemaVersionWarning pins item 5 at the verb: a valid -// review.json without the optional schema_version records cleanly, with no -// warning about the key the CLI assumes. func TestRecordOmitsSchemaVersionWarning(t *testing.T) { review := `{"body":"> [!IMPORTANT]\n> Record service check with enough length.","approved":false,"comments":[]}` bundle(t, "local-noschema", review) diff --git a/internal/core/report/coverage_next_test.go b/internal/core/report/coverage_next_test.go index b465cf24..8a8fbdfe 100644 --- a/internal/core/report/coverage_next_test.go +++ b/internal/core/report/coverage_next_test.go @@ -20,8 +20,6 @@ const coverageDiff = "diff --git a/notes.txt b/notes.txt\nindex 1111111..2222222 const generatedDiff = "diff --git a/dist/app.min.js b/dist/app.min.js\nindex 3333333..4444444 100644\n" + "--- a/dist/app.min.js\n+++ b/dist/app.min.js\n@@ -1,3 +1,3 @@\n top\n-old line\n+new line\n bottom\n" -// generatedTypeScriptDiff adds a `.gen.ts` path the review never attests: the -// shared generated predicate must exempt it instead of scoring it unattested. const generatedTypeScriptDiff = coverageDiff + "diff --git a/clients/ts/src/refusal-codes.gen.ts b/clients/ts/src/refusal-codes.gen.ts\n" + "index 3333333..4444444 100644\n--- a/clients/ts/src/refusal-codes.gen.ts\n" + @@ -120,9 +118,6 @@ func TestRunNextCoverageRefusesCorruptReview(t *testing.T) { } } -// TestRunNextCoverageExemptsGeneratedTypeScript pins the prompt's promise on -// the read verb: a `.gen.ts` path omitted from coverage[] is exempt, so it -// neither drags the percentage down nor appears in the unattested list. func TestRunNextCoverageExemptsGeneratedTypeScript(t *testing.T) { req := coverageNextRequest(t, map[string]string{ "full.diff": generatedTypeScriptDiff, @@ -139,9 +134,6 @@ func TestRunNextCoverageExemptsGeneratedTypeScript(t *testing.T) { } } -// TestRunNextCoverageRefusesArrayRanges pins one input contract for -// coverage[].ranges: an array is not a range string, and next must report the -// same bad-review-input problem record does instead of measuring a silent 0%. func TestRunNextCoverageRefusesArrayRanges(t *testing.T) { req := coverageNextRequest(t, coverageFiles(coverageReview("notes.txt", `"coverage":[{"file":"notes.txt","ranges":["1-2"]}],`))) resp, ref := reportcore.RunNextCoverage(req) diff --git a/internal/core/report/gate_test.go b/internal/core/report/gate_test.go index 57e82229..c95b5515 100644 --- a/internal/core/report/gate_test.go +++ b/internal/core/report/gate_test.go @@ -446,10 +446,6 @@ func (p *liveProgress) Human(line string) { p.human = append(p.human, line) } func (p *liveProgress) Warn(msg string) { p.warnings = append(p.warnings, msg) } func (p *liveProgress) Diag(_ string) {} -// TestRunReportLocalBundleLiveSkip pins the structural skip: a local bundle -// has no live threads to verify, so every posture reads neutral with zero -// network and no warning — a step report always takes is not noise. The typed -// gate dimension still records the skip. func TestRunReportLocalBundleLiveSkip(t *testing.T) { dir := t.TempDir() t.Chdir(dir) @@ -491,8 +487,6 @@ func TestRunReportLocalBundleLiveSkip(t *testing.T) { } } -// liveDimensionStatus reads the typed live_threads dimension's status, empty -// when the gate carries none. func liveDimensionStatus(resp *core.ReportResponse) string { if resp.Data.Gate == nil { return "" diff --git a/internal/core/report/render.go b/internal/core/report/render.go index 34e538a8..256b63df 100644 --- a/internal/core/report/render.go +++ b/internal/core/report/render.go @@ -16,8 +16,6 @@ import ( ) func buildResponse(st *state) *core.ReportResponse { - // The gate runs first: next and the human footer name the merge when the - // requested check passes, so both surfaces read the same result. var gateFailed bool var checkLines []string var gate *core.ReportGate @@ -46,9 +44,6 @@ func buildResponse(st *state) *core.ReportResponse { return resp } -// nextStep names the next action from the open count, overridden by a passing -// --check gate: findings below the tier's floor do not stand between the run -// and a merge. func nextStep(st *state, open int) string { if st.flags.Check != "" && st.gatePassed { return "merge — gate passes" diff --git a/internal/provenance/basis.go b/internal/provenance/basis.go index a008a04c..7815970b 100644 --- a/internal/provenance/basis.go +++ b/internal/provenance/basis.go @@ -273,10 +273,6 @@ func replaceBasisLine(body string, lines []string, i int, computed, expected str } } -// insertBasisLine adds the computed Basis line under the confidence lead, -// keeping a blank line before a following heading. A body with no leading quote -// block has no lead to insert under: it stays byte-identical, because a line -// prepended above the verdict callout would break the marker the gate reads. func insertBasisLine(lines []string, computed string) (string, *core.Problem) { at := leadEnd(lines) if at == 0 { diff --git a/internal/provenance/provenance_test.go b/internal/provenance/provenance_test.go index 9591fe5e..7f64e2ae 100644 --- a/internal/provenance/provenance_test.go +++ b/internal/provenance/provenance_test.go @@ -323,9 +323,6 @@ func TestApplyBasisLineInsertsBlankBeforeHeading(t *testing.T) { } } -// TestApplyBasisLineSkipsPlainBody pins item 7: with no leading quote block -// there is no confidence lead to insert under, so the body stays byte-identical -// and no warning claims an edit record did not make. func TestApplyBasisLineSkipsPlainBody(t *testing.T) { t.Parallel() const body = "A plain review body with no quote lead.\n\n## Summary\nReviewed." From 979f22e1335a9dc244a82a2b90c437981408f993 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 15:56:04 +0200 Subject: [PATCH 14/15] changeset: fold the STA-425 fixes into the 0.7.0 notes --- .changeset/03-review-quality-and-provenance.md | 4 ++++ .changeset/11-fixes.md | 2 ++ .changeset/sta-425-basis-plain-body.md | 8 -------- .changeset/sta-425-coverage-ranges.md | 7 ------- .changeset/sta-425-gate-next.md | 8 -------- .changeset/sta-425-generated-exemption.md | 7 ------- .changeset/sta-425-local-skip-info.md | 8 -------- .changeset/sta-425-optional-schema-version.md | 7 ------- 8 files changed, 6 insertions(+), 45 deletions(-) delete mode 100644 .changeset/sta-425-basis-plain-body.md delete mode 100644 .changeset/sta-425-coverage-ranges.md delete mode 100644 .changeset/sta-425-gate-next.md delete mode 100644 .changeset/sta-425-generated-exemption.md delete mode 100644 .changeset/sta-425-local-skip-info.md delete mode 100644 .changeset/sta-425-optional-schema-version.md diff --git a/.changeset/03-review-quality-and-provenance.md b/.changeset/03-review-quality-and-provenance.md index a69c6b69..358cc1f0 100644 --- a/.changeset/03-review-quality-and-provenance.md +++ b/.changeset/03-review-quality-and-provenance.md @@ -25,3 +25,7 @@ - **Validation pass** — a trusted `prompts/validate.md` pass writes `validation.json` per sig, `rigor_policy` floors each severity tier, and `post --require-rigor` narrows it per invocation: advisory by default, a receipted withhold in gate mode. [Rigor floors](docs/manual.md#rigor-floors-and-the-validation-pass) - **Published key names** — `prompts/review.md` tags the evidence rung as `rigor` and the in-bounds flag as `in-bounds`, and an archtest holds every published key to `review.schema.json`. [Rigor floors](docs/manual.md#rigor-floors-and-the-validation-pass) - **Verdict reconciliation** — binding verdicts reconcile separately from summary and inline content, so a retried approval does not duplicate a GitLab summary note. [Submit per host](docs/manual.md#submit-post-per-host) +- **Plain-body Basis line** — `record` leaves a `review.json` body with no leading quote block byte-identical and reports no `basis-replaced` warning, because there is no confidence lead to insert under. [Review-input problems](docs/manual.md#review-input-problems) +- **Array-valued coverage ranges** — `next --coverage` refuses a `coverage[].ranges` array with the same `bad-review-input` problem `record` reports, instead of reading it as a silent 0% attestation. [Diff coverage](docs/manual.md#diff-coverage-agent-attestation) +- **Passing gate next step** — a passing `report --check ` names `merge — gate passes` in the envelope's `next` and human footer, leaving `address open threads` for a failing gate. [Machine surface](docs/manual.md#machine-surface) +- **More generated paths** — `*.gen.*` and `zz_generated.*` now count as generated in the shared role heuristic, so `next --coverage` and the risk floor exempt them like the other generated patterns. [Diff coverage](docs/manual.md#diff-coverage-agent-attestation) diff --git a/.changeset/11-fixes.md b/.changeset/11-fixes.md index ae670180..d96a3896 100644 --- a/.changeset/11-fixes.md +++ b/.changeset/11-fixes.md @@ -15,3 +15,5 @@ - **`pr-wait` inconsistent reads** — a head that is not yet the same on both APIs is retried instead of failing the bounded wait, and `inconsistent_observations` keeps the retry visible. [Bounded foreground waits](docs/manual.md#bounded-foreground-waits) - **Windows watchdog resume** — a command that failed before starting under load retries the thread lookup instead of refusing `resume suspended verify process`. [Bounded foreground waits](docs/manual.md#bounded-foreground-waits) - **`backtest mine` in a partial clone** — a `--filter=blob:none` clone refuses `partial-clone` with the step that fetches the missing objects, instead of stalling. [Backtest](docs/manual.md#backtest-szz-candidates) +- **Quiet local live skip** — a local bundle's live recheck writes one `info:` line to the human stream instead of a warning or a `--json` `warnings[]` entry; failed remote reads still warn. [Machine surface](docs/manual.md#machine-surface) +- **Optional review schema version** — `record` accepts a `review.json` without `schema_version` and reads it as version 1, while a present value other than `"1"` still refuses. [Review-input problems](docs/manual.md#review-input-problems) diff --git a/.changeset/sta-425-basis-plain-body.md b/.changeset/sta-425-basis-plain-body.md deleted file mode 100644 index ea9fb084..00000000 --- a/.changeset/sta-425-basis-plain-body.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@stainless-code/verdict": patch ---- - -**No false `basis-replaced` warning** — a `review.json` body with no leading -quote block has no confidence lead to insert a Basis line under, so `record` -leaves it byte-identical and reports nothing instead of warning that it -inserted a line it did not insert. diff --git a/.changeset/sta-425-coverage-ranges.md b/.changeset/sta-425-coverage-ranges.md deleted file mode 100644 index 87392bc7..00000000 --- a/.changeset/sta-425-coverage-ranges.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@stainless-code/verdict": patch ---- - -**Coverage range shape** — `next --coverage` refuses an array-valued -`coverage[].ranges` with the same `bad-review-input` problem `record` reports, -instead of printing a silent 0% attestation. diff --git a/.changeset/sta-425-gate-next.md b/.changeset/sta-425-gate-next.md deleted file mode 100644 index 6239b5cd..00000000 --- a/.changeset/sta-425-gate-next.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@stainless-code/verdict": patch ---- - -**Gate-passing `next`** — when `report --check ` passes, the envelope's -`next` and the human footer now say `merge — gate passes` instead of -`address open threads`. Findings below the tier's floor no longer read as the -next step. diff --git a/.changeset/sta-425-generated-exemption.md b/.changeset/sta-425-generated-exemption.md deleted file mode 100644 index a1932ee9..00000000 --- a/.changeset/sta-425-generated-exemption.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@stainless-code/verdict": patch ---- - -**Generated-path coverage exemption** — `*.gen.*` and `zz_generated.*` paths -now count as generated in the shared role heuristic, so `next --coverage` and -the risk floor exempt them exactly as the review prompt promises. diff --git a/.changeset/sta-425-local-skip-info.md b/.changeset/sta-425-local-skip-info.md deleted file mode 100644 index 76bab2a1..00000000 --- a/.changeset/sta-425-local-skip-info.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@stainless-code/verdict": patch ---- - -**Quiet local `report`** — a local bundle's live recheck is a structural skip, -so `report` now prints one `info:` line on the human stream instead of warning -about it. The skip stays out of `--json` `warnings[]`; a failed live read on a -remote bundle still warns. diff --git a/.changeset/sta-425-optional-schema-version.md b/.changeset/sta-425-optional-schema-version.md deleted file mode 100644 index ff299f17..00000000 --- a/.changeset/sta-425-optional-schema-version.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@stainless-code/verdict": patch ---- - -**Optional `schema_version`** — `record` no longer warns that a valid -`review.json` omits `schema_version`, which it reads as version 1. A present -value other than `"1"` still refuses. From 907db022a1fd4c4480dd86f8e9db8bd4644b0acc Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 16:10:06 +0200 Subject: [PATCH 15/15] fix(coverage): validate ranges on chunked bundles --- .../03-review-quality-and-provenance.md | 2 +- internal/core/coverage/coverage.go | 23 +++++++++++++------ internal/core/coverage/coverage_test.go | 19 +++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/.changeset/03-review-quality-and-provenance.md b/.changeset/03-review-quality-and-provenance.md index 358cc1f0..ae29b890 100644 --- a/.changeset/03-review-quality-and-provenance.md +++ b/.changeset/03-review-quality-and-provenance.md @@ -26,6 +26,6 @@ - **Published key names** — `prompts/review.md` tags the evidence rung as `rigor` and the in-bounds flag as `in-bounds`, and an archtest holds every published key to `review.schema.json`. [Rigor floors](docs/manual.md#rigor-floors-and-the-validation-pass) - **Verdict reconciliation** — binding verdicts reconcile separately from summary and inline content, so a retried approval does not duplicate a GitLab summary note. [Submit per host](docs/manual.md#submit-post-per-host) - **Plain-body Basis line** — `record` leaves a `review.json` body with no leading quote block byte-identical and reports no `basis-replaced` warning, because there is no confidence lead to insert under. [Review-input problems](docs/manual.md#review-input-problems) -- **Array-valued coverage ranges** — `next --coverage` refuses a `coverage[].ranges` array with the same `bad-review-input` problem `record` reports, instead of reading it as a silent 0% attestation. [Diff coverage](docs/manual.md#diff-coverage-agent-attestation) +- **Array-valued coverage ranges** — `next --coverage` refuses a `coverage[].ranges` array on plain and chunked bundles with the same `bad-review-input` problem `record` reports, instead of reading it as a silent 0% attestation. [Diff coverage](docs/manual.md#diff-coverage-agent-attestation) - **Passing gate next step** — a passing `report --check ` names `merge — gate passes` in the envelope's `next` and human footer, leaving `address open threads` for a failing gate. [Machine surface](docs/manual.md#machine-surface) - **More generated paths** — `*.gen.*` and `zz_generated.*` now count as generated in the shared role heuristic, so `next --coverage` and the risk floor exempt them like the other generated patterns. [Diff coverage](docs/manual.md#diff-coverage-agent-attestation) diff --git a/internal/core/coverage/coverage.go b/internal/core/coverage/coverage.go index 8706d45d..8c0b7c1b 100644 --- a/internal/core/coverage/coverage.go +++ b/internal/core/coverage/coverage.go @@ -154,13 +154,18 @@ type claim struct { // Evaluate reads the bundle's hunk snapshot and the review's attestation, and // returns the summary plus the warnings a caller should surface. A chunked -// bundle is not evaluated: chunks[] is its attestation, and one gate per bundle -// is the contract. +// bundle is not evaluated line by line: chunks[] is its attestation, and one +// gate per bundle is the contract. // // generated is the shared generated-path predicate; this package never owns a // second list. func Evaluate(dir string, review *jq.Obj, generated func(string) bool) (Summary, []string, *core.RefusalError) { if attested, total, ok := chunked(dir, review); ok { + var warns []string + _, _, problems := parseClaims(review, &warns) + if len(problems) > 0 { + return Summary{}, warns, badReviewInput(problems) + } return Summary{Chunked: true, Chunks: total, ChunksAttested: attested}, nil, nil } rows, ref := loadRows(dir) @@ -171,11 +176,7 @@ func Evaluate(dir string, review *jq.Obj, generated func(string) bool) (Summary, var warns []string claims, present, problems := parseClaims(review, &warns) if len(problems) > 0 { - return Summary{}, warns, &core.RefusalError{ - Code: CodeBadReviewInput, - Message: fmt.Sprintf(msgReviewProblem, len(problems)), - Problems: problems, - } + return Summary{}, warns, badReviewInput(problems) } warns = append(warns, unknownClaims(claims, files)...) sum := summarize(files, claims, generated) @@ -183,6 +184,14 @@ func Evaluate(dir string, review *jq.Obj, generated func(string) bool) (Summary, return sum, warns, nil } +func badReviewInput(problems []core.Problem) *core.RefusalError { + return &core.RefusalError{ + Code: CodeBadReviewInput, + Message: fmt.Sprintf(msgReviewProblem, len(problems)), + Problems: problems, + } +} + // unknownClaims warns about entries naming a path the bundle has no hunks for: // a binary, rename-only, or entirely absent file attests nothing and must not // read as coverage. diff --git a/internal/core/coverage/coverage_test.go b/internal/core/coverage/coverage_test.go index 19ba1e03..3de63ff3 100644 --- a/internal/core/coverage/coverage_test.go +++ b/internal/core/coverage/coverage_test.go @@ -273,6 +273,25 @@ func TestChunkedSkips(t *testing.T) { assertChunkedSkipped(t, dir) } +func TestChunkedArrayRangesRefuse(t *testing.T) { + dir := writeBundle(t, fixtureRows()) + if err := mkdirAll(dir + "/chunks"); err != nil { + t.Fatal(err) + } + writeFile(t, dir+"/chunks/manifest.json", `{"schema_version":"1","chunk_count":1,"chunks":[{"name":"chunks/01.diff"}]}`) + writeFile(t, dir+"/chunks/01.diff", "diff") + _, _, ref := Evaluate(dir, mustReview(t, `{"coverage":[{"file":"src/db.ts","ranges":["1-2"]}]}`), notGenerated) + if ref == nil { + t.Fatal("Evaluate refused nothing; want bad-review-input for array ranges on a chunked bundle") + } + if ref.Code != "bad-review-input" { + t.Errorf("refusal code = %q, want bad-review-input", ref.Code) + } + if len(ref.Problems) != 1 || ref.Problems[0].Path != "$.coverage[0].ranges" || ref.Problems[0].Code != "wrong-type" { + t.Fatalf("problems = %+v, want one wrong-type at $.coverage[0].ranges", ref.Problems) + } +} + // TestChunkedCountsTheManifest proves the count comes from the manifest and not // from the files beside it: an extra diff and a missing one leave the count // alone, which is the number a receipt reports.