feat: inline COMMENT-state PR review (findings anchored to changed lines) #18

Merged
steve merged 2 commits from feat/inline-review into main 2026-06-29 01:59:36 +00:00

2 Commits

Author SHA1 Message Date
steve 4ea80cad1f fix: address swarm review of the inline PR review (PR #18)
Build & push image / build-and-push (pull_request) Successful in 8s
From PR #18's own review — the FIRST run with consensus consolidation live (it
posted one ranked consensus comment across 7 models instead of 7 walls).

- Anchor inline comments to ADDED lines only (parseDiffNewLines no longer
  records context lines): Gitea reliably accepts comments on added lines, so the
  all-or-nothing review POST won't be rejected for an off-change anchor.
- Span-scan anchoring (anchorLine): a cluster whose min line is just outside the
  diff still anchors if any line in its [line,maxLine] span is an added line.
- Path normalization (normPath) on both diff and finding paths, so "./pkg/x.go"
  vs "pkg/x.go" vs a "b/"-prefixed diff path all match (and the comment Path is
  the normalized repo-relative one).
- deletePriorReviews: paginate (cap 10 pages) and bail on a non-2xx GET, so a
  stale marked review past page 1 is still removed and the "replace not stack"
  guarantee holds better under failure.
- mergeIntoCluster backfills an empty title/detail from any report (not only a
  strictly-higher-severity one).
- Rename inlineReviewHTTPTime -> inlineReviewHTTPTimeout (emit.go convention).

Graded the run's 36 findings in gadfly-reports (notably a 7/7-consensus
deletePriorReviews error-handling finding — the consensus signal working as
intended). XSS-framed findings marked false (Gitea sanitizes review markdown);
trusted-input and gofmt-clean ones likewise. Tests updated for added-only
anchoring + span scan. gofmt/vet/bash -n clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 21:59:27 -04:00
steve 7577c21039 feat: inline COMMENT-state PR review (findings anchored to changed lines)
Build & push image / build-and-push (pull_request) Successful in 7s
Adversarial Review (Gadfly) / review (pull_request) Successful in 15m18s
Phase 3. Alongside the consensus comment, the consolidator now posts ONE Gitea
pull review (state COMMENT — advisory, never request-changes/approve, so it can
never block a merge) whose inline comments anchor each consensus finding to the
exact changed line. The "reviewer integrated with Gitea" the project wanted,
without the blocking.

- review.go: a unified-diff parser (parseDiffNewLines — hunk-length-bounded, so a
  content line that looks like "+++ "/"@@" isn't mistaken for a header), inline
  comment building filtered to lines actually in the diff, and the Gitea reviews
  API client (raw new_position/event=COMMENT fields). Re-runs delete the prior
  gadfly review (body marker) instead of stacking.
- consensus.go: cluster.detail restored (now consumed by the inline comment body);
  renderConsensus takes precomputed clusters; runConsolidate clusters once and
  drives both the consensus comment and the inline review.
- entrypoint.sh: fetch the PR diff and pass GADFLY_DIFF_FILE to the consolidator
  (GITEA_API/TOKEN/PR already in its env).
- README + reusable workflow (`inline_review` input) + entrypoint docs.

Best-effort throughout: no diff / API creds, or any post error → the consensus
comment still stands; the review is never required and never blocks. Validated
the Gitea reviews API + line anchoring live before building. Tests: diff parser
(incl. header-like content + multi-file), inline filtering. gofmt/vet/bash -n clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 19:07:32 -04:00