Skip to content

Add a persistent pull request review queue and board - #600

Open
dorooleg wants to merge 3 commits into
ClickHouse:mainfrom
dorooleg:hcpp/tasks-code-review
Open

dorooleg wants to merge 3 commits into
ClickHouse:mainfrom
dorooleg:hcpp/tasks-code-review

Conversation

@dorooleg

@dorooleg dorooleg commented Nov 1, 2026 •

Copy link
Copy Markdown

Pull requests requested from a team currently have no durable review queue or separate board in Nerve. Add an opt-in Code Review service that keeps one task per PR until confirmed closure, polls tracked PRs independently of search membership, and preserves immutable review versions and partial attempts.

The authenticated board shows queue state, SHAs, CI, per-version history, schedule health and committed budget. Mermaid diagrams render locally with strict settings, sanitization and a source fallback. Repository selection, schedule, board name and limits live in configuration; profiles default to disabled.

The controller reserves budget before workflow creation, retains cumulative version spend across retries/restarts, shares a daily cap, and separates measured spend from uncertain interrupted usage. Draft/head checks run immediately before execution and result admission. Failed admission retries do not launch another paid audit. PR-level queue age survives base churn; workflow teardown is awaited before releasing a reservation.

Review workers use session-bound MCP tools for SHA-pinned source reads and atomic report checkpoints, so analysis does not require shell access or weaker sandbox settings. The tools restrict access to the active workflow and reject other sessions, stopped attempts, path traversal and symlinks. CI failure context is canonicalized before the first fingerprint to prevent redundant versions from API ordering. Native Codex parent token usage is metered during a turn and retained across interrupted final accounting; late meter samples cannot overwrite terminal costs. Heuristic child estimates remain separate from the measured parent floor.

The renderer preserves immutable diagram source, retries literal note punctuation only after a syntax error, preserves inline sequence commands, and keeps pale highlights readable in dark mode.

No GitHub writes are performed. Repository tests are not executed because this feature does not provision a secret-free test sandbox; reports must disclose this limitation. Startup/restart behavior, pause/resume, backup and installation steps are documented in docs/code-review.md.

Validation: the initial implementation passed the full backend suite — 8,223 passed, 46 skipped; frontend — 1,250 passed; production build and migration numbering check passed. Backend tests ran with ambient NERVE_DOCKER and NERVE_WORKSPACE unset. An independent review found issues that were fixed and covered by regression tests. New frontend files pass lint; the full lint result has the same 125 errors and 17 warnings as the base commit. npm audit reports the same 19 affected packages as the base, with no newly affected packages. The follow-up source/checkpoint tools and CI-order fix passed 312 backend checks, including workflow, MCP, budget and artifact integration, and independent review. Automated tests use synthetic PRs and temporary state.

The metering follow-up passed 396 affected backend checks and independent review. The final frontend suite passed 1,263 tests across 94 files; production build and changed-file lint passed. Browser checks covered authenticated board/history, all four report diagrams and five green highlights in both themes, source copying, and no external rendering requests.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Nerve seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@nerveai

nerveai commented Nov 1, 2026 •

Copy link
Copy Markdown

Nerve PR review · 🔴 Needs rework

Updated for 3fab94d: live budget metering now counts the native Codex parent turn, a late meter sample can no longer change a finished run, and Mermaid retries note labels that contain semicolons. The metering is correct and tested. All three blockers are unchanged.

This adds an opt-in PR-review controller: GitHub polling, immutable review versions, a budget ledger, a task projection and a board. Budget reservation and restart recovery are careful.

Completeness: thorough backend tests and docs; migration v062 is unique and merges cleanly into main. CI has not run (fork PR).

Before merge:

  • Review language is hard-coded. nerve/code_review/prompt.py:24 says "Write in Russian.", and artifacts.py:69-72 rejects a report without «новое».
  • Each comment starts a new paid review. Comments and reviews are in the fingerprint (github.py:117-119, db/code_review.py:96). Any comment, bots included, queues a re-audit, and one that lands mid-run makes the result stale (code_review/service.py:397).
  • The worker still has every tool. Only the prompt limits its tools (prompt.py:11-12). The Claude spec has no allowlist (code_review/service.py:321-325), and claude.py:664-677 auto-approves Bash, gh with the operator's token, and Nerve's tools. The new tools are registered for every session and external MCP client (handlers/__init__.py:51), even with code_review off. Gate them the way hoa_ tools are gated (registry.py:172-181).

Worth considering:

  • Split out the metering fix. It changes budget enforcement for every Codex workflow run (workflows/service.py:879-883, codex/backend.py:1589-1599). It relies on _prev_total_usage/_turn_total_base, which open Codex: count usage per notification and report the last call's context #473 removes; a separate PR lets the two land in order.
  • Its own scheduler. code_review/service.py:38,81-86 schedules outside CronService, so a parked instance never wakes to poll.

Checked: full suite in an offline sandbox at 3fab94d (3 chunks): 8247 passed, 39 skipped; test_slack_integration.py excluded (it hangs offline on main too). Read the 3fab94d delta, the meter path and Codex turn accounting; ran a merge check against main and open PRs. Frontend not run locally. · automated review by nerveai. Mention @nerveai to ask a follow-up.

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.

3 participants