Skip to content

fix: make review posting deterministic - #138

Open
factory-nizar wants to merge 1 commit into
devfrom
nizar/submit-review-idempotency
Open

fix: make review posting deterministic#138
factory-nizar wants to merge 1 commit into
devfrom
nizar/submit-review-idempotency

Conversation

@factory-nizar

Copy link
Copy Markdown
Contributor

Summary

  • make submit_review atomic and idempotent per MCP process, with a hard refusal after a successful or in-flight submission
  • enforce action-side turn limits for both review passes (100 candidate turns, 40 validator turns) without retrying runaway sessions
  • make the validator file-only and post review_validated.json through one deterministic GitHub API call
  • validate diff anchors, bound GitHub payloads, and render posting results in the tracking comment
  • share validated-review, diff-index, review-posting, and result-parsing primitives with the GitLab flow

Validation

  • bun test (618 passed)
  • bun run typecheck
  • bun run format:check
  • git diff --check

Add per-process review submission guards, hard turn limits for both review passes, and move validated GitHub review posting into a deterministic CI step.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@factory-droid

factory-droid Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Droid finished @factory-nizar's task —— View job


Security Review

The deterministic posting flow has two high-confidence gaps: it does not pin the review to the validated head commit, and the file-only validator still exposes a write-capable GitHub token to shell execution.

startLine: startLine !== null && startLine < anchor ? startLine : null,
side,
old_path: asNonEmptyString(comment.old_path),
old_line: oldLine,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Pin the review to the validated commit

The validator emits commit_id, but this parser drops it, so the deterministic GitHub posting request defaults to the PR's latest head. If a commit is pushed after pr.diff is generated, GitHub resolves the old anchors against the new head and can reject the atomic review or attach findings to different code; preserve the validated SHA and pass it as the review's top-level commit_id.

context,
});
const allowedTools = Array.from(new Set(baseTools));
const mcpTools = JSON.stringify({ mcpServers: {} });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] [security] Remove GitHub credentials from the validator process

The file-only validator still enables Execute, and every action variant passes GITHUB_TOKEN into the Droid process running with unsafe permission skipping. A prompt injection in the required-to-read PR diff can therefore invoke the GitHub API directly with that token, bypassing this empty MCP configuration and the claimed single deterministic posting call; omit the token from the validator process and expose it only to preparation and posting steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant