Skip to content

brief: reach (16) and library (17) sections from the finished scan database; golden masters re-blessed (Part of #8534) - #8546

Merged
squid-protocol merged 1 commit into
mainfrom
sensors/brief-reach-libraries
Nov 16, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
sensors/brief-reach-libraries

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

This changes scan output: the LLM brief (<target>_galaxy_llm.md) gets two short sections, so both golden brief fixtures are re-blessed. After section 15 (function call resolution): 16. Reach (Who Depends On What) (the five most-called source files and the five most-included headers: gitgalaxy reach, wiki 08-24) and 17. Libraries (What The Repository Leans On) (the eight external libraries with the most files: gitgalaxy libsurface, wiki 08-25). They are read from the master database galaxyscope has just written, which now reaches generate_artifacts as scan_db; both sections are absent when the scan wrote no database or there is nothing to say, and a failure to read never stops the brief. No table, no column, no change to any other output. Follows #8532, #8535, #8544; tracking issue #8534.

What changed in scan output, and why it is safe

  • The only difference in the golden masters is 12. Scan Output Snapshots / LLM Brief in both fixtures: one 35-line insertion (sections 16 and 17) and nothing else moved (checked line by line against HEAD). crucible_check.py: both legs FAIL before the bless with exactly that one difference each, PASS after (also re-checked after the rebase onto current main).
  • The sections are deterministic: ordering is by count then path, the library list ignores the user's own library files (shipped table only), and no machine path appears.
  • scan_db is None when the scan wrote no database (--llm-only and the like), so those briefs are unchanged.

Sample, fastapi (a Python repository):

## 16. REACH (Who Depends On What)
| File | Caller files | Caller functions | One hop out |
| `fastapi/applications.py` | 560 (+10 possible) | 299 | 220 |
| `fastapi/exceptions.py` | 57 | 101 | 12 |
## 17. LIBRARIES (What The Repository Leans On)
| Library | Files | Sites | API names |
| inline_snapshot | 297 | 297 | 0 |
| pytest | 278 | 278 | 0 |
| pydantic | 232 | 246 | 0 |
| starlette | 44 | 82 | 0 |

and curl (C): openssl 19 files, 452 sites, 231 API names, c-ares 9 / 51 / 27, wolfssl 9 / 135 / 86.

A bug the gates caught, fixed here

tests/tools/test_cli_contract.py::test_a_clean_scan_exits_0_and_writes_the_documented_reports failed on the first full run: a clean scan left repo_galaxy_master.db-wal and -shm in its output directory. Cause: a read-only open of a database in WAL mode creates those sidecar files. The sections open the master database after the scan finishes writing it, so every scan would have left them. The sensors now open it through reach.open_scan_db: immutable when no -wal file is beside the database (nothing is mid-write; the writer's last close removes it), an ordinary read-only open otherwise (so a live write-ahead log is still read in full). This also stops the standalone gitgalaxy reach and libsurface from leaving files beside a user's database. Tests pin both cases (no sidecars after reading; a live -wal's rows are still seen).

Honest note: after the fix the CLI contract test passed in 25 of 25 loaded runs and in the gate's own environment, and the full affected gate passed on a rerun, but one earlier gate run after the fix reported the same two files once and I could not reproduce it. CI runs this exact test; I will read it.

Design choices in the libraries section

It is written for a model to read, so it favours a short list over a long one: a library in the shipped table (validated) is always listed; one only discovered is listed when an import names it (Python, Go, Java, Rust, JS); a C or C++ include never is unless it is in the table, because a directory or bare header is far more often a platform header the system-header list does not know (libuv shows gnu/, hurd/, vm/, TargetConditionals.h) than a dependency. The command itself still lists everything. Possible callers show beside the reach count as "(+N possible)".

Type of change

  • Other: scan output (LLM brief), recorder + engine plumbing; no parsing change

Class / Sibling gaps

Class: post-scan views the brief could carry from the finished master database. Handled here: reach and libraries. Sibling gaps: (1) the SARIF, SBOM and GPU outputs do not carry reach or libraries (the SBOM already lists dependencies from manifests); (2) the brief shows the top five or eight only, by design; the commands list everything; (3) a C or C++ dependency that is not in the shipped table does not appear in section 17 (adding it to the table is a one-line contribution); (4) delta (--incremental) scans read the same database and are not specially handled; (5) the sections do not yet appear in the architecture brief doc published on the generated branch until its next run.

CI checklist

  • python tests/tools/audit_check.py passes
  • python tests/tools/crucible_check.py: before the bless both legs differ only in the brief; after, both PASS (full precision and zero dependency)
  • python tests/tools/pr_gates.py --fast: lint, audits, secrets, xray, gen-docs, derived, workflows, gauntlet pass; affected passes (3,603 tests in one process, and 589 s on the gate rerun); tests/tools/test_cli_contract.py passes
  • tests/tools_recorders/test_brief_reach_libraries.py (6 tests: absent without a database, reach rows and the header count, libraries and the C filter, unreadable database never stops the brief, generate_artifacts wiring, section order), 2 new sidecar tests, test_llm_recorder.py, test_reach_sensor.py, test_libsurface.py pass
  • tests/tools/docs_read_by_tests.txt regenerated with change_classifier.py --write (it was already stale on main: cobolrt entries)

Lessons for agents

  • A read-only SQLite open (mode=ro) of a WAL-mode database creates -wal and -shm files beside it; anything that reads a scan's master database after the scan, or a user's, must open it immutable when no -wal file exists (reach.open_scan_db), or test_cli_contract.py::test_a_clean_scan_exits_0_and_writes_the_documented_reports fails on the extra files.
  • tests/tools/docs_read_by_tests.txt goes stale whenever main moves a tool or test that names a doc: after a rebase run python tests/tools/change_classifier.py --check, and --write when it says stale, before pushing (pr_gates derived gate).
  • A test that must write <target>_galaxy_llm.md should build the name in code: a literal X_galaxy_llm.md in a test is picked up as a doc the tests read.

🤖 Generated with Claude Code

https://claude.ai/code/session_018srRveGdV73aUiuqkipAic

…can database; golden masters re-blessed

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.

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 merged commit 7f3122e into main Nov 16, 2026
59 checks passed
@squid-protocol
squid-protocol deleted the sensors/brief-reach-libraries branch November 16, 2026 23:49
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