Skip to content

test(#4109): fold the scan DB's function rows and import graph into the golden master - #4119

Merged
squid-protocol merged 2 commits into
mainfrom
fix/4109-golden-db-snapshot
Oct 2, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/4109-golden-db-snapshot

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #4109: the DB slice, the largest gap. SARIF, SBOM, graph SQLite, GPU JSON and the LLM brief stay open on the issue.

Problem

The golden master snapshotted only <repo>_galaxy_audit.json. Everything the engine computes per function lives only in <repo>_galaxy_master.db (archetype, z-score, call list, fan-in/out, PageRank, usage status), and so does the resolved import graph (edge_data). None of it was regression-tested on the corpus. For example, two functions swapping archetypes inside one file left the per-file mix unchanged, so the golden diff showed nothing.

What this adds

tests/golden_db_snapshot.py folds a canonical slice of the DB into the audit dict as a new per-file section, 11. Scan DB Snapshot:

Sub-key (one fixture file each) Source
Function Archetype, Function Z-Score, Calls Out To, Fan In, Fan Out, PageRank, Usage Status function_data, keyed "<func>@<start_line>"
Import Edges edge_data, as sorted "<kind>:<dst path>"
  • Floats are rounded to 6 places. Ids and the mode-dependent token_mass are excluded, so the slice is byte-identical in full-precision and zero-dependency mode (verified).
  • No new fixture format. golden_store already splits every per-file sub-key into its own part file, so the slice inherits the existing toolchain unchanged: deep_compare diffs it, update_golden_master.py blesses it, and crucible_check.py checks it.
  • One integration point. golden_diff.load_and_sanitize attaches the slice whenever a fresh audit JSON has its sibling *_master.db. Every reader of a fresh scan therefore sees the fixture's shape: the golden test, the bless, bless_scope, scope_check and rebase_rebless. Fixture directories never get it attached twice.

Golden master

  • Blessed against crucible v1.6.0: 2,084 files, 45,550 functions, 2,506 import edges.
  • That's 8 new part files, ~17 MB per fixture, against ~42 MB of existing fixture each. This is a real cost; calls_out_to is the largest part at 4.7 MB.
  • No existing part changed.
  • crucible_check.py passes in both modes.

Tests

  • tests/test_golden_db_snapshot.py builds a synthetic DB and checks:
    • rows, keys and exact name+line collisions;
    • rounding;
    • edge rendering;
    • that token mass is excluded;
    • the sibling-DB lookup;
    • that load_and_sanitize attaches the slice to a fresh scan and never to a fixture directory.
  • test_golden_store canonical-bytes check: green. audit_check all clear; Python 3.9 compiles.

Merge order

#4113 changes the function population, but this slice reads function_data, which #4113 doesn't touch, so they don't interact. If another PR re-blesses first, re-run crucible_check.py --update --yes here (or rebase_rebless.py).

🤖 Generated with Claude Code

…he golden master

The golden master snapshotted only <repo>_galaxy_audit.json. What the engine
computes per FUNCTION lives only in <repo>_galaxy_master.db -- archetype,
z-score, call list, fan-in/out, PageRank, usage status -- and the resolved
import graph is in edge_data; none of it was regression-tested on the corpus.
Two functions swapping archetypes inside one file was invisible.

tests/golden_db_snapshot.py folds a canonical slice of the DB into the audit
dict as a new per-file section, "11. Scan DB Snapshot" (rows keyed
"<func>@<line>", floats rounded, ids and mode-dependent token mass excluded).
golden_store already splits each per-file sub-key into its own part file, so
the slice inherits the whole toolchain unchanged: deep_compare diffs it,
update_golden_master blesses it, crucible_check checks it.
golden_diff.load_and_sanitize attaches it whenever a fresh audit JSON has its
sibling *_master.db, so every reader of a fresh scan (the golden test, the
bless, bless_scope, scope_check, rebase_rebless) sees the fixture's shape.

Blessed: 2,084 files, 45,550 functions, 2,506 import edges; 8 new part files,
~17 MB per fixture; byte-identical in both modes. No existing part changed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@squid-protocol squid-protocol added data-integrity Issues relating to RAM state or SQLite database fidelity testing Unit, integration, and E2E pipeline verification labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit c85062e into main Oct 2, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the fix/4109-golden-db-snapshot branch October 2, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-integrity Issues relating to RAM state or SQLite database fidelity testing Unit, integration, and E2E pipeline verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant