Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
032d4a7
A class-body member line or a prototype is placed on the class and th…
zlareb1 Dec 6, 2026
e20ece3
Wrap the placement comments and import the member rules at module level
zlareb1 Dec 6, 2026
2bf7011
A class-body line is placed only when it is shaped as a declaration
zlareb1 Dec 6, 2026
34bbe17
A Python decorator's argument line and a free prototype's same-named …
zlareb1 Dec 6, 2026
9cfdd9e
A class-body line is placed only when it is a whole declaration on it…
zlareb1 Dec 6, 2026
2f57160
A file-scope prototype follows the member-line rules and matches only…
zlareb1 Dec 6, 2026
9f80fe9
A prototype is placed only with the function it declares, and a struc…
zlareb1 Dec 6, 2026
8ef5fd5
A commented or braced prototype and a struct's method are not placed …
zlareb1 Dec 6, 2026
1d24eb2
A file-scope prototype is placed only on a free function the index sh…
zlareb1 Dec 6, 2026
ae85ba9
The C++ parser holds a row of a nested type and of a method under #elif
zlareb1 Dec 6, 2026
9e31834
A type defined in a typedef gets a row, and a nested type keeps its d…
zlareb1 Dec 6, 2026
984a9aa
No line is placed when code.impact's read of the diff's rows hit its …
zlareb1 Dec 6, 2026
4c95601
A C++ union is a struct row, and a Python docstring is read only belo…
zlareb1 Dec 6, 2026
703c0bf
No line is placed when a changed file is past the 200 code.impact reads
zlareb1 Dec 6, 2026
6fedda6
The C++ line rules move to domain, and impact's cut read is tested by…
zlareb1 Dec 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 94 additions & 7 deletions docs/features/code-index/history-and-prs.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,100 @@ line there is exempt, so the comment below it is what keeps such a change visibl
brace, a namespace line, an access specifier and an `#include` are code: each can move
unchanged code into another scope or change which overload it calls. A comment in
another language is a change, since the compiler reads some (a Go build constraint, a
cgo preamble, a TypeScript reference). A prototype or a call in a class body can change
what the class holds. A registration above a changed signature, or a member below a
function's closing line, is in no function at the side that holds it. The rule reads the
changed lines and the line above each run alone, so a blank line inside a multi-line
string or a heredoc, a comment-like line inside a C++ raw string or a macro argument, or
a declarator line whose macro is not spelled in capitals or with `_` (`* buf unused`,
`* NonNull ptr`), reads as blank or as a comment.
cgo preamble, a TypeScript reference). A registration above a changed signature is in
no function at the side that holds it. The rule reads the changed lines and the line
above each run alone, so a blank line inside a multi-line string or a heredoc, a
comment-like line inside a C++ raw string or a macro argument, or a declarator line
whose macro is not spelled in capitals or with `_` (`* buf unused`, `* NonNull ptr`),
reads as blank or as a comment.

A changed line outside every function is placed on a definition, and adds no
`unmapped_changes`, where the language says which definition it belongs to. That
definition is then a touched symbol: it seeds the radius, and the tests section claims
its coverage, so the brief settles only when that claim says `covered_by`, and an
uncovered one answers `gaps`.

- A line of a class body is placed on the class, on the side that holds it: a line the
diff removes on the index's class, a line it adds that no function of the new side
holds on the class that holds the run's lines and the line on each side of it in the
index. In C++ that is a member line, a declaration whole on one line: a member, a
static constant, a method prototype or a constructor, ending with `;`, with every
bracket it opens closed on the line and none closed it did not open. Any other line
stays a change: a brace, a class head or its base clause, an access specifier, a
`using` or `friend` declaration, a namespace or preprocessor line, a line of a
prototype or a template head spread over lines (the head they continue may be
`virtual`), a macro call, a statement (`return x;`), a line holding `virtual`,
`override` or `final` (they change which function a call through a base reaches, an
override no claim on the class covers), a line that holds one of those words after a
member, `/*`, `*/`, a raw string's opener or a quote no literal closes, and a line
below one that does not end a declaration or a scope's head (a `virtual` or a
`template <...>` alone on the line above). The words are read as the line spells them:
an override declared without `override` reads as a member, and a claim on the class
then decides it. In Python an attribute (`retries = 3`, `name: str`) of a class body
outside its methods is placed when it leaves no bracket open and the line above it is
code that leaves none open either, and a string line (a docstring) when it sits right
below the class's head, whole on its line. Any other line stays a change: a `class` or
`def` head, a decorator, a compound statement's head, a `return` line, a line with an
odd count of `"""` or `'''` (it opens or closes a string around lines the diff
leaves), a decorator's argument, which belongs to the method below it, a string line
below any other line (an argument's or a value's, below a dict key's `:` too), and a
line below a blank or comment line, where the brackets open above are not known.
- A C++ prototype is placed also on the function it declares, when it is a member line
by the rules above and the diff's files outside tests hold definitions of one
qualified name for it: in a class body the function whose qualified name is the
class's and the prototype's; at file scope a free function of its name in the same
file or a file of the same stem in its directory (`widget.h` and `widget.cpp`), or a
registration function by the index's registration rule (`registerWidgets`), which is
often declared beside the call that runs it. A free function is one at global scope or
in a scope the index shows to be a namespace: a scope that holds a class or struct row
and neither is one nor sits in one (a class whose own row sits outside the diff's
files, with a nested class's row in them, reads as one). A function in a scope the
diff's files show nothing about may be a method of a class declared elsewhere, so a
file-scope prototype is not placed on it, and one the compiler tier names in an
anonymous namespace is not placed either. A prototype whose function the diff's files
do not define stays a change, in a class body too: its defaults and parameters reach
the function's callers, which a claim on the class does not decide. So does a
prototype in a class body when a function of its name sits in a scope nested in the
class, which it may declare instead, and a class-body line that names something before
a `(` but is not read as a prototype (a default argument written with braces). A
trailing `//` comment is not read, unless it holds a `#`, `/*`, `*/` or a quote, which
keep the line a change. The namespace a file-scope prototype sits in is not read
either: a free function of its name in another namespace of the same-stem file is its
candidate as well. Definitions under two qualified names leave it a change, and so
does a file-scope line whose parentheses start with a literal
(`static const std::regex re("a+");`), a constant built by a constructor. A
registration statement inside a registration function's body is that function's line
already.
- The rules read the changed line, the line above it and the index's rows, and they are
as good as those rows. A line of a method the parser did not read as one (a head
spelled with a macro it cannot expand) sits in the class body by the rows, so a
declaration in its body (`size_t n = rows.size();`) reads as a member line and is
placed on the class that holds the method: a claim on the class then decides it. The
parser holds a row of each named class or struct, a nested one and one defined in a
variable declaration or a `typedef` included, and of each method under `#if`, `#elif`
and `#else`; a union is a struct row, and an unnamed class, struct or union
(`struct { int a; } pair;`) has none, so its body reads as the scope around it, a
statement in an inline method of it too. A C++ `struct` is no definition the brief
claims, and `code.impact` reads its rows for placement alone: a line of the body of a
struct the index holds a row of stays a change. Since only the changed line and the
one above it are read, a line inside a string or a macro call that spans lines with no
`\` (a raw string's body, a call's arguments) reads as what its own text declares when
the line above ends a declaration, and is placed as one: the hunk's lines are not read
for the string or the call around it.
- No line is placed that a macro or a statement continues (the line above it ends with
`\` or `??/`), that starts a run the hunk shows no line above (a diff with no context),
or that sits in a function the new side pairs with no row, or on a side nobody read.

A constant or a static at file scope stays a change: the index links no C++ variable to
its readers, and a Python `reads` edge records an attribute read (`config.LIMIT`, a
typed receiver's field) but not a bare name read in its module or after `from config
import LIMIT`, so the readers it holds are not all of them and no claim on them could
decide the line. So do an `#include`, a `using` line, a namespace line and a brace.
Shell scripts have no class and no prototype, and the other languages' lines in no
function stay changes as before. A data member or a static constant of a class is placed
on the class like its other members: the brief claims the definition a change sits in,
as for a function whose body changes, not the code that reads it, and a constant at file
scope sits in no definition.

The symbols section lists the wiring the PR adds as counts in `collapsed`, not as rows.
The fold is how the section shows them: their coverage claims and regression records
Expand Down
4 changes: 3 additions & 1 deletion docs/features/code-index/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ line the diff adds that the unmapped-line rule does not exempt (a blank line or
`//`, prose or doxygen comment line, with the limits in [history and
PRs](history-and-prs.md)) sits in no function, and so does each line of a hunk sent with
its header alone that replaces lines: `causes` holds `unmapped_changes` and `epistemic`
is `lower_bound`.
is `lower_bound`. A member line of a C++ or Python class body and a C++ prototype are
placed on the class and the function they declare instead, which join `touched_symbols`
and seed the radius ([history and PRs](history-and-prs.md) lists the rules).
`impacted_tests` holds the rows `code.test_gate` lists for the same change at its default
depth, whatever `depth` the radius is walked at, with the same `why` kinds, so the two ops
name the same tests; test-map rows of the impacted paths ride as `test_map` rows. At
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/operations/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ Symbol-shaped (name/symbol_id) or diff-shaped (files/diff) blast radius.
| `impacted_tests` | `list[dict[str, Any]]` | The test files code.test_gate lists for the same change at its default depth (2, whatever `depth` the radius is walked at), at most 30, strongest evidence first: each row as a code.test_gate `tests` row ({test_path, why, evidence, run… |
| `co_change_files` | `list[dict[str, Any]]` | Files changed in the same merged PRs as the seed paths, most often first ({path, prs}, at most 20): the last 10 PRs for the symbol shape, 50 for the diff shape. |
| `blast_radius_score` | `float` | impacted/50 + test-map rows/40, capped at 1. |
| `touched_symbols` | `list[dict[str, Any]]` | Diff shape only: the symbols the change touches (the functions its changed lines sit in when a diff was given, else every function in the files), and the files that historically co-change with the touched set but are absent from it — the… |
| `touched_symbols` | `list[dict[str, Any]]` | Diff shape only: the symbols the change touches (the functions its changed lines sit in when a diff was given, and the class or function a C++ or Python member line or a C++ prototype outside every function is placed on; else every… |
| `co_change_missing` | `list[dict[str, Any]]` | Diff shape: co-change files absent from the change ({path, prs, of}, at most 5, support at least 4 PRs and 15%); empty for the symbol shape. |
| `owners` | `list[dict[str, Any]]` | Who to ask: {author, share, prs, reviews, last_merged_at} from merged PRs over the seed paths — the PRs a person AUTHORED (`prs`) and the ones they REVIEWED (`reviews`, inline comments), recency-decayed (120-day half-life), share floor, at… |
| `reverts` | `list[dict[str, Any]]` | Merged PRs over the seed paths that were REVERTS ({pr_number, title, merged_at}, newest first, <=5): the one kind of history that says what not to do, invisible to symbol lookups (the code is back) and to co-change (same files as the… |
Expand Down
20 changes: 11 additions & 9 deletions server/code/api/models_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,11 @@ def _drop_unset(self, handler: SerializerFunctionWrapHandler) -> dict[str, Any]:
# predictor of a revert or fix PR it is weak (within noise in a
# calibration replay).
blast_radius_score: float = 0.0
# Diff shape only: the symbols the change touches (the functions its changed
# lines sit in when a diff was given, else every function in the files), and the files that
# historically co-change with the touched set but are absent from it —
# the "did you forget to update X?" list.
# Diff shape only: the symbols the change touches (the functions its changed lines
# sit in when a diff was given, and the class or function a C++ or Python member
# line or a C++ prototype outside every function is placed on; else every function
# in the files), and the files that historically co-change with the touched set but
# are absent from it — the "did you forget to update X?" list.
touched_symbols: list[dict[str, Any]] = Field(default_factory=list)
# Diff shape: co-change files absent from the change ({path, prs, of}, at most 5,
# support at least 4 PRs and 15%); empty for the symbol shape.
Expand Down Expand Up @@ -710,11 +711,12 @@ def _drop_unset(self, handler: SerializerFunctionWrapHandler) -> dict[str, Any]:
# constructor seed with no edge in an index that predates constructor
# calls through factories), truncated (the walk or its page stopped short
# of the graph), unmapped_changes (diff shape: a changed source line sits in
# no function, such as module-level code, a class body, a file with no
# definition, or a line the diff adds with no new side read or in a function the
# index holds no row of), new_side_unread (diff shape: the new side of a changed
# source file was asked for and not read), new_side_failed (with new_side_sha: a read
# of it failed, and a later call may read it)}.
# no function and is placed on no definition, such as module-level code, a class
# body line that is no member line, a file with no definition, or a line the diff
# adds with no new side read or in a function the index holds no row of),
# new_side_unread (diff shape: the new side of a changed source file was asked for
# and not read), new_side_failed (with new_side_sha: a read of it failed, and a later
# call may read it)}.
epistemic: str = "lower_bound"
# Why `epistemic` is `lower_bound`, from the set above; empty when it is `exact`.
causes: list[str] = Field(default_factory=list)
Expand Down
4 changes: 2 additions & 2 deletions server/code/app/index/review_brief_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ async def _symbols_section(
by_hop: dict[Any, Any] = dict(impact.get("by_hop_counts") or {})
hop1 = int(by_hop.get(1) or by_hop.get("1") or 0)
folded = sum(collapsed.values())
note = f"{len(kept)} touched functions" + (f" and {folded} collapsed" if folded else "")
note = f"{len(kept)} touched definitions" + (f" and {folded} collapsed" if folded else "")
out = section(
SERVED,
verdict=verdict,
Expand Down Expand Up @@ -476,7 +476,7 @@ def _unmapped(diff: str, inp: BriefInputs, kinds: dict[str, str]) -> bool:
is not blank (`diff.is_blank`) of a source file the call graph is not built for, any
change to one the diff carries no text of, and a line that is not blank of a source
file an open PR deletes, which impact's parse of its diff leaves out. Impact maps
every other source line (`diff.unmapped_lines`)."""
every other source line (`diff.place_lines`)."""
from server.code.domain.index.verdicts import is_graphed_path

# ponytail: a blank line inside a multi-line string or a heredoc in no function reads
Expand Down
Loading