kReview
A self-hosted Forgejo reviewer that chunks diffs too big for one model call and lists every file it didn't fully cover.
The problem
A review comment reads the same whether the model saw the whole change or a third of it. Diffs outgrow the context window (the text a model can consider in one request) and new pushes land while a review is still running, and unless the bot says what it cut, the comment implies it read everything. kReview used to post reviews like that; A narrow review should say so traces how.
Architecture
kReview receives Forgejo webhooks authenticated with a scoped, HMAC (a keyed hash that authenticates a message)-derived bearer credential, runs the configured model adapter, and keeps one sticky summary comment per pull request. Adapters cover the Codex and Claude Code CLIs, OpenCode, OpenRouter, and a generic command that takes JSON on stdin. Multi mode runs several reviewers on the same input and has a synthesizer reconcile their findings. If synthesis fails, kReview falls back to the deterministic merge it uses for chunked reviews; if one reviewer fails, it posts the other's result with a provider-coverage note.
kReview first drops generated and vendored (third-party code copied into the repository) files (by default lockfiles,
dist/, and minified bundles). Each model call gets an input budget of the
model's context window minus a 40k-token output reserve. A diff that doesn't
fit is split into chunks under that budget, up to 50 chunks with 4 in flight
by default. Files split at hunk (one contiguous block of changes in a file's diff) boundaries, and a single hunk that's
still too big gets cut into smaller synthetic hunks, so a huge new file is
partly reviewed instead of skipped. Files past the last chunk are listed as not
reviewed. Chunk results are deduplicated, ranked by severity and confidence,
and capped at 8 findings for one call, plus 3 per extra chunk up to 24.
Every changed file ends up fully reviewed, partially reviewed, excluded, or not reviewed, and the comment lists which is which. A review that misses any changed file opens with a "Partially reviewed" banner. When a newer head arrives, kReview aborts the running review, including the provider run, Forgejo requests, and comment publishing, and queues the new head. A burst of pushes collapses into one review of the latest. On a re-review the model gets the previous findings, so it can drop fixed issues and keep the title and severity of the ones that remain. A finding someone dismissed or marked won't-fix stays gone unless the change makes it worse.
An adaptive router picks a fast or deep review from measurable signals like high-risk paths, 26 or more changed files, 2,000 or more changed lines, partial coverage, and gaps in the change-impact map. Pull request text never counts. A deep review gives the model bounded, read-only repository tools when the operator has enabled them; a second reviewer joins only if the operator opted into multi-reviewer deep reviews. Verification is separate from routing: a verifier rechecks findings by default, and if it fails, every mode except fixed publishes only findings whose quoted source anchors in the diff or the supplied repository context.
Every response carries an x-request-id header. On shutdown kReview stops
taking webhooks, flips /readyz to 503, and lets running reviews finish.
/healthz, /readyz, and opt-in, token-protected Prometheus (a metrics system that scrapes and stores time-series data) metrics
expose its state. It ships as one compiled binary and keeps its review queue,
history, and index vectors in PostgreSQL.
Boundaries
kReview never merges or pushes with its own credential. Its kReview commit
status turns to failure when a review reports findings, and whether that
blocks a merge is up to your branch protection. The optional agent gateway can
merge and push for an agent, but only with that user's own Forgejo identity,
so Forgejo still decides what the agent may do.
kReview treats everything a pull request contains as untrusted data: the prompt fences it, and provider output is size-capped before parsing. The CLI adapters run hardened by default: Codex in a read-only sandbox with the shell tool off, Claude Code with built-in tools disabled, both ignoring user configuration, and OpenCode with deny-all permissions. Those are prompt rules and CLI flags, not OS isolation. For a hard boundary, run the provider in a container that can't read kReview's config or auth directories.
The optional repository index comes from a read-only bare mirror (a Git repository with history but no checked-out files) and covers the base branch only. Language servers, when an operator installs them, read the PR head on the host or in a pinned, network-less container. Optional analyzers run against a read-only worktree in digest-pinned, network-less containers. kReview never takes a command from the reviewed repository.
Optional stats record route, coverage, token, and cost data for each run, plus each finding's text and quoted source snippet. They never store the full prompt, the full diff, or resolved secrets, but that database still holds source-derived content and needs the same protection as the code.
A clean, fully covered review means the models found nothing in what they read. kReview doesn't see production data, runtime behavior, or intent the author didn't write down, and because language servers are fail-open, one review can carry more context than the next.