Repository navigation
gitgalaxy reach: count header includes from the scan's stored include strings (no source tree, no new table) (Closes #8529) - #8544
Merged
Conversation
… strings (no source tree, no new table) A header's reach is its include count. It needed --src because the resolver read the #include lines from the source tree; the scan already stores each file's include strings in file_data.raw_imports, which is all the resolver needs. Headers are now counted from them by default (--src still reads the source instead; the two give identical counts). The resolver follows C's own order: a quoted include relative to the includer's folder first (../x.h, sub/x.h), then the existing path rules. No schema change, no scan output change. Part of #8529. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRveGdV73aUiuqkipAic
Contributor
6 tasks done
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]>
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.
Summary
gitgalaxy reachreported a header's reach as the number of files that#includeit, but only with--src, because the resolver read the#includelines from the source tree. The scan already stores every file's include strings infile_data.raw_imports, and the resolver needs nothing else. So headers are now counted from the stored strings by default: no source tree, no new table, no schema change, no change to scan output.--src ROOTstill reads the source instead; the two readers give the same counts edge for edge. The resolver now follows C's own search order: a quoted include is looked for relative to the includer's folder first (../redismodule.h,sub/x.h), then by the existing path rules (a/x.hmatches the header ending ina/x.h; a barex.hprefers the includer's folder, then the longest shared path). The open item of #8529 asked whether the include resolver could be improved before adding a table to persist include counts: it needs neither. Closes #8529.Type of change
Measured
Scored against libclang's own record of which file includes which header (exact: it comes from the preprocessor; every
.cfile parsed as a translation unit with every header folder on the include path, direct inclusions at any nesting depth), on six C repositories, per header:popularitycolumn, SpearmanReading it: nearly every real include is found. Precision is 83 to 98% because every textual
#includeis counted, including those inside an#ifthe preprocessor did not take (another platform's headers), so "exactly right" is lower than the ranking agreement. Against the engine'spopularitycolumn the new count ranks headers better on redis, libuv and ndpi, level on hiredis and zlib, and worse on expat (+0.885 against +0.958). A correction to what #8529 said: the include-related columns it quoted (+0.38 to +0.71) werepagerank_scoreandimport_count;popularityis a good proxy (+0.68 to +0.96), andimport_countis poor (-0.32 to +0.45 here). Exploratory: six repositories, C only; headers of other languages have no include directive and are not measured.Class / Sibling gaps
Class: header reach for C-family sources, wherever the scan stores include strings. Handled here: the stored-imports reader, the relative-include rule, the shared resolver for both readers. Sibling gaps: (1)
#includestrings inside an untaken#ifare counted (the scan has no preprocessor); (2) a barex.hthat matches several headers picks the one sharing the longest path with the includer, which is wrong when the build's-Iorder says otherwise; (3) headers of languages with no include directive (Python, Go, Java, Rust) are not measured by include; (4) the stored strings do not say<x.h>from"x.h", so a system header that shares a name with a repository header can be matched to it.CI checklist
python tests/tools/audit_check.pypassestests/tools/test_reach_sensor.py(17 tests; 2 new: the stored-imports reader agrees with the source reader and needs no source tree, and a relative include resolves from the includer's folder) andtest_libsurface.pypassFiles:
gitgalaxy/tools/sensors/reach.py,tests/tools/test_reach_sensor.py,docs/wiki/08-24-reach-sensor.md.Lessons for agents
file_data.raw_importsholds a file's include or import strings (JSON list, sorted, deduplicated, relative forms such as../x.hkept, quotes and angle brackets dropped): enough to compute include graphs after the scan without re-reading source.🤖 Generated with Claude Code
https://claude.ai/code/session_018srRveGdV73aUiuqkipAic