Skip to content

code.impact, code.edit_context and code.coverage_claim name the tests the test gate links, and a module's own test file leads the examples - #1725

Merged
zlareb1 merged 5 commits into
mainfrom
fix/test-links-shared-links-and-example-ranking
Nov 29, 2026
Merged

zlareb1 merged 5 commits into
mainfrom
fix/test-links-shared-links-and-example-ranking

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Related: #1707

Changelog category (leave one):

  • Improvement

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.impact impacted_tests holds the test files code.test_gate lists for the same change, each with its why, where it held test-map rows only; code.edit_context returns tests and test_link_state for a definition with no test call site to show; code.coverage_claim reads the same call-chain links and, for Python, the test modules named after the source module. Test examples come first from the test module named after the definition's module.

Why

Four ops answered "which tests go with this definition" from four different reads, so they disagreed about one definition and three of them were often empty. Measured on Python repositories at the revision the index holds, against two kinds of ground truth: changes with a known fix and the tests that fix makes pass, and repositories whose own suite ran with per-test coverage.

  • code.impact. impacted_tests came from the test map alone. No measured index holds one, so the list was empty for every definition asked.
  • code.coverage_claim. Its call leg walked calls edges its own way: no constructor credit, a second hop only when the first found fewer than three tests, rows in path order. Its sibling leg looks for a Python test beside the source or under a src/-mirroring tests/ tree. That finds the test module of 4 of 461 source modules that have one in the six development repositories, which keep tests in a top-level tree, and of 707 of 902 in the six held-out ones, four of which keep tests beside the package.
  • code.edit_context. 59% of edited definitions got no test example and nothing that said why. The 50 example candidates were cut in (tier, confidence, path, line) order before ranking, so the alphabetically first test paths filled the cut.

What changes:

  • One builder. link_tests and build_gate, which code.test_gate already uses, feed the other three ops. impacted_tests is the gate's tests for the same change. A definition with no test call site carries the gate's first three rows as tests and its status as test_link_state. The coverage claim's call leg lists the test files a call or fixture-use chain reaches, in the gate's order.
  • Mirror rule. mirror_test_paths reads the index's own test paths and returns the Python test modules named after a source module, wherever the repository keeps them: a file a test affix names after it (test_app.py, app_test.py), then a directory named after it, then a file with the bare name. Their call sites are read into the example cut first and ranked first. They join the conventional sibling paths as the coverage claim's sibling files.

Decisions taken on the development repositories, each by a rule stated before its run:

  • Mirror files are not rows of the builder. Placed ahead of file neighbours they lost 11 first ranks and 13 within three of 79 definitions, and 9 first ranks of 100 on coverage truth. Placed behind them they added no test file the fix makes pass and no covering file at any rank. So code.test_gate is unchanged.
  • The coverage claim counts calls only. The gate's walk also follows overrides and inherits. With those, one of 23 definitions no test executes moved from unknown to covered_by (two test classes override it). The claim's leg keeps the links a calls or fixture_use edge makes: 0 of 23, and 17 of 199 executed definitions move to covered_by.
  • One affix, with its underscore. The first rule read test_unittest.py as a test of unit. Reading one affix finds the test file that the fix makes pass first for 14 of 79 definitions against 10.
  • Bare names last. A file with the module's bare name under a test directory (tests/<app>/models.py) is support code more often than a test. Ranked last, the five listed files hold a module's own test_<stem>.py for 355 of 358 modules of the largest development repository against 322.

One decision came from the held-out file layouts, after the held-out answers were read:

  • The sibling paths stay. The plan was to replace the Python sibling paths with the mirror rule, on the development finding that they match nothing. The held-out layouts show they match where tests sit beside the package, and that the mirror rule lists that file for 708 of the 713 modules where they match. So the sibling paths are kept and the mirror rule is added to them. The 110 definitions were asked again at this commit and every answer of every op is the same as at the frozen one.

Results. Development figures were used to design the change; held-out figures were read once, at a frozen commit.

Changes with a known fix: the answer names a file of a test the fix makes pass development, before after held-out, before after
code.impact impacted_tests, names nothing 100% (79/79) 14% (11/79) 100% (31/31) 3% (1/31)
first 0% 47% (37/79) 0% 68% (21/31)
within three 0% 57% (45/79) 0% 77% (24/31)
code.edit_context examples, names nothing 59% (47/79) 59% (47/79) 52% (16/31) 52% (16/31)
first 18% (14/79) 23% (18/79) 32% (10/31) 32% (10/31)
within three 22% (17/79) 27% (21/79) 35% (11/31) 35% (11/31)
code.edit_context examples or tests, names nothing 59% (47/79) 14% (11/79) 52% (16/31) 3% (1/31)
first 18% (14/79) 48% (38/79) 32% (10/31) 68% (21/31)
within three 22% (17/79) 57% (45/79) 35% (11/31) 71% (22/31)
code.coverage_claim, names nothing 51% (40/79) 8% (6/79) 26% (8/31) 16% (5/31)
first 19% (15/79) 32% (25/79) 26% (8/31) 26% (8/31)
within three 27% (21/79) 39% (31/79) 42% (13/31) 42% (13/31)
any rank 34% (27/79) 49% (39/79) 45% (14/31) 45% (14/31)
Per-test coverage: the answer names a file of a test that executes the definition development, before after held-out, before after
code.impact impacted_tests, first 0% 85% (169/199) 0% 81% (81/100)
within three 0% 91% (182/199) 0% 88% (88/100)
code.edit_context examples or tests, first 28% (56/199) 84% (167/199) 22% (22/100) 79% (79/100)
within three 29% (58/199) 91% (181/199) 23% (23/100) 87% (87/100)
code.coverage_claim, first 36% (72/199) 68% (135/199) 14% (14/100) 85% (85/100)
within three 38% (76/199) 70% (140/199) 15% (15/100) 88% (88/100)
code.coverage_claim verdict covered_by, executed definitions 27% (54/199) 36% (71/199) 15% (15/100) 22% (22/100)
verdict covered_by, definitions no test executes 0 of 23 0 of 23 2 of 20 2 of 20
  • Agreement. code.coverage_claim has a call-chain row exactly when code.impact has one for 79 of 79 development and 31 of 31 held-out definitions (47 and 17 before). Of the definitions code.edit_context calls unlinked, neither op has a call-chain row for any.
  • Example ranking. Of 18 development definitions with a test call site in a file of a test the fix makes pass, that file is first for 16 (12 before) and within three for 17 (13). Five of the six definitions whose rank changed are in one module. On held-out no example changed for any of 151 definitions, so held-out neither supports nor contradicts the ranking; it is kept under the rule fixed beforehand (kept on a tie when the first-rank count does not fall).
  • The mirror rule in the coverage claim. On held-out coverage truth 65 of 79 sibling rows of executed definitions are a covering test's file, and 62 of 100 executed definitions get their only covering file from one. On the held-out changes with a known fix it adds none for a definition that had none: 3 of 20 sibling rows are a file of a test the fix makes pass, and the sibling paths already found all three.

What got worse:

  • Definitions no test executes are named a test more often. impacted_tests names a test file for 17 of 23 such development definitions and 20 of 20 held-out (0 before); 4 and 8 of those have a row about the definition (static_call), the rest are file_neighbor rows. code.coverage_claim names one for 19 of 23 and 20 of 20 (1 and 2 before), as path_convention rows that change no verdict. test_link_state is unlinked for 66 of 100 executed held-out definitions and linked for 7 of 20 unexecuted ones: it says what the index holds, not whether a test runs the code, and the field's description says so.
  • Three development definitions rank lower. One example list puts the mirror module's test ahead of the test the fix makes pass (first to second). Two coverage-claim lists lose the first place path order had given the right file (first to second).
  • Coverage-claim row precision. On the changes with a known fix, the share of listed files that hold a test of the change falls from 8% (31/365) to 7% (46/633) on development and from 31% (14/45) to 19% (14/74) on held-out: more files are listed and none of the added ones is counted by this lower bound.

Scope and risk

  • Touches code.impact, code.edit_context, code.coverage_claim, the example read of code.symbol with test_examples_only, and one line of the plugins' blast-radius text.
  • Leaves alone code.test_gate's answers (the handler now calls the shared helpers; its rows are the same on every measured change), code.callers, what the index stores, the test map and its worker. No migration, no setting, no re-index.
  • Cost. Statements per request on the development changes: code.impact 12.3 to 17.2, code.edit_context 25.7 to 30.4, code.coverage_claim 10.1 to 13.5. code.impact walks the callers twice, once for its radius and once for the links, because the two walks differ in seeds and overlay; that is left for a follow-up. The mirror read is one key-range read of loom.code_files per request.
  • Enrichment deadline. The tests block is read after the examples come back empty, inside its own code_enrich_timeout_s. The measurement ran with a 30 s deadline on a loaded machine; how many blocks the default 0.5 s drops on an unloaded server is not measured.
  • Other languages. The mirror rule is Python's. Every sibling path, Python's included, is as before.
  • Generic module names. For models.py, base.py or utils.py many test files carry the name and five are listed.
  • Found, not changed here. In a diff that touches a function and its only caller, code.test_gate lists the callee unlinked although alone it is linked through the caller (2 of 77 development definitions): the walk skips an edge between two touched definitions.

Compatibility, rollout and rollback

  • Wire, code.impact. impacted_tests rows are code.test_gate tests rows: {test_path, why, evidence, run, run_unknown} plus links_to, hop, callers, via, confidence, src_path or callees by why. A test-map row keeps src_path and confidence and gains why: "test_map"; rows of other kinds carry no src_path. At most 30 rows. blast_radius_score still counts test-map rows.
  • Wire, code.edit_context. A definition with no test call site gains tests (at most three {test_path, why, evidence, hop, run}) and test_link_state (executed, unexecuted, linked, unlinked). Both are absent when examples is non-empty.
  • Wire, code.coverage_claim. calls_edge and calls_edge_2 rows read <test> reaches it in N hop(s); equal tier and confidence keep the links' order instead of path order; Python sibling_file rows read named after <source path>.
  • Plugins. Version 1.2.80 for both. The blast-radius line counts impacted_tests rows other than file_neighbor and stem_partner as "tests reaching it". A plugin of the previous release against this server counts every row there.
  • Operator steps. None.
  • Rollback. Reverting leaves nothing behind.

Tests

  • Measurement. 61 changes with a known fix at an indexed base commit, split by repository into development (5 repositories, 79 edited definitions) and held-out (5 repositories, 31), and three repositories with per-test coverage (two development, one held-out; 100 executed and up to 20 unexecuted definitions each). Each op is asked per edited definition from a server started from the checkout; the base commit's answers come from an unmodified checkout in the same session.
  • Unit tests. Added for the mirror rule, the example cut and rank, the first_paths and test_paths_named statements, link_state, the symbol-shaped links against the gate's answer for the same definition, impacted_tests against the gate's rows, the tests block, and the coverage claim's legs. Six fakes of code.impact tests gained the two reads the links make. test_impacted_tests_follow_the_read_order_on_a_tie became test_impacted_tests_are_in_a_total_order_on_a_tie: the order is the gate's, which is total. test_depth_two_is_skipped_when_the_first_hop_has_enough is replaced, since the claim reads both hops as the gate does.
  • Not run locally. The pytest suites. The functions of 66 test modules on the changed call paths were called directly before and after; the modules this change touches pass and the rest give the same results as on main. ruff format --check, ruff check, the mypy gate, the function-length gate and every generator --check pass. tests/analyzer/shapes.txt gains two shapes; both statements ran against a real index.

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. The measurements above were run and read by the agent; no human has reviewed the diff yet.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/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).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

🤖 Generated with Claude Code


Note

Medium Risk
Changes response shapes and test-identification logic for several public code-intelligence ops; behavior shifts for API consumers but leaves indexing, test_gate row rules, and storage unchanged per scope notes.

Overview
Unifies how Loom names tests across code.impact, code.edit_context, code.coverage_claim, and code.test_gate by routing them through shared helpers in test_links.py (link_tests, gate_of, definition_links). code.impact impacted_tests is now the same ordered tests rows code.test_gate would return (with why, evidence, hop, run, etc.), not bare test-map {test_path, src_path, confidence} rows.

The reverse call-graph walk tracks call chains (call_hop, call_via for constructor/fixture/enclosing) and uses calls / fixture_use only for coverage-claim call evidence (override/inherit edges no longer imply execution).

Python test discovery adds mirror naming (mirror_stem, mirror_test_paths, test_paths_named) so tests named after a module are found beyond sibling paths; example enrichment prioritizes those modules via first_paths on edge reads. Edit context adds tests + test_link_state when there are no test call-site examples.

Claude/Codex blast-radius rendering excludes file_neighbor / stem_partner from “tests reaching it.” Docs, MCP descriptions, SDK types, and plugin version 1.2.84 follow the new wire shapes.

Reviewed by Cursor Bugbot for commit 34dc256. Bugbot is set up for automated code reviews on this repo. Configure here.

… the test gate links, and a module's own test file leads the examples

Each op had its own legs, so they disagreed about one definition: `impacted_tests`
read only the test map, which no measured index holds; the coverage claim walked
`calls` edges its own way and found a Python test only beside its source; the edit
context cut its 50 example candidates in path order before ranking them.

- `link_tests` and `build_gate` are the one builder. `impacted_tests` holds the gate's
  rows for the same change. A definition with no test call site carries the first three
  rows as `tests` and a `test_link_state`. The coverage claim's call-chain leg lists the
  links a call or a fixture use makes, in the links' order.
- `mirror_test_paths` finds the test modules named after a Python module among the
  index's test paths, wherever the repository keeps them. Their call sites are read
  into the example cut first and ranked first, and they join the conventional sibling
  paths as the coverage claim's sibling files.
- The plugin's blast line counts a test as reaching the change only when its row is
  about the touched definitions.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 29, 2026 12:23am UTC
loom-telemetry Ready Ready Preview Nov 29, 2026 12:23am UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.

Fix All in Cursor

❌ 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 e6153fb. Configure here.

Comment thread server/code/app/symbol/impact.py Resolved
…eep their rank

Review fixes for the shared test links.

- The walk records, per node, the shortest chain of `calls` and `fixture_use` edges
  that links it to a touched definition and what that chain ends at. The coverage
  claim lists those nodes only: a test that calls an override of the subject is not
  evidence, and a test an override reached first is listed by the chain of calls a
  later hop finds.
- A test that calls only the function a nested function is defined in is weak
  evidence (`calls_edge_2`, `short_name_grep`): it cannot make `covered_by` or pass
  the control. A test that builds the class of a constructor stays exact. Every
  call-chain row says what its chain ends at.
- Test examples are ranked by the key they had. The test modules named after the
  definition's module are still read into the candidate cut first.
- `code.impact` walks its test links at the gate's default depth whatever depth the
  radius is asked at, so `impacted_tests` is the gate's answer.
- A directory that holds a module names no test after it, and a mirror row of the
  claim says which rule matched.
- The bounded numbers this change names say why they are not settings, and the list
  of older ones drops the three that are gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
zlareb1 and others added 3 commits November 29, 2026 05:44
Merges main up to the commit the branch's two changes were last checked on.
The two plugin manifests conflicted on the version line; both keep the
branch's bump, one above main's version.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
….2.84

Main's manifests moved to 1.2.83, so the branch's plugin change takes the next
free version. The Rust wire models are regenerated from the merged registry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…e is named after no module

A diff that also edits a test file seeded the test links of code.impact with that
file's functions, so impacted_tests listed the tests that call a changed test helper
and code.test_gate did not. The diff shape now hands the links the definitions of
source files only; the radius is still seeded by every touched function.

A Python file under testdata/, fixtures/, __fixtures__/ or __snapshots__/ matched the
mirror rule by its name or its directory and could lead the test modules named after
a source module. The rule now names no payload file after a module, as
is_test_unit_path already reads those trees.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 merged commit 2bf02e8 into main Nov 29, 2026
83 of 90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant