Skip to content

fix(review): allow proofRefs and evidence to cite repository paths outside candidate diff - #1926

Closed
decode2 wants to merge 1 commit into
Gentleman-Programming:mainfrom
decode2:fix/1920-review-proof-scope-admission
Closed

fix(review): allow proofRefs and evidence to cite repository paths outside candidate diff#1926
decode2 wants to merge 1 commit into
Gentleman-Programming:mainfrom
decode2:fix/1920-review-proof-scope-admission

Conversation

@decode2

@decode2 decode2 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1920

Reviewer evidence and proof_refs entries were being validated against the changed-path manifest (allowed) instead of the full frozen repository path manifest (repository). A reviewer is permitted to cite any immutable repository file as contextual proof for a finding; only the finding location itself must reside inside the changed-path manifest. Validating proof references against allowed caused valid results — where a reliability or resilience finding referenced an unmodified contract or interface file — to be rejected with out_of_scope, quarantined by review abandon, and then irrecoverable via review repair --preflight (eligible_candidates: 0), forcing a new budget spend in violation of the exactly-once budget rule.

Changes

  • internal/reviewtransaction/artifact_admission.go: in AdmitArtifact, evidence and ProofRefs loops now call referenceOutsideScope(value, repository, repository) instead of referenceOutsideScope(value, allowed, repository). Finding location validation against wantPaths (changed-path manifest) is unchanged.
  • internal/reviewtransaction/artifact_admission_test.go:
    • Updated TestAdmitArtifactRequiresCompletedBoundInScopeInspection proof/evidence out-of-scope cases to use paths absent from the repository manifest (the actual admission boundary).
    • Updated TestReferenceOutsideScopeRecognizesOnlyStructuredRepositoryPaths to call referenceOutsideScope with repository-as-allowed, matching the new semantics.
    • Added TestAdmitArtifactAllowsProofRefsToUnmodifiedRepositoryFiles — RED-first regression: a finding whose location is inside the candidate diff but whose proof_ref cites a valid unmodified repository file must be admitted as completed.

Verification

go test ./internal/reviewtransaction/... # PASS (23.6s)
go test ./...                            # PASS (all packages)

Summary by CodeRabbit

  • Bug Fixes
    • Artifact admission now allows evidence and proof references to structurally valid repository files even when they weren’t included in the changed-path manifest, as long as those files are unmodified.
    • Malformed or unrecognized repository-path references are still rejected as out of scope.
    • Proof references to paths missing from the frozen repository snapshot are rejected.
  • Tests
    • Updated existing cases for non-canonical path tokens and added coverage for unmodified out-of-manifest evidence/proof handling and missing-repository-path rejection.

@decode2 decode2 added the type:bug Bug fix label Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 966031e8-ee3e-420e-b516-7cb6a6095529

📥 Commits

Reviewing files that changed from the base of the PR and between 7b9c04a and b2bf8c0.

📒 Files selected for processing (2)
  • internal/reviewtransaction/artifact_admission.go
  • internal/reviewtransaction/artifact_admission_test.go

📝 Walkthrough

Walkthrough

Artifact admission now rejects malformed or unknown repository-path references while allowing structurally valid evidence and proof references to known repository files outside the changed-path manifest. Tests cover malformed references, unmodified-file references, and absent repository paths.

Changes

Proof reference scope

Layer / File(s) Summary
Admission scope checks
internal/reviewtransaction/artifact_admission.go
AdmitArtifact uses proofReferenceIsMalformed for evidence and proof validation, checking structural validity and frozen-repository membership without enforcing changed-path inclusion.
Scope regression coverage
internal/reviewtransaction/artifact_admission_test.go
Tests classify non-canonical references as out of scope and verify admission of known unmodified files, while rejecting paths absent from the frozen repository.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Issue 1757 — Both changes modify provider-owned AdmitArtifact validation.

Suggested reviewers: alan-thegentleman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: allowing proofRefs and evidence to cite repository paths outside the candidate diff.
Linked Issues check ✅ Passed The code separates proof/evidence repository scope from changed-path scope and the tests confirm the #1920 behavior.
Out of Scope Changes check ✅ Passed The changes stay focused on artifact admission logic and its tests, with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/reviewtransaction/artifact_admission_test.go`:
- Around line 231-245: The test coverage only exercises ProofRefs, not the
canonical.Evidence admission path for unmodified files. Add an analogous test
near TestAdmitArtifactAllowsProofRefsToUnmodifiedRepositoryFiles that sets
request.Result.Evidence to internal/secret.go:42, asserts completed admission,
and verifies canonical.Findings[0].Evidence preserves that reference.

In `@internal/reviewtransaction/artifact_admission.go`:
- Around line 219-220: ProofRefs currently allow unknown bare paths because they
reuse the permissive evidence tokenizer. In
internal/reviewtransaction/artifact_admission.go:219-220, update the
proof-reference validation around referenceOutsideScope to use a proof-specific
validator that requires a known repository path; in
internal/reviewtransaction/artifact_admission_test.go:224-225, add a negative
admission test covering a bare unknown proof path without relying on free-form
evidence expectations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2bd5ecac-bb0c-43bc-9538-411daa7b7599

📥 Commits

Reviewing files that changed from the base of the PR and between ffbcc12 and e93d801.

📒 Files selected for processing (2)
  • internal/reviewtransaction/artifact_admission.go
  • internal/reviewtransaction/artifact_admission_test.go

Comment on lines +231 to +245
func TestAdmitArtifactAllowsProofRefsToUnmodifiedRepositoryFiles(t *testing.T) {
_, _, request := admittedArtifactFixture(t)
// Finding location remains inside changed-path manifest
request.Result.Findings[0].Location = "internal/a.go:10"
// ProofRef references an unmodified repository file outside the changed-path manifest
request.Result.Findings[0].ProofRefs = []string{"internal/secret.go:42"}

canonical, admission, err := AdmitArtifact(request)
if err != nil || admission.Decision != ArtifactAdmissionCompleted {
t.Fatalf("AdmitArtifact() = %q, %v; want completed when proof_ref references valid repository path", admission.Decision, err)
}
if len(canonical.Findings[0].ProofRefs) != 1 || canonical.Findings[0].ProofRefs[0] != "internal/secret.go:42" {
t.Fatalf("AdmitArtifact() proofRefs = %v, want [internal/secret.go:42]", canonical.Findings[0].ProofRefs)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add end-to-end coverage for unmodified-file evidence.

The new regression covers ProofRefs, but the separate canonical.Evidence admission path is not tested with a valid unmodified repository file. Add an analogous case using internal/secret.go:42 in request.Result.Evidence and assert completed admission plus canonical evidence preservation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/reviewtransaction/artifact_admission_test.go` around lines 231 -
245, The test coverage only exercises ProofRefs, not the canonical.Evidence
admission path for unmodified files. Add an analogous test near
TestAdmitArtifactAllowsProofRefsToUnmodifiedRepositoryFiles that sets
request.Result.Evidence to internal/secret.go:42, asserts completed admission,
and verifies canonical.Findings[0].Evidence preserves that reference.

Comment thread internal/reviewtransaction/artifact_admission.go Outdated
@decode2
decode2 force-pushed the fix/1920-review-proof-scope-admission branch from e93d801 to 7b9c04a Compare July 28, 2026 14:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/reviewtransaction/artifact_admission_test.go (1)

207-225: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Preserve the allowed-versus-repository distinction in this test.

Passing repository as both arguments makes every known repository path appear in scope, so the renamed “outside scope” cases no longer exercise referenceOutsideScope’s changed-path filtering. Restore a distinct allowed subset, or remove this helper test if the function is intentionally retired.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/reviewtransaction/artifact_admission_test.go` around lines 207 -
225, Update the referenceOutsideScope test to pass a distinct allowed-path
subset as its first argument and the full repository as its second, so the
outside cases exercise changed-path filtering; preserve the existing
expectations. If referenceOutsideScope is intentionally retired, remove this
helper test instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/reviewtransaction/artifact_admission.go`:
- Around line 200-201: Update the failure diagnostics in the proof-reference
validation branches, including the branch guarded by proofReferenceIsMalformed,
to describe malformed repository references rather than paths outside the frozen
candidate. Preserve the existing ArtifactAdmissionOutOfScope result and fail
flow while changing both affected messages consistently.
- Around line 219-220: Require explicit proof references in the admission flow
to match a canonical path present in the frozen repository manifest, not merely
pass malformed-path checks. Update proofReferenceIsMalformed or split the
validators so path-like tokens with known == false are rejected, and add a
negative admission test covering not-in-repository.go:42. Apply these changes at
internal/reviewtransaction/artifact_admission.go:219-220 and 440-449, and
internal/reviewtransaction/artifact_admission_test.go:94-96.

---

Outside diff comments:
In `@internal/reviewtransaction/artifact_admission_test.go`:
- Around line 207-225: Update the referenceOutsideScope test to pass a distinct
allowed-path subset as its first argument and the full repository as its second,
so the outside cases exercise changed-path filtering; preserve the existing
expectations. If referenceOutsideScope is intentionally retired, remove this
helper test instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b7e7e179-3c9b-4f1d-9c43-beffe5232cc8

📥 Commits

Reviewing files that changed from the base of the PR and between e93d801 and 7b9c04a.

📒 Files selected for processing (2)
  • internal/reviewtransaction/artifact_admission.go
  • internal/reviewtransaction/artifact_admission_test.go

Comment on lines +200 to 201
if proofReferenceIsMalformed(evidence, repository) {
return fail(ArtifactAdmissionOutOfScope, "reviewer evidence references a path outside the frozen candidate")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Update the diagnostics to match the new validation.

These branches now reject malformed repository references, not references outside the changed-path manifest. Messages such as “outside the frozen candidate” are misleading for inputs like ./internal/a.go:3; report a malformed repository reference instead.

Also applies to: 219-220

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/reviewtransaction/artifact_admission.go` around lines 200 - 201,
Update the failure diagnostics in the proof-reference validation branches,
including the branch guarded by proofReferenceIsMalformed, to describe malformed
repository references rather than paths outside the frozen candidate. Preserve
the existing ArtifactAdmissionOutOfScope result and fail flow while changing
both affected messages consistently.

Comment thread internal/reviewtransaction/artifact_admission.go
@decode2
decode2 force-pushed the fix/1920-review-proof-scope-admission branch from 7b9c04a to b2bf8c0 Compare July 28, 2026 15:47

@dnlrsls dnlrsls left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two changes are needed before merge:

  1. internal/reviewtransaction/artifact_admission.go:329referenceOutsideScope is no longer called by production code after this change. The dead-code ratchet reports it as a new unreachable function, which is why the Unit Tests job is failing. Please remove the obsolete helper and its dedicated test, or restore a live production use.

  2. internal/reviewtransaction/artifact_admission.go:201,220 — rejected malformed or repository-absent references are still described as being “outside the frozen candidate.” Under this PR, repository paths outside the candidate are valid. Please update both diagnostics to identify malformed references or paths absent from the frozen repository manifest, and assert the diagnostic in tests.

Targeted admission tests pass, and the prior unknown-path and evidence-coverage concerns are resolved at the current head.

@dnlrsls dnlrsls left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required Unit Tests fail because the patch makes referenceOutsideScope unreachable under the dead-code ratchet. Please remove or legitimately reuse that helper, restore the missing Linked Issue, PR Type, Test Plan, and Contributor Checklist sections from the required template, and rerun CI. The new repository-scope admission tests otherwise match #1920.

@Alan-TheGentleman

Copy link
Copy Markdown
Contributor

This candidate is superseded by main commit 3ecf60b4, which delivered and closed #1920. Please do not continue implementation, dead-code cleanup, or conflict resolution on this branch. No further code changes are requested here; preserve the PR only as historical context for the delivered fix.

@decode2

decode2 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing this PR as superseded. Maintainer-designated commit 3ecf60b delivered and closed issue #1920 and is present in the release and current main, so continuing this branch would duplicate the shipped fix. Thank you for the contribution.

@decode2 decode2 closed this Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(review): repair preserved results rejected by proof-scope admission

3 participants