Skip to content

feat(task-board): QA Agent + Code Reviewer review flow with ship-to-production - #5520

Merged
guitavano merged 6 commits into
mainfrom
review-agents
Jul 31, 2026
Merged

guitavano merged 6 commits into
mainfrom
review-agents

Conversation

@guitavano

@guitavano guitavano commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds two per-org automated reviewers that run on a task's PR once the Super Agent finishes, plus a ship-to-production merge flow. All reviewers are derived identities over the org's agent runtime (same pattern as the Super Agent) — no seeding.

Reviewers (org-flag gated)

  • QA Agent (qa_agent_enabled) — verifies the task actually solved the problem (exercises the feature).
  • Code Reviewer (code_reviewer_enabled) — reviews the code using the repo's stack-appropriate review skills.
  • Both run as linked threads shown live on the card; the Super Agent "delegates" to each in the activity feed.
  • Headless trigger: fires from the projector's run-terminal hook when a Super Agent run finishes (no UI needed). The modal's 10s poll is a reconcile-on-view safety net.

Decision & merge

  • TASK_BOARD_REVIEW_DECISION { reviewer, decision, notes }:
    • request_changes → hands back to the Super Agent with the feedback + gh pr checkout so it updates the same PR.
    • approve → records the sign-off.
  • Auto-merge (auto_merge flag) merges once every enabled reviewer approves; otherwise a manual "Ship to production" button (+ TASK_BOARD_PROMOTE_TO_PRODUCTION).
  • CI gate: never ships on failing/pending checks (client hides the button + server mergeLinkedPr refuses).

PR card

  • Live state, #123 ↗ GitHub link, action row (Edit / preview / ship).
  • Expandable checks footer — merges the Status API + Checks API, and opens each failing check's output markdown (GET_CHECK_RUN).
  • deco deploy preview link, lifted from the deploy bot's PR comment (Cloudflare cloudflare-workers-and-pages[bot] branch preview / deco.cx decobot).
  • Concurrent GitHub reads (was ~9s serial → ~2–4s) + a loading skeleton.

Other

  • Settings → Organization → "Reviewers & merge" with the 3 toggles.
  • resolveGithubConnection prefers the connection matching the PR's repo (or the broad org-level one) so multi-repo-scoped orgs resolve live state correctly.
  • Dispatch defaults the sandbox target to the env-configured provider (STUDIO_SANDBOX_PROVIDER) so background runs work under --local-sandbox-provider (prod unchanged).
  • Migration 154 adds the review_* activity actions.

Testing

  • bun run fmt, typecheck (shared/api/web), bun run lint (0 errors), bun run knip (0) all pass.
  • Unit tests: reviewer sentinel validation, checks status mapping (Status API + check-runs merge), preview-URL extraction (both bot formats), promotion readiness — 77 pass.
  • Pure-logic only; the I/O paths (enqueue, merge, GitHub fetch) are e2e-tier per TESTING.md.

Notes

  • The checks footer + preview add GitHub round-trips per poll (now concurrent). Can be optimized (cache / progressive load) later.

🤖 Generated with Claude Code


Summary by cubic

Adds per‑org QA Agent and Code Reviewer that auto‑review a task’s PR after the Super Agent, with approve/request‑changes and CI‑gated ship‑to‑production. Hardens the flow with idempotent reviewer enqueue and token‑verified decisions.

  • New Features

    • Automated reviewers (qa_agent_enabled, code_reviewer_enabled) run as linked threads; triggered headlessly when the Super Agent run finishes.
    • TASK_BOARD_REVIEW_DECISION: approve records sign‑off; request_changes hands back to the Super Agent with feedback to update the same PR.
    • Auto‑merge when all enabled reviewers’ approvals are verified if auto_merge is on; otherwise manual "Ship to production" via TASK_BOARD_PROMOTE_TO_PRODUCTION.
    • CI gate blocks merges on failing or pending checks.
    • PR card: live status, expandable checks footer (Status + Checks APIs with failing check output), deploy preview link, and faster GitHub reads (concurrent fetch + skeleton).
    • Settings → Organization → Reviewers & merge: toggles to enable reviewers and auto‑merge.
    • Migration: run 154-task-board-qa-activity (review_* actions) and 155-task-board-review-claims (per‑cycle review claims + tokens).
  • Bug Fixes

    • Re‑review now re‑runs reviewers: recording the status_changed → in_review activity on backstop transitions resets the cycle boundary.
    • Strict preview host guard to prevent injected links from PR comments.
    • Org‑scoped GitHub connection resolution on PR merges.
    • Hardened review flow: per‑(task, reviewer, cycle) claim dedups concurrent enqueues; decisions are token‑verified and auto‑merge requires verified approvals.
    • Added unit tests for checks status mapping, preview host guard, reviewer idempotency/re‑run, and the verified‑approval gate; aligned Task Manager tools integration to include TASK_BOARD_REVIEW_DECISION.

Written for commit bdf0192. Summary will update on new commits.

Review in cubic

guitavano and others added 6 commits July 31, 2026 15:48
…roduction

Add two per-org automated reviewers that run on a task's PR once the Super
Agent finishes, gated by org flags, plus a manual "ship to production" merge.

- Reviewers: QA Agent (verifies the task solved the problem) and Code Reviewer
  (reviews the code with the repo's stack review skills). Enabled per-org via
  `qa_agent_enabled` / `code_reviewer_enabled` flags; both run as linked threads
  shown live on the card, delegated by the Super Agent.
- Trigger is headless: fires from the projector's run-terminal hook when a
  Super Agent run finishes (no UI required); the modal's poll is a safety net.
- Decision via `TASK_BOARD_REVIEW_DECISION` (request_changes hands back to the
  Super Agent with feedback + `gh pr checkout` to update the same PR; approve
  records the sign-off). Auto-merge (`auto_merge` flag) merges once every enabled
  reviewer approves; a manual "Ship to production" button + merge tool otherwise.
- Merge is gated on CI: never ships on failing/pending checks (client + server).
- PR card: live state, an expandable checks footer (Status API + Checks API,
  with each failing check's output markdown), and the deco deploy preview link
  (lifted from the deploy bot's PR comment). Concurrent GitHub reads + a
  loading skeleton.
- Dev: dispatch defaults the sandbox target to the env-configured provider so
  background runs work under `--local-sandbox-provider`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…g-scoped merge conn

Address blockers/important findings from the branch review:
- Re-review never re-ran the reviewers: the thread-finish backstop advanced a
  task to In Review without recording a `status_changed` activity, so the
  reviewer cycle boundary (`lastInReviewAt`) went stale after a request_changes
  fix pushed to the same PR. Record the transition so reviewers re-run.
- Preview-host match was an unanchored substring on attacker-writable PR-comment
  URLs (phishing button + a URL the autonomous QA agent opens). Replace with a
  strict hostname check (`isDecoPreviewHost`).
- `resolveGithubConnection` resolved a linked connectionId without an org filter
  on a PR-merge (write) path — org-scope the lookup.
- Add unit tests: `isDecoPreviewHost` (incl. the decoy), `reviewerHandledThisCycle`
  (incl. the re-review prior-cycle case).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…tokens, dedup enqueue

P1:
- #4 double-enqueue race: per-(task,reviewer,cycle) claim table
  (INSERT ... ON CONFLICT DO NOTHING) gates each reviewer so a
  concurrent/duplicate trigger enqueues a reviewer at most once per cycle.
- #5 reviewer identity forgery: each claim mints a reviewToken bound to the
  reviewer; TASK_BOARD_REVIEW_DECISION marks a decision `verified` only when
  the token resolves to a claim whose reviewer matches. Auto-merge gate
  requires every enabled reviewer's latest verdict to be a VERIFIED approve,
  so one agent can't forge the two-reviewer sign-off.

P2:
- #6 tests: shared review-cycle reducer + verifiedOnly anti-forgery gate,
  checks-status parsing/preview-host, reviewer re-review cycle.
- #7 duplication: extract enqueueAgentRunForTask (thread create + link +
  persist-before-dispatch + enqueue) shared by the Super Agent and reviewer
  enqueues; reuse StudioContextFactory instead of a local copy.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
# Conflicts:
#	apps/api/src/storage/task-board.ts
#	packages/shared/src/organization/schema.ts
#	packages/shared/src/tools/tool-io.ts
…s integration assertion

The studio-pack integration test pinned the Task Manager's selected_tools
without TASK_BOARD_REVIEW_DECISION, which the review flow added to the
manager. Align the expected list with the source (task-manager.ts) and the
unit test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
# Conflicts:
#	apps/web/src/layouts/task-board/task-dialog.tsx
@guitavano
guitavano merged commit 3c04e91 into main Jul 31, 2026
26 checks passed
@guitavano
guitavano deleted the review-agents branch July 31, 2026 20:37
decocms Bot pushed a commit that referenced this pull request Jul 31, 2026
PR: #5520 feat(task-board): QA Agent + Code Reviewer review flow with ship-to-production
Bump type: minor

- decocms (apps/api/package.json): 4.157.0 -> 4.158.0
- @decocms/native (apps/native/package.json): 4.157.0 -> 4.158.0
- @decocms/shared (packages/shared/package.json): 0.11.2 -> 0.12.0

Deploy-Scope: both
pedrofrxncx added a commit that referenced this pull request Aug 1, 2026
enqueueEnabledReviewers awaited each reviewer's claim+enqueue
sequentially, even though QA and Code Reviewer are independent DB rows
keyed by their own kind. This runs on TASK_BOARD_ITEM_PRS_GET's
synchronous 10s-poll path, so with both reviewers enabled (shipped in
#5520) the round-trip serialized two full claim+thread-create+dispatch
chains back to back.
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