fix: scope TTSR read-before-edit rule to existing files only#2488
fix: scope TTSR read-before-edit rule to existing files only#2488alex-solovyev merged 1 commit intomainfrom
Conversation
The read-before-edit TTSR rule fired false positive ERROR-level violations when creating new files via the Write tool. The Write tool itself only requires a prior Read for existing files, but the aidevops rule layer did not distinguish new vs. existing files. Changes: - build.txt: Replace blanket 'No exceptions' with scoped guidance for existing files, and add new-file guidance (verify parent dir instead) - index.mjs: Add negative lookahead for creation patterns (creat, new file, generat) so the regex skips new file creation contexts - Update correction and systemPrompt text to mention the exception Closes #2487
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses and resolves an issue where the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Feb 27 21:28:59 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
WalkthroughRefines the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
|
There was a problem hiding this comment.
Code Review
This pull request aims to fix a false positive in the read-before-edit rule by refining its trigger condition. The changes to the prompt in build.txt and the descriptive fields in index.mjs are clear and align with the goal. However, the updated regular expression in index.mjs, while addressing the original problem, introduces a risk of false negatives due to overly broad keywords. I've provided a suggestion to make the pattern more specific and robust.
| pattern: "(?:I'll edit|Let me edit|I'll write to|Let me write)(?:(?!I'll read|let me read|I've read|already read).){0,200}$", | ||
| correction: "ALWAYS Read a file before Edit/Write. These tools fail without a prior Read in this conversation.", | ||
| description: "Always Read a file before Edit or Write to existing files", | ||
| pattern: "(?:I'll edit|Let me edit|I'll write to|Let me write)(?!.*(?:creat|new file|new \\w+ file|generat))(?:(?!I'll read|let me read|I've read|already read).){0,200}$", |
There was a problem hiding this comment.
The keywords creat and generat are too broad and could lead to false negatives. For instance, if an agent's response is "I will edit file X, then create a pull request", the keyword creat will match "create", causing this rule to be incorrectly skipped. The read-before-edit check should still apply to file X in this scenario.
To make this more robust, the keywords should be more specific to file creation, for example by tying creat and generat to the word file.
| pattern: "(?:I'll edit|Let me edit|I'll write to|Let me write)(?!.*(?:creat|new file|new \\w+ file|generat))(?:(?!I'll read|let me read|I've read|already read).){0,200}$", | |
| pattern: "(?:I'll edit|Let me edit|I'll write to|Let me write)(?!.*(?:creat.*file|new file|new \\w+ file|generat.*file))(?:(?!I'll read|let me read|I've read|already read).){0,200}$", |



Summary
Fixes #2487
The
read-before-editTTSR rule fired false positive ERROR-level violations when creating new files via the Write tool. The Write tool itself only requires a prior Read for existing files, but the aidevops rule layer did not distinguish new vs. existing files.Changes
build.txt:91: Replace blanket "No exceptions" with scoped guidance — Read is required before Edit/Write to an existing file. For new files, verify the parent directory exists instead.index.mjs:1493-1498: Add negative lookahead(?!.*(?:creat|new file|new \w+ file|generat))to the TTSR regex so it skips new file creation contexts.correctionandsystemPrompttext to mention the new-file exception.Verification
Tested the updated regex against 13 cases:
Impact
Summary by CodeRabbit