Skip to content

plugin: enrich lines say why a count is 0, and an edit gets one line of tests (#1507) - #1617

Merged
swapnilpaliwal-sd merged 1 commit into
0.1.4from
fix/1507-enrich-hook-actionable
Sep 28, 2026
Merged

swapnilpaliwal-sd merged 1 commit into
0.1.4from
fix/1507-enrich-hook-actionable

Conversation

@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor

Fixes #1507, #1546, #1604

What was wrong

The PostToolUse enrichment is what agents read after every Read, Grep and Edit, and most of it went unused:

The change

  • hooks/_graphline.py (new): zero_label() prints entry (<reason>), ? framework (@X), 0 resolved, N by name, ? framework (overrides a library method), ? framework (extends B) or ? framework (@X on Owner), in that order of strength. With no signal it prints 0. Each is one indexed query. body_line() prints the tests that reach a body edit and the command, using command_for from test-impact. distinct_paths() gives the shortest path suffix that tells same-named files apart.
  • hooks/enrich.py:
    • Grep previews name callers ORDER BY is_test, display and count test callers separately.
    • Declarations of one name are ordered base first (with ⇣ N override(s)), then production, then path, with (+N more declaration(s)).
    • A shell grep after |, or over non-source files, is silent. Constant-shaped words are skipped, a shell grep matches whole names, and the prefix match uses GLOB.
    • A Read no longer prints a header with no lines under it.
    • Edit: silent when no declaration changed. A declaration already reported this session is dropped. Body-only changes get one line.
  • hooks/changes.py: the same one line for body-only changes on the Bash and UserPromptSubmit paths.
  • Both hooks ask impact with shown_target.
  • graph_sql.impact also returns test_ids, an additive key.

Tests

tests/enrich_lines.py: 28 checks, each silence paired with a near-miss control. 21 fail on 0.1.4, and all controls hold there. Suites: enrich_budget 17/17, hosts, fastpath 4/4, directive 12/12, and run.py: java 119/119, python 71/71, csharp 14/14.

Smoke (corpus copies, fresh index, before vs after)

  • Java web app, Read of a controller: 7 of 7 callables printed ←0. After: 3 ←entry (http), 3 ←? framework (@ModelAttribute / @InitBinder) and 1 more entry. Grep previews now name production callers first (<two production callers>, …; 5 in tests), and the base interface comes first with its override count.
  • Java body edit of a service method: 897 chars (14 reader rows) became 113 chars: graph: body edit of <Service>.<method>: 3 test(s) reach it; run: mvn test -Dtest=<TestClass>. A comment-only edit is silent before and after.
  • Python web app: three request hooks went from ←0 to ←? framework (@app.before_request). pytest | grep -E 'FAILED|ERROR' used to name an unrelated error_... helper, and is now silent. A grep over source is still annotated.

Deep scan deferred: no full-corpus or held-out measurement was run; the smoke numbers above are the only corpus numbers.

…of tests (#1507, #1546, #1604)

Read/Grep enrichment:
- A method with no resolved caller no longer prints a bare "<- 0". It prints
  "<- entry (http)" from entry_points, "<- ? framework (@x)" from a
  non-inert decoration on the method, "<- 0 resolved, N by name" from
  unresolved call sites that write its name, "? framework (overrides a
  library method)" for an @OverRide with no base in the repo, and
  "? framework (@x on Owner)" from a class annotation. With no signal it
  still reads "<- 0".
- The Grep caller preview names production callers before test callers
  and counts the tests apart (#1507).
- A name declared several times lists the base first with its override
  count, production before tests, then by path; same-named files print
  with the path suffix that tells them apart, and the rest are counted
  (#1546).
- A shell grep after a pipe, or over files no graph indexes, adds nothing;
  a constant-shaped word (FAIL, DONE) is not looked up; a shell grep
  matches whole names; the Grep tool's prefix match is case-sensitive
  (GLOB) instead of LIKE (#1604).
- A Read whose callables have no edges no longer prints a header over no
  lines.

Edit hooks (enrich.py and changes.py):
- An edit that changes no declaration prints nothing.
- A declaration already reported this session is not reported again on
  the PostToolUse Edit path.
- A body-only change prints one line: the tests that reach it and the
  command test-impact would print for them.
- Impact is asked with the target as `changed` prints it; the
  package-qualified target was refused, so every Java signature edit
  said "(impact unavailable)".

tests/enrich_lines.py: 28 checks with near-miss controls; 21 fail on the
base branch, all controls hold there.
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