feat: migrate LLM rule evaluation to evidence-based validation model#30
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR separates pattern-matching evidence collection from final policy evaluation within the engine, addressing the false-positive limitations of static regex rules like
ALN-001.Instead of immediately generating a violation on an LLM API call pattern match, the match is treated as a Finding Candidate and evaluated in a post-scan validation pipeline. By default, all rules fall back to direct promotion, but specific rules (such as
ALN-001/MIT-003-A) run through specialized context-aware validators to inspect the file for validation safeguards.Closes #20
Acceptance Criteria Verification
evaluate_candidatesto act as an evaluation filter at the end of the file scan.# anchor: validatecomments).DOCS/research/evidence_evaluation.mdexplaining the new pipeline design.Proposed Changes
scan_fileinanchor/core/engine.pyto route findings throughevaluate_candidates.pydantic,instructor,guardrails,marshmallow,jsonschema,.validate(),.parse_obj(),json.loads(),BaseModel, or a# anchor: validateinstruction comment). Candidates with validation markers are safely discarded.tests/unit/test_evaluation.pyto cover both invalid and validated LLM invocation scenarios.DOCS/research/evidence_evaluation.mdexplaining the new pipeline design.Verification Results