Skip to content

gitgalaxy reach: caller counts, header include counts and the scope of a name from a finished scan (Part of #8529) - #8532

Merged
squid-shepherd[bot] merged 1 commit into
mainfrom
sensors/reach-command
Nov 16, 2026
Merged

squid-shepherd[bot] merged 1 commit into
mainfrom
sensors/reach-command

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

New read-only command gitgalaxy reach SCAN_DB [--src ROOT] [--callee NAME] [--top N] [--all-roles] [--json FILE] (gitgalaxy/tools/sensors/reach.py, wired into gitgalaxy/cli.py beside assess). It reads a finished *_galaxy_master.db and reports who depends on a file: per source file the distinct caller files, caller functions and callers one hop out; per header the number of files that #include it (resolved by path, so same-named headers in different folders stay separate; needs --src); files the call graph cannot see as "not measured" with a reason. Only kind = 'call' edges that resolve to exactly one definition count, ties and ambiguous edges are reported as left out, and tied calls (fcall_candidates, #8161) are shown beside the count as possible callers. --callee NAME scopes a rename or removal: who calls NAME, from fcall_data when the repository defines it and from fcall_external (#8530) when it does not; on a scan without that table it says so. The database is opened read-only, no column is added and no scan output changes, so no golden master moves. Part of #8529.

Type of change

  • New feature (a post-scan command; no parsing or engine logic change)

Measured

On three real scans the headline numbers match the research prototype (curl lib/mprintf.c 403 caller files, libgit2 src/util/errors.c 591, redis src/zmalloc.c 88); a run takes a fraction of a second. Scope check on curl: scanning the parent of 193cb00ce9 (free to curlx_free, 471 files touched) and running --callee free lists 168 files; the commit changed free( calls in 161 and 157 are in both (recall 0.98, precision 0.93). Exploratory validation of the underlying call graph over seven repositories: per function the engine's callers agree with a text search at Spearman +0.74 to +0.92 with precision 1.00 (about half of a text search's callers are found); for headers call-based reach does not work, hence include counts.

Class / Sibling gaps

Class: post-scan "who depends on this" questions answerable from fcall_data, fcall_candidates, fcall_external and the import lists the scan already stores, for any language that writes them. Handled here: source-file reach, header include counts for C-family sources, possible callers from tied calls, scope of a name. Sibling gaps: (1) header include counts are computed from the source tree at run time (--src) because the scan does not persist them: persisting them is the open item of #8529; (2) Go and Python call matching is by bare name, so same-named methods in different packages merge and counts there over-state reach: call-graph resolver work, not this command; (3) navigation and the Connectivity page edits for the new wiki page (docs/wiki/index.md, mkdocs.yml, 08-14) are a follow-up docs PR to stay within the 5-file limit; (4) a stable-foundations list and a combined recent-activity view are research prototypes, not in this command.

CI checklist

  • python tests/tools/audit_check.py passes
  • tests/tools/test_reach_sensor.py (13 tests), tree-wide guards (289 passed, 1 skipped), tests/tools (4,730 passed; 1 failure, test_l5_speedups::test_javac_session_compiles_live_and_rejects_stillborn, fails identically on unmodified main: this box's JDK has no javac), existing assess CLI tests (45 passed, 22 skipped), time ratchet (4,795 tests, none over the limit)
  • Scan output unchanged: no recorder, parser or engine file touched

Files (hand-written, 5): gitgalaxy/tools/sensors/__init__.py, gitgalaxy/tools/sensors/reach.py, gitgalaxy/cli.py, tests/tools/test_reach_sensor.py, docs/wiki/08-24-reach-sensor.md.

Remaining slices

  1. Docs follow-up (3 files): docs/wiki/index.md and mkdocs.yml entries for 08-24, and the 08-14-api-exposure.md limitation and measured-behavior text.
  2. Persist per-header include counts (Persist external calls and header include counts so a scan can scope a rename (fcall_external, gitgalaxy reach) #8529).

Lessons for agents

  • pytest tests/tools/test_l5_speedups.py::test_javac_session_compiles_live_and_rejects_stillborn fails on a box whose JDK has no javac; it fails the same on main, so it is not a regression in your change.

🤖 Generated with Claude Code

https://claude.ai/code/session_018srRveGdV73aUiuqkipAic

…f a name from a finished scan (read-only)

New post-scan command 'gitgalaxy reach SCAN_DB [--src ROOT] [--callee NAME]' (gitgalaxy/tools/sensors/reach.py): per source file, distinct caller
files, caller functions and callers one hop out from fcall_data; per header, the files that #include it, resolved by path; tied calls
(fcall_candidates) shown beside the count as possible callers; --callee NAME lists who calls a name, from fcall_data when the repository
defines it and from fcall_external when it does not. Only kind='call' edges that resolve to one definition count; the rest are reported.
Opens the database read-only; adds no column and changes no scan output. Wiki page 08-24.

Part of #8529.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018srRveGdV73aUiuqkipAic
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Nov 16, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot merged commit 11a0c8a into main Nov 16, 2026
54 checks passed
@squid-shepherd
squid-shepherd Bot deleted the sensors/reach-command branch November 16, 2026 18:41
squid-protocol added a commit that referenced this pull request Nov 16, 2026
…can database; golden masters re-blessed (#8546)

The LLM brief gets two short sections after 15 (call resolution): 16 "Reach (Who Depends On What)" (the five most-called source files and the
five most-included headers, from gitgalaxy reach) and 17 "Libraries (What The Repository Leans On)" (the eight external libraries with the most
files, from gitgalaxy libsurface; a C or C++ library only if it is in the shipped table, a discovered one only when an import names it). They read
the master database galaxyscope has just written, passed to generate_artifacts as scan_db; absent without one, and a failure to read never stops the
brief. No table, no column; the only scan output that changes is llm.md (a 35-line insertion in both golden brief fixtures).

Reading a WAL-mode database read-only creates -wal and -shm files, which the documented scan output must not contain (test_cli_contract caught it):
the sensors now open the database immutable when no -wal file is beside it (nothing is mid-write) and read-only otherwise.

Closes nothing; follows #8544 (header counts from stored imports) and #8532.


Claude-Session: https://claude.ai/code/session_018srRveGdV73aUiuqkipAic

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant