From b3bc5e76c030a2c7739cbd465fad4b0cef425b2c Mon Sep 17 00:00:00 2001 From: nizar Date: Mon, 2 Mar 2026 14:54:15 -0800 Subject: [PATCH 01/10] feat: support custom review guidelines via review-guidelines skill Read .factory/skills/review-guidelines.md from the workspace and inject its content into all review prompt templates (code review, candidates, validator, and security review). This allows repository maintainers to define repo-specific review guidelines without polluting AGENTS.md. Closes FAC-16667 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> refactor: address review feedback - Use .factory/skills/review-guidelines/SKILL.md path (follow skill conventions) - Extract formatGuidelinesSection() helper to centralize prompt formatting - Use consistent tags across all templates Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> docs: add custom review guidelines section to README Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index f0ec5f9..803283c 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,19 @@ Set `automatic_review: true` to run code reviews automatically on non-draft PRs. | `security_scan_schedule` | `false` | Configuration for scheduled security scans (when invoked from scheduled workflows). | | `security_scan_days` | `7` | Number of days of commits to scan for scheduled security scans. | +## Custom Review Guidelines + +You can add repository-specific review guidelines by creating a `.factory/skills/review-guidelines/SKILL.md` file: + +```markdown +Additional checks for this codebase: +- React hooks rules violations +- Missing TypeScript types on public APIs +- Prisma query performance issues +``` + +These guidelines are automatically loaded and injected into all review prompts (code review, security review, and validation passes). No workflow changes needed. + ## Security Skills The security review uses specialized Factory skills installed from the public `Factory-AI/skills` repository: From 987bf4dc488aebdfdda5b9635c29e9b91d6ae57c Mon Sep 17 00:00:00 2001 From: Nizar Alrifai Date: Tue, 3 Mar 2026 14:14:33 -0800 Subject: [PATCH 02/10] feat(review): add suggestion block guidance Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> fix(review): escape suggestion blocks in prompt Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> fix(review): enforce suggestion-only replacements Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> update --- README.md | 13 ------------- .../templates/review-candidates-prompt.ts | 8 ++++++++ src/create-prompt/templates/review-prompt.ts | 16 ++++++++++++++++ .../templates/review-validator-prompt.ts | 8 ++++++++ 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 803283c..f0ec5f9 100644 --- a/README.md +++ b/README.md @@ -169,19 +169,6 @@ Set `automatic_review: true` to run code reviews automatically on non-draft PRs. | `security_scan_schedule` | `false` | Configuration for scheduled security scans (when invoked from scheduled workflows). | | `security_scan_days` | `7` | Number of days of commits to scan for scheduled security scans. | -## Custom Review Guidelines - -You can add repository-specific review guidelines by creating a `.factory/skills/review-guidelines/SKILL.md` file: - -```markdown -Additional checks for this codebase: -- React hooks rules violations -- Missing TypeScript types on public APIs -- Prisma query performance issues -``` - -These guidelines are automatically loaded and injected into all review prompts (code review, security review, and validation passes). No workflow changes needed. - ## Security Skills The security review uses specialized Factory skills installed from the public `Factory-AI/skills` repository: diff --git a/src/create-prompt/templates/review-candidates-prompt.ts b/src/create-prompt/templates/review-candidates-prompt.ts index 1ee761a..9085807 100644 --- a/src/create-prompt/templates/review-candidates-prompt.ts +++ b/src/create-prompt/templates/review-candidates-prompt.ts @@ -194,6 +194,14 @@ Write output to \`${reviewCandidatesPath}\` using this exact schema: - **comments**: Array of comment objects - \`path\`: Relative file path (e.g., "src/index.ts") - \`body\`: Comment text starting with priority tag [P0|P1|P2], then title, then 1 paragraph explanation + If you have **high confidence** a fix will address the issue and won’t break CI, append a GitHub suggestion block: + + \`\`\`suggestion + + \`\`\` + + Keep suggestions minimal, scoped to the reported line range, preserve exact leading whitespace, and do not exceed 250 lines. + Only include replacement lines (no unchanged context, no duplicated original code), and do not include removed/LEFT-side lines. - \`line\`: Target line number (single-line) or end line number (multi-line). Must be ≥ 0. - \`startLine\`: \`null\` for single-line comments, or start line number for multi-line comments - \`side\`: "RIGHT" for new/modified code (default), "LEFT" only for removed code diff --git a/src/create-prompt/templates/review-prompt.ts b/src/create-prompt/templates/review-prompt.ts index 3216ce9..71749b5 100644 --- a/src/create-prompt/templates/review-prompt.ts +++ b/src/create-prompt/templates/review-prompt.ts @@ -316,6 +316,22 @@ One short paragraph explaining *why* this is a bug and *how* it manifests. * Code snippets ≤3 lines, Markdown fenced * Matter-of-fact, non-accusatory tone +### Suggestion blocks (when applicable) + +If you have **high confidence** a fix will address the issue and won’t break CI, include a GitHub suggestion block after the explanation: + +\`\`\`suggestion + +\`\`\` + +Rules: +* Only include a suggestion when the fix is clear and high-confidence +* Keep the suggestion minimal and scoped to the reported line range +* Do not exceed 250 lines in a suggestion block +* Preserve exact leading whitespace of replaced lines +* Only include the replacement lines (no unchanged context, no duplicated original code) +* Do not include removed/LEFT-side lines in suggestions + --- ## Phase 3: Submit Review diff --git a/src/create-prompt/templates/review-validator-prompt.ts b/src/create-prompt/templates/review-validator-prompt.ts index f4c124a..176d770 100644 --- a/src/create-prompt/templates/review-validator-prompt.ts +++ b/src/create-prompt/templates/review-validator-prompt.ts @@ -107,6 +107,14 @@ Reject if: * It's not anchored to a valid changed line * It's already reported (dedupe against existing comments) +Suggestion block rules: +* If an approved comment includes a GitHub suggestion block, ensure the fix is **high confidence** and minimal +* Suggestion blocks must preserve exact leading whitespace and not exceed 250 lines +* If the fix is clearly high confidence but the candidate lacks a suggestion block, add one to the approved comment body +* If the suggestion is not high confidence, remove the suggestion block or reject the candidate +* Ensure suggestion blocks only include replacement lines (no unchanged context, no duplicated original code) +* Do not include removed/LEFT-side lines in suggestions + When rejecting, write a concise reason. ======================= From 0e620c16ce101e5a9b9f68975fcf976f96b8f91d Mon Sep 17 00:00:00 2001 From: Nizar Alrifai Date: Tue, 3 Mar 2026 15:52:00 -0800 Subject: [PATCH 03/10] fix(review): allow insert-only suggestions Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- src/create-prompt/templates/review-candidates-prompt.ts | 3 ++- src/create-prompt/templates/review-prompt.ts | 3 ++- src/create-prompt/templates/review-validator-prompt.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/create-prompt/templates/review-candidates-prompt.ts b/src/create-prompt/templates/review-candidates-prompt.ts index 9085807..ceec366 100644 --- a/src/create-prompt/templates/review-candidates-prompt.ts +++ b/src/create-prompt/templates/review-candidates-prompt.ts @@ -201,7 +201,8 @@ Write output to \`${reviewCandidatesPath}\` using this exact schema: \`\`\` Keep suggestions minimal, scoped to the reported line range, preserve exact leading whitespace, and do not exceed 250 lines. - Only include replacement lines (no unchanged context, no duplicated original code), and do not include removed/LEFT-side lines. + Only include replacement lines (no unchanged context). For insert-only suggestions, include the anchor line unchanged plus the new lines (this is the only allowed duplication). Do not include removed/LEFT-side lines. + If you need to re-add deleted content, anchor on a nearby RIGHT-side line and replace that line with itself plus the added lines (insert-only via replacement). - \`line\`: Target line number (single-line) or end line number (multi-line). Must be ≥ 0. - \`startLine\`: \`null\` for single-line comments, or start line number for multi-line comments - \`side\`: "RIGHT" for new/modified code (default), "LEFT" only for removed code diff --git a/src/create-prompt/templates/review-prompt.ts b/src/create-prompt/templates/review-prompt.ts index 71749b5..08d0b90 100644 --- a/src/create-prompt/templates/review-prompt.ts +++ b/src/create-prompt/templates/review-prompt.ts @@ -329,8 +329,9 @@ Rules: * Keep the suggestion minimal and scoped to the reported line range * Do not exceed 250 lines in a suggestion block * Preserve exact leading whitespace of replaced lines -* Only include the replacement lines (no unchanged context, no duplicated original code) +* Only include the replacement lines (no unchanged context). If you need an insert-only suggestion, include the anchor line unchanged plus the new lines (this is the only allowed duplication) * Do not include removed/LEFT-side lines in suggestions +* If you need to re-add deleted content, anchor on a nearby RIGHT-side line and replace that line with itself plus the added lines (i.e., insert-only via replacement) --- diff --git a/src/create-prompt/templates/review-validator-prompt.ts b/src/create-prompt/templates/review-validator-prompt.ts index 176d770..a22f6ff 100644 --- a/src/create-prompt/templates/review-validator-prompt.ts +++ b/src/create-prompt/templates/review-validator-prompt.ts @@ -112,8 +112,9 @@ Suggestion block rules: * Suggestion blocks must preserve exact leading whitespace and not exceed 250 lines * If the fix is clearly high confidence but the candidate lacks a suggestion block, add one to the approved comment body * If the suggestion is not high confidence, remove the suggestion block or reject the candidate -* Ensure suggestion blocks only include replacement lines (no unchanged context, no duplicated original code) +* Ensure suggestion blocks only include replacement lines (no unchanged context). For insert-only suggestions, allow the anchor line unchanged plus new lines (only allowed duplication) * Do not include removed/LEFT-side lines in suggestions +* For re-adding deleted content, anchor to a nearby RIGHT-side line and replace that line with itself plus the added lines When rejecting, write a concise reason. From 8a49f73b7b240708be180433e8252c67309afd84 Mon Sep 17 00:00:00 2001 From: Nizar Alrifai Date: Tue, 3 Mar 2026 15:55:04 -0800 Subject: [PATCH 04/10] fix(review): clarify insert-only suggestions Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- src/create-prompt/templates/review-candidates-prompt.ts | 2 +- src/create-prompt/templates/review-prompt.ts | 2 +- src/create-prompt/templates/review-validator-prompt.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/create-prompt/templates/review-candidates-prompt.ts b/src/create-prompt/templates/review-candidates-prompt.ts index ceec366..b2f0c11 100644 --- a/src/create-prompt/templates/review-candidates-prompt.ts +++ b/src/create-prompt/templates/review-candidates-prompt.ts @@ -201,7 +201,7 @@ Write output to \`${reviewCandidatesPath}\` using this exact schema: \`\`\` Keep suggestions minimal, scoped to the reported line range, preserve exact leading whitespace, and do not exceed 250 lines. - Only include replacement lines (no unchanged context). For insert-only suggestions, include the anchor line unchanged plus the new lines (this is the only allowed duplication). Do not include removed/LEFT-side lines. + Only include replacement lines (no unchanged context). For insert-only suggestions: anchor on a RIGHT-side line and repeat it **unchanged**, then append the new lines. Do not modify the anchor line or include removed/LEFT-side lines. If you need to re-add deleted content, anchor on a nearby RIGHT-side line and replace that line with itself plus the added lines (insert-only via replacement). - \`line\`: Target line number (single-line) or end line number (multi-line). Must be ≥ 0. - \`startLine\`: \`null\` for single-line comments, or start line number for multi-line comments diff --git a/src/create-prompt/templates/review-prompt.ts b/src/create-prompt/templates/review-prompt.ts index 08d0b90..33e0577 100644 --- a/src/create-prompt/templates/review-prompt.ts +++ b/src/create-prompt/templates/review-prompt.ts @@ -329,7 +329,7 @@ Rules: * Keep the suggestion minimal and scoped to the reported line range * Do not exceed 250 lines in a suggestion block * Preserve exact leading whitespace of replaced lines -* Only include the replacement lines (no unchanged context). If you need an insert-only suggestion, include the anchor line unchanged plus the new lines (this is the only allowed duplication) +* Only include the replacement lines (no unchanged context). For insert-only suggestions: anchor on a RIGHT-side line and repeat it **unchanged**, then append the new lines. Do not modify the anchor line. * Do not include removed/LEFT-side lines in suggestions * If you need to re-add deleted content, anchor on a nearby RIGHT-side line and replace that line with itself plus the added lines (i.e., insert-only via replacement) diff --git a/src/create-prompt/templates/review-validator-prompt.ts b/src/create-prompt/templates/review-validator-prompt.ts index a22f6ff..8f458b9 100644 --- a/src/create-prompt/templates/review-validator-prompt.ts +++ b/src/create-prompt/templates/review-validator-prompt.ts @@ -112,7 +112,7 @@ Suggestion block rules: * Suggestion blocks must preserve exact leading whitespace and not exceed 250 lines * If the fix is clearly high confidence but the candidate lacks a suggestion block, add one to the approved comment body * If the suggestion is not high confidence, remove the suggestion block or reject the candidate -* Ensure suggestion blocks only include replacement lines (no unchanged context). For insert-only suggestions, allow the anchor line unchanged plus new lines (only allowed duplication) +* Ensure suggestion blocks only include replacement lines (no unchanged context). For insert-only suggestions: allow a RIGHT-side anchor line repeated **unchanged** plus the new lines; do not modify the anchor line * Do not include removed/LEFT-side lines in suggestions * For re-adding deleted content, anchor to a nearby RIGHT-side line and replace that line with itself plus the added lines From ce717392e84a7bb52cccc614d13ec7a37374bb99 Mon Sep 17 00:00:00 2001 From: Nizar Alrifai Date: Tue, 3 Mar 2026 16:00:22 -0800 Subject: [PATCH 05/10] fix(review): keep anchors consistent across phases Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- src/create-prompt/templates/review-candidates-prompt.ts | 3 ++- src/create-prompt/templates/review-prompt.ts | 1 + src/create-prompt/templates/review-validator-prompt.ts | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/create-prompt/templates/review-candidates-prompt.ts b/src/create-prompt/templates/review-candidates-prompt.ts index b2f0c11..0f6e261 100644 --- a/src/create-prompt/templates/review-candidates-prompt.ts +++ b/src/create-prompt/templates/review-candidates-prompt.ts @@ -205,7 +205,8 @@ Write output to \`${reviewCandidatesPath}\` using this exact schema: If you need to re-add deleted content, anchor on a nearby RIGHT-side line and replace that line with itself plus the added lines (insert-only via replacement). - \`line\`: Target line number (single-line) or end line number (multi-line). Must be ≥ 0. - \`startLine\`: \`null\` for single-line comments, or start line number for multi-line comments - - \`side\`: "RIGHT" for new/modified code (default), "LEFT" only for removed code + - \`side\`: "RIGHT" for new/modified code (default). Use "LEFT" only for removed code **without** suggestions. + If you include a suggestion block, choose a RIGHT-side anchor and keep it unchanged so the validator can reuse it. - \`commit_id\`: "${prHeadSha}" - **reviewSummary**: diff --git a/src/create-prompt/templates/review-prompt.ts b/src/create-prompt/templates/review-prompt.ts index 33e0577..76f94b5 100644 --- a/src/create-prompt/templates/review-prompt.ts +++ b/src/create-prompt/templates/review-prompt.ts @@ -350,6 +350,7 @@ Rules: * Anchor using **path + side + line** * RIGHT = new/modified code, LEFT = removed code * Line numbers must correspond to the chosen side + * If you include a suggestion, keep the anchor on RIGHT-side lines and do not change the anchor line content * Use \`github_pr___submit_review\` for the summary * Use \`github_pr___delete_comment\` or \`github_pr___minimize_comment\` for outdated "no issues" comments * Use \`github_pr___reply_to_comment\` to acknowledge resolved issues diff --git a/src/create-prompt/templates/review-validator-prompt.ts b/src/create-prompt/templates/review-validator-prompt.ts index 8f458b9..27aa6cd 100644 --- a/src/create-prompt/templates/review-validator-prompt.ts +++ b/src/create-prompt/templates/review-validator-prompt.ts @@ -106,6 +106,7 @@ Reject if: * It's stylistic / naming / formatting * It's not anchored to a valid changed line * It's already reported (dedupe against existing comments) +* The anchor (path/side/line/startLine) would need to change to make the suggestion work — reject instead Suggestion block rules: * If an approved comment includes a GitHub suggestion block, ensure the fix is **high confidence** and minimal @@ -115,6 +116,7 @@ Suggestion block rules: * Ensure suggestion blocks only include replacement lines (no unchanged context). For insert-only suggestions: allow a RIGHT-side anchor line repeated **unchanged** plus the new lines; do not modify the anchor line * Do not include removed/LEFT-side lines in suggestions * For re-adding deleted content, anchor to a nearby RIGHT-side line and replace that line with itself plus the added lines +* Do not change the anchor fields (path/side/line/startLine) from the candidate — only edit the body When rejecting, write a concise reason. From 427c95f7df60943fbc4cc03880a1a653c6f60876 Mon Sep 17 00:00:00 2001 From: Nizar Alrifai Date: Tue, 3 Mar 2026 16:04:06 -0800 Subject: [PATCH 06/10] refactor(review): slim suggestion rules Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .../templates/review-candidates-prompt.ts | 8 +++++--- src/create-prompt/templates/review-prompt.ts | 5 ++--- .../templates/review-validator-prompt.ts | 12 ++++-------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/create-prompt/templates/review-candidates-prompt.ts b/src/create-prompt/templates/review-candidates-prompt.ts index 0f6e261..3603eaf 100644 --- a/src/create-prompt/templates/review-candidates-prompt.ts +++ b/src/create-prompt/templates/review-candidates-prompt.ts @@ -200,9 +200,11 @@ Write output to \`${reviewCandidatesPath}\` using this exact schema: \`\`\` - Keep suggestions minimal, scoped to the reported line range, preserve exact leading whitespace, and do not exceed 250 lines. - Only include replacement lines (no unchanged context). For insert-only suggestions: anchor on a RIGHT-side line and repeat it **unchanged**, then append the new lines. Do not modify the anchor line or include removed/LEFT-side lines. - If you need to re-add deleted content, anchor on a nearby RIGHT-side line and replace that line with itself plus the added lines (insert-only via replacement). + **Suggestion rules (minimal):** + - Keep suggestion blocks ≤ 250 lines + - Preserve exact leading whitespace + - Use RIGHT-side anchors only; do not include removed/LEFT-side lines + - For insert-only suggestions, repeat the anchor line unchanged, then append new lines - \`line\`: Target line number (single-line) or end line number (multi-line). Must be ≥ 0. - \`startLine\`: \`null\` for single-line comments, or start line number for multi-line comments - \`side\`: "RIGHT" for new/modified code (default). Use "LEFT" only for removed code **without** suggestions. diff --git a/src/create-prompt/templates/review-prompt.ts b/src/create-prompt/templates/review-prompt.ts index 76f94b5..a69520d 100644 --- a/src/create-prompt/templates/review-prompt.ts +++ b/src/create-prompt/templates/review-prompt.ts @@ -329,9 +329,8 @@ Rules: * Keep the suggestion minimal and scoped to the reported line range * Do not exceed 250 lines in a suggestion block * Preserve exact leading whitespace of replaced lines -* Only include the replacement lines (no unchanged context). For insert-only suggestions: anchor on a RIGHT-side line and repeat it **unchanged**, then append the new lines. Do not modify the anchor line. -* Do not include removed/LEFT-side lines in suggestions -* If you need to re-add deleted content, anchor on a nearby RIGHT-side line and replace that line with itself plus the added lines (i.e., insert-only via replacement) +* Use RIGHT-side anchors only; do not include removed/LEFT-side lines +* For insert-only suggestions, repeat the anchor line unchanged, then append new lines --- diff --git a/src/create-prompt/templates/review-validator-prompt.ts b/src/create-prompt/templates/review-validator-prompt.ts index 27aa6cd..92f67e8 100644 --- a/src/create-prompt/templates/review-validator-prompt.ts +++ b/src/create-prompt/templates/review-validator-prompt.ts @@ -108,14 +108,10 @@ Reject if: * It's already reported (dedupe against existing comments) * The anchor (path/side/line/startLine) would need to change to make the suggestion work — reject instead -Suggestion block rules: -* If an approved comment includes a GitHub suggestion block, ensure the fix is **high confidence** and minimal -* Suggestion blocks must preserve exact leading whitespace and not exceed 250 lines -* If the fix is clearly high confidence but the candidate lacks a suggestion block, add one to the approved comment body -* If the suggestion is not high confidence, remove the suggestion block or reject the candidate -* Ensure suggestion blocks only include replacement lines (no unchanged context). For insert-only suggestions: allow a RIGHT-side anchor line repeated **unchanged** plus the new lines; do not modify the anchor line -* Do not include removed/LEFT-side lines in suggestions -* For re-adding deleted content, anchor to a nearby RIGHT-side line and replace that line with itself plus the added lines +Suggestion block rules (minimal): +* Preserve exact leading whitespace and keep blocks ≤ 250 lines +* Use RIGHT-side anchors only; do not include removed/LEFT-side lines +* For insert-only suggestions, repeat the anchor line unchanged, then append new lines * Do not change the anchor fields (path/side/line/startLine) from the candidate — only edit the body When rejecting, write a concise reason. From d0beb92df1369f038df9705b4156821399aa8518 Mon Sep 17 00:00:00 2001 From: factory-nizar Date: Tue, 3 Mar 2026 16:35:39 -0800 Subject: [PATCH 07/10] Update src/create-prompt/templates/review-prompt.ts Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- src/create-prompt/templates/review-prompt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/create-prompt/templates/review-prompt.ts b/src/create-prompt/templates/review-prompt.ts index a69520d..8326ed4 100644 --- a/src/create-prompt/templates/review-prompt.ts +++ b/src/create-prompt/templates/review-prompt.ts @@ -349,7 +349,7 @@ Rules: * Anchor using **path + side + line** * RIGHT = new/modified code, LEFT = removed code * Line numbers must correspond to the chosen side - * If you include a suggestion, keep the anchor on RIGHT-side lines and do not change the anchor line content + * If you include a suggestion, keep the anchor on RIGHT-side lines; for insert-only suggestions, repeat the anchor line unchanged, then append new lines * Use \`github_pr___submit_review\` for the summary * Use \`github_pr___delete_comment\` or \`github_pr___minimize_comment\` for outdated "no issues" comments * Use \`github_pr___reply_to_comment\` to acknowledge resolved issues From 172ff3b84b07148a5fa78df295c9e642771596e8 Mon Sep 17 00:00:00 2001 From: factory-nizar Date: Wed, 4 Mar 2026 19:06:21 +0000 Subject: [PATCH 08/10] update 250 to 100 --- src/create-prompt/templates/review-candidates-prompt.ts | 4 ++-- src/create-prompt/templates/review-prompt.ts | 2 +- src/create-prompt/templates/review-validator-prompt.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/create-prompt/templates/review-candidates-prompt.ts b/src/create-prompt/templates/review-candidates-prompt.ts index 3603eaf..5bdedbc 100644 --- a/src/create-prompt/templates/review-candidates-prompt.ts +++ b/src/create-prompt/templates/review-candidates-prompt.ts @@ -200,8 +200,8 @@ Write output to \`${reviewCandidatesPath}\` using this exact schema: \`\`\` - **Suggestion rules (minimal):** - - Keep suggestion blocks ≤ 250 lines + **Suggestion rules:** + - Keep suggestion blocks ≤ 100 lines - Preserve exact leading whitespace - Use RIGHT-side anchors only; do not include removed/LEFT-side lines - For insert-only suggestions, repeat the anchor line unchanged, then append new lines diff --git a/src/create-prompt/templates/review-prompt.ts b/src/create-prompt/templates/review-prompt.ts index 8326ed4..86b02f9 100644 --- a/src/create-prompt/templates/review-prompt.ts +++ b/src/create-prompt/templates/review-prompt.ts @@ -327,7 +327,7 @@ If you have **high confidence** a fix will address the issue and won’t break C Rules: * Only include a suggestion when the fix is clear and high-confidence * Keep the suggestion minimal and scoped to the reported line range -* Do not exceed 250 lines in a suggestion block +* Do not exceed 100 lines in a suggestion block * Preserve exact leading whitespace of replaced lines * Use RIGHT-side anchors only; do not include removed/LEFT-side lines * For insert-only suggestions, repeat the anchor line unchanged, then append new lines diff --git a/src/create-prompt/templates/review-validator-prompt.ts b/src/create-prompt/templates/review-validator-prompt.ts index 92f67e8..2bc2575 100644 --- a/src/create-prompt/templates/review-validator-prompt.ts +++ b/src/create-prompt/templates/review-validator-prompt.ts @@ -109,7 +109,7 @@ Reject if: * The anchor (path/side/line/startLine) would need to change to make the suggestion work — reject instead Suggestion block rules (minimal): -* Preserve exact leading whitespace and keep blocks ≤ 250 lines +* Preserve exact leading whitespace and keep blocks ≤ 100 lines * Use RIGHT-side anchors only; do not include removed/LEFT-side lines * For insert-only suggestions, repeat the anchor line unchanged, then append new lines * Do not change the anchor fields (path/side/line/startLine) from the candidate — only edit the body From e5455ae83490d9b108581fa825d713914e404e0d Mon Sep 17 00:00:00 2001 From: Nizar Alrifai Date: Thu, 5 Mar 2026 11:48:06 -0800 Subject: [PATCH 09/10] Add validator_model input to allow separate model for validator pass Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- action.yml | 5 +++++ src/tag/commands/review-validator.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index e419f98..e8c517c 100644 --- a/action.yml +++ b/action.yml @@ -99,6 +99,10 @@ inputs: description: "Override reasoning effort for review flows (passed to Droid Exec as --reasoning-effort). If empty and review_model is also empty, the action defaults internally to gpt-5.2 at high reasoning." required: false default: "high" + validator_model: + description: "Override the model used for the validator pass (phase 2) of code review. If empty, falls back to review_model. Only applies when review_use_validator is true." + required: false + default: "" review_use_validator: description: "Enable two-pass review: generate candidate comments to JSON, then validate and post only approved ones." required: false @@ -347,6 +351,7 @@ runs: REVIEW_CANDIDATES_PATH: ${{ inputs.review_candidates_path }} DROID_COMMENT_ID: ${{ steps.prepare.outputs.droid_comment_id }} REVIEW_MODEL: ${{ inputs.review_model }} + VALIDATOR_MODEL: ${{ inputs.validator_model }} REASONING_EFFORT: ${{ inputs.reasoning_effort }} - name: Run Droid Exec (validator) diff --git a/src/tag/commands/review-validator.ts b/src/tag/commands/review-validator.ts index 96f8ea8..40d40de 100644 --- a/src/tag/commands/review-validator.ts +++ b/src/tag/commands/review-validator.ts @@ -103,11 +103,13 @@ export async function prepareReviewValidatorMode({ droidArgParts.push(`--enabled-tools "${allowedTools.join(",")}"`); droidArgParts.push('--tag "code-review"'); + const validatorModel = process.env.VALIDATOR_MODEL?.trim(); const reviewModel = process.env.REVIEW_MODEL?.trim(); + const modelToUse = validatorModel || reviewModel; const reasoningEffort = process.env.REASONING_EFFORT?.trim(); - if (reviewModel) { - droidArgParts.push(`--model "${reviewModel}"`); + if (modelToUse) { + droidArgParts.push(`--model "${modelToUse}"`); } if (reasoningEffort) { droidArgParts.push(`--reasoning-effort "${reasoningEffort}"`); From 916f6dce194691798a8f7bb849fecb5e9a230148 Mon Sep 17 00:00:00 2001 From: Nizar Alrifai Date: Fri, 6 Mar 2026 09:48:17 -0800 Subject: [PATCH 10/10] Add strict deduplication rules to validator prompt Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- src/create-prompt/templates/review-validator-prompt.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/create-prompt/templates/review-validator-prompt.ts b/src/create-prompt/templates/review-validator-prompt.ts index 2bc2575..e754f4a 100644 --- a/src/create-prompt/templates/review-validator-prompt.ts +++ b/src/create-prompt/templates/review-validator-prompt.ts @@ -108,6 +108,13 @@ Reject if: * It's already reported (dedupe against existing comments) * The anchor (path/side/line/startLine) would need to change to make the suggestion work — reject instead +### Deduplication (STRICT) + +Before approving a candidate, check for duplicates: +1. **Among candidates**: If two or more candidates describe the same underlying bug (same root cause, even if anchored to different lines or worded differently), approve only the ONE with the best anchor and clearest explanation. Reject the rest with reason "duplicate of candidate N". +2. **Against existing comments**: If a candidate repeats an issue already covered by an existing PR comment (from \`${commentsPath}\`), reject it with reason "already reported in existing comments". +3. Same file + overlapping line range + same issue = duplicate, even if the body text differs. + Suggestion block rules (minimal): * Preserve exact leading whitespace and keep blocks ≤ 100 lines * Use RIGHT-side anchors only; do not include removed/LEFT-side lines