Related code
A vote reads a finding's claim, the code the harness read around the cited line and the diff section of the cited file. A diff holds only the code a change touches, and whether a sink is reachable, or whether a check elsewhere already neutralizes it, often rests on code the change leaves alone: the definition of a function it calls, or the callers of the function it sits in. Related code gives the votes of the lenses that ask for it those excerpts, picked by rules of code from the finding's cited row and read from the repository at a commit quorum resolves. It is off unless you turn it on. This page says what it is and why it is off, how to turn it on, which commit it reads, what the rules read, the files it never reads, how comments are treated, the bounds, what a person sees, how it is measured, and what it cannot do.
What related code is, and why it is off
For each finding of a profile with a lens that asks, code works out a short list of excerpts from the finding's cited row, the one row of the diff's new side that its file and line name:
- The definitions of the names on that row: a function, a class, a type, a constant or a method that the row uses and the repository defines elsewhere.
- The callers of the function around that row: where the function the cited row sits in is called, with the rows around the call.
Each excerpt is a few rows of code with its file and its lines, at most 1536 bytes, its comment lines left out (Comments). A vote of a lens that asks is sent them as one block, related-code, first in its user message, before the claim, fenced as data like the diff, and the notice of the request says what it holds: code of the repository outside the diff, read by code, where a comment proves nothing.
- Code picks, no model chooses. The excerpts come from the cited row and the read commit, never from a vote and never from the claim's words, so no text a model wrote names a file, a commit or a read. Every voter of a finding receives the same excerpts in the same order, a prefix each, and the votes stay blind and the confidence arithmetic: Lenses and policy.
- Only the lenses that ask. A lens sets
relatedCode: true. Of the built-in lenses,security'sreachabilityanddefensesdo,code-review'srealdoes andperformance'shotdoes, since each asks something that code outside the diff can answer. The others,impactamong them, and the whole ofbest-practices, are sent what they always were: Related code in a lens. - Never the finder, never a system message. Related code is untrusted text at the trust level
repository, the trust of a{ repository }document: whoever writes the read commit writes it. It is data in a vote's user message and nothing else. - A result records no code. It records each excerpt's path, lines, kind, name and size, and counts of what was dropped: Related code.
Why it is off. More text before a vote is not better by itself: an excerpt can sway a vote toward a true finding or away from it, and the code it shows is picked by rules whose starting values come from measurements on quorum's own TypeScript, and no labelled set of findings has tuned them. No measurement has yet shown that it makes the panel drop more false findings without dropping true ones (The measurement), so related code is an opt-in, unmeasured, and every number below is a starting value that a later release may change. The rules, the language table and the gates are versioned together (meta.relatedCode.rules), so two results picked by other rules are never compared.
Turning it on
quorum --range "$BASE...$HEAD" --related-code
quorum --range "$BASE...$HEAD" --no-related-coderelatedCode: true # the votes of the lenses that ask carry related code; off when unset
profiles:
security: {} # its reachability and defenses lenses ask for it
team-security:
extends: security
lenses:
- {id: defenses, question: Do existing checks elsewhere already neutralize this?, relatedCode: true}| Where | Setting | Default |
|---|---|---|
| The config, at the top | relatedCode: true | false |
| One review | --related-code, or --no-related-code to turn a config's off | the config's |
| A lens of a profile | relatedCode: true | false; true for security's reachability and defenses, code-review's real and performance's hot, inherited with a base's lenses |
No QUORUM_* variable sets it. A flag on a lens changes nothing while the switch is off, so the built-in lenses carry theirs always. --print-config prints the switch, and under each profile the lenses that ask, while it is on: Printing the resolved config.
- A reader opens before any call. With it on, the review opens the repository at the read commit once the source and the context are read, before the banner, the estimate and any call. A reader that cannot open ends the review with exit
2, and nothing is sent. - The review says so. Before any call it writes one line on stderr, the lenses that ask by profile, in the profile's order, then the commit and how the source names it:
related code: on for security's reachability and defenses, read at 3a9c2d1, the merge base. When no lens of the profiles that run asks for it, as with--profile best-practices, it saysrelated code: on, read at 3a9c2d1, the merge base, and no lens of the profiles that run asks for it, and the run warns once,relatedCode: is on, and no lens of the quorum's profiles asks for related code: set relatedCode on a lens. Under--progress none, which writes the warnings and the errors alone, the start line is not written and the warnings are; under--progress jsonit is therelatedCodeof therun:startevent: What a person sees. - A source with no commit runs without it, and says so. A diff file or standard input names no commit to read, and the local changes of a repository with no commit yet have none: the review is the one quorum runs with it off, request for request, and warns
related code: off for this review, since a diff names no commit to read it at, or... since the repository has no commit yet to read it at, in every progress mode butjson, whose event says it. The result recordsmeta.relatedCodeasoff, withdifforno-commit-yetfor its reason. - A path review counts it in its bounds. The estimate a path review prints before any call counts the block each vote of a lens that asks may carry, so the token cap it derives holds them: The bounds of a path review.
quorum mcpand a bench suite refuse it. The MCP server refuses a config that turns it on when it starts, since its calling agent can write the commits it would read: The MCP server. A patch suite refuses a configuration that turns it on, since a patch names no commit to read it at, and a panel suite does too, since its arms turn it on and off themselves: Benchmarks.
| Error | When | Exit |
|---|---|---|
Error: --related-code: cannot be given with --no-related-code | Both flags | 2, with the usage, before any config |
Error: --range: related code cannot read the commit <short> it is read at (<why>): review with --no-related-code | The commit does not resolve, or git cannot list it, as in a partial clone that lacks a blob, which quorum never fetches. The flag named is the source's own: --range, --local, --staged or --path | 2, before the banner, with no request sent |
Error: --range: related code would list more than 16 MiB of file names at <short>, more than quorum reads: review with --no-related-code | A repository whose listing at the read commit passes 16 MiB of names, kept by the gates below | 2, as above |
Error: relatedCode: quorum mcp reads no code of the repository, since its calling agent can write the commits it would read | quorum mcp with a config that turns it on | 2, at launch |
Error: relatedCode: is on, and a patch suite's case is a patch, which names no commit to read related code at: turn it off in the configuration | quorum bench of a patch suite with such a configuration | 2, before any review |
Error: relatedCode: is on in the configuration, and a panel suite's arms turn related code on and off themselves: turn it off in the configuration | quorum bench of a panel suite with such a configuration | 2, before any judgment |
A lookup or a read that fails later, once the review runs, costs that finding its excerpts and nothing else: it is counted (unreadable) and the vote reads all of the diff it reads without them.
The commit it is read at
| Source | Read commit | Why |
|---|---|---|
--range <base>...<head> | The merge base | The diff starts there, and for every path the change leaves alone the merge base's file is the head's, so related code, the evidence and the diff are one snapshot of the code the change runs with, read where the change cannot have written. The merge base is an ancestor of the base, on its trusted side |
--local, --staged | HEAD | The last commit, whose files the change leaves alone are the working tree's. Never the working tree itself |
--path <path>, at --at <rev> | The reviewed commit | The files it reviews are its own commit's, so related code of a commit you do not trust has the trust of the code under review: What it cannot do |
Never the working tree, the head of a range or a file the change touches. Quorum reads the commit through its own git, as it reads every source: one listing of the commit's files, then the files by their ids, no revision typed by anyone, no network and nothing fetched, and a file's attributes are the read commit's own, never the working tree's, so a change cannot hide a file from the lookup: How quorum runs git.
What the rules read
Each finding's excerpts come from these rules, applied in this order, to the cited row alone:
- The names. The identifiers of the row, 3 to 64 characters, once its string literals and its trailing comment are set aside, less the language's keywords, in the order they first stand on the row, at most 8. A name after
.,?.,->or::is a member: it is looked up after the bare names, and only when the repository defines it exactly once. - One lookup. One
git grepof the read commit for the row's names and the name of the function around it, fixed strings and whole words, no pathspec, through quorum's own git. A name's hits are capped at 256 KiB, and a name over it is dropped whole and counted. The cap counts every hit of the name on a file the reader lists, those in files the operator'sexcludenames, in files the change touches and in files of another language family included, since the rules refuse those after the lookup: excluding a directory does not spare a name's cap. - The definitions. A hit is a definition when the language table reads its line as defining the name. A name that a file of the change defines, which the diff shows, is left to the diff: no excerpt, and never a same-named definition elsewhere, which would nearly always be the wrong one. A name with more than 20 definitions is dropped as too common. The rest are ranked by the cited file's own directory first, then by the shortest path distance, then by path and line, and the first is shown: at most 4 definition excerpts for a finding, in the names' order. A definition's excerpt is its row and up to 23 rows after it, ending early at the row that closes it.
- The function around the cited row. The nearest row above it, at a lower indentation, that the language table reads as a function header. A path review climbs through the whole file, a change review through the rows of the cited hunk and then the function text git wrote on the hunk's header. When none is found there are no callers, and the finding says so (
noFunction); so it does when the function's name is no name to look up, under 3 characters, over 64 or a keyword. The climb's name is in every result as the verdict'sfunction(A verdict), related code on or off, since the climb reads only the diff's rows: a test file, which related code never reads, has it too. - The callers. The hits of that function's name that are no definition, in files the gates admit, the cited file and every file the change touches left out. A row that imports or re-exports the name is no call site, and is neither shown nor counted: an
import, afrom x import, ause, ausingdirective, a CommonJSrequirethat destructures, a re-exportexport { name } from, a Go import and a Rubyrequire, each by the table's pattern for its language. A name with more than 20 call sites is dropped as too common. The rest are ranked as definitions are, except that in one file a call-shaped row, the name followed by(or by a generic argument list and then(, comes before the file's other rows, so a call is shown where a reference or an import list'sname,stands above it. One call site for each file, and the first 3 files give a caller excerpt each: the 6 rows above the call and the one after it, where a guard upstream stands. - The order. The definitions in the names' order, then the callers by rank. An excerpt that is dropped, because it is held, not read as source, past a finding's caps or past a vote's room, is never replaced by the next hit, so a planted decoy cannot choose what survives.
The language table knows nine languages, by file extension: TypeScript and JavaScript, which share one family, Python, Go, PHP, Ruby, Rust, Java and C#. A hit counts only on a file of the cited file's family, so a Go definition never answers a Python name. A finding in a file of any other language gets no excerpt (cited-file). The table's rows are data, with a fixture for each pattern; the patterns outside TypeScript have not been measured against real code, which What it cannot do repeats.
A finding that cites no row of its own, a scanner's file-level candidate or a line no hunk shows of the new file, gets no excerpt either (no-row).
The files never read
The read commit's listing is the allowlist, and a hit counts only on a path it holds, matched byte for byte, that passes every gate.
In the listing, from the path and the entry alone:
- A regular file of at most 1 MiB. Never a link, a submodule's gitlink or a larger file.
- A path of strict UTF-8.
- A language the table knows, by extension.
- Not a secret's name: the names and suffixes held back as secrets in every source: Files held back as secrets.
- Not a file named like instructions to an agent:
CLAUDE.md,AGENTS.md,GEMINI.md,.cursorrules,.windsurfrules,.clinerules,REVIEW.md,*.instructions.md,.github/copilot-instructions.mdand any file under.cursor/rules/, in any case. Their text is aimed at a model, so it is no code to show a voter. - Not a default skip: a vendored directory, a lockfile, a minified file or a test file by its name, as a path review skips them: What a path review skips.
For each review:
- Not a path the operator's
excludenames. - Not a path the change touches. In a change review, every path any section of the diff names, on either side, and every file
meta.leftOutlists (a binary, a submodule, a held secret, an excluded file), since the head's version of it is the change's and its base copy may hold a check the change removed. The diff is written with--no-renames, so both sides of a rename and a deleted file are touched. In a path review, the cited file alone: the other files under review are readable, and the cited file's own definitions are left to the diff. - Not a file of another language family than the cited file's: a hit there counts for nothing.
After the read, an excerpt of a file is dropped and counted as notSource when the file holds a NUL byte in its first 8000 bytes, is no UTF-8, is a pointer to a large file, or has a row of the excerpt over 1000 bytes (minified or generated), or when the row its excerpt starts from is a comment: the hit read a comment as code.
Before it is sent, an excerpt whose text holds a credential quorum recognizes, a hidden character, or text addressed to an AI reviewer is held whole, counted by what held it (held) and never sent: Advisory flags lists the last two. A tab stays, so Go's code is not held, and a carriage return at the end of a row does not count, so a CRLF file is read.
Comments
Comment lines are left out of an excerpt. A row whose first characters open a comment in its language, and the rows of a block comment, are dropped, each run replaced by one row, (<n> comment line(s) left out), and counted (commentLines). A comment at the end of a code row stays, since dropping it needs a lexer for each language.
Why: related code is there to show a check, and a comment is none. A planted or stale comment such as "validated upstream" is the attack that flips a verdict, and the description of the block says a comment proves nothing. The diff keeps every comment, as it always has: only the code outside it is read this way.
The bounds
| Bound | Per | Value |
|---|---|---|
| Names looked up, and the function's name | Finding | 8, and one |
| Definitions or call sites of a name | Name | At most 20, else dropped as too common |
| Excerpts | Finding | 4 definitions and 3 callers, each at most 1536 bytes of whole rows, the header included |
| The block | Vote | Whole excerpts in order, up to the least of 8 KiB, a quarter of the room the vote's request leaves with an empty diff block, and the room left once the diff block holds what the vote sends without related code. A voter that states no room takes 8 KiB |
| Lookups | Review | One for each distinct cited row, and at most one in flight for each profile |
| Files read | Review | 32 MiB in all, each file once; a finding whose unread files together pass what is left gets none (review-cap), and a later finding whose files fit what is left is still read |
| Hits of a name | Lookup | 256 KiB |
| File names listed | Review | 16 MiB |
- The diff block is the same with and without it. The block is chosen from the room a request has without related code, so related code never pushes out any of the diff a vote reads without it, and on a small window it may hold one excerpt or none, counted (
overRoom). - An overflow is said, never a gap. Every drop is counted in the finding's record and the review's: a vote with less related code reads all of the diff it reads without it, so it is no less than a vote without it, and no cap of related code makes a review incomplete.
- Every vote is reserved with its block under the token cap, as every call is.
What a person sees
A review that reads related code says what it gave, in every format and in the live view. Every line is written from an event or a field of the result, never from what a vote said, and every path in one passes inertLine, or a code span in Markdown, as every path in a report does. A review with related code off writes none of it, and its reports are the ones it always wrote.
Under a finding of a profile with a lens that asks, after its claim and its test coverage and before its evidence, the text report names the excerpts its votes were given, each as its file, its lines and what it answers, wrapped at 80 columns as the claim is. A file is written as the finding's own is: bare when it holds ASCII letters, digits and ._/@+~=,- only, else as a JSON string, kept whole at a wrap, so a name that holds ; and spaces never reads as two excerpts:
HIGH security src/api/files.ts:42 CWE-22
The requested name reaches the file system through safeJoin without a check.
related code: src/lib/paths.ts:9-31, the definition of safeJoin;
src/api/routes.ts:118-125, a caller of serve
41 export function serve(root, name) {
> 42 + const target = safeJoin(root, name)
43 return readFile(target)
kept by 3 of 3 lenses- An excerpt cut at its byte cap ends with
(cut). - A lens that was shown fewer closes the line,
; reachability was shown the first 1for the first,, defenses the first 1for the next ones,nonefor 0: every voter is sent the same excerpts in the same order, and a vote that did not have the room carried a prefix. - A finding given none says why,
related code: none (2 names the change defines, 1 name too common), in the words of the counts below, with the finding's own words for the reasons that count findings:no function around the cited row,its lookup failed,no cited row of its own,its file is one related code does not read,past the review's 32 MiB of filesandstopped. When the rules found nothing to say,none (nothing found). - A finding of a profile with no lens that asks has no line, whatever the review reads:
best-practices' findings never do.
After the last profile's lines the text report totals what the review gave, or says why it gave none:
related code at 0c41d7e, the merge base: 3 of 4 findings given some; 7 excerpts,
9412 bytes; 12 comment lines left out; 2 names too common, 1 excerpt past a
vote's room
related code: off for this review, since a diff names no commit to read it atThe totals read <g> of <f> finding(s) given some: the findings the review worked out related code for, and those a vote carried an excerpt for; then the excerpts and their bytes, an integer, as a document's are; then the comment lines left out and the counts of what the rules dropped, each part left out at 0. The counts, each through the plural of its noun, in this order, and a finding's line says the same words for the names and the excerpts:
| Count | The review's totals | A finding's line |
|---|---|---|
| Names a touched file defines | <n> name(s) the change defines | the same |
| Names with too many definitions or call sites | <n> name(s) too common | the same |
| Member names defined more than once | <n> member name(s) defined more than once | the same |
| Names past the 8 looked up | <n> name(s) past the 8 looked up | the same |
| No function around the cited row | <n> finding(s) with no function around the cited row | no function around the cited row |
| Excerpts past the caps | <n> excerpt(s) past a finding's 4 definitions and 3 callers | the same |
| Excerpts not read as source | <n> excerpt(s) not read as source | the same |
| Excerpts held | <n> excerpt(s) held (<k> credential(s), <k> hidden character(s), <k> addressed to a reviewer), each kind left out at 0 | <n> excerpt(s) held |
| Excerpts past a vote's room | <n> excerpt(s) past a vote's room | the same |
| Lookups git failed | <n> lookup(s) git failed | its lookup failed |
| No cited row | <n> finding(s) with no cited row | no cited row of its own |
| A file related code does not read | <n> finding(s) in a file related code does not read | its file is one related code does not read |
| Past the review's 32 MiB of files | <n> finding(s) past the review's 32 MiB of files | past the review's 32 MiB of files |
| Stopped | <n> finding(s) stopped | stopped |
The other places say it as follows:
- The live view ends the panel row of a profile with a lens that asks with the findings given some, of those worked out so far:
security panel ████████░░░░░░░░░░░░ 12/30 votes · 3 kept · related code 4/6. The bar gives up cells before the count is cut: The live view. The row counts the findings an excerpt was picked for, and the totals count the findings a vote carried an excerpt to, so on a small window, where no vote has the room for what was picked, the row can end at4/4while the totals read3 of 4 findings given some. - The progress lines hold the start line and the off warning (Turning it on) and one warning more, written when git failed a finding's lookup, so its finding goes without:
warning: related code: the lookup of src/api/files.ts:42 failed, so its finding goes without related code. It names the row, its file written as the finding's is, starts with no profile's id and is a warning, so--progress nonewrites it, and the off warning, which is the only other line of the review's events it writes: The modes. Under--view public, whose log names no finding's file or line, it readswarning: related code: a lookup failed, so its finding goes without related code, in every mode that writes it. A program that callsrunQuorumis sent them throughonProgress: Library API. - The summary on stderr has one line, after the reports line and before the gaps:
related code: 3 of 4 findings, 7 excerpts. A review whose related code is off (a diff, or no commit yet) writes none, since its warning said so; a review that opened a reader writes its totals in every report, this line among them, even when no lens of its profiles asks, as0 of 0 findings, 0 excerpts: The summary. - The Markdown summary ends a finding's head with its excerpts in code spans,
· related code: `src/lib/paths.ts:9-31`, `src/api/routes.ts:118-125`, nothing for a finding given none, and has a#### Related codeblock after the documents read, one item, the totals without the words its heading says and the commit in a code span:- read at `0c41d7e`, the merge base: 3 of 4 findings given some; 7 excerpts, 9412 bytes; .... The budget keeps the block whole. A finding's line comment and the SARIF log say none of it: Reports for GitHub. quorum reportwrites them from a saved result, through the same reporters, in every format and under--view public, which keeps the excerpts' places, the counts and each vote's count, and never whether a vote's reasoning quotes a row of an excerpt:quorum report.
The measurement
The panel suite measures it: each case is judged in three arms, off, off again and on, the same finding with the panel as it is, again, and with related code read from the case's clone at its read commit (Panel suites). A report sets on against off on every case and on the common subset, the cases whose votes were given an excerpt, and says, apart, how often the related code reached the code that refutes a false finding, which cases were given some, and how many discards quote it (Reading a panel report).
The gate for turning it on by default is stated before the run, for each configuration, and every part must hold:
- False kept falls: the paired interval of
onagainstofffor the false findings excludes 0. - True kept holds within 10 points: the lower bound of the paired interval of
onagainstofffor the true findings is above -10, on every case and on the common subset. - No configuration falls past that margin, whatever the others do.
- The noise floor is below the effect:
off againagainstoffputs the panel's own noise lower than whatonmoved.
Why it stays off until the suite is larger. Showing that a change loses nothing, within a margin of 10 points, takes 150 to 170 true findings, and the first suite holds 30 true ones and 23 false ones. By the computation it was planned with, it can show a halving of false keeps, but not a cut of 30%, and it sees a loss of 20 points of true findings only 40% to 57% of the time. So a run of it can support keeping related code off, or growing the suite, and cannot support turning it on by default, which waits for 150 to 170 true findings. A 15-point margin would take about 75, sooner and weaker, and is not the gate. Until then related code is an opt-in the docs call unmeasured, and a decision to turn it on names the profiles it covers: the suite's cases are security's, so code-review's real and performance's hot stay unmeasured, as their profiles are.
Retrieval recall may read as optimistic on the findings suite. The rules ship at their starting values, written from measurements on quorum's own TypeScript, the repository that suite's false cases come from. The dry run that shows each case reached or not and what it was shown (Tuning the rules) checked them on those false cases before the first on run and changed nothing, so no case of the suite set a rule and the rules are untuned. The report says to read the recall on that suite as optimistic, and on another suite that no case of it set the rules. A change of a rule is another version, whose on records are never mixed with an earlier one's.
The discards that quote related code answer a question the measurement leaves open: whether a discard rests on a row the vote was shown. They are counted, never printed, and a refutation that must name the row it relies on is a design left for later, a phase of its own only if on against off loses true findings.
What it cannot do
- The change chooses the names. The names on the cited row decide which base code loads, though never what it says: a change can steer a lookup, and cannot write the file it finds.
- Base text others wrote still reaches a voter. An earlier contributor or a third party wrote the code an excerpt shows: a string, or a comment at the end of a row, can claim a check that is not there.
- A real check may not apply. An excerpt that shows a check shows it for the cited row's names, not for the claim, so a voter can weigh a check that does not cover the case: the risk every filter shows.
- A definition can be picked wrong, and a caller is the first call of its file in rank, which may not be the one that matters. The rules read one hop: the definition of a name and a caller of the function, not what a check calls in turn.
- It misses code it never reads: a check that lives in a test, in a vendored file, in a file over 1 MiB, in a language the table does not know, or only in the working tree.
- The patterns outside TypeScript are unmeasured. The rules were measured on TypeScript alone, against a type checker; the other languages' patterns are pinned by fixtures and not yet measured on real code.
- Every voter of a finding receives the same excerpts. A wrong pick therefore misleads all of them alike, where independent votes would not: the panel's independence says less about it than about the diff.
- Recall still rests on the finder. Related code gives the votes of a finding something to weigh and gives the finder nothing, so a finding the finder never proposed is not helped.
- A path review of a commit you do not trust. The code related code reads is the reviewed commit's own, so it has the trust of the code under review. Plant a check in it, and a voter reads it.
- Local changes where an agent writes the commits.
--localand--stagedreadHEAD, which an agent that commits writes; leave it off there, andquorum mcprefuses it for that reason.
Threat model lists the channel, its controls and what remains.
Next
Threat model — the attacker, the assets, the residual risk stated plainly, the controls in place today, and what the panel's independence is worth.
