Skip to content

fix(review): bind scoped validation to correction delta #1215

Description

@Sechi42

Pre-flight Checklist

  • I have searched existing issues and this is not a duplicate
  • I understand that PRs will be rejected if the linked issue does not have status:approved

📝 Bug Description

In Gentle AI 2.1.0, scoped correction validation has no native, materialized identity for the immutable delta between the post-freeze/pre-correction candidate and the current candidate. A detached validator can therefore compare candidate paths against HEAD or the full worktree state instead of the correction baseline.

When candidate files were already modified or untracked before correction, this inflates the authored-line count with original candidate content. A valid correction can then be terminally escalated for exceeding its correction budget even though its behavioral checks pass and the correction actor changed fewer lines than authorized.

🔄 Steps to Reproduce

  1. On Windows with OpenCode and PowerShell, use Gentle AI 2.1.0 to start a native review over a candidate containing modified tracked files and at least one intended untracked file.
  2. Freeze the review findings and open a 120-line correction budget for four accepted IDs.
  3. Apply a correction that changes exactly 78 authored lines across three already-in-scope files, including partial edits to pre-existing candidate files while leaving an intended untracked candidate file in scope.
  4. Run focused and full tests and confirm they pass.
  5. Invoke the single allowed detached scoped validator.
  6. Have the validator derive its apparent delta from HEAD or the full candidate-path state because no native pre-correction snapshot/delta artifact is available.
  7. Observe that it counts pre-existing candidate content, including the full intended untracked file, and escalates because the apparent line count exceeds 78 despite successful behavioral validation.

✅ Expected Behavior

When the correction budget opens, native authority should capture the exact pre-correction candidate snapshot/revision. Finalize and scoped validation should derive a content-addressed correction delta from that baseline to the current candidate, including untracked paths while counting only bytes authored during correction.

The immutable delta and native authored-line count should be exported to the detached validator. Native finalize should enforce the correction budget from that derived delta rather than trusting agent-reported counts. Partial edits to pre-existing candidate files and files already untracked before correction must be measured correctly.

❌ Actual Behavior

The detached validator has no authoritative pre-correction baseline or materialized fix-delta identity. It can fall back to HEAD or full candidate-path state and misclassify original candidate content as correction work.

In the observed review, the correction actor reported 78 authored lines within a 120-line budget and all behavioral checks passed, but validation counted 175 additions/3 deletions in one tracked file, 30 additions in another, and 133 lines from an already-untracked candidate file. It then terminally escalated for exceeding 78 lines.

This is terminal because the bounded lifecycle permits only one scoped-validator execution. The false escalation consumes that sole validation opportunity; no second validator can re-run against a corrected baseline.

Gentle AI Version

2.1.0

Operating System

Windows

AI Agent / Client

OpenCode

📋 Affected Area

CLI (commands, flags)

💡 Logs / Error Output

review lineage: review-9e5cbc12109846cf
frozen candidate: 13 files / 1263 changed lines
correction budget: 120 changed lines
accepted IDs: R4-001, R4-002, RELIABILITY-001, RELIABILITY-002
correction actor authored lines: 78 across 3 in-scope files
focused tests: 52 passed
full tests: 635 passed

validator-derived candidate-path state:
- tracked file A: 175 additions, 3 deletions
- tracked file B: 30 additions
- intended untracked file: 133 lines

behavioral validation: passed
budget validation: escalated because apparent delta exceeded 78 lines

Additional Context

Concrete repair proposal

  • Capture and bind the pre-correction candidate snapshot/revision in native authority when the correction budget is opened.
  • At finalize/scoped-validation, derive a content-addressed correction delta from that baseline to the current candidate.
  • Include untracked files in the derivation without counting content that was already present in the pre-correction candidate.
  • Expose/export the immutable correction delta and native authored-line count to the detached validator.
  • Validate the correction budget natively from the derived delta instead of trusting an agent-reported line count.
  • Add regression tests for untracked files present before correction and partial edits to pre-existing candidate files.
  • Preserve fail-closed behavior for actual path, content, finding-ID, and budget drift.

Duplicate search and related work

Open and closed issues/PRs and v2.1.0 release notes were searched for scoped validator correction delta, untracked files line count, correction budget, immutable fix delta, validator escalation, review finalize validation, authored lines, fix delta, correction snapshot, and pre-correction.

No searched issue or PR directly covers this defect.

Shell: Windows PowerShell.

No source content, local usernames, or absolute paths are included in this report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions