Skip to content
GitHub

DevelopAnalyses

@holtkeeper/review

AI code review of merge requests: the review analyzer reviews one merge request, posts inline comments (with one-click suggestions) and a summary, resolves its own threads once fixed, and answers replies in its threads. It talks to the forge only through GitForge and to the LLM only through Agent.

reviewMergeRequest(run) runs replaceable steps (ReviewSteps, override any of them with run.steps):

  1. load — getMergeRequest, getMergeRequestDiff, listDiscussions (open diff threads through openThreads, our resolved ones through settledThreads), and the previous review from history: the newest review record with ref !<iid> that reviewed something.
  2. plan — reads the checkout’s rules files (readCheckoutRules, and the path rules from REVIEW.md), decides the mode and scopes the diff: added lines of reviewable files, minus ignore globs (plus globs from REVIEW.md, see below). Deleted, binary and forge-collapsed files are skipped. Incremental: compareCommits(lastHead, head) intersected with the MR diff; only lines both add are in scope. That holds when the last head is an ancestor of the head, and also when it was amended or force-pushed on the same base (the MR’s baseSha is an ancestor of the last head): the tree diff from the last head is then what the author changed. A rebase that moves the base gets a full review.
  3. deterministic — with includeChecks (by default testids, which skips itself in repositories without test attributes), runs the injected checks (secrets, testids; checksFor(repo) builds them per repository, e.g. with the team’s test id overrides) on the checkout and keeps issues touching lines in scope. A fix whose edits lie entirely on changed lines becomes the comment’s suggestion. Findings of agentCompletedChecks (testids: interactive elements added without a test attribute) go to the agent instead when there is one: the prompt lists them with the project’s convention, the agent comments on the ones it agrees with and suggests the attribute in the project’s style, and the rest are dropped. Without an agent they are posted as found.
  4. agentReview — one structured agent task (taskKind: 'review', model tier picked by depth: main for small changes, deep for large ones): the system prompt holds the rules; context holds the review’s rules from the guideFor hook (ReviewRun.guide): the checkout’s rules files (readCheckoutRules(runner, dir, signal?): the files git ls-files lists that @holtkeeper/rules reads — root REVIEW.md, AGENTS.md, CLAUDE.md, .github/copilot-instructions.md, CONTRIBUTING.md, nested AGENTS.md/CLAUDE.md, .github/instructions, .cursor/rules, .claude/rules, .windsurf/rules, .continue/rules — plus root rules files on disk git does not list) resolved with the changed files in scope, together with panel rules, policies and learnings on the server; without the hook, or when it fails, resolveRules of the rules files alone; then options.instructions; the prompt holds the MR title and description, the ticket it names when one can be read, the REVIEW.md path rules matching files in scope, open threads, our resolved threads (not to be raised again) and the numbered diff per file (+ in scope, ~ reviewed before, - removed). The agent reads more code with its tools instead of getting whole files. The checkout is never installed, so the system prompt sends dependency questions to the package tools: the organization’s own packages and third-party libraries alike through find_packages by export name, then package_api (versions default to what the repository uses), with package_docs for library docs and package_source for code. Where that version comes from depends on the files in scope: package.json and lockfiles.resolve, or for Go-only scopes the go.mod of the module owning the file (go.sum for the exact version), or both when the scope mixes JavaScript or TypeScript with Go (.go, go.mod, go.sum, go.work). A “Packages and public API” block tells it when to use them: a dependency version change goes to package_changes (API diff, a library’s changelog and the uses in this checkout it breaks); a change to the public API of a package other repositories import goes to package_usage for the repositories it breaks, with the major bump it needs; code that seems to reinvent something is checked with find_packages first. With Go files in scope it adds Go’s rules: internal/ and main packages reach only this module’s callers, adding a method to an exported interface breaks outside implementations, a new major changes the import path, and package_api gets the require version of the owning go.mod. When Go files change, the prompt also carries the modern Go guidelines before the diff. Besides comments it returns a summary (what the change does and the problems this answer reports; earlier threads are not restated, the summary note counts them), a verdict, a walkthrough (logical changes with their files) effort (1–5, how hard the change is for a human to review) and reviewMinutes (its estimate of a careful human review of the diff it saw; split reviews sum the parts’, and give none when a part failed).
    • The server mounts code (code.search, code.outline, code.symbol, code.imports; the adapter’s own file tools read and grep), knowledge, packages, git, stack and assets for review tasks and code, knowledge, packages and git for review-verify, and answers reads of dependencies the checkout does not hold from the package index (externalFiles, see @holtkeeper/server). The prompt points at code.symbol with references: true for finding every reader and writer of a value.
    • Every pass mounts the lockfiles toolset of @holtkeeper/agent-tools (lockfiles.resolve: the versions every lockfile resolves for a package, parsed in full), and when the merge request touches a dependency file the prompt carries the computed dependency changes before the diff. The system prompt forbids claims that a lockfile lacks a package, has a wrong entry or must be updated unless that section or lockfiles.resolve says so, and asking to update a lockfile the section calls consistent.
    • The system prompt asks for a deliberate pass: every changed file, the code around each change, its callers and the code paths it touches read with the tools (more for larger diffs); error paths, retries and idempotency, edge cases, concurrency and the contract with callers checked; every distinct problem reported up to maxComments instead of stopping at the first.
    • A pass over more than INVESTIGATE_MIN_FILES (3) files or INVESTIGATE_MIN_LINES (80) changed lines sets followUpWithoutTools: an answer given without opening any code is followed up once, asking the agent to inspect the changed code and return the complete JSON again (all findings, not only new ones). The extra turn counts in usage like any other.
    • Turn limit: each pass gets reviewTurns(files) = 40 + one per file + one per 15 changed lines, at most REVIEW_MAX_TURNS (90), so larger slices of a diff are read more thoroughly; an explicit maxTurns overrides it. Turns not needed are not spent.
    • A diff over SPLIT_MAX_LINES (600) changed lines or SPLIT_MAX_FILES (12) files is split by splitReviewFiles: files of one directory stay together, files under __tests__, __mocks__, __snapshots__ and __fixtures__ counting as files of the folder above so tests stay with their code (splitGroupOf; a directory over a limit is cut in path order, a file over the line limit is a part of its own), parts hold at most 12 files and are balanced by changed lines. Each part runs its own pass on the main tier whatever the depth, at high reasoning effort (PART_EFFORT: at medium, parts answered after a read or two), told it is the only reviewer of its lines and to read what the changed code relies on and its callers before answering (SPLIT_CONCURRENCY, 6 at once so usual splits run in one wave, each with its own turn limit, reviewTurns capped at PART_MAX_TURNS (50), and the usual budget) with the MR title and description, the list of every file in scope, and only its own numbered diff, open threads, path rules and check requests. Second passes: the parts with the most logic (riskyParts: at least SECOND_PASS_MIN_LINES, 150, changed lines in files isLogicFile accepts, i.e. not tests, stories, styles, fixtures, translations, config, docs or assets; at most SECOND_PASS_MAX_PARTS, 2) get a second, independent pass with the same prompt and their files in reverse order, run in the same queue as the parts (progress counts every pass). Runs differ in what they notice, so a second look at the stores and services catches what one pass missed. mergePassFindings folds a second-pass finding near a first-pass one (same file, lines within 2, same line and category or similar text) into it, with the higher severity, and adds the rest; the summary, walkthrough, effort and time stay the first pass’s. A part fails only when all its passes fail. Scenario plan: while the parts run, planScenarios asks the fast tier once, without tools (taskKind: 'review-plan'), for at most SCENARIO_MAX (6) cross-file scenarios likely to hide a bug (an action and its undo, an action after another removed its data, two inputs at once, a failure halfway, a flag set in one place and read in another), each with the files it crosses and what to check, from the title, description, ticket and numbered diff (up to SCENARIO_DIFF_MAX_CHARS, 200 000 characters; the files past it are listed by path). A failing plan gives none. After the parts, one cross-part pass (CROSS_PART_TURNS, 30 turns plus SCENARIO_TURNS, 3, per scenario, on deep when the review is deep) gets the list of files with their changed-line counts instead of the diff and reads the numbered diff of the files it looks into with the mr.diff tool (mergeRequestDiffTools, toolset mr), so the whole diff is not repeated on every turn; it also gets the parts’ walkthrough and summaries and the findings they reported (number, path, line, severity, title) and looks only for what a slice could not see: contracts between changed modules and their callers in other parts, the same change applied differently in parallel code, state and lifecycle across files, code a part only skimmed. The scenarios are its mandatory checklist: it traces each through the code and answers per scenario problem, fine or not-checked (scenarios), which the run logs as counts. It adds findings, writes the summary and the walkthrough of the whole merge request, which replace the parts’ (it gets their walkthrough entries with their files and merges them by logical change, so one file does not show up in several rows), and names part findings that report the same problem as another one (duplicates, e.g. one omission seen from two files): dropDuplicates drops them and the kept finding takes the higher severity. Never its effort. When it fails or gives none, the parts stand and their summaries and walkthroughs are joined, unless a spend limit stopped it. Candidates are concatenated (the usual dedupe and maxComments cap apply), effort is the highest and the verdict the worst. A part that fails does not lose the others: the summary lists its files as not reviewed and the verdict becomes needs-changes (so approve: 'when-clean' never approves a partly reviewed MR); the review fails only when every part fails, a spend limit (BudgetExceededError) stops a part, or the job is aborted. Smaller diffs keep one pass.
    • Grounding and suspicions. The system prompt asks for findings grounded in code the agent read: a claim about code outside the diff (a caller, a guard, another method relying on a value, a missing test) should come from reading that code with the tools, listed in the finding’s evidence (path, line, note). It also asks it to investigate every suspicious pattern and not to drop a suspicion it could not prove: such a finding is reported with unverified: true (written as the problem it would be) and posted only when the verification confirms it, so a missed bug costs more than a wrong suspicion, as Cursor Bugbot does with aggressive passes and a validator. Before calling a flag, field or return value wrong it finds every reader and writer; before saying tests are missing it looks at the files in scope (all parts) and the checkout’s test files.
    • Computed sections before the diff. impact (on unless false): impactSection lists, for the declarations each pass changes (JavaScript family; functions, classes, methods, fields, exported constants, types), their references by file with writes and reads of fields apart and the uses in tests, plus the test files of every changed file; split parts get the section of their own files. Pure deletions select no declaration. apiChanges (the apiChangesFor hook): the public API changes between the merge request’s base and head, computed in a temporary worktree and never stored; the server passes branchApiChanges of @holtkeeper/api-surface limited to packages other repositories import (by the newest usages records), so app repositories get no section. Either failing leaves its section out.
  5. media — images the diff adds or changes go to the injected MediaReviewer (see below).
  6. validate and rank — every comment must target a new-side line shown by the diff; a line outside it moves to the nearest changed line (at most 5 away) or is dropped; in incremental reviews lines reviewed before are dropped. Suggestions must cover exactly startLine..line: copies of neighbouring lines are trimmed, no-op suggestions dropped, broken ranges lose the suggestion. After the agent the discussions are read again (withFreshThreads), since replies resolve threads while it works. Findings repeating an open thread, one of our resolved threads (fixed, withdrawn or left to the author: a later run never raises them again), a deterministic finding or an earlier finding are dropped (sameFinding; for threads, the category comes from our comment’s heading): same path and line within ±2 with a similar text (or the same line and category), or line within ±15 and about the same code — at least three shared inline code spans, half of the shorter comment’s (sameCode), which catches rephrasings in inflected languages. Passes over the same part are merged by the same rule. The rest is filtered by minSeverity and ranked by severity; below major findings about behavior (security, bug, performance) come before those about maintainability, tests, docs and style of the same severity, so the comment limit cuts the latter first (the prompt asks for bug on anything that makes the program do the wrong thing or leave out what it should do, e.g. a missing event or log record). maxComments plus VERIFY_HEADROOM (5) of them go to verification, and the first maxComments that survive it are posted: the extra ones fill the places of refuted findings, and what is left is counted as over the limit. verify (on unless verify: false) — after ranking, verifyFindings gives the agent’s findings about to be posted to a skeptical second pass (taskKind: 'review-verify', read and search tools plus git) that tries to disprove each one from the code: callers, guards, readers and writers, tests, history. Major and critical findings are checked on deep, the rest on main, both groups at once with verifyTurns (6 + 2 per finding, at most 30). Each finding in the prompt carries the numbered code around it (12 lines either side) and around up to three of its cited evidence lines (4 either side), so most findings need few reads. refuted findings are dropped and stored in refuted with the reason (stats.dropped.refuted counts them); confirmed, uncertain and unanswered ones are posted. An unverified suspicion is marked as such in the prompt and posted only when confirmed (it then loses the mark); otherwise it goes to refuted with Not confirmed: <reason>, also when its group fails, and the run logs how many suspicions were confirmed. Without verification (verify: false, no agent) suspicions are dropped the same way (dropUnverified). Evidence paths that do not exist in the checkout are dropped first (existingEvidence). When a refuted finding was major or critical, the agent’s own verdict no longer counts: the verdict follows the remaining comments. When anything was refuted, reviseSummary (one fast call without tools, taskKind: 'triage') removes the claims of the refuted agent findings from the agent’s summary and keeps the rest; on failure the summary stays as written. The prompts tell the reviewer and the verifier to read a dependency’s code with the library source tool (organization packages included) rather than refute or skip a finding because the code is missing from the checkout. A failing group (or one stopped by a spend limit) keeps its findings but the suspicions; check findings are never sent.
  7. recheck — after new commits every open thread of ours whose file is still in the diff is re-checked (those whose file changed first; nothing when no file changed since the last review) on the fast model tier (taskKind: 'triage', at most 10 per run, threadsToRecheck). The prompt names the files changed since the last review, since a fix may land elsewhere: a missing test in a test file, a caller in another module. Fixed ones are resolved with a short note, threads whose file left the diff are resolved too. A thread that is still relevant and that the agent raised again gets a “still applies” reply instead of a duplicate comment.
  8. post — one submitReview with the comments and the summary note (verdict; right under it the estimated review time or the advice to split as a callout, see sizeCallout; agent summary, review effort, the walkthrough in a collapsed table, findings per severity, thread outcome (earlier threads resolved and still open, kept ones included), what was not reviewed), event: 'approve' when approve: 'when-clean' and the review is clean (verdict looks-good, no major/critical finding, no thread still open). Incremental runs without anything new post nothing. Rejected comments are marked in the data.
  9. resolve summaries — on forges where the summary is a resolvable thread (GitLab) and that have resolveDiscussion, the run lists the discussions again and resolves every unresolved summary thread of Holtkeeper’s own account: its first note is a summary note (isSummaryNote: the ### Holtkeeper review: heading and the summary marker) outside the diff, and its author is the token’s account (getCurrentUser, else botUsername; with neither nothing is resolved), so a human’s copy of a summary is never touched. With resolveSummary: 'when-clean' (default) this happens only when the verdict is looks-good, so needs-changes summaries stay open until a later clean run resolves them together with its own; always resolves after every run that reached the post step, never leaves them. Summary threads are never finding threads (openThreads keeps positioned discussions only), so dedupe and re-checks ignore them. A failing lookup or resolve (e.g. comments switched off) is logged and never fails the review; forges without resolveDiscussion are skipped.

When the in-scope diff exceeds maxDiffLines the review is skipped with a summary note (posted once until the MR gets small enough); the note carries the advice to split too.

Every note carries a hidden marker (<!-- holtkeeper:review id=<finding> -->); later runs and the webhook use it to recognize our threads, in addition to botUsername.

createReviewAnalyzer(deps) / reviewAnalyzer — kind and analysis review, scope repo, needs checkout, forge, history and an optional agent. Without an agent only deterministic findings are posted and threads are not re-checked.

Option Default Meaning
mergeRequest required MR number (iid)
mode auto auto: incremental when a previous review exists and its head is an ancestor
maxComments 15 inline comments per run
minSeverity minor info, minor, major, critical
includeChecks ['testids'] true, false or a list of secrets, testids (or secrets,testids); testids skips itself when the catalog is empty
approve never when-clean approves clean reviews
resolveSummary when-clean when-clean resolves our summary threads after a looks-good run, always after every run, never leaves them open
depth auto model tier: standard (main, Sonnet), deep (deep, Opus), auto picks by the estimated review time
deepFromMinutes 60 estimated review minutes from which depth: auto reviews on deep
verify true second pass that drops findings the code contradicts (see verify above)
impact true computed callers, readers and writers and tests of the changed declarations in the prompt
costLimitUsd 4.5 (DEFAULT_REVIEW_COST_LIMIT_USD) soft spend limit of the agent passes in USD; 0 turns it off. See Cost control
showCost true last line of the summary note with how long the review took and what it cost (durationMs, usage.costUsd)
ignore lockfiles, generated, snapshots, dist, … path globs (DEFAULT_IGNORE); globs without / also match base names
maxDiffLines 3000 skip bigger diffs (added + removed lines in scope)
language the MR description’s language language of comments, the summary, the walkthrough and thread replies; code, suggestions, code comments and technical terms stay in English
instructions — extra rules for this run, appended after the resolved rules
media true review images with the MediaReviewer
citations link how posted notes show cited rules and learnings: link, details or off (see Citations)
replies false answer the replies people left in our threads instead of reviewing
releaseBranches DEFAULT_RELEASE_BRANCHES source:target branch globs of merge requests not reviewed (develop:main, release/*:main, main:develop, …); [] reviews them
reviewOwn false review merge requests authored by botUsername
force false review even what releaseBranches and reviewOwn skip (/holtkeeper review force=true)
goGuidelines { enabled: true } modern Go guidelines for merge requests changing Go modules; tag pins an upstream release (vX.Y.Z)
sizeAdvice { enabled: true, largeMinutes: 60, tooLargeMinutes: 120, model: 'agent' } estimated review time and the advice to split; enabled: false leaves both out
progressNote first progress note while the review runs: first before the first review of a merge request, always before every review, never

resolveReviewDepth(depth, files, deepFromMinutes?) picks the tier of the review: a diff reviewed in one pass runs on it, a split one runs its parts on main and only the cross-part pass on it (most turns go to the parts, so this keeps a large review at roughly Sonnet cost while the pass that sees the whole diff runs on Opus). standard always runs on main, deep always on deep. auto (default) estimates the files under review with the deterministic combined model of estimateReviewMinutes (default effort, so it is known before the agent runs) and goes deep from deepFromMinutes (DEFAULT_DEEP_FROM_MINUTES, the same 60 as largeMinutes): a merge request the summary would call large gets the stronger model. Incremental runs estimate only the new commits, so a small push to a large merge request stays on main. The run logs the chosen depth with the estimate; usage.model in the record names the model that ran. Thread re-checks stay on fast and replies on main whatever the depth.

Not reviewed by default. Before any checkout, a merge request between releaseBranches (release candidates like develop → main, back-merges like main → develop: their code was reviewed on the way into the integration branch) or authored by botUsername (Holtkeeper’s own update, propagation and test merge requests; compared case-insensitively, so it needs the forge’s bot username set in the panel) is stored as mode: 'skipped' with the reason and nothing is posted. force overrides both; replies runs (replies) are never skipped. Set the options per repository or group through the analyzers.review setting.

What the job should set: ref = the MR head sha (the webhook does). The engine’s mirror fetches every ref, so the head of fork MRs (refs/merge-requests/<iid>/head) resolves too. When the checkout is not at the head, the analyzer checks out the head itself through context.checkout.

ReviewAnalyzerDeps: checks (QualityChecks by name), checksFor(repo) (the checks for one repository; wins over checks, which it falls back to on failure), testsExpected(repo) (the server reads repo.tests; for a repository with no tests by design the run gets ReviewRun.tests: false: the system prompt drops “missing tests” from the minor severity and “callers and tests”, and the tests category unless check requests of that category exist (then it is listed with a note that it is only for the flagged lines), and agent findings of category tests are dropped unless they complete a requested check finding, so the testids check is unchanged), guideFor(repo, { repoFiles, files? }) (the resolved rules for a review or thread reply, given the rules files read from the checkout (RepoRuleFile[]) and the changed files in scope — absent for thread replies, so every file-scoped rule applies; a ReviewGuide { text, sources } whose sources — the source of every block that made it into the text, deduped, in prompt order, e.g. All repositories, Team widgets, AGENTS.md — are stored as ruleSources; reviewGuideOf(resolved) builds one from ResolvedRules; the server passes its rules resolver), knowledge: { access, teamsOf? } (the knowledge toolset of @holtkeeper/agent-tools is mounted: search_knowledge over rules and learnings, propose_learning), toolsetsFor (review-specific tool sets; the host attaches the shared code tools), apiChangesFor(repo, { dir, baseSha, files, signal? }) (the computed public API changes section; see Computed sections), issueTrackerFor(repo) (the repository’s issue tracker, for the ticket context; the server passes its jira credential lookup), mediaReviewer, goGuidelines(tag?) (the guideline set to use, for an optional pinned tag; default: the bundled snapshot; the server passes goGuidelinesSource over its key-value store), botUsername (a string, or a function of the repository since each forge has its own), steps.

The record is stored with ref !<iid>.

When the merge request names a ticket and the tracker can show it, the reviewer gets the ticket’s title, type, status and description (up to TICKET_PROMPT_CHARS, 3 000 characters) after the description, with the instruction to check the change against it and report where the code contradicts it or leaves out what it asks for, without asking for work the merge request does not claim. Keys (ABC-123, issueKeysIn) come from the title, the upper-cased source branch (feature/abc-123-x) and the description, in that order, at most REVIEW_TICKETS_MAX (2). ReviewRun.tickets(keys) reads them; the analyzer builds it from issueTrackerFor(repo) and issueDetails, so only tickets the tracker’s issue could actually read come back, and the server’s lookup picks the most specific jira credential covering the repository. Without a tracker, a tracker without issue, no key, an unknown ticket, no access (401, 403 and 404 read as unknown) or a failing lookup, the prompt says nothing about tickets and the agent gets no tracker tool: there is nothing it could not use. The run logs ticket context: <keys>, that none could be read, or why it was skipped. The scenario planner of split reviews gets the same tickets.

Right after the skip check, before the checkout, the analyzer posts a short note saying the review is running and asking to wait for it (startProgress, hidden marker PROGRESS_MARKER). With progressNote: 'first' (default) only a merge request without an earlier review gets it, so later pushes stay quiet; replies runs (replies) and shadow runs never post it. Before posting, leftover progress notes of Holtkeeper’s own account (a crashed run) are deleted. While the review runs, ReviewRun.onProgress (ReviewStage: the agent passes with parts done, the cross-part pass, verification, posting) edits the note into a checklist of these steps with the current one marked and the estimated time left (minutesLeft: rough minutes per step in STAGE_MINUTES, what is left of the current step at least a minute), refreshed about once a minute; edits go out one at a time, only when the text changes, and stop when the review ends. When the review ends the note is deleted (deleteMergeRequestNote; a forge without it gets the note edited to say the review finished); when the run fails the note is edited to say so and to suggest /holtkeeper review. A forge that refuses the note never stops the review.

The texts Holtkeeper writes itself, not the agent (the progress note, the summary’s verdict, scope, effort, time, findings, thread outcome and not-reviewed lines, the feedback request, and the resolved / still-applies thread notes), come from reviewMessageCatalog (@holtkeeper/messages). The language is reviewLocale(language, description): the language option when it names a language, else the language detected in the merge request description, else English. With ReviewAnalyzerDeps.messages (a MessageStore) a missing or outdated translation is made once by the job’s agent (taskKind: 'translate', its usage added to the record’s usage) and reused by later reviews; without it everything is English. The ### Holtkeeper review: heading, the Walkthrough label, severity labels, categories, markers and the terms of the catalog stay in English. summaryNote, walkthroughTable and threadNote take the ReviewMessages as an optional last argument (English by default), and ReviewRun.messages passes them through the pipeline.

Every summary except a skipped one ends with a request for feedback (summary.feedback): replies in a thread that explain how it should be feed learnings (see @holtkeeper/rules), and 👍 / 👎 count in the quality measures.

Every agent task of a review carries AgentTask.phase (ReviewPhase, kept on the usage record as phase): initial for the first review of a merge request (no earlier review that reviewed something), update for a review after new commits (incremental, or a full re-review after a force push), recheck for the check of earlier threads against the new commits (recheckThreads, inside an update run) and reply for an answer in a thread. Planning, splitting, verification, summary revisions and translations take the phase of the pass they run in; the start note’s translation, which runs before the pass is known, has none. withPhase(agent, phase) sets the phase on every task that names none; reviewPhases lists them in order.

Citations (cite.ts). The agent cites a rule it applies as [rule:<id>] and a learning as [learn:<id>]; stored records keep that text. Before a note is posted (inline comments, the summary, answers in threads) citationRenderer(style, lookup) shows the citations by the citations option: link (default) keeps the citation as the text of a link, [\[rule:<id>\]](<panel URL> "<the rule's title>"), so GitLab shows the rule’s name on hover and the link opens it for editing (/knowledge/rules?rule=<id>, /knowledge/learnings?learning=<id>; without server.publicUrl the citation stays plain text); details also appends each cited rule once as a collapsed <details> block; off shows nothing. citedRules reads the linked form too, and a citation that is not shown stays in the note as a hidden <!-- [rule:<id>] --> comment, so citedRules still finds it when the note is read back from the forge and learnings keep being reinforced. A citation of an id ReviewAnalyzerDeps.citedRulesFor does not know (a removed rule), and every citation when the lookup fails, is shown as nothing. Notes read back from the forge for an agent (a thread’s conversation, the open threads of a re-check and of dedupe) go through plainCitations, which turns the links back into the plain [rule:<id>] the agent wrote. Set citations per repository or group through the analyzers.review setting.

Replies (replies.ts, thread.ts). With options.replies the analyzer answers every reply that waits in the merge request in one run and stores a reply record (threads holds one entry per handled thread with the answer kind as reason; ReviewMetrics.replies counts them by replyActions). pendingReplies({ forge, repo, mr, botUsername? }) lists the threads our review started (repliedThreads: the first note carries the review marker or is the bot’s, and is not a note of another Holtkeeper feature) whose last note is a person’s and does not carry our done mark. With nothing pending the run ends before any checkout. answerReplies then answers every reply on the main tier with the checkout, its tools and the resolved rules as context: one thread through replyToThread, several through answerThreads (up to REPLY_BATCH threads per call, each answered on its own by id), and a thread a batch left out through replyToThread again. Every answer picks an action (ANSWER_RULES): explain, concede or update in words; fixed when the reply claims a fix and the code confirms it (a Resolved at <head> note, the thread is resolved); open when the code still has the problem (Still applies at <head>); none when the reply needs no answer (thanks, a promise to fix it later): no note, the done mark, outcome ack. A reply that says the code is fine as it is declines the comment and always gets an answer. A general thread (the summary) is answered with reviewThreadsState: every diff thread of ours with its state, so the answer never calls a resolved thread open.

There is no separate sorting step: a cheap model sorting replies first read a short “it is fine” as agreement and left it unanswered, while nearly every reply needs the main model anyway. There is no limit on answers per thread. The answer rules (ANSWER_RULES) first decide whether the reply declines, claims a fix or asks, then leave the decision to the author and resolve the thread when they ask to close it, decline a minor or info comment, or decline again after an answer of ours; a first decline of a major or critical comment gets at most three sentences on the remaining risk. A resolved thread counts as settled for later reviews.

The checkout, toolsets and rules are set up once, only when there is a reply to answer. Before posting, the thread is read again: one that got a newer note meanwhile is skipped (skipped, that note queues its own run). Answered notes lose the seen mark the server left on them. Runs of the review analyzer on one repository never overlap (the job queue), so a replies run and a review never answer the same thread twice.

A review after new commits helps too: openThreads carries the waiting reply of each of our threads (OpenThread.reply), threadsToRecheck puts those threads first and the re-check sees the reply. A thread the re-check finds fixed is resolved with its status note and loses the seen mark; every other thread with a waiting reply is left for the replies run, so a decline (“it will do for now”) is answered by the rules above instead of a “still applies” note.

replyToThread({ forge, repo, mr, discussion, agent, dir?, botUsername?, language?, context?, stillPending? }) answers the latest reply in a thread we started, on the main model tier: explain, concede (and resolve) or update with a new suggestion (GitLab ```suggestion:-N+0 markup). Threads not started by us, and threads whose last note is ours, are skipped, and so is a thread for which stillPending answers false right before posting. postThreadAnswer posts one such answer.

Lasting rules taught in replies are not extracted here: the server looks at each reply separately with a cheap filter and a fast-tier call and stores the rule as a learning (see @holtkeeper/server). commentFinding(body) reads the category, severity and finding id back from an inline comment commentBody wrote, so reactions on it can be counted per category and an open thread’s severity is known without the stored run.

MediaReviewer.review({ repo, mergeRequest, refs, files, usages, code, paths }) gets added or changed png/jpg/gif/webp/svg files (SVG text via readFile, raster bytes via the optional forge.readFileBytes, left out when the forge lacks it), the added lines that mention them, code — markup and component files (.html/.jsx/.tsx/.vue/.svelte/.astro) whose added lines contain <svg, <path or a d= attribute, with their head text and added line numbers (inlineSvgFiles) — and paths, every path the diff adds or changes. The step runs when there are images or such code files. Its comments become minor performance findings that count toward maxComments; its Markdown summary is appended under “Images”. With language set (and an agent), the titles and bodies of these findings are translated by one fast call without tools (localizeFindings; code, numbers and technical terms stay as written); English, a failed call or an unusable answer keep the original text. noopMediaReviewer is the default.

Every review (unless sizeAdvice.enabled is false) estimates how long a careful human review of the whole merge request takes and stores it as ReviewData.size. Large merge requests get advice to split them in the summary note.

  • Estimate. estimateReviewMinutes is deterministic and counts the files of the whole merge request minus ignored paths (lockfiles, generated code, snapshots, build output, ## Ignore of REVIEW.md), also in incremental runs (ReviewPlan.fullScope). sizeAdvice.model picks the model (reviewTimeModels; reviewTimeModelInfo holds each one’s label, source and summary, which the panel shows as the option labels and the field description):

    Model Source Estimate
    agent (default) CodeRabbit-style estimate by the reviewing model the agent’s reviewMinutes, kept between a third and twice the combined estimate; combined when the agent gave none. Incremental runs reuse agentMinutes of the previous review, since their agent sees only the new commits
    combined Bacchelli & Bird, ICSE 2013; CodeRabbit effort tiers; SmartBear/Cisco understanding by effort (2, 5, 10, 20, 30 min for 1–5) + reading at 400 weighted lines an hour × effort factor (×0.3, ×0.5, ×1, ×1.3, ×1.6) + 0.5 min per file, at most 30 files
    smartbear SmartBear / Cisco study 5 min + reading at 500 weighted lines an hour + 1 min per file; ignores effort
    psp Kemerer & Paulk, IEEE TSE 2009 5 min + reading at 200 weighted lines an hour + 1 min per file; ignores effort
    effort-tiers CodeRabbit “Estimated code review effort” (tiers 1–3 observed, 4–5 extrapolated) 5, 10, 25, 50, 90 min for effort 1–5; ignores size

    Weighted lines: added 1, removed 0.3; lines repeated from earlier files of the merge request (sizedFiles: the same added or removed line, whitespace ignored, at least 8 characters — mirrored code, one edit applied to many files) count 0.3 of that; test files and stories (*.stories.*) 0.5, docs 0.3, and declarative files a reviewer skims 0.3: styles (.css, .scss, .less, styled.ts, styles.ts, *.styles.*, *.css.ts), config and data (.json, .yaml, .toml, .ini, .properties) and files under locales/, i18n/ or translations/. Effort is the agent’s effort, 3 when absent. The result is rounded to the minute, at least 1. ReviewSize.model records the model used and ReviewSize.agentMinutes the agent’s unbounded estimate. Incremental runs take the higher effort of this and the previous review; groups (logicalChanges(walkthrough): entries sharing a file count once) is stored but no model uses it. Durations (formatDuration) use the review language’s duration.* messages.

  • Callout. sizeCallout puts the estimate and the review effort (Review effort: N/5, then left out of the scope line) right under the summary heading as a quoted block led by an emoji of its level (⏱️ ok, ⚠️ large, 🛑 too-large), so it is the first thing a reader sees: the advice to split when the note carries one, else one bold line. In incremental runs that line says the estimate covers the whole merge request.

  • Levels. ok below largeMinutes (60): the callout says Estimated review time: ~N min.. large from 60: the note says how long the review takes and suggests splitting by functionality if the changes allow it. too-large from tooLargeMinutes (120): it also says plainly that a person cannot review this thoroughly in one sitting and asks for a split. Both large levels end with a note for authors whose code an AI agent writes: ask it to split this merge request now and to split large changes by functionality from now on. Authorship is not detected; the note is conditional.

  • Splittable. With an agent and a checkout, planSplit asks the fast tier once, without tools (taskKind: 'review-split'), given the title, description, files with their line counts and the walkthrough, whether splitting would make the review easier. It writes no plan of the split: the note keeps the estimate, the complexity and the advice to split. When the agent finds that splitting would not help (a mechanical rename, generated code, one atomic change), the note gives the estimate and its reason, with no advice to split and no AI note. The same call puts the fixed texts into the review language (language, else the description’s); without an agent, or when the call fails, they stay in English. Records from before may carry direction, older ones parts (titled file lists) and texts.parts; they are no longer produced or shown.

  • When. The advice appears in full reviews and in skipped (maxDiffLines) notes. Incremental runs repeat it only when the level is worse than the previous review’s, so pushes to a large merge request do not repeat the same text.

go-guidelines/ brings the guidelines of JetBrains/go-modern-guidelines (Apache-2.0) into reviews of Go code. Each guideline has an id, the Go version it needs (since_version, major.minor), the guideline text, details and before/after examples.

  • Data. goGuidelinesSchema validates a guidelines.json with length caps (1–500 unique guidelines, texts and examples bounded, files over 1 MB refused); modernizer, category and impact are optional because v0.1.1 predates them. upstream/guidelines.json is the unchanged v0.1.1 file (bundledGoGuidelines(), tag BUNDLED_GO_GUIDELINES_TAG), with the upstream LICENSE and a NOTICE next to it; it is the fallback whenever no refreshed copy is usable.
  • Refresh. refreshGoGuidelines({ fetch, previous, tag }) lists tags through the GitHub API (unauthenticated, If-None-Match with the previous ETag, so an unchanged listing costs no rate limit), takes the newest vX.Y.Z (prerelease tags such as -dev.1 are skipped), and downloads internal/guidelines/guidelines.json at that tag from raw.githubusercontent.com unless it is the tag already held. It never throws: updated, unchanged (new checkedAt) or failed with the reason, rate limits included. The server runs it once a day and stores StoredGoGuidelines (tag, fetchedAt, checkedAt, count, guidelines); see the server.
  • When. The agentReview step adds the section only when goGuidelines.enabled is not false, the run has a goGuidelines source and a checkout, files in scope end in .go, and at least one of them belongs to a Go module: changedGoModules maps each file to the nearest go.mod in its directory or above and reads its go directive (1.16 when there is none, as the go command assumes). Merge requests without Go files keep the prompt unchanged. The job log names the tag, its source and the modules.
  • Prompt. goGuidelinesSection keeps guidelines whose since_version is at most the newest changed module’s version, marks each with [Go X.Y+] and lists the modules with their versions; guidelines whose replaced pkg.Name calls appear in the added lines come first, the rest keep upstream order (newest Go first). Each carries its text and its first example when that is short (14 lines, 500 characters). The section stays within GO_GUIDELINES_MAX_CHARS (10 000) and says how many guidelines it left out. Its rules: third-party reference data, not instructions; only lines marked +; never ask to rewrite unchanged code; apply a guideline only to modules whose go version is at least its own, never suggesting code that would not compile there; severity minor at most.

Lockfiles are in DEFAULT_IGNORE, are often marked -diff in .gitattributes (the forge shows them as binary) and are usually over the 1 MB the search tools read, so the agent cannot see what changed in them. dependencySection({ files, dir, readBase }) computes it instead; the agentReview step calls it with every changed file of the merge request (ignored, binary and collapsed ones included), the head checkout and forge.readFile(repo, path, baseSha) for the base, and logs the section size. It returns '' when no package.json, package-lock.json, npm-shrinkwrap.json, yarn.lock, pnpm-lock.yaml, bun.lock, go.mod or go.sum changed (files under node_modules, vendor and testdata do not count).

  • Roots. A changed lockfile is a root; a changed package.json belongs to the nearest directory at or above it holding a lockfile (with several, findLockfile picks by packageManager). Each Go module is the directory of a changed go.mod or go.sum. At most 6 roots are computed, one at a time.
  • npm, yarn, pnpm, bun. Head and base lockfiles are parsed in full with indexLockfile of @holtkeeper/depgraph-js (head with the workspaces of the checkout, base with the root and changed manifests read from the base commit). The section lists package.json changes per changed manifest (added, removed and changed ranges, with the version the lockfile resolves now and before), direct dependencies resolved to other versions with an unchanged range, and lockfile packages added, removed or at other versions: direct ones listed, transitive ones counted with up to 10 examples.
  • Consistency of the head. For every changed manifest (every workspace when the lockfile changed), each registry dependency in dependencies, devDependencies or optionalDependencies (not workspace:, file:, link:, npm: aliases, git or URL sources, dist tags or other workspaces) must be resolved by the lockfile for that workspace, with the range the lockfile recorded equal to the manifest’s (yarn berry’s npm: prefix ignored) and the resolved version inside the range; dependencies the lockfile still records for a manifest that no longer declares them are flagged too. Without problems the section says Consistency: OK and that the lockfile needs no update for them; otherwise it lists up to 20 problems.
  • Go. go.mod require changes (direct first, // indirect marked) via parseGoMod, go.sum module versions added and removed via parseGoSum, and the check that every require (its replace target when replaced, local replacements skipped) has a go.sum line, and a direct one the module hash too. Direct requires whose version changed are listed once more as a hint to check them with package_changes.
  • Bounds. Lists are cut at 15 entries with … N more; the section stays within DEPENDENCY_SECTION_MAX_CHARS (8 000) and ends with a pointer to lockfiles.resolve when cut. It never throws: a root it cannot read or parse says so.

Put a REVIEW.md at the repository root; it is the first repository rules file in the agent context, after panel rules that apply everywhere. Write it for a reviewer: what matters in this codebase (money math, migrations, public API stability), what not to flag (style handled by tools, generated code), how tests are expected to look. A section headed ## Ignore (or ## Skip) lists path globs, one per bullet, added to the ignore option:

## Ignore
- `src/generated/**`
- legacy/*.js

A section headed ## Paths (or ## Path instructions) gives rules for files matching a glob, one per bullet as - `glob`: rule; indented lines continue the rule. Rules whose glob matches a file in scope go into the prompt with the matching files:

## Paths
- `migrations/**`: every migration must be reversible.
- `src/api/**`: keep the public contract; bump the version
on breaking changes.

ReviewData: MR, head, previousHead, mode (full, incremental, reply, skipped), verdict, summary, walkthrough, effort, size (estimated minutes, level, counted files, lines and groups, and the advice the note carried: its localized texts, splittable, reason (direction or parts in older records); absent with sizeAdvice off), comments (id, path, lines, severity, category, source, suggestion with the original text, evidence the agent cited, posted/error, link), refuted (agent findings the verification dropped, with its reason; optional), threads (resolved/replied/kept with reason), skipped files, stats (files, changed lines, dropped findings by reason), approved, checks, usage (turns, cost, tokens and model, the provider id of the first agent run that named one — the main review run), ruleSources (where the rules that reached the agent come from, in prompt order; absent when none did), promptVersion (reviewPromptVersion(), see Measuring quality; absent without an agent review) and durationMs (wall time of the run, posting included; skipped runs have none). The last four are optional, so records stored before them still parse. The MR link and comment links must be http(s) URLs; the schema rejects anything else.

Report sections: Summary (with effort, the review time or the advice to split, and the walkthrough), Findings (table by severity, comments with tags new/rejected/suggestion, findings no longer reported compared with the previous review of the same MR), Suggestions (changes block with applicable: false — suggestions are applied in the forge), Threads, Not reviewed. Metrics: verdict, comments, major and critical, suggestions, threads resolved, files reviewed, cost.

reviewMetrics(data) is the kind’s metrics, stored with every record as ReviewMetrics: mergeRequest (its id), verdict, mode, posted comments and their counts per severity (severities, every severity present), suggestions, findings the forge rejected, discussions resolved, approved, costUsd, and the merge request’s title, url and author, model, promptVersion, durationMs, ruleSources and reviewMinutes (the estimated human review time), refuted (agent findings the verification pass dropped) and, on reply records, reply (explain, concede or update: how the thread was answered) so a fleet table needs no record data. reviewMetricsSchema parses stored metrics; fields newer than a record are absent. The server’s Quality › Reviews (GET /api/reviews) lists rows from these metrics only.

Three tools tell whether a change to the prompts or the pipeline made reviews better, before and after it ships.

What became of each comment (outcome.ts, quality.ts). When a merge request is merged or closed, the server stores for every inline comment Holtkeeper posted an outcome on its ReactionSignal, with severity, source, model, promptVersion and the number of human replies (see @holtkeeper/server). findingOrigins(runs) finds the run that first posted each finding (its head, model and prompt version); linesTouched(changes, finding) tells whether the changes from that head to the final one touched the commented lines; findingOutcome combines it with the thread state:

Outcome Meaning
fixed The commented lines changed after the review.
resolved The thread was resolved but the lines are unchanged.
ignored The thread is still open and the lines are unchanged.
unknown The forge could not compare the commits, or the file is binary or collapsed.

qualityRows(signals, by) groups signals by category, severity, model, promptVersion or source and counts only comments of merged merge requests (a closed one says nothing about whether a finding was right). acceptance is fixed / (fixed + resolved + ignored); addressed is (fixed + resolved) / judged. It is a proxy: a comment can be right and still not fixed, so compare groups and versions with each other rather than reading one number as truth. The server serves it as GET /api/reviews/quality.

Which rules help (citations.ts). The resolved rules ask the agent to cite what it applies as [rule:<id>] (a panel rule) or [learn:<id>] (a learning). citedRules(text) finds those citations ({ kind, id }, each once, in order) in a comment’s title and body. ruleCitations(runs, signals) turns stored review runs (CitingRun: repository, merge request, run time, ReviewData.comments) into one RuleCitation (kind, id) per posted comment and citation (the first run that posted a finding wins), joined by repository, merge request and finding id with its ReactionSignal: outcome fixed / resolved as above, ignored becomes dismissed, a closed merge request closed, one without an outcome yet open; replies and 👍/👎 come from the signal. summarizeCitations(citations) counts them per outcome with the replied ones and the last citation time (CitationSummary). The server reinforces cited learnings when a merge request ends.

reviewPromptVersion() is p- and eight hex digits of a hash over the system prompts in each variant, the review context, the task prompt with every block (tickets and the scenario checklist included), the scenario planner’s prompts, the follow-up text, the size limits that split a diff and the limits of second passes and scenarios. It changes with any edit of those and needs no manual bump. The recheck, thread reply, localization and splittable check prompts are not part of it.

Shadow mode (shadow.ts). shadowReview(run) runs the whole review against the real forge, checkout and agent without posting, replying or resolving: dryRunForge(forge) lets reads through and collects submitReview, replyToDiscussion and resolveDiscussion in wouldDo and drops note marks; any other forge method throws, so a write step added to the pipeline later fails in a dry run instead of posting. Leave run.analyses out to compare strategies on the same, full diff. compareReviews(a, b) pairs findings one to one (same file, line within 2 lines, and the same category or a similar text) and reports what only a or only b found, the verdicts and the cost, so a new pipeline can run beside the current one on real merge requests.

Golden set (eval/). goldenCases are small invented merge requests: file maps before and after the change (EvalCase), with the problems a careful reviewer should find (ExpectedFinding: file, lines, optional words the comment must mention, accepted categories, minimum severity) and changes it should leave alone (no expected problems, to measure false positives). Cases are written with defineCase, which finds a problem’s lines by its text, so editing a case cannot silently move them; the cases test checks that every problem sits on a changed line. Cases must be invented: never copy code of a repository Holtkeeper analyzes.

runEval({ cases, agent, repeat?, concurrency? }) writes each case into a temporary checkout, serves it through a fake forge, runs the real pipeline (reviewMergeRequest) with the given agent and scores the posted comments with scoreCase: a comment matches the first expected problem on its file whose lines it overlaps (give or take 2 lines), whose words it mentions and whose category it uses; a second comment on a found problem is a duplicate, anything else is a false positive, so the expected list is treated as complete. summarize gives precision (comments on a problem), recall (problems found), f1, underrated findings, how many clean changes still drew a comment, cost and time; formatEval prints them with the missed problems and the false positives. Models are not deterministic: repeat each case a few times and compare summaries, not single runs.

One command runs the golden set with a real model and prints the acceptance of real review comments next to it: holtkeeper review-eval (@holtkeeper/cli).

  • maxDiffLines skips huge MRs before any agent call; ignored paths never reach the prompt.
  • Incremental reviews only send new lines as in scope; nothing new means no agent call.
  • Large diffs cost one pass per part (see agentReview), and a shallow answer on a non-trivial diff costs one follow-up request.
  • Re-checks run on the fast model tier and are capped at 10 threads per run.
  • Whether a large merge request is splittable is one small fast call without tools, made only when the note gives the advice to split; it writes no split plan.
  • The resolved rules are capped (12 000 characters, deterministic text) and goes into context so the provider can cache it across runs.
  • Usage per run (turns, costUsd, tokens) is stored in the record and shown in the report.

Every turn of a pass resends its prompt and the conversation so far, so the review keeps both small:

  • Passes mount only the tools they use; the cross-part pass reads the diff on demand (mr.diff) instead of carrying it.
  • Second passes run only over parts with at least 150 changed lines of logic, at most two; the scenario plan is one fast call without tools. Both run only for split reviews.
  • read_file returns REVIEW_READ_LINES (400) lines unless the agent asks for a range, and only once tool results in the conversation pass REVIEW_TRIM.maxChars (400,000 characters, about 100k tokens) all but the newest REVIEW_TRIM.keepLast (8) long ones are cleared (trimToolResults of @holtkeeper/agent); the calls stay, so the agent can run one again. This guards the context window and is no saving: clearing changes the cached prefix, so the conversation after it is written to the cache again at 1.25x the input price, while a kept result costs a cache read (0.05x) per later turn.
  • With costLimitUsd, each pass gets a soft limit (answerAtCostUsd) from REVIEW_BUDGET_SHARES: a single pass 60%, the passes over the parts of a split review 55% together (evenly, second passes included), its cross-part pass 25%, verification 25% (60/40 between the serious and the other findings when both groups run). A pass that reaches its share stops reading and answers with what it found, so the review posts instead of failing; the hard budget caps (maxCostUsd) still apply.
  • Each pass logs one line to the job log (runTracked with a label, runSummary): turns, prompt tokens, the size of its first request (startTokens: system prompt, task prompt and tool schemas) and cost, so a growing fixed context shows up.
  • Duplicate detection is word overlap and shared code spans, not semantics.
  • The summary note is submitted with the comments, so it cannot mention comments the forge rejected (the stored data does).
  • Suggestions in replies use GitLab’s markup.
  • ## Ignore and ## Paths are read from the whole REVIEW.md, but the prompt carries REVIEW.md cut to the rules files budget; keep important rules near the top of a long file.
  • Threads re-checked as fixed are resolved without asking the author.
  • An outcome is read from the lines of a comment: a finding fixed by a change elsewhere (or by deleting the code in a later merge request) counts as ignored or resolved, and renames of the file the comment is on are followed only through the forge’s own rename detection.
  • The golden set is small and invented. Treat its numbers as a regression signal for a change, not as the quality of reviews on your repositories; the acceptance on real merge requests is the other half.