Deepen AI review contract invariants#64
Merged
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.
This pull request introduces significant improvements to the AI review contract, prompt rendering, and validation logic. The main changes include a stricter contract for category-severity semantics, dynamic generation of prompt documentation and examples, and improved test coverage for these features. The codebase is refactored to centralize category and severity definitions, and to ensure that documentation and validation stay in sync with the contract.
AI Review Contract and Validation Enhancements:
getAiReviewFindingCategorySeverityandvalidateAiReviewFindingSemanticsfunctions to enforce that each finding's severity matches its category, with new validation errors reported when mismatched. [1] [2] [3] [4]AI_REVIEW_CATEGORY_GROUPS, and now deriveAI_BLOCKING_CATEGORIESandAI_WARNING_CATEGORIESfrom this mapping for consistency.Prompt Rendering and Documentation:
review-prompt.mdto use template placeholders for focus areas, categories, output examples, and field documentation, which are now dynamically rendered inreview-prompt.tsusing the contract definitions. [1] [2] [3] [4]AI_REVIEW_FINDING_FIELD_PROMPT_DOCSandAI_REVIEW_OUTPUT_EXAMPLEfor auto-generating up-to-date prompt documentation and JSON examples. [1] [2]Type and API Improvements:
AiReviewFindingFieldPromptDoc,AiReviewFindingKey,AiReviewTopLevelKey) and constants for better type safety and external usage. [1] [2] [3]Code Cleanup and Refactoring:
validateFindingSemanticslogic fromreview-output/normalization.tsin favor of the new centralized validation. [1] [2] [3] [4]Test Coverage:
These changes make the AI review contract stricter, the prompts more maintainable, and the validation logic more robust and easier to extend.