Skip to content

feat(review): configurable AO code review backend (V1) (#192)#197

Open
neversettle17-101 wants to merge 9 commits into
mainfrom
feat/issue-192
Open

feat(review): configurable AO code review backend (V1) (#192)#197
neversettle17-101 wants to merge 9 commits into
mainfrom
feat/issue-192

Conversation

@neversettle17-101

Copy link
Copy Markdown
Collaborator

Summary

Implements configurable AO code review (V1) for issue #192. A worker's PR can be reviewed by a configured reviewer agent: the reviewer runs one-shot over the worker's own worktree, and the result is posted to GitHub. The worker picks the feedback up through AO's existing SCM observer → review-nudge path.

This folds in the V1 design comment (now reflected in the issue body), which supersedes the original HLD.

What changed

Domain / config

  • ProjectConfig.reviewers ([]ReviewerConfig{ harness }), validated against known harnesses. No enabled flag.
  • Empty/unset reviewers resolves to a default reviewer (claude-code) via ResolvedReviewers().
  • domain.Review / domain.ReviewRun with status (pending|complete|failed) and verdict (approved|changes_requested) vocab.

Storage

  • Migration 0011_add_review_tables.sql: review (one per worker, session_id UNIQUE) + review_run (per pass).
  • sqlc queries + review_store.go (upsert-reuse, run insert/result, latest/list).

Service

  • Rewrote the in-memory review stub as a persisted ReviewService (Trigger, Submit, List).
  • Trigger reuses/creates the review row, records a pending review_run, and launches the reviewer over the worker's worktree (reusing AgentResolver + Runtime).
  • Submit posts the verdict+body to the PR and marks the run complete (body is not persisted — it lives on GitHub).
  • New ports.PRReviewPoster, implemented on the GitHub adapter (POST /pulls/{n}/reviews).

HTTP / CLI / Frontend

  • Session-scoped routes: POST /sessions/{sessionId}/reviews/trigger, POST .../submit, GET .../reviews. Regenerated OpenAPI + TS types.
  • ao review trigger|submit|list.
  • Adapted ReviewDashboard to the per-worker reviews API.

Out of V1 / later

Derived in_review status; auto-trigger on PR HEAD SHA advance; Greptile no-workspace adapter; reviewer read-only permission mode; one-per-(session_id, pr_url) keying.

Testing

  • go build ./... && go test ./... && go vet ./... — pass.
  • golangci-lint run on changed packages — 0 issues.
  • New tests: domain config validation + default resolution, store round-trips, ReviewService (trigger/submit/list, validation, failure paths), GitHub poster (httptest), CLI commands.
  • npm run sqlc / npm run api — no drift.
  • Frontend tsc could not run in this environment (deps not installed); ReviewDashboard.tsx was aligned to the regenerated schema.ts and CI will run the real typecheck.

Closes #192

🤖 Generated with Claude Code

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Add per-project configurable code review of a worker's PR. A reviewer
agent runs one-shot over the worker's own worktree and posts its result
to the PR; the worker picks the feedback up through the existing SCM
observer review-nudge path.

- domain: ProjectConfig.reviewers (+ default reviewer harness), Review /
  ReviewRun types and verdict/status vocab.
- storage: review + review_run tables (0011), sqlc queries, store methods.
- service/review: rewrite the in-memory stub as a persisted ReviewService
  (Trigger/Submit/List) with a reviewer Runner over agent resolver +
  runtime; ports.PRReviewPoster implemented on the GitHub adapter.
- http: session-scoped routes POST /sessions/{id}/reviews/trigger,
  POST .../submit, GET .../reviews; regenerated OpenAPI + TS types.
- cli: ao review trigger|submit|list.
- frontend: adapt ReviewDashboard to the per-worker reviews API.

Closes #192

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Comment thread backend/internal/adapters/scm/github/review_poster.go Outdated
Comment thread backend/internal/cli/review.go Outdated
Comment thread backend/internal/cli/review.go Outdated
Comment thread backend/internal/daemon/lifecycle_wiring.go Outdated
Comment thread backend/internal/domain/projectconfig.go Outdated
Comment thread backend/internal/domain/projectconfig.go Outdated
Comment thread backend/internal/httpd/controllers/reviews.go
Comment thread backend/internal/service/review/review.go
Comment thread backend/internal/service/review/review.go
…viewer to worker harness

Per PR #197 review feedback:
- Reviewer agent posts its review to the PR itself, so remove the
  ports.PRReviewPoster port, the GitHub review poster, the submit HTTP
  route + DTO, and the service Submit method (#1, #4, #7).
- Trigger spawns the reviewer agent over the worker's worktree with its
  own review prompt, mirroring the session launch flow (resolve agent by
  harness -> argv -> runtime.Create) (#8, #9).
- Default reviewer harness reuses the worker's harness when supported,
  falling back to claude-code; reviewer config stays independent of the
  worker override (#5, #6).
- Drop the `ao review` CLI for this PR's scope (#2, #3).

Regenerated OpenAPI + TS types.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Per maintainer request, bring back `ao review submit`. AO records the
reviewer's verdict and body on the review_run and marks the pass complete;
it does not post to GitHub — the reviewer agent posts its review to the PR
itself.

- storage: add review_run.body (0011), persist via Insert/UpdateReviewRunResult.
- service: restore Submit (no SCM poster) storing verdict + body.
- http: restore POST /sessions/{id}/reviews/submit + SubmitReviewInput.
- cli: ao review submit [worker] --verdict --body (worker from arg/--session/$AO_REVIEW_WORKER).
- runner: reviewer prompt instructs posting to GitHub and recording via ao review submit.

Regenerated OpenAPI + TS types.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@neversettle17-101

Copy link
Copy Markdown
Collaborator Author

Per maintainer request, restored ao review submit (commit 8ace34b). It records the reviewer's verdict + body on the review_run (new body column) and marks the pass complete — AO does not post to GitHub; the reviewer agent posts its review to the PR itself, so there is still no PRReviewPoster. Re: thread on reviews.go submit (now reopened in effect): endpoint is back as POST /sessions/{sessionId}/reviews/submit, plus ao review submit [worker] --verdict --body.

Comment thread backend/internal/service/review/runner.go Outdated
Comment thread backend/internal/service/review/runner.go Outdated
…ompt

Per PR #197 review:
- Move the concrete reviewer runner out of the service layer into a new
  internal/review_runner package (package reviewrunner), beside other
  orchestration packages like session_manager. The service keeps only the
  Runner interface + RunSpec it depends on; the agent-resolver + runtime
  launch flow lives in review_runner.
- Sharpen the reviewer prompt: tell the agent to diff against the PR base,
  focus on high-confidence findings, post via `gh pr review`, and record
  the result with `ao review submit`; review-only (no commits/edits).
- Add unit tests for the runner.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Comment thread backend/internal/review_runner/runner.go Outdated
Comment thread backend/internal/storage/sqlite/migrations/0011_add_review_tables.sql Outdated
Comment thread backend/internal/storage/sqlite/migrations/0011_add_review_tables.sql Outdated
Comment thread backend/internal/storage/sqlite/migrations/0011_add_review_tables.sql Outdated
…wer prompt

Per PR #197 review:
- review_run: status default 'running' (drop 'pending'), drop CHECK
  constraints on status/verdict, drop the updated_at column and the
  session/iteration index. Propagated through queries, domain, store,
  service, and tests.
- Reviewer prompt no longer hardcodes GitHub/gh commands — it instructs the
  agent to use whatever review tooling the provider offers, keeping the
  flow extensible across SCM providers.

Regenerated sqlc + OpenAPI/TS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Trigger now spawns the reviewer agent first and then writes the review_run
with a status derived from the launch outcome (running on success, failed
if it never started), instead of inserting a running row and correcting it
to failed afterwards.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

…rnesses

Reviewers are now their own pluggable adapter set, separate from the worker
agent registry — adding a reviewer (claude-code today, greptile tomorrow) is
a one-line registration that does not widen the worker harness vocabulary,
and a worker harness does not automatically become a valid reviewer.

- domain.ReviewerHarness: a distinct vocabulary (AllReviewerHarnesses) with
  its own IsKnown; ReviewerConfig/Review/ReviewRun use it. ResolveReviewerHarness
  reuses the worker harness only when it is itself a supported reviewer, else
  falls back to claude-code.
- ports.Reviewer: a reviewer-specific contract (ReviewCommand → argv + env)
  that models one-shot / non-prompt CLIs natively instead of forcing every
  reviewer through the worker's interactive GetLaunchCommand(Prompt:...).
- internal/adapters/reviewer: a separate registry + resolver (mirrors the
  worker agent registry) with the claude-code reviewer adapter, which owns the
  review prompt and reuses the worker claude-code launch construction.
- review_runner resolves via the reviewer registry (not the worker
  AgentResolver) and merges AO_REVIEW_WORKER into the adapter's env.
- daemon wires the reviewer resolver. Registry/domain parity is test-enforced.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot left a comment

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.

neversettle17-101 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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.

Add configurable AO code review backend

1 participant