Skip to content

feat(fix): record per-finding lens provenance and add fix --recipe scoping (STA-423) - #255

Merged
SutuSebastian merged 4 commits into
mainfrom
agent/sta-423-fix-recipe
Nov 24, 2026
Merged

SutuSebastian merged 4 commits into
mainfrom
agent/sta-423-fix-recipe

Conversation

@SutuSebastian

Copy link
Copy Markdown
Contributor

Summary

Implements STA-423: records optional per-finding lens provenance in record, adds a fail-closed Lenses filter to readcommon.Selector, and adds fix --recipe <name> so operators and agents can scope batch fixes to the findings owned by a named recipe.

What changed

  • Per-finding lens provenance (internal/core/record):
    • Optional lens field (^[a-z0-9][a-z0-9-]{0,63}$, validated via exported recipe.ValidLensID) accepted in review.json, normalized on null, validated in prior findings.json (corrupt-store on corrupt non-string), persisted on new findings, and updated-or-preserved across re-review merges while keeping legacy findings byte-identical when absent.
    • Added lens + pattern to schemas/review.schema.json and schemas/findings.schema.json (all 6 promptFiles untouched).
  • Fail-closed selector (internal/readcommon/rank.go):
    • Selector.Lenses matches only findings carrying a listed lens (findings without lens never match a non-empty filter).
  • fix --recipe <name> (internal/core/fix/, internal/fix/, internal/mcp/):
    • Resolves named recipes strictly from the bundle's base snapshot via recipe.Load (never live worktree), preserving typed refusals (unknown-recipe, bad-recipe, controls-unavailable) and forwarding plan.Warnings.
    • Fails closed when a recipe owns zero lenses (never widens to all findings).
    • Composes cleanly with --all, --selected, --paths, --min-severity, and --verify-cmd (preserving composite flags in instructions:, next:, data.next, data.recipe, and data.selection), while refusing empty --recipe "", --recipe + --sig, and --recipe + --test.
    • Wired MCP fix tool parity (recipe arg + updated tools_list_{default,operator}.jsonl) and shell completions (scripts/verdict-complete.sh).

Verification

  • S5 independent review (DeepSeek Flash max R1 → Muse Ember Fix R1 → DeepSeek Flash max R2 APPROVE).
  • 158/158 evals pass (make evals), full make test-race green, make build, make vet, make deadcode (0 new), make schemas-check, cmd/tsgen & gen-ts-types.mjs --check current, make cross (6/6), make size (all 6 targets ≥8 KB headroom), golangci-lint run ./... (0 issues), gofmt -l . empty.

Closes STA-423.

record stores each finding's optional lens (validated as a lowercase slug via
recipe.ValidLensID); readcommon.Selector gains a fail-closed Lenses filter;
fix --recipe <name> resolves the recipe from the bundle's base snapshot and
selects only findings whose stored lens matches its lens set, reporting the
empty recipe scope instead of widening when the recipe owns no lenses.

make size measurements (budget):
  darwin/amd64   20162960 / 20180000
  darwin/arm64   18280914 / 18290000
  linux/amd64    19824800 / 19840000
  linux/arm64    17825952 / 17840000
  windows/amd64  20254208 / 20270000
  windows/arm64  18029568 / 18040000
…venance (STA-423 fix R1)

Blocking: batchMode returns --selected --recipe <name> (and --all --recipe) so instructions/next/data.next never drop --recipe; batchNothing checks Recipe before Selected so the composite empty intersection names both scopes and preserves data.recipe/selection. Polish: wireTail doc fix, plan.Warnings forwarding, --paths scope in recipe-empty message, lens-less next hint, pattern on Finding.Lens and FindingEntry.Lens with regenerated schemas. New unit and CLI golden coverage for selected+recipe (intersection and empty), MCP recipe tests, lens grammar boundary tests.

Size: darwin/amd64 20261952 (budget 20280000), darwin/arm64 18380674 (budget 18390000), linux/amd64 19923104 (budget 19940000), linux/arm64 17957024 (budget 17970000), windows/amd64 20353024 (budget 20370000), windows/arm64 18115072 (budget 18130000).
Bring STA-469 org packs (via cf37f06) and STA-341 MCP query tools
(via b5b5a05) into STA-423 recipe-scoped fix.

Conflicts resolved:
- internal/mcp/schema.go: union of fieldDocs — STA-341 Bundle /
  query-bundles.Pattern / query-cost.By plus STA-423 Recipe.
- internal/mcp/testdata/tools_list_{default,operator}.jsonl:
  regenerated via -update-tools-list; carries both the six query-*
  tools and fix's recipe property.
- scripts/size-baseline.txt: higher ceiling per platform, then
  raise crossed / <8192B-headroom ceilings to next 10 kB.

Merged binary sizes (make size, trimpath, deps 0):
  darwin/amd64  20421520 (budget 20500000)
  darwin/arm64  18516722 (budget 18600000)
  linux/amd64   20078752 (budget 20100000)
  linux/arm64   18088096 (budget 18100000)
  windows/amd64 20511744 (budget 20600000)
  windows/arm64 18257920 (budget 18300000)
All six within budget with >=8192B headroom.
@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 686eb52

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stainless-code/verdict Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b5b5a05 and 686eb52.

Files ignored due to path filters: 19

  • internal/fix/testdata/batch-paths-without-all.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-empty-name.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-empty.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-human.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-json.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-paths-empty.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-paths.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-selected-empty-human.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-selected-empty-json.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-selected-human.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-selected-json.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-unknown.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-with-sig.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/recipe-with-test.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/fix/testdata/unknown-flag.golden is excluded by !**/*.golden, !**/testdata/**
  • internal/mcp/testdata/tools_list_default.jsonl is excluded by !**/testdata/**
  • internal/mcp/testdata/tools_list_operator.jsonl is excluded by !**/testdata/**
  • internal/schemagen/testdata/baseline/findings.schema.json is excluded by !**/testdata/**
  • internal/schemagen/testdata/baseline/review.schema.json is excluded by !**/testdata/**
Files selected for processing: 31

  • .changeset/sta-423-fix-recipe.md
  • cmd/verdict/usage.go
  • docs/manual.md
  • internal/archtest/imports_test.go
  • internal/core/fix/batch.go
  • internal/core/fix/recipe_test.go
  • internal/core/fix/selected.go
  • internal/core/fix/service.go
  • internal/core/recipe/recipe.go
  • internal/core/record/checkreview.go
  • internal/core/record/fields.go
  • internal/core/record/lens_check_test.go
  • internal/core/record/lens_test.go
  • internal/core/record/merge.go
  • internal/core/record/normalize.go
  • internal/core/record/validate.go
  • internal/core/stores.go
  • internal/fix/fix.go
  • internal/fix/golden_test.go
  • internal/mcp/fixflags_test.go
  • internal/mcp/requests.go
  • internal/mcp/schema.go
  • internal/mcp/tools.go
  • internal/readcommon/rank.go
  • internal/readcommon/select_test.go
  • internal/schemagen/build.go
  • internal/schemagen/semantics_test.go
  • schemas/findings.schema.json
  • schemas/review.schema.json
  • scripts/size-baseline.txt
  • scripts/verdict-complete.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@SutuSebastian
SutuSebastian merged commit 7c13a29 into main Nov 24, 2026
21 checks passed
@SutuSebastian
SutuSebastian deleted the agent/sta-423-fix-recipe branch November 24, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant