Repository navigation
gitgalaxy libsurface: which libraries a repository leans on, which files lean hardest, how the surface changes (Part of #8534) - #8535
Merged
Conversation
…les lean hardest, how the surface changes (read-only) New post-scan command 'gitgalaxy libsurface SCAN_DB [SCAN_DB_AFTER] [--lib NAME]' (gitgalaxy/tools/sensors/libsurface.py): from file_data imports and fcall_external it discovers every external library (engine's own stdlib and system-header lists; the repository's own packages set aside), ranks the files coupled to one library by sites per line, and shows the API names and files added or dropped between two scans. Library definitions are three layers, later wins by name: discovery (no list), a shipped table of glob patterns for 20 C-family libraries (library_table.py), and user TOML files (XDG config, ROOT/.gitgalaxy/libraries.toml, --libs). Globs, not regexes. Opens the databases read-only; adds no column and changes no scan output. Wiki page 08-25. Part of #8534. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRveGdV73aUiuqkipAic
Contributor
Part of #8534. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRveGdV73aUiuqkipAic
…fix-match limitation (curl's own SSL_ macros count as OpenSSL) Part of #8534. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRveGdV73aUiuqkipAic
This was referenced Nov 16, 2026
Merged
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
New read-only command
gitgalaxy libsurface SCAN_DB [SCAN_DB_AFTER] [--lib NAME] [--libs FILE] [--src ROOT] [--top N] [--json FILE](gitgalaxy/tools/sensors/libsurface.py, wired intogitgalaxy/cli.pybesideassessandreach). From a finished scan'sfile_data(imports, lines) andfcall_external(#8530) it gives three views: the external libraries in use (files, sites, distinct API names); the files coupled to one library, most coupled first (where work on the library lands); and, for two scans, the API names added and dropped and the files newly or no longer coupled. A site is a matching import or include plus a call to one of the library's API names; density is sites per line. Counts and lists only, no score, no risk claim. Databases are opened read-only; no column is added and no scan output changes. Part of #8534.Who defines a library (three layers, later wins by name;
disable = trueremoves an entry): (1) discovery with no list, every external import root: first dotted component (Python), host/owner/repo (Go), package prefix (Java), first::component (Rust), package name (JS/TS), include directory or header name (C-family), after the engine's ownis_stdlib_module/is_system_headerlists and the repository's own packages are set aside; (2) a shipped table (library_table.py, Python data so no packaging change) of glob patterns for the API names of 20 C-family libraries, needed because a library reached through a wrapper header is invisible to includes alone; (3) TOML files:$XDG_CONFIG_HOME/gitgalaxy/libraries.toml,ROOT/.gitgalaxy/libraries.toml,--libs FILE. Patterns are globs, never regexes, so a pattern a user writes cannot hang the matcher; a malformed file is refused with a message (exit 2), patterns are length-bounded.Type of change
Measured
On curl, prometheus, sphinx, commons-lang and ripgrep scans the discovery lists are sensible; curl OpenSSL matches the research prototype exactly (19 files, 452 sites, 231 API names). The research test (coupling to a library vs where its work lands, recall@20, 19 pairs in curl, libarchive and harfbuzz) was re-run through this module with the glob table: +0.389 over a size ranking (99.7% lower bound +0.344), -0.018 against the registered regexes (non-inferior at -0.05), and +0.000 against the regex prototype on every one of the 19 pairs: the glob table loses nothing. Includes alone gave +0.253 and lost to the full measure by -0.136, which is why the table has API names. Outside C (import coupling only, registered before running): +0.241 over size on 11 evaluable pairs (Go +0.395 on 5, Python +0.102 on 5, Java one library; Rust not evaluable). Surface change, curl OpenSSL 2020-06 to 2022-12: 31 API names added, 15 dropped; 90% of the added names were absent from the earlier source and 80% of the dropped names gone from the later one, which checks the diff's accuracy about what appeared and disappeared, not that each name is the library's: at least three dropped names (
SSL_IS_PROXY,SSL_CONN_CONFIG,SSL_SET_OPTION) are curl's own macros that share theSSL_prefix, so the looseSSL_*pattern counts them (documented as a limitation on the wiki page); the added names include the OpenSSL 1.1 object API. All exploratory; the research is in the temporal-crucible repository (docs/sensor-overhaul/sensors/library_surface.md).Class / Sibling gaps
Class: questions about a repository's dependencies answerable from the imports, includes and external calls a scan already stores, for any language that writes them. Handled here: library discovery in C-family, Python, Go, Java, Rust and JS/TS; coupled-file ranking; surface change between two scans; API-name matching for the 20 shipped C-family libraries; user and project overrides. Sibling gaps: (1) API names for Go, Python, Java, Rust and JS libraries: the scan records external calls there as bare names with no package, so names cannot be attributed; those languages use imports only (resolver work, not this command); (2) C++, Objective-C and Fortran probably have the same wrapper-header problem as C, untested; (3) discovery lists Rust workspace crates and unrecognised platform headers (
in.h) as libraries:disable = trueremoves them, parsingCargo.toml/go.modwould not need a guess but is a different input; (4) a prefix pattern also matches a repository's own macros or functions with that prefix (curl'sSSL_*macros): excluding names the repository defines needs the scan to store macro definitions, not done here; the weak units in the research (c-ares, glib, libarchive zlib) are reported, not tuned; (5) the navigation entries for wiki page 08-25 are in this PR (docs/wiki/index.md,mkdocs.yml).CI checklist
python tests/tools/audit_check.pypassestests/tools/test_libsurface.py(37 tests; breaking the JDK-package skip or the call-matching logic on purpose fails 1 and 3 of them), tree-wide guards (289 passed, 1 skipped),tests/toolsplustest_assess.py(4,810 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), time ratchet (4,890 tests, none over the limit)Files (hand-written, 7):
gitgalaxy/tools/sensors/libsurface.py,gitgalaxy/tools/sensors/library_table.py,gitgalaxy/cli.py,tests/tools/test_libsurface.py,docs/wiki/08-25-library-surface.md,docs/wiki/index.md,mkdocs.yml.Remaining slices
More table entries; Rust and the other wrapper-header languages need their own evidence first.
Lessons for agents
gitgalaxy/): name it as a module constant (XDG_CONFIG_ENV,DISABLE_KEY) aschronometerdoes for its env vars.cat > filewith no heredoc hangs the shell on stdin: write scratch files with the Write tool (.claude/rules/python-test-traps.md).🤖 Generated with Claude Code
https://claude.ai/code/session_018srRveGdV73aUiuqkipAic