Repository navigation
The test gate touches only the edited definitions and labels every test with its evidence - #1707
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Nov 28, 2026
zlareb1
force-pushed
the
fix/test-links-gate-evidence-links
branch
from
November 28, 2026 13:47
813d7a2 to
6bfe2b8
Compare
…st with its evidence code.test_gate picked its seeds from hunk-header names and new-side hunk spans, read no classes, and listed a touched definition as `untested` whenever the static graph held no test edge to it. Against SWE-bench Verified gold patches and per-test coverage that list flagged tested and untested code alike. - The touched definitions are the innermost function or class holding a changed old-side line (the revision the index holds). A hunk sent without its lines changes what its header's old range says, so the hooks' zero-context headers read the same. A header name is used only for a definition the index holds no body extent for. code.impact's diff shape shares the rule. - A class's callers credit its `__init__` and `__new__`, and the callers of a function credit the functions nested in it. - Each test row says its kind of evidence in `why`: `changed_test`, `coverage`, `static_call`, `file_neighbor` (new: the test files calling other definitions of the edited files, one grouped read), `test_map`. `graph_hop` and `stem_partner` are gone. - `untested` holds only definitions a verified coverage run measured unexecuted. `unlinked` holds the ones no run measured and no call chain links a test to; a file-level row never clears it, and it is no obligation. - `epistemic` is `measured` or `lower_bound`, never `exact`. - The plugins say "the index links no test to" for `unlinked`, "measured unexecuted at <commit>" for `untested`, ask for a test only for the latter, and ask for file neighbours only up to four tests in all. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A diff whose hunk carries fewer lines than its counts, followed by another file's `---`/`+++` header, read that header as a removed and an added line and lost the file. The header is now recognised when a hunk header follows it, or when the hunk has no line yet. The operations guide lists the evidence kinds instead of adding a table, so the cell positions of the page's other tables stay where its translations expect them. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
zlareb1
force-pushed
the
fix/test-links-gate-evidence-links
branch
from
November 28, 2026 14:21
6bfe2b8 to
7470e07
Compare
8 of 10 tasks
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…ad against a definition's body The gate listed up to `limit` file neighbours ahead of the test map, so thirty neighbour files pushed every map row off a default page, and a plugin of the previous release took each of them for a test to run. Neighbours say nothing about a touched definition: the server lists them only while the other kinds leave fewer than four rows. `stem_partner` is a kind again, and a test file a call chain links keeps that row ahead of a file-level map row, because a test file is listed once and the call-chain row names the test and the definition. On an index with an imported coverage run, rows in a covering test's file are 97% for `coverage`, 91% for `static_call`, 53% for `stem_partner` and 31% for `test_map`. A coverage run is read against every tier row's extent of a definition that is wider than one line. A compiler row may be the declaration line only; testing that line marked a function whose body ran as unexecuted under `epistemic: measured`. A definition with no wider extent is not measured. Text added directly above a definition touches it only when the added lines are all decorators, which needs the diff's lines; a new function added there is a change no definition answers for. In Python, lines appended as deep as the line above continue the definition that line ends. A file's removed ranges are merged before one walk, so the cost of a headers-only diff follows the file's extent and not what its hunk headers claim. `measured` also needs every changed source file to touch a definition, and `causes` keeps the call graph's causes under either answer. The hop-only `confidence` of a `static_call` row is gone: it came from two repositories and ignored the edge's own tier. A neighbour's `callees` counts a definition both tiers hold once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… by bisection The fallback for a hunk whose lines sit in no definition walked every row of the file for each hunk. Rows are grouped by bare name in line order, so a headers-only diff of thousands of hunks costs a bisection each. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b518d58. Configure here.
… keeps same-named definitions apart and orders coverage rows by call chain and specificity - A coverage run is read against the lines after the first of every extent a tier holds of a definition at the run's commit. The first line is the declaration, which runs when the module is imported, under whichever test imports it first. The extents are matched by id in the read that carries their parsing commit, so tiers parsed at different commits are measured on the extent the run's commit holds. - Touched rows are no longer folded by qualified name. The store already folds the two tiers' rows of one definition where their spans coincide; rows that share a name and sit apart (a property's getter and setter) are different definitions, touched and measured apart. - A `coverage` row carries the specificity of its test-map row as `confidence`, and the test name, `hop`, `callers` and `via` of a call chain that links the file too. Within a kind a chain-linked file is first, then the more specific row. - `truncated` is also a cause when the read of the coverage rows was cut. - The wire comment, the feature page and the skill reference say that a `static_call` test is linked by a call chain and usually, not always, runs the definition, and that a change of test files only is `lower_bound` with no cause. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…is documented as not placed The index holds no column for a definition. Where a class and its last method end on one line, text added below that line and indented less than it may be the method's (a statement after its last nested block) or the class's (a new method), and the two indents the diff shows cannot tell which. The run touches neither and counts in unmapped_changes, so the answer is lower_bound. The operations page and the docstring say so, and a test holds the three cases. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
7 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related: #1696
Related: #1709
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
code.test_gatetouches only the functions and classes a diff's changed lines sit in, labels every test with its kind of evidence inwhy(changed_test,coverage,static_call,stem_partner,test_map,file_neighbor;graph_hopis nowstatic_call), and splits the touched definitions intountested(a verified coverage run measured them unexecuted) and the newunlinked(the index links no test to them, which is not proof that none runs them). The Claude Code and Codex plugins word the two differently and ask for a test only foruntested; the new lists need the next server release.Why
The gate's two lists did not say what they claimed. Measured against two kinds of ground truth, for Python repositories at the revision the index holds:
untestedon the development repositories, and for 39% of those the same answer'stestsnamed the file of a test that exercises them. It touched 208 definitions the patch does not edit against 61 it does, because a hunk header namingas_sqlselected everyas_sqlin the file and context lines leaked into neighbours. Class-body edits touched nothing: an edit to an attribute of two classes answeredobligations: false,epistemic: "exact".untestedheld 66% of the definitions a test executes and 83% of the ones no test executes on the development pair: the list did not separate them.The cause is in how seeds are picked and in what a missing edge is taken to mean:
__init__.What the gate does now:
unmapped_changes; so does a changed source file that touches no definition. Rows that share a qualified name in one file and sit apart are different definitions (a property's getter and setter, the arms of a conditional definition), and a changed line touches the one it sits in: the store folds the two tiers' rows of one definition where their spans coincide, and the gate folds nothing by name.code.impact's diff shape uses the same rule and still seeds functions only.__init__and__new__(via: constructor), and a function's callers credit the functions nested in it (via: enclosing).changed_test,coverage,static_call,stem_partner,test_map,file_neighbor. Within a kind a file a call chain names a test in is first, the nearest hop before the others, then the file linked to more touched definitions, then the one with more tests doing so, then the more specific coverage row. Acoveragerow carries the specificity of its test-map row asconfidence, and when a call chain links the file too it keeps the chain's test name,hop,callersandvia. A test file is listed once, under its first kind.untestedneeds a coverage run at a commit the index verified, read against the definition's body: the lines after the first of every extent a tier holds of it at the run's commit. The first line is the declaration, which runs when the module is imported, under whichever test imports it first. A definition with no extent wider than one line is not measured.unlinkedis everything else with no call chain to a test, and no file-level row clears it.obligationsis true fortestsoruntestedonly.epistemic.measuredneeds a verified run for every touched definition, every changed line in a definition and every changed source file touching one.causeskeeps the call graph's causes under either value, because they limittests;truncatedis also set when the read of the coverage rows was cut. A change of test files only touches no source definition and islower_boundwith no cause.Decisions taken on the development repositories, by rules stated before the held-out run:
static_call. Ordering by links and linking tests moved the first test file that the fix makes pass to rank one for 40 of 79 definitions against 27 by path, and was worse for no instance.coverage, 91% forstatic_call, 53% forstem_partner, 31% fortest_map. With the map ahead of the call-chain rows, as before this change, a test file a call chain links was listed as a map row and lost the test's name andlinks_to:static_callrows fell from 181 to 19.coverage. Three orders were compared on the same development answers, by how often the first row is the file holding the most tests that execute the definition: a chain-linked file first and then the more specific row, 136 of 200 (181 within three); a chain-linked file first and then by path, 128 (170); the more specific row first and then the chain, 134 (177). The first is used. Ordered by path alone, as at the previous commit of this branch, it was 106 (169).stem_partnerandtest_map; they stay last because they are a fill and take no row's place.confidenceonstatic_callrows. The share of named tests that execute the linked definition was 92 of 102, 48 of 61 and 38 of 61 at one, two and three hops on two repositories. A number that is a function of the hop alone, ignores the edge's own tier and has no held-out figure per hop is not served.Scope and risk
code.test_gate, the diff shape ofcode.impact, and the plugins' wording.code.callers,code.edit_context,code.coverage_claimand the test map. No migration, no setting, no re-index.unmapped_changesand the file's neighbours. One of 41 development changes is of this kind (decorators added to six classes). A caller that sends the diff with its lines gets the classes.mainsorts it before them; that order is measured on coverage rows only.unmapped_changes.unlinkedno longer holds a stop. The edit-time line names the changed definitions fromunlinked.Compatibility, rollout and rollback
code.test_gateoutput.tests[].whyvalues arechanged_test,coverage,static_call,stem_partner,test_map,file_neighbor:graph_hopis renamedstatic_call,coverageandfile_neighborare new, andstem_partnerandtest_maprows now follow the call-chain rows.coveragerows carrylinks_toandconfidence, and thehop,callersandviaof a call chain that links the file too, whose testevidencethen names after the measurement.static_callrows gaincallers,links_toandvia;file_neighborrows carrycallees. Newunlinked,unlinked_total,unlinked_capped.untestedrows gaincommitand the list is empty without a verified coverage run.obligationsno longer counts unlinked definitions.epistemicismeasuredorlower_bound, neverexact;causesgainsunmapped_changesandno_coverage, is no longer emptied, and holdstruncatedalso when the read of the coverage rows was cut.touched_symbolscan hold classes.code.impact. Diff-shapedtouched_symbolsholds the functions the changed lines sit in;via: headerappears only for a definition without a body extent.untestedrows carry nocommitand it serves nounlinked. A plugin of the previous release against this server names the tests oftests, which hold at most four rows when only neighbours are found, and names no function, becauseuntestedis empty without a coverage run.Tests
The measurement asks a server started from this branch the same questions as one started from
main, on the same read-only indexes, and scores the answers offline. Repositories were split into development and held-out before any answer was scored. Every column of this branch is read at commit a6c2c82, after the fixes of two reviews. Each round fixed its rule on the development repositories first and then read the held-out columns once at the frozen commit; the first two tables came out the same as at the previous round's commit, row for row. Themaincolumn of the third table is the baseline commit on the same coverage index. One pass of the third table's development sample lost six calls to the evaluation database's memory limit while three servers shared it and was asked again alone; no call failed in the runs reported.Gold patches, gate at depth 2 (a test file is right when it holds a test the fix makes pass):
touched_symbolsuntestedunlinkedunlinkedwith the right file in the same answerThe two rows about the touched set measure agreement with the labelling rule, not independent truth: the labels are the innermost definition of each old-side line, the rule the gate now uses. The labels also count text added just above a top-level definition as that definition, which the gate does not: that is the one held-out label it no longer touches, and the two development labels it never touched (a method added at the end of the class above).
Per-test coverage, gate at depth 2, index without a coverage import (one-line diffs inside sampled definitions; a test is right when coverage shows it executes the definition):
static_callrows in a covering test's filefile_neighborrows in a covering test's fileuntesteduntestedunlinkedunlinkedWithout a coverage run
untestedis empty, andunlinkedseparates executed from unexecuted code no better than the old list did, which is why it is worded as the index's view and asks for nothing.The same sample on an index with the coverage run imported. The three repositories were indexed into a new database (2 minutes 20 seconds), and each suite's per-test coverage was loaded through the coverage importer from a source in the importer's table layout, at the indexed commit.
mainhas nountestedfrom a coverage run, nocoveragekind and nomeasuredanswer, so its column holds the order rows only:mainmainuntesteduntestedepistemic: measuredcoveragerows in a covering test's filestatic_callrows in a covering test's filestem_partnerrows in a covering test's filetest_maprows in a covering test's fileThe order of kinds chosen on development holds on held-out. The one unexecuted definition read as executed is a function whose own body ran only at import while a test ran the function nested in it; the gate reads a definition's extent with the definitions nested in it.
What the second review's fixes changed in this table, against the previous commit of this branch on the same answers:
coverage. At that commit the covering files of one definition tied and were listed by path. The file with the most covering tests was first for 53% of development definitions and 55% of held-out ones, which on held-out was belowmain's 65%; it is now 68% and 70%. A covering test function was within three for 9% and 2%, and is now 36% and 25%, the same as on the index without a coverage run.untestedanswer changed. Eleven developmentcoveragerows were of a test that ran the declaration line and no line of the body (a nested function'sdefruns with the function around it); they are gone, and the kind's share of rows in a covering test's file went from 97% to 99%.What got worse:
file_neighborrows, which is why the kind is labelled, capped and never clearsunlinked. On held-out, four are@overloadstubs the index holds no symbol for: their line is now the class body's, so the class is touched and its tests are named. Over all rows, 59% of the named files hold a covering test against 91% before.static_callrows alone hold the right file within three for 48% against 55% for every row before; the file neighbours bring it to 77%.Cost, from
system.query_logon indexes of up to 56,000 symbols, under a loaded host: the neighbour read took 43 ms at the median and 253 ms at most, read at most 97,280 rows and 7 MiB, and used at most 8 MiB. With a coverage run the measured path adds a keyed read of the coverage files (15 ms at the median, at most 34 rows) and of the test map (13 ms, at most 440 rows). Nothing is indexed or stored.Also checked:
code.impact's diff shape answers all 41.ruff format --check,ruff check, the mypy gate, the function-length gate, every generator's--check, the analyzer corpus (one changed shape; the second review's fixes change no statement), the Codex copies'--check, andnode --teston the plugin's gate tests.Not verified here:
memory.for_fileonmaintoo; this change leaves it.claude plugin eval. It needs model calls.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked by measurement on ground truth as described above, by reading the diff, and by the gates listed.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code
Note
High Risk
Backward-incompatible
code.test_gateand diff-shapedcode.impactsemantics affect pre-PR and plugin stop hooks; accuracy now depends on coverage imports and diff shape (headers-only vs full lines).Overview
code.test_gateis reworked so a diff seeds only the innermost definitions whose old-side changed lines sit inside them (classes included), with finer placement rules for insertions, decorators, and Python indentation; unmapped lines addunmapped_changes. Test recommendations are evidence-typed (coverage,static_callreplacinggraph_hop,file_neighbor, etc.) via a new link path instead of crediting tests only through a reverse call walk.Touched code splits into
untested(verified coverage measured the body unexecuted, withcommit) andunlinked(no coverage and no static chain—informational, does not drive obligations).epistemicis nowmeasuredorlower_bound(notexact);obligationsignoresunlinkedalone.The same diff parsing applies to
code.impacttouched_symbols. Claude Code / Codex plugins (v1.2.77) mirror the wording: stop hooks prompt on unexecuted coverage only; edit-time lines surfaceunlinkedseparately. Docs, SDK types, andmeasured_definitionsin coverage support the new contract.Reviewed by Cursor Bugbot for commit 79b960e. Bugbot is set up for automated code reviews on this repo. Configure here.