Contents
Reference

Architecture

How a review flows through Cerbie on Cloudflare, and why it's built that way.

Cerbie runs entirely on Cloudflare. The goal is the best review in the shortest wall-clock time. Every design choice below either cuts latency (parallelism, warm mirrors, no installs, prompt caching) or raises signal (specialists, independent verification, convergence across rounds).

flowchart TD
  GH[GitHub webhooks] --> W[Worker: verify + gate]
  W --> DO[PullRequestCoordinator<br/>one Durable Object per PR]
  DO -->|debounce, supersede| WF[ReviewWorkflow]
  WF --> CTX[Context step]
  CTX --> S1[Summary]
  CTX --> S2[Primary reviewer<br/>sharded for large PRs]
  CTX --> S3[Specialists:<br/>security · data · contracts]
  CTX --> S4[Custom checks]
  CTX --> S5[Deterministic:<br/>deps · OSV · lockfile · secrets · workflows]
  CTX --> S6[Follow-up of<br/>earlier findings]
  S2 & S3 --> PC[Pattern coverage<br/>patterns and migrations only]
  PC & S4 & S5 & S6 --> V[Verifier<br/>fresh context]
  V -->|risky PR that would be approved| C[Approval challenge<br/>+ verification of its findings]
  V --> P[Publish: review, inline comments,<br/>check runs, thread housekeeping]
  C --> P
  S1 -.->|posted as soon as ready| GH2[Sticky summary comment]
  S2 & S3 & V -.->|tools| GIT[(Git mirror container<br/>shallow bare clones)]
  S2 & S3 & V -.->|LLM calls| LLM[cerbie-llm-gateway<br/>CLIProxyAPI container]
  P --> D1[(D1: runs, findings,<br/>users, settings)]
  WF --> R2[(R2: context, results,<br/>rendered output)]

Request flow

  1. Webhook (apps/worker/src/index.ts, webhooks.ts). The Worker verifies the HMAC signature and deduplicates by delivery ID in D1; push and pull_request_review_thread deliveries, which nothing uses, are answered straight after the signature check with no D1 query (the GitHub App needn’t subscribe to them). It then reads .cerbie/config.yaml from the base branch to decide whether this event should trigger a review (drafts, ignored authors and labels, base branches, cerbie: skip). Commands (@cerbieai …) and thread replies are handled here too. Afterwards, PR lifecycle events, people’s reviews and other apps’ CI (check runs and suites, commit statuses) are recorded in pull_events with the time they happened, so the time from ready for review to merge can be split into waiting on review, CI or a person. Recording is idempotent per delivery and never changes how the delivery is handled. GitHub sends a check suite’s requested only to the app that owns it, so of other apps’ CI Cerbie is often told only that a suite completed: a completed check run keeps its started_at, and each completed suite on a commit that was a PR’s head is read back from GitHub once (suite-runs.ts, one REST call per 100 runs, after the delivery is handled), its runs’ starts and completions recorded with the backfill’s shapes and delivery ids so a run is never counted twice, and the suite marked runs_read. That read never waits out a rate limit and stops once less than half the hourly budget is left; a suite it skips is read by the hourly cron, 50 a tick, merged PRs’ first. The hourly cron deletes CI events older than 90 days; lifecycle and review events are kept. When the merge is recorded, pull-cycles.ts works out where the PR’s time went from those events and Cerbie’s live review runs and saves it in pull_cycles (migration 0017 documents the buckets), and works it out again if an earlier event is recorded after that. The buckets always add up to the time to merge, so when review and CI are both pending each moment goes to whichever finishes last, as that is what the PR was waiting on (the stretch of review, or of CI, under way at that moment, known in full once the PR has merged; review on a tie). Next to them, review_active_ms and ci_active_ms (migration 0019) are how long review and CI were each pending, overlap included, so each can be driven down on its own. When the rules change, bump CYCLE_VERSION: a second hourly cron tick (:47, its own invocation so it never eats into the main tick’s D1 query budget) rebuilds rows worked out with older rules, 50 a tick, latest merges first, and an admin can rebuild the rows of the repositories they can read at once with POST /api/pull-cycles/recompute, a batch per call (pass the returned next back as after). PRs with events older than the CI retention keep the rows they have (counted as kept). PRs Cerbie reviewed live before recording began (2026-10-09T13:48:50Z, BACKFILL_BEFORE in pull-backfill.ts) are backfilled by the hourly cron, ten PRs a tick, from their GitHub timeline, head-branch pushes and CI: only what happened before that moment and isn’t already recorded (a delivery just before it can arrive after), so nothing is counted twice, as rows shaped like live ones with a backfill: delivery id, so a rerun records nothing new. An installation is left alone for the tick once either hourly GitHub budget is below half (checked before every request) or at the first rate limit; a PR whose backfill fails part-way is tried again next tick. The Insights page reads the rows through GET /api/insights/cycle (time-to-merge.ts), with the same filters as GET /api/insights and the window applied to the merge (CLI reviews have no PR, so source=local matches nothing); medians and the 90th percentile are worked out in the Worker over the window’s rows. The PR page shows its own row and its lifecycle and review events, CI left out. Missed events (reconcile.ts, CRB-96). GitHub sometimes never delivers an event and never redelivers one that failed, so the review it should have started never runs (lleverage#10351’s ready_for_review, 9 Nov 2026). Every 15 minutes, in its own cron invocation, Cerbie lists each reviewed repository’s 50 most recently updated open PRs (one REST call), keeps those last updated in the past 24 hours but not the last 15 minutes (a webhook for that change may still be arriving or debouncing), and drops any with a review run of their current head (review_runs_pr, only that PR’s rows) or paused. The rest are gated exactly as the pull_request webhook gates them, reading the config once per base branch, and queued as a reconcile review through the PR’s coordinator, which never queues a head it already reviewed or is reviewing and, for these, nothing while another review is queued, being launched or running (unless it stopped reporting), so an out-of-date listing never replaces a newer push. The PR’s row is inserted if a lost delivery left none, and otherwise updated only from a listing newer than what was recorded, never over a merge. At most five a tick; an installation is left alone once less than half of its hourly GitHub budget is left. The reconcile setting in D1 ({"enabled": false}, or other limits; see ReconcileOptions) changes it without a deploy.

    Reviews that could not finish (review-retries.ts, CRB-111). The same cron retries a review that failed or ended INCOMPLETE for a transient reason: a stage that timed out, a Workflow that Cloudflare failed or that was lost, a GitHub rate limit or server error, D1 overload, or the model gateway or provider erroring. It reads each listed PR’s latest run (review_runs_pr, newest first, one row) and retries it when that run is of the PR’s current head (so nothing newer exists), ended at least ten minutes ago (twenty for the second retry) and the head has had fewer than two automatic retries. A failure a retry can’t fix (a model with no provider, spent model quota, a parse error, an INCOMPLETE review with no failed stage) is left for a person. The retry is a whole review with trigger retry, gated as the webhook gates the PR unless a person asked for the review being retried, and queued through the coordinator with ifIdle like the reviews above, forced because the coordinator counts the head of a review that failed as reviewed; it shares the five-a-tick cap, after unreviewed heads. Only the stages that didn’t finish are not re-run on their own: a retry re-reads the PR as any review does, earlier findings included, and the verifier needs every stage’s candidates. The failed or INCOMPLETE review says what happens next in its check, comment or review: that Cerbie retries by itself, or, once the head’s retries are used up, that a manual retry (@cerbieai review) is needed. A retry that replaces an INCOMPLETE review takes its round, so retries add no rounds to the loop numbers. maxRetries (0 switches retries off) and retryDelayMinutes in the reconcile setting change it without a deploy; docs/queries/review-retries.sql counts automatic and manual retries by week and lists open PRs whose head is still without a finished review.

  2. Coordinator (coordinator.ts). One Durable Object per PR debounces bursts of pushes using a single alarm. If a newer head arrives while a review is running, the old Workflow is terminated as the push arrives (no tokens spent on stale code) and the new head is reviewed once the debounce ends. A review that has begun publishing is left to finish first, so it is never cut off halfway through its writes: a push or the PR closing waits six minutes from the latest attempt of its publish step, and a push goes on waiting while that step is sleeping out a GitHub rate limit. A publish step retried after it posted its review finishes that review’s threads and check even if the head has moved since, unless its replacement has already been launched (docs/queries/superseded-spend.sql reports what superseded reviews spent). Re-delivered or duplicate events for an already-reviewed head are ignored.

  3. Workflow (review/workflow.ts). A Cloudflare Workflow makes every stage durable and independently retried:

    • start: creates the Cerbie (Review) check run (in progress) and, on a PR’s first review, a placeholder summary comment.
    • context: fetches PR metadata, files and patches, CI status, discussion, the linked Linear ticket, guideline files, .cerbie/, and the PR’s earlier findings. In parallel it syncs the git mirror to the exact base and head commits. The bundle goes to R2. Triage (deterministic, zero latency) picks the tier and streams.
    • Fan-out, all in parallel: summary, reviewer streams, custom checks, deterministic checks, follow-up of earlier findings. The summary is posted the moment it is ready. A reviewer stream counts as done only with evidence that it covered its files (reviewShortfall, fileEvidence in packages/core/src/coverage.ts): the primary and light reviewers must list every assigned file in filesReviewed, and a file whose diff was omitted for size, or that GitHub gave no diff for though lines changed, counts only if the run read it at the head before it submitted, with diff_file or with a read_file of lines the change touches (any lines of a new file; of another file GitHub gave no diff for, only diff_file shows the change) (a read in the same step as the submission came back too late to be seen, and does not count; nor does a read past the end of the file, which is an error); a lens stream (security, data, contracts, checks, challenge) must list at least one. A stream that used its last step to submit, having run out of steps, is not done either. Each agent’s closing tool call is checked in one place (runAgent): the last call that parses wins, and a missing or invalid call, or files left unlisted, gets one repair turn before the stage fails. The follow-up is held to the same for a fix under review: it cannot confirm one resolved while a file of the finding that the push changed (any place of a pattern) was neither in its prompt as a diff nor read. Nor can the verifier reject a finding in a file it was given no diff of and never read: it fails, and its candidates are kept ungraded. A failed required stream makes the review INCOMPLETE.
    • coverage: only when a reviewer reported a pattern (a finding with other places), or when the change looks like a migration (one identical line removed or added in at least 30% of 12 or more source files, migrationShape). It searches the whole change: every changed file, including those past GitHub’s file list (a compare lists 300 files, a pull request 3,000; the git mirror lists the rest, wholeChange, in pages: the first 3,000 files with their diffs, then up to 20,000 more a page with line counts only, to at most 50,000 files) and those whose diff no reviewer was given, with git grep over the head and a search of the diff’s removed and added lines. Each search is one bounded agent (the verifier’s model at medium effort, at most 12 steps), all in parallel:
      • For each pattern a reviewer reported, and on a migration each other finding (patterns first, at most six), it looks for further places of the same problem, reads each hit and reports the places it confirmed. They join the finding as instances before verification. The verifier decides each pattern on a bounded sample of its places (verificationSample); the rest stay listed, as not individually verified, in the GitHub comment, cerbie review and the run page. Which places those are is the review’s own: they are kept apart from its findings, which are stored as before, and in its result.json only as unverified (place keys), which no later review reads.
      • On a migration, it checks the meanings the repeated edit looks to drop (lostMeanings, at most three): words naming a state or meaning (destructive, selected, opacity-0, aria-…) that the change removes in many files and seldom adds back, at the places where it removes one and adds nothing naming the same meaning in that hunk. The agent decides whether the new code keeps the meaning another way, and if not reports one pattern with every place, which is verified like any other candidate. Reviewers reading a part of a large change at a time tend to miss these: on lleverage-ai/lleverage#7099, dropped destructive styling was raised a place or two at a time over nine later rounds. The live view records each finding that gained places (places_added) and each meaning checked (meaning_checked). An open pattern that gains places this way gets instance_added when saved. If a search fails on a reported pattern, the review goes on without it. On a migration the search is required: if it fails, in whole or in part (a report made before any search or read of the change came back with a result counts as failed, and one of the base does not count, and the note keeps why a search failed so a transient cause is retried), or code search is unavailable, the Pattern coverage row fails and the review is INCOMPLETE (coverageUnsearched).
    • verify: candidates are merged and deduplicated. Duplicates of still-open earlier findings are dropped so threads aren’t repeated. An earlier finding a deterministic check raises again at this head stays open even if the follow-up calls it resolved, and stands where the check now reports it, never milder than before: the check is ground truth. An open finding of a repository check takes the severity the check is configured with now, so a changed configuration applies to findings already raised; one people settled keeps the severity they settled it at. A verifier with a fresh context confirms, adjusts or rejects every candidate against the code, and grades each one it keeps by consequence and reach; a fixed table turns those into the severity (see Severity). A candidate it never decides on (including when it fails) leaves coverage incomplete, so the review cannot approve on a reviewer’s label alone. Reports the verifier marks as duplicates of one another are one finding, as severe as the worst of them; a chain of them that ends at an earlier finding makes each one a restatement of it, graded on its own. Only a checks stream can attribute a finding to a repository check, and such a violation keeps the check’s configured severity. The confidence floor and suggestion cap apply.
    • challenge: only when the PR is risky (deep tier, or any specialist ran), the verified findings would still approve it, and the review covers more than 60 changed lines (200 below the deep tier; CHALLENGE_SKIP_LINES, counted like changedLines: an incremental review counts what it reviews). Below those sizes it rarely finds anything, so the stage is recorded as skipped with the reason. One reviewer gets the first pass’s notes, files read and findings, and looks for failure modes nobody traced. Its should-fix and critical findings go through a second verification (verify challenge). If the challenge fails, coverage is incomplete and the PR is not approved.
    • publish: the head guard skips publication if the PR moved. Cerbie then posts one review (verdict, inline comments with suggestions), gives every open finding a thread, and completes the check runs (one per custom check, named Cerbie (<title>); a check titled Review, which would collide with Cerbie (Review), is reported as a configuration problem and gets none). A plain approval (nothing found) is posted without a comment; the full review is in the check run’s details and on the run page. Earlier inline comments are left untouched. Every open finding that is new or has no thread yet gets an inline comment, whatever its severity, because a reply reaches Cerbie only on a finding’s own thread. The comment goes where GitHub takes one, best first: the finding’s lines, another place of its pattern, the nearest line of its file that the diff shows, or the file as a whole (subject_type: file, posted on its own after the review, as a review can’t carry one); a comment anywhere but the finding’s lines says so. Only a finding with no file in the diff stays in the review body. When GitHub rejects the review’s comments together (422), the review goes out with every finding in its body and the comments are posted one at a time, a second apart, a rejected one on its file instead, so one bad position costs one finding its thread and not all of them. docs/queries/finding-threads.sql gives the weekly share of findings without a thread. A suggestion’s thread is resolved as it is opened, so an optional comment never holds up a merge where every conversation must be resolved; a reply on it still reaches Cerbie, and a later review leaves the thread as it finds it (one a person reopened stays open), unless the finding is graded worse, when Cerbie opens it again with a reply saying why. For a fixed finding, Cerbie resolves its thread, first posting a short “✅ Addressed in …” reply if someone replied there and Cerbie didn’t have the last word. It updates the summary with the verdict. An approval replaces Cerbie’s earlier blocks by itself (GitHub counts a reviewer’s latest approval or request for changes), so they are not dismissed; a comment that no longer blocks (a held approval, or findings left to a person) dismisses them (mustDismissBlocks).

    The reads and writes of start, context and publish that don’t depend on one another run together (together.ts, which waits for all of them before the step fails, so a retried step never runs alongside its own earlier write). What must stay in order does: GitHub writes go one at a time, the head guard is answered before anything is saved, and findings are saved before the review is posted. The stages of a run that read the same commits share one sync of the git mirror (MirrorSyncs): the first syncs, the rest reuse it, and a stage whose call the mirror refuses checks whether the commits are gone (a restarted container), fetches them again and repeats the call once. Each stage records its sync as a mirror_sync event (time, whether it was reused). docs/queries/stage-overhead.sql gives the weekly median time of the three steps and the mirror syncs per stage.

  4. Replies (reply-workflow.ts). A reply on a Cerbie thread, or @cerbieai <question>, from a person or a bot the repository names in reviews.command_bots, runs a short agent with the same tools. The agent re-reviews the finding(s) a reply concerns with the reply as context: it may withdraw, confirm a fix, accept a reasoned deferral (should-fix and suggestions only) or uphold the finding, and one top-level comment can cover several findings. One answer also settles the other open findings it answers in the same way, so nobody repeats it on every thread: on a thread reply the agent is shown the PR’s other open findings below critical (siblingCandidates, those sharing a concern name, a link or a cited rule with the thread’s finding first, concernLink in packages/core/src/history.ts) and names in sameConcern those the reason it accepted also settles, each checked at its own place; on a top-level comment such a decision carries sameAs. Only a withdrawal or an accepted deferral extends this way, at the decision its source got, never to a critical, and a requirements finding can be deferred so but not withdrawn (standingDecisions); a confirmed fix never does. Such a decision is applied only once its source is settled by the same answer (applyDecisions reads that from storage: when a reply settles other findings, each reason names the reply’s comment), so it is refused with it. Each thread settled this way gets a short note linking to the answer (marked cerbie:same-concern, posted once): at most forty per answer; the decision says where the answer is and applyDecisions posts the note after applying, so a decision refused because the head moved or the finding changed is never announced, and one applied late, after a running review, still is. The audit entry records sameAs on the decision. Where the base branch’s configuration names who may accept a risk (reviews.risk_acceptors), the workflow works out before the agent runs whether the comment’s author is one (riskAcceptance, review/risk-acceptors.ts: the login, or active membership of a listed team read from GitHub; never a bot, and a team that can’t be read has no members), tells the agent, and afterwards turns any deferral asked for by someone else back into a kept finding with its spread dropped (authorisedDecisions), replying with who must confirm; the agent’s reading of the comment never decides who may accept. A named acceptor’s deferral is stored as risk accepted by @login in the finding’s state reason, from which the summary comment lists accepted risks (acceptedRisks). It is capped at three replies per thread; a reply after that gets one note on the thread, once per budget, saying Cerbie won’t answer there again and that @cerbieai review with the reasoning, on the PR itself, still decides the finding. Its decisions go to the PR’s coordinator, which applies them (applyDecisions) and re-decides the verdict (reassessVerdict) in one serialised step, never concurrently with a review; if nothing blocks, it approves without re-reviewing the PR (and without a comment). Threads of withdrawn and fixed findings are resolved; a deferred finding’s thread stays open for a person to close. Withdrawn and deferred findings are not raised again unless they come back more severe. Hand-resolved threads do not change findings, and a fix review that keeps a finding open unresolves its hand-resolved thread after giving the cases, so a finding that still blocks is never hidden in a closed conversation.

Local reviews and the review cache

The Cerbie CLI runs the same ReviewWorkflow before a pull request exists:

  1. cerbie login uses GitHub device flow through the CerbieAI app (/cli/v1/login/*). Like the dashboard, it is for active members of CERBIE_ALLOWED_GITHUB_ORGS, re-checked hourly; someone who leaves loses every CLI session. The Worker keeps only a hash of the CLI session token, and checks every request against the user’s permission on the repository, matched on their immutable GitHub ID. Repositories of organisations that aren’t approved are refused.
  2. cerbie review uploads a thin git bundle (merge base..head; uncommitted work becomes a temporary commit) to /cli/v1/repos/:owner/:name/reviews. The Worker reserves the user’s rate-limit quota, stores the bundle in R2 and starts the workflow with params.local (PR number 0, never published).
  3. The context step syncs the merge base from GitHub, imports the bundle into the git mirror and diffs there. Policy comes from the tip of the target branch on GitHub, as for a PR. Git objects are content-addressed, so the reviewed commit is exactly the code its SHA names.

The CLI also reads Insights (cerbie insights, time-to-merge, pr, backfill) from /cli/v1/insights, /cli/v1/insights/cycle, /cli/v1/pulls/:owner/:name/:number and /cli/v1/insights/backfill. These answer with the dashboard’s own code (reads.ts, shared with /api/insights, /api/insights/cycle and the PR page) over the repositories the dashboard would show the same GitHub account (readableRepos in access.ts, whose answers are stored per account in repo_access for both), so the numbers match the dashboard’s for the same filters. Unlike the review routes, which need Cerbie to be on for the repository, they include repositories an admin turned off, as the dashboard does.

Follow-up reviews are incremental unless decideReviewScope (packages/core/src/scope.ts) says otherwise. They cover the files whose own PR diff changed since the last reviewed commit (prDiffChanges compares each file’s diff against the merge base, using the last run’s stored context; only after the merge base moved are hunk positions ignored), so merging the base branch in doesn’t count main’s changes as the PR’s. When no reviewed file changed, the run carries the last verdict forward: no model calls, the findings that run left open move to the new head’s lines (or the files whose findings can’t be placed are reviewed), the checks move to the new head, and a review is posted only if Cerbie’s standing review no longer matches (publishCarry). A carried run records reused_run_id with a since_sha. A pull request push that only fixes the findings of a last review that requested changes (isFixOnly over the findings open at that review, counting those resolved in reply since, and after a base-branch merge only over the files whose own PR diff changed; the same rules, tier and specialists; no affected importers or departed files; fixFacts in review/context.ts) gets the fix_only scope: no reviewer or check streams run, only the follow-up and the verifier on its gaps, so it runs like the lockfile-only follow-up. Anything new it saves is a suggestion unless critical (asFixOnlyFinding), and a finding under review that the follow-up left unassessed makes the review incomplete (unassessedFixes). If every finding open at that review was cleared in reply at the new head (Db.clearedInReply), it is confirmed: the follow-up doesn’t run, though a deterministic check that still reports one of those findings reopens it as a case of its own rule. A verdict is carried only if the run that reached it recorded the current ENGINE_VERSION (review/cache.ts) in its context; otherwise the follow-up is a full review, so a fix to the review logic reaches PRs already in flight. Incremental reviews ignore the engine version: what they cover is reviewed with the current logic, and prompt edits alone (which change the policy hash, not the engine version) don’t force anything. A change to the repository’s review rules never widens a review that follows on from another, a pull request’s or a local one. Following on from a local review also needs the same linked ticket, recipe, prompts and engine version (setupHash in review/cache.ts, the policy hash without the rules; assemble compares it, and the whole policy hash for a local review stored before it was recorded). rulesFingerprint (review/context.ts) hashes the rules that apply to the PR’s changed paths (configuration, instructions, matching rules and nested instructions, the guideline files read for those paths, org instructions) and each applicable custom check by id. When it differs from the last review’s, the push isn’t fix_only, and the checks that are new or changed (rulesSince) run over the PR’s whole diff in their own whole check streams beside the incremental review, turning a carry into an incremental review of no files. Every check that applies to the PR has a result at every reviewed head: a narrowed review (incremental or fix_only) keeps the last review’s result for each applicable check it doesn’t run (scope.keptChecks, as a carry republishes them all), and a check the last review has no result for runs over the whole PR like a changed one (a fix_only push is then reviewed as an ordinary incremental one, and a carry becomes a review of that check alone, unless a later review didn’t finish, which makes it a full one as it would a carry). A result taken from an earlier review (kept, carried or reused) is reported only for a check that still applies at the head (reportedChecks in review/carry.ts): a check that stopped applying to the PR’s files leaves no result, though its id is still configured. A review with no files of its own records the files its whole-diff checks read as the files it reviewed (coveredFiles), and its summary is written from the PR’s whole diff (summaryDiff). A context stored before the fingerprint has only rulesHash, the hash of every rule in the repository, which is still written and is compared for those reviews instead; once it differs, none of that review’s check results is kept, since any of the checks may be what changed. The other signals need no model call either: whole-PR triage and delta share. The number of incremental reviews since the last full one and its age are not signals: both once forced a full review (the sixth incremental in a row, a full review over three days old), and what those re-reads found was mostly in code already reviewed, sending approved PRs back. A push that changes what a module exports never goes full for that alone: the review stays incremental and also covers the PR’s unchanged files that import the module by a relative path, however many there are (findImporters in review/context.ts reads up to 80 files whole and above that searches them in the git mirror for import lines, importSearchPatterns; a file it can’t read or search counts as importing). The reviewers get the export-changing hunks and each module’s importers (scope.exportChanges, “Exports changed since the last review” in the brief) and review those files only for how they use what changed; the widened files are sharded like any others, a light review’s among them (lightShards: only a widened light review is ever split, sized for the light model). Only when the PR has more files than can be read one by one and the mirror can’t search them is the review full. Local (CLI) reviews follow on in the same way, from the requester’s latest complete local review of the same branch against the same base (review/local.ts). Their heads are often amended, rebased or synthetic, so instead of a compare they re-import the earlier run’s bundle into the mirror and diff the two trees, and find the reviewed run in that chain (Db.localReviewHistory). A pull request’s first review takes over its author’s latest local review of its head branch the same way: findings still open are posted as new, those resolved locally aren’t mentioned, and a carry publishes like a cache hit with the findings moved to the PR’s lines. Each run’s context records the rules fingerprint, engine version and whole-PR triage for the next decision, and its row records the scope it got (full, incremental, carry or fix_only), the reason, the run it follows on from and the files it reviewed, which the dashboard shows on every run; eval/scope-replay-2026-10-08.md replays production history through it as it was then. A follow-up that covers the whole PR without that decision being asked also records why (fullReviewReason in packages/core/src/scope.ts, from what buildContext knows): it was asked for (a comment, a re-run of the check, the dashboard, the retry of such a review, or a request still owed when a later push started the review), the base branch changed, the head was already reviewed, the branch was rebased or force-pushed past the last reviewed commit, the commits since couldn’t be read, or no review has covered the PR yet (the last one having ended INCOMPLETE, say: only a review with complete coverage moves last_reviewed_sha, so after an incomplete one the next follows on from the last covered commit if there is one). A fresh local review (cerbie review --fresh) of a branch reviewed before, or of a pull request (--pr), says it was asked for. The reason is the run’s scope_reason and the review’s “Full review: …” line; the unexplained_full_reviews query in docs/queries/review-loops.sql lists any later full review without one.

Every review’s context records the rules each reviewable file of the PR was last read under by a reviewer (readUnder, by path at its head): the current ones for the files a full or incremental review reads, and the last review’s record for the rest, so a fix-only review or a carried verdict, which run no reviewer, add nothing. A follow-up review’s context carries what that says of the review it follows on from (push.reviewed: reviewedCoverage in review/context.ts): the files reviewers have read, which of them were last read under other rules than apply to the PR now, and the specialists the PR had. A context from before the record was kept counts only what its own review read, so on a PR already in flight nothing outside the last review’s files is late until its next full review. A reviewer’s finding the verifier kept is late (isLateFinding, packages/core/src/late.ts) when every place of it is in one of those files on lines the push left alone, unless the earlier reviews couldn’t have raised it: a repository check’s finding, one citing written guidance in a file last read under other rules, one from a specialist the PR hadn’t had, or one in a file read only because the push changed what it imports. A late finding is saved and posted marked as such (Finding.late, stored as origin = 'late', no column of its own), as a suggestion unless it is critical (asLateFinding), after the confidence floor and max_suggestions have been applied to the review’s findings as graded, so it is never dropped by the cap and takes none of its places. A later review reporting it again keeps it a suggestion while it would still be late raised then (holdLate), unless the push touched its file, which puts its fix under review: a case against the fix is folded in without its own place, so the finding takes the grade it is given. A review with a late finding is not a neutral review of its code, so the cache never reuses it (settlement_filtered). There is no push.reviewed, so nothing is late, on a first review, a review a person asked for in full, one that follows on from a local review or checks a local change against a PR, or when the previous head can’t be compared.

When a push touches the lines of an earlier finding, or other lines in its file, it is reviewed as a fix of that finding (review/fix-review.ts, packages/core/src/fixreview.ts). So is a finding resolved in one of the PR’s last three reviews whose file the push changed again (timed from finding_events), and every finding when the push can’t be compared. The follow-up checks the fix against the finding’s whole rule (invariant, each mustStillWork and failingCases case, neighbouring inputs, callers, and what the code before the fix handled, readable at ref: previous), and reports every case it gets wrong as a gap. Its gaps are verified on their own, apart from other reviewers’ candidates, so neither is ever folded into the other. A finding under review that the follow-up would resolve, or that was resolved before, stays an earlier finding until verification is done: a reviewer reporting it again is folded into it by the usual restatement rules, and that report is one more case. Then a confirmed same_concern gap or a reviewer’s case keeps the finding open, or reopens it, at least as severe as before unless a repository check sets its severity, with the case added to its failingCases (kept apart from mustStillWork, which is behaviour a fix must not break; migration 0022), and Cerbie lists every failing case on its thread. A new_regression is a finding of its own, linked by related_finding_id with relation_confirmed = 1. Regressions of one problem (the same concern, or the same problem nearby in one file, followed from one to the next) are one finding with every place and failing case, the worst grade among them, and still to be verified if any was left undecided; one another reviewer also reported merges into that report. Only an assessment that finished resolves or moves a finding, and only a review with complete coverage moves the findings under review: an incomplete one leaves the baseline where it was, so it saves them at their place there, which the next review compares from. Each review moves open findings with the files its push renamed, and records in its result.json the findings it saved whose places at its head it knows (placed: with complete coverage and every change its push made known, those new to the PR and those it knew the place of at its baseline). Before targeting, every earlier finding, open or recently resolved, is placed at the baseline head: as saved, if the review that last saved it was the baseline’s and listed it; through the renames since, if one at another head listed it and the changes from there are known along one line of history; otherwise (an incomplete, failed, superseded or older review, a force-push, a deferral reopened from storage, or a finding never placed since) it is reviewed as a fix whatever the push changed. Step-back notes count as posted only in Cerbie’s own reviews. Each run’s result.json records the outcome (fixReview). Once fixes for one finding have stayed open at two reviewed heads, Cerbie posts a single step-back note on its thread, or in the review body when it has no thread (marked, and looked for in every review body on the PR before posting, so it is never posted twice). A whole PR loops once three of its live reviews have asked for changes, or two findings are linked (related_finding_id, a fix_regression or same_concern, through one another) to one earlier finding (review-loops.ts). The next review that asks for changes then shows one step-back note in its body, above the findings, naming what still blocks with each rule; it takes the place of the per-finding notes due in the body that review, and carries their markers. An approving review gets none, as there is no next push to change. Once fix reviews have kept a should-fix finding open at four reviewed heads (HANDOVER_ROUNDS, counted from the fixReview of every complete run on the PR, however old) and every blocking finding is one of those, a review with complete coverage leaves them to a person. It stops asking for changes over them: the review is a comment headed “Left to a person” (and so is the summary comment), with a neutral check, it dismisses Cerbie’s earlier blocks (a comment replaces none), and it never approves, so a maintainer decides whether what remains holds the PR. A critical finding, or any other blocking finding, keeps the block; reassessment after a reply decides the same way. The note has its own marker, and Cerbie reads the PR’s reviews before posting it, so it is posted once per PR; when they can’t be read, no note. The same steps run on their own, outside a review, through evaluateFixReview.

A model’s word doesn’t clear a blocking finding on its own (packages/core/src/clearance.ts, review/clearance.ts). Both paths that clear one are held to it: a review’s follow-up classifying it resolved (supportedClassifications) and a reply’s reviewer deciding it is fixed or wrong (supportedDecisions, after standingDecisions). “Fixed” on a should-fix or critical finding stands only with code evidence, worked out in code and never asked of a model (fixEvidence): the commits since the finding was raised change its lines or lines right beside them (lines), its file when the patch or the finding’s place there isn’t known (file), or a line naming an identifier or another file the finding names in backticks or by path (symbol). A finding in a package.json also counts a change to another dependency file (a lockfile, another manifest, pnpm-workspace.yaml) as file: a lockfile committed for a manifest’s line is its fix. none (the pushes are known and change nothing of it) and unknown (the heads couldn’t be compared, or the list of changes was cut short and its file isn’t in it) both leave it open. buildContext computes it for every review and every reply (pushEvidence, carried as fixEvidence): from GitHub’s compare of the last reviewed head with the current one, or after a force-push from the mirror’s tree diff of the two heads, counting only the pull request’s own files and files removed, since that diff carries the base branch’s changes too; after a retarget, which forgets the reviewed head, from the head of the last finished review. A file of a finding that such a diff changes though the pull request no longer does (a force-push dropped its change there) counts as file. A finding a review that didn’t finish raised or reopened sits past that baseline, at a head the baseline’s compare would count the introducing change of: until a complete review has taken it in (Db.openedSinceReview, from finding_events), it is measured from the head it became open at instead (FixBaseline.raisedAt), which is no evidence while that is still the head. Evidence a reviewed push gave is kept on the finding while it stays open (findings.fix_evidence, migration 0037), so a fix pushed two reviews ago still counts when it is confirmed later. A critical finding, fixed or wrong, also needs one bounded second check to agree (runClearanceCheck, the recipe’s verifier model through the usual fallback, held to the read-evidence rule, and to reading at the head a finding’s file the pull request no longer changes, or some code when the mirror says that file is gone): on a review it runs as its own step beside the reviewers, only when a critical finding has code evidence, and adds no round; on a reply it runs once for all the critical findings being cleared, and never for a should-fix finding or a suggestion, so those replies make no other model call. A check that disagrees, fails, times out, or has under two minutes of the reply’s step left to run leaves the finding open, and nothing is approved over it. A finding kept open this way is published as any other still open (the review’s coverage notes say how many were held); a reply on its thread is told why, in place of the confirmation. A decision spread to other findings (below) is held to its own finding’s evidence, and is dropped when the decision it was spread from is refused. A suggestion never blocks, so nothing is asked of it, nor of a deferral or an accepted risk, which is a person’s decision. A review holds a repository check’s finding to the severity the check is configured with now, the one it resolves it at. A finding Cerbie’s own deterministic checks raised is held like any other: not every such check runs again on every review, so a check’s silence is not taken for a fix. A PR’s first review taking over a local review’s findings, and a local review not checked against a PR, are not held to this. finding_events.support records what stood behind each clearance (code_evidence, verifier, code_evidence+verifier, or none); docs/queries/clearance-support.sql counts them.

cerbie review --pr (or a branch with an open, reviewed PR) checks a local change against that PR before it is pushed. It is a local review (PR number 0, shadow, charged like any other) with params.local.pr set, accepted only after the usual repository access check and only for an open PR of that repository, against its base. Its context step follows on from the PR instead of a local chain (followPullRequest): the PR’s open findings at its last reviewed head, the tree diff from that head, the fixes to review, and the PR’s history for the scope decision, description, discussion and settled findings. It reads the PR’s reviewed head and findings in one D1 batch (loadPrCheckBaseline, Db.prCheckSnapshot), and fails, to be retried, while a review of the PR is part way through publishing: a review saves its findings before it moves the reviewed head. It runs with trigger cli-pr, which keeps it out of local chains, hand-offs and the cache. It never saves or posts anything, and its result.json records what it was checked against (pullRequest), from which /cli/v1/reviews/:id reports each finding as resolved, still open, reopened, newly broken or new (cli/pull-check.ts).

Every run records a cache key: merge base, head tree and a policy hash (.cerbie/ and guideline files, org instructions, the linked ticket as read, recipe, prompts). A PR’s first review (or any local review) that finds a complete, non-incremental run with the same key from the last 14 days publishes that run’s findings instead of reviewing again; only the summary is written fresh. If an older run of the same code is still in progress, the workflow sleeps and waits for it. Runs only wait for older runs, so two can never wait on each other.

Review tiers

Tier When Streams
light Docs, tests or lockfiles only, or ≤60 substantive changed lines with no risk signals One focused reviewer
standard Everything else Primary reviewer, plus specialists whose signals fire (contracts above 150 substantive lines, or with both security and data signals)
deep Configured paths.risk match, >600 substantive lines, or >200 with both security and data signals Primary (sharded across up to four reviewers for big diffs) plus every signalled specialist

Signals come from paths (auth, migration, routers/, …) and added code ($transaction, dangerouslySetInnerHTML, exec(, removed exports, …). For the security specialist, a change of 150 substantive lines or fewer needs the stronger signal: a security term in a line it adds outside its tests. A path with session or token in it, or a test that mentions a password, calls for the specialist only above that size (paths.risk names the paths that get it at any size); below it the specialist rarely found anything on those alone. Such a file still comes first in the security specialist’s diff when it runs. A change that bears on both security and data keeps the contracts specialist at any size. Otherwise triage errs towards running a specialist: a parallel call that finds nothing costs far less than a missed lens.

A change to these rules is judged on what production reviewed, not on examples: scripts/replay-triage.mjs re-triages a month of stored reviews with the rules of the working tree and reports the tier share, the cost, and which pull requests would lose a specialist that had a confirmed finding (see the script header for what it can and cannot see). The deterministic checks, custom checks and follow-up always run when relevant.

Why agents don’t run code

Installing dependencies for the monorepo takes minutes and gigabytes, and CI already runs type checks and tests. Cerbie reads CI status instead and spends its budget on what CI can’t catch: logic, authorisation, data integrity, concurrency and contracts. Agents get a read-only toolset over exact commits:

Tool Backed by
read_file, list_directory git mirror (git show/ls-tree); falls back to the GitHub contents API
grep, find_files git grep/ls-tree against the commit object, with no checkout (full monorepo grep takes about 0.5s)
diff_file, git_log PR patches or git diff; shallow history

The git mirror (containers/git) is a small Bun server. It keeps one shallow, bare clone per repository in a container that stays warm for 30 minutes. Cold sync of the monorepo takes about 5s, a warm incremental sync about 10ms. It receives a per-request, repository-scoped, read-only installation token and never executes repository code.

It also lints the GitHub Actions workflows and action definitions a change adds to or modifies (/lint-workflows), with pinned, checksum-verified builds of zizmor (security: template injection, unpinned third-party actions, dangerous triggers, broad permissions) and actionlint (correctness, with ShellCheck on run: scripts). Only those files are copied into a scratch directory for the request; zizmor runs --offline, neither tool gets a token, and each has a 30-second limit and capped output. The result depends only on those files: Cerbie applies its own zizmor policy (GitHub’s actions/* and github/* may be pinned to a tag, anything else to a commit), doesn’t read the repository’s zizmor.yml or actionlint.yaml, and disables inline # zizmor: ignore[…] comments, so a change can’t switch off the audits it’s checked against. Cerbie reports only what lands on lines the change adds or modifies: high-severity zizmor findings as should-fix, everything else as suggestions, with the rule’s id and documentation. ShellCheck’s reports are moved from the run: key to the script line they’re about, and dropped when the line can’t be told exactly. ShellCheck notes below warning level, and unknown runner labels that aren’t one edit away from a GitHub-hosted label (most are self-hosted or larger runners), are left out. When the linters can’t run, the coverage table shows “Workflow lint” as unavailable and the review carries on without them. checks.workflows: false turns this off.

Models

Every LLM call goes through cerbie-llm-gateway, a CLIProxyAPI instance in a Cloudflare Container reached over a service binding. Model assignments are a recipe (apps/worker/src/llm.ts). Admins can override it in the dashboard without a deploy; a save is checked against the gateway first, a role can name a fallback model for provider errors, refusals and early stalls, and each review and reply records the recipe it ran with (see Changing a model).

Every role defaults to GPT-6.1 Sol; always prefer it over GPT-6 Sol. Roles differ in effort and step budget. GPT-6.2 Sol and Astra are not in the default recipe until they pass the corpus gate in Changing a model.

Role Default Why
primary GPT-6.1 Sol, high effort Deepest tracing of behaviour
challenge GPT-6.1 Sol, high effort Runs after verification, only on risky PRs (deep tier or any specialist) whose verified findings would still approve, and not on small reviews (60 changed lines or fewer; 200 below the deep tier). It reads the first pass’s notes and findings and hunts for failure modes nobody traced. Its findings are verified separately; if it fails, the review is incomplete rather than approved
specialist GPT-6.1 Sol, high effort Focused lenses in parallel
verifier GPT-6.1 Sol, high effort Re-checks each finding in a fresh context with its own tools
light GPT-6.1 Sol, high effort Small PRs still get the strongest reviewer
summary, reply GPT-6.1 Sol, low / medium effort Speed

The large shared context (PR brief, guidance, numbered diff) is the first message in each conversation, so every tool-loop step reuses it from the prompt cache (automatic on OpenAI; an explicit breakpoint on Anthropic).

How much of the change a prompt carries follows the model (apps/worker/src/model-limits.ts): a table of each model’s context window and output limit, a fixed four characters per token, and a budget in tokens for the inline diff (40,000), one primary reviewer’s shard (22,500) and the summary’s diff (20,000). A model whose input window (context window less output limit) is under 200,000 tokens gets the same share of what it has, so its diffs and shards are smaller; a role’s fallback counts, since it is given the same prompt. A larger window does not raise the sizes, and a model the table lacks gets the full budget. For every model with room, that is 160,000, 90,000 and 80,000 characters. shard (packages/core/src/triage.ts) splits a diff of more than 1.2 shards between as many primary reviewers as it needs at one shard each, four at most. It takes the files in path order and cuts them into consecutive runs, a file keeping its tests with it for as long as they are together within 1.2 equal shares and 1.2 shards of budget (unless that would leave fewer groups than shards, or put more over budget). Of all the ways to cut it takes one whose largest shard, where that is over 1.2 shards of budget, is no larger than it must be, then the one with the least size above 1.2 shards of budget (so no reviewer is over budget when some layout keeps them all within it), then the least above 1.2 equal shares, then the least below 0.8, then the fewest leading directories shared across its cuts (a package’s edge before a directory’s), then the shards nearest the equal share. The layout depends only on the files’ paths and patch sizes, and is in neither the policy hash nor the scope decision, so changing it re-reviews nothing. A change needing more than four shards is not split further: its shards may be over budget, and the review’s coverage says so when one is. That line (oversizeCaveat in review/prompt.ts, “This change is past what one review round covers”) appears when a reviewer that owns files was given more than 1.2 shards of diff, or any stream (a specialist or a batch of checks too) was not shown some of its files’ diffs, and only then. A diff that does not fit is named in the prompt for the agent to read with its tools, and the stage records a diff_omitted event; when a specialist’s or the check evaluator’s diffs don’t all fit, the files triage gave that lens a signal for (for security, the repository’s risk paths and active escalation categories among them; for the evaluator, the files its checks apply to) are rendered first, then the smaller. A PR discussion with an entry cut to its own limit, or cut as a whole to its latest 40,000 characters, records discussion_trimmed.

Every model response’s finish reason is checked. One that stopped at the model’s output limit (length) is not a finished answer: nothing in it is used (the SDK runs none of its tool calls), the stage fails with ModelTruncated and records a truncated event, and no forced turn or fallback model follows. The review ends INCOMPLETE and is retried like other transient failures (review-retries.ts), at most twice per head.

Data

Trust boundaries

Edit this page on GitHub ↗