Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7268054
A review brief names at most five tests to run first and counts the t…
zlareb1 Dec 6, 2026
1154438
The brief's docs state the one-test rule as built
zlareb1 Dec 6, 2026
ce2c82e
The gate reads a merged PR's diff from the merge commit; one run comm…
zlareb1 Dec 6, 2026
3eeb504
The brief groups the gate's first 200 rows and a command-less file jo…
zlareb1 Dec 6, 2026
a5c8051
The run_first row caps a test's paths, says when the gate read a cut …
zlareb1 Dec 6, 2026
4abe1d5
The run_first row says cut only for a change the gate did not read in…
zlareb1 Dec 6, 2026
45ea153
The run_first row reads cut off the files the gate read and its trunc…
zlareb1 Dec 6, 2026
8e5aa7a
The run_first row leaves out the test files the PR deletes and keeps …
zlareb1 Dec 6, 2026
9ffe7e2
The run_first row treats a deletion with no diff sides as deleted and…
zlareb1 Dec 6, 2026
78c9852
A drifted changed file marks the run_first row cut, and a gate holdin…
zlareb1 Dec 6, 2026
9b888ac
Only a drifted source file or a failed drift read marks the run_first…
zlareb1 Dec 6, 2026
576c1ae
The run_first drift test drifts a non-source file inside the indexed …
zlareb1 Dec 6, 2026
8023112
A test builds an open PR's brief and checks the gate reads its diff a…
zlareb1 Dec 6, 2026
f6f829d
The run_first tests split by behaviour, a dotfile is its own test, an…
zlareb1 Dec 6, 2026
00c58a5
The run_first domain tests split by behaviour and the brief's gate fa…
zlareb1 Dec 6, 2026
6ca2187
A merged PR's test reads its deleted tests off its own diff, and the …
zlareb1 Dec 6, 2026
c628101
The merged-PR deletion test keeps only the case it can fail on and sa…
zlareb1 Dec 6, 2026
453a7d3
run_first lists RUN_FIRST tests with no limit parameter, and the brie…
zlareb1 Dec 6, 2026
062db25
IMPACT_SEED_FILES names the test gate's file cap at its definition
zlareb1 Dec 6, 2026
437866a
SEED_FILES names the cap both reads share, deleted tests are read off…
zlareb1 Dec 6, 2026
1485d68
deleted_paths sits with the diff parsers, a brief with no diff marks …
zlareb1 Dec 6, 2026
c19c1f4
deleted_paths adds the deleted-file-mode paths to whole_files', and t…
zlareb1 Dec 6, 2026
4e114e1
A test file the PR renames away is no test to run first either
zlareb1 Dec 6, 2026
78d526a
The run_first docstring and cut comment name renames and a brief with…
zlareb1 Dec 6, 2026
54195b9
The docs limit the deleted-test rule to the rows the brief reads
zlareb1 Dec 6, 2026
ef5d666
Merge remote-tracking branch 'origin/main' into feat/brief-run-first
zlareb1 Dec 6, 2026
17d193c
The fan-out paragraph wraps at 92 columns after the advice clause
zlareb1 Dec 6, 2026
1f888d1
The docs say a changed file past the first 50 is a cut only when the …
zlareb1 Dec 6, 2026
6bbac07
The docs state the changed-files cut as one rule: a changed file the …
zlareb1 Dec 6, 2026
a5f5e77
The changed-files cut names the gate's read set in parentheses
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
52 changes: 41 additions & 11 deletions docs/features/code-index/history-and-prs.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,17 @@ stores its first 200 changed paths as rows; its `rows_total`, verdict and causes
every changed path. The `rationale` section is never stored, so a read that does not
serve it (the trivial tier, or `sections` without it) answers `gaps`, `unsettled` with
`rationale:not_requested`, or `no_source_change`: `covered_no_gaps` needs `rationale` in
`sections` (or `sections` empty) on the standard or full tier. A brief one of whose
reads raised is served and not stored, and the next read builds it again (the test home
is advice: a read of it that raised or was refused decides no verdict, though one that
raised still keeps the brief unstored); so is an open PR's brief built without its diff,
or from an overlay that was off (`overlay:error` when git could not read its diff), left
a changed file unreached when its parse time was spent or its parse could not run here,
or parsed another head. A parse of a file that raised or ran past its limits does the
same on every build of that file, at an open PR's head and at a merged PR's parent
alike, so that brief is stored, `unsettled`: `code.impact` names `new_side_unread` for
the file, and an open PR's `overlay_note` counts it. A build that replaces a brief of an
older version is tried once (below).
`sections` (or `sections` empty) on the standard or full tier. A brief one of whose reads
raised is served and not stored, and the next read builds it again (the test home and the
tests to run first are advice: a read of one that raised or was refused decides no verdict,
though one that raised still keeps the brief unstored); so is an open PR's brief built
without its diff, or from an overlay that was off (`overlay:error` when git could not read
its diff), left a changed file unreached when its parse time was spent or its parse could
not run here, or parsed another head. A parse of a file that raised or ran past its limits
does the same on every build of that file, at an open PR's head and at a merged PR's parent
alike, so that brief is stored, `unsettled`: `code.impact` names `new_side_unread` for the
file, and an open PR's `overlay_note` counts it. A build that replaces a brief of an older
version is tried once (below).

A change to what a brief stores or how its verdict reads it raises the payload version
(`v` in the payload). A stored brief of the current version is served as it was built.
Expand Down Expand Up @@ -459,6 +459,36 @@ at most eight sites, outside the methods of its own class (the
its head's, which the index rows are not at, so its brief collapses nothing. The
section's `note` gives both counts.

The first `tests` row, `kind: "run_first"`, names the tests to run first: the first five
tests `code.test_gate` lists for the PR's diff, in its order, so every test that says
`must_run` comes before a lead and the strongest evidence comes first. Files that share a
run command are one test, and a file with no run command joins the first test that holds a
file of its directory and name up to the first dot (a case's expected output beside its
script; a dotfile's whole name); files with different run commands are never one test. A
test of several files names its first five in `test_paths` and counts them in
`test_paths_total`. Each test carries its run command (`run`, with `run_unknown: true` when
the gate knows none) and the gate's `why`, `evidence` and `must_run` for its first file. The
brief reads the gate's first 200 rows. `left_out` counts the test files the gate holds under
none of the five, and `must_run_left_out` how many of them say `must_run`. A file past those
200 rows and a lead the gate cut are counted whatever their run command, and the gate's
count of cut leads is a lower bound. The row says `cut: true` when the gate did not read the
whole change, or read a changed source file on another revision: a changed file is missing
from the gate's `changed_files` (the files it read), the diff is longer than 200,000
characters, the gate's causes say `truncated` (its call-graph walk or coverage read was
cut), or a changed source file is drifted (the index holds it at another revision than the
diff's old side, so its lines may map onto other definitions) or the drift read failed, or
the brief was built with no diff (from its changed paths alone), when its list may name a
file the PR deletes. Its list and counts are then of what it read. The gate reads test links
at the revision the index holds, as the claim rows do, so the brief of a merged PR built
after the index moved past it can name a test added since. A test file the PR deletes or
renames away is no test to run: with the diff, its row among those the brief reads is
neither listed nor counted. The row is advice no verdict rests on: a read of the gate that
raised keeps the brief unstored, and a refused read, or a gate that lists and counts no
test, leaves the row out. A gate that names no test, or only deleted ones, but counts other
tests or the leads it cut gives a row with no tests and their count in `left_out`. A brief
stored with no `run_first` row says nothing of the tests to run first: `code.test_gate`
lists them.

Each `tests` row of a symbol or setting carries the coverage claim's `verdict`, its
`strongest_tier` (`code.coverage_claim`'s evidence tiers), up to two `tests` of that tier
by repository path, and `tests_at_tier`, how many tests of that tier the claim listed (it
Expand Down
4 changes: 4 additions & 0 deletions docs/features/code-index/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,10 @@ the nested one), or an override or a subclass, as a test double is. The other `s
rows, and the `test_map` and `file_neighbor` rows, say `false` too. Those rows may not run
the changed code, and a caller with a budget can leave them out.

A review brief names the first five tests of this list, one per test, in its `tests`
section's `run_first` row, with the count of the test files it leaves out ([review
briefs](history-and-prs.md#review-briefs-and-conventions)).

The gate reads a test file (one under a test directory such as `tests/`, `test/` or `spec/`,
or a test-named file such as `foo_test.go`) as a test, except a definition there that other
tests call or take as a fixture (a `conftest.py` fixture, a builder): that is a helper. A
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 @@ -1473,7 +1473,7 @@ A merged PR's review brief: the point read of what the ingest built at merge —
| `tokens_used` | `int` | Estimated tokens of the sections served. |
| `token_budget` | `int` | The budget the sections were cut to: the request's, else the tier's. |
| `decisions` | `dict[str, bool]` | one-bit answers read off the section verdicts: test_only, symbol_with_regressions, uncovered_symbol, randomized_setting, deleted_lines_blamed |
| `sections` | `dict[str, dict[str, Any]]` | name -> {status, verdict, epistemic, causes, rows, rows_total, tokens, truncated}; `rows_total` counts every row, of which `paths` stores the first 200; `failed` names the reads of a section that raised, among its causes; `symbols` adds… |
| `sections` | `dict[str, dict[str, Any]]` | name -> {status, verdict, epistemic, causes, rows, rows_total, tokens, truncated}; `rows_total` counts every row, of which `paths` stores the first 200; `failed` names the reads of a section that raised, among its causes except the advice… |
| `trace_run_id` | `str` | Id of this call's trace row; pass it to `code.outcome`. |

## `code.scip_ingest`
Expand Down
8 changes: 4 additions & 4 deletions server/code/api/models_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ def _drop_unset(self, handler: SerializerFunctionWrapHandler) -> dict[str, Any]:
decisions: dict[str, bool] = Field(default_factory=dict)
# name -> {status, verdict, epistemic, causes, rows, rows_total, tokens, truncated};
# `rows_total` counts every row, of which `paths` stores the first 200; `failed` names
# the reads of a section that raised, among its causes; `symbols` adds `collapsed`
# ({registration | factory | constructor | one_line: count}) for the wiring the PR
# adds that it lists as counts, not rows, and marks a function an open PR's overlay
# adds `via: added`.
# the reads of a section that raised, among its causes except the advice reads
# (`code.test_home`, `code.test_gate`); `symbols` adds `collapsed` ({registration |
# factory | constructor | one_line: count}) for the wiring the PR adds that it lists as
# counts, not rows, and marks a function an open PR's overlay adds `via: added`.
sections: dict[str, dict[str, Any]] = Field(default_factory=dict)
# Id of this call's trace row; pass it to `code.outcome`.
trace_run_id: str = ""
47 changes: 36 additions & 11 deletions server/code/app/index/review_brief.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
weekly fan-in; the wiring the PR adds that nothing but a registry
or its own class reaches (`WIRING_KINDS`) is a count per kind in
`collapsed`, not a row, and is claimed like any other row;
- `tests` — a coverage claim per touched function and setting, with the
claim's strongest evidence tier and only the tests of that tier,
and the test file this PR's fingerprint belongs in;
- `tests` — the first tests code.test_gate lists for the diff, one per test
with the reason it is there and how many were left out; a coverage
claim per touched function and setting, with the claim's strongest
evidence tier and only the tests of that tier; and the test file this
PR's fingerprint belongs in;
- `settings` — the facts of every setting the diff declares, changes in the
history file or uses in a new stateless test;
- `history` — each touched function's regression record;
Expand Down Expand Up @@ -79,7 +81,7 @@
# builds it again (`server.code.app.review_brief._rebuild`). The previous release answers
# a brief of this version by its own rules, so a new cause ships its reading there first
# (rolling-upgrades rule 103).
PAYLOAD_VERSION = 3
PAYLOAD_VERSION = 4

SECTION_ORDER: tuple[str, ...] = (
"paths",
Expand Down Expand Up @@ -131,10 +133,13 @@
MAX_SETTINGS = 8
MAX_COVERAGE_SETTINGS = 4
MAX_BLAME_RANGES = 5
MAX_DIFF_CHARS = 200_000 # CodeImpactInput.diff's cap
# The changed files the brief's impact read seeds from.
# not a setting: CodeImpactInput.files' max_length
IMPACT_SEED_FILES = 50
MAX_DIFF_CHARS = 200_000 # CodeImpactInput.diff's and CodeTestGateInput.diff's cap
# The changed files the brief's impact and test-gate reads seed from.
# not a setting: CodeImpactInput.files' and CodeTestGateInput.files' max_length
SEED_FILES = 50
# The rows of code.test_gate the tests to run first are picked from.
# not a setting: CodeTestGateInput.limit's maximum
GATE_ROWS = 200
# The paths section stores the first this many changed paths as rows (impact's
# `paths_seen` cut); `rows_total` counts them all, and its verdict and causes read all.
# not a setting: it bounds a stored row list
Expand Down Expand Up @@ -553,8 +558,8 @@ def section(
failed: list[str] | None = None,
) -> dict[str, Any]:
"""One section. `failed` names the reads of it that raised (`failure_cause`), which are
among its `causes` too unless no verdict rests on the read (`code.test_home`); the key
rides only when there are any."""
among its `causes` too unless no verdict rests on the read (`code.test_home`,
`code.test_gate`); the key rides only when there are any."""
rows = rows or []
out: dict[str, Any] = {
"status": status if rows or status != SERVED else EMPTY,
Expand Down Expand Up @@ -859,6 +864,24 @@ def wiring_kind(qualified_name: str, *, lines: int, path: str) -> str:
return WIRING_ONE_LINE if lines == 1 else ""


def deleted_paths(diff: str) -> set[str]:
"""The paths of the files a git diff deletes or moves away: a `+++ /dev/null` side
(`whole_files`), a `deleted file mode` line for a deletion git prints with no sides (a
binary or an empty file), or a rename's `rename from` path."""
marked: set[str] = set()
header = ""
for line in diff.split("\n"):
line = line.removesuffix("\r")
if line.startswith("diff --git "):
header = line
elif line.startswith("deleted file mode") and header:
marked.add(_git_header_paths(header)[0])
elif line.startswith("rename from "):
marked.add(line[len("rename from ") :])
marked.discard("")
return marked | set(whole_files(diff))


def whole_files(diff: str, *, added: bool = False) -> dict[str, list[str]]:
"""The lines of each file the diff deletes (`+++ /dev/null`), by its old path, or with
`added` of each file it adds (`--- /dev/null`), by its new path."""
Expand Down Expand Up @@ -1194,7 +1217,7 @@ def serve(
"DRIFTED",
"EMPTY",
"FAILED",
"IMPACT_SEED_FILES",
"GATE_ROWS",
"INDEX_ERROR",
"NOT_BOUND",
"NOT_BUILT",
Expand All @@ -1205,6 +1228,7 @@ def serve(
"RATIONALE",
"RESTRICTED",
"SECTION_ORDER",
"SEED_FILES",
"SERVED",
"SERVED_ORDER",
"TIERS",
Expand All @@ -1220,6 +1244,7 @@ def serve(
"checked_names",
"class_member",
"decisions_of",
"deleted_paths",
"deleted_ranges",
"failed_reads",
"failure_cause",
Expand Down
Loading
Loading