Repository navigation
Description
Summary
galaxyscope is non-deterministic for the whole-repo symbol-reference signal: scanning the same file blob with identical documented inputs can persist different state_unreferenced (→ risk_tech_debt) and risk_api_exposure values across runs. Surfaced by the temporal-crucible rung-6 instrument-control audit (epic #2982); it sets the spillover-tail max there and is a correctness bug in the risk vector.
Reproduction (observed)
File lib/curlx/base64.c in curl, scanned at two commit pairs where the file blob is byte-identical on both sides (same 40-hex blob hash), and every documented input to _calc_api_exposure/_calc_tech_debt is identical across the two scans:
| inputs (identical both scans) | persisted output (differs!) |
|---|---|
arch_api 3=3, def_encapsulation 3=3, total_loc 286=286, popularity 0=0, pagerank_score 0.000346=0.000346 |
risk_api_exposure 2.4495 → 13.9454 |
good_debt=0, bad_debt=0 both |
risk_tech_debt 41.2713 → 0.0 |
The smoking gun: file_data.state_unreferenced reads 3 in one scan and 0 in the other, while a parallel tracking column raw_state_unreferenced correctly holds 3 in both. Since _calc_api_exposure(raw_signals, total_loc, popularity) is a pure function of arch_api/def_encapsulation/total_loc/popularity — all byte-identical — the output cannot legitimately differ. Reproduced on two unrelated commit pairs on this file.
Likely cause
state_unreferenced (unreferenced_by_name, "is this symbol referenced anywhere in the repo") is a whole-repo / cross-file computation — exactly the kind of shared state a multi-worker scan can corrupt under a race. A live galaxyscope --db-only run with ~10–12 workers was active during the audit. Two hypotheses to distinguish:
- Multiprocessing race in the symbol-reference index (shared cache / ordering).
#ifdef-gated static-pass variance — curl builds base64 support conditionally per TLS backend; if the static pass resolves a different conditional branch depending on worker/thread scheduling,arch_api/state_unreferencedcould vary without a shared-cache bug.
How to confirm
Re-scan just the two commit pairs single-worker (--workers 1 or equivalent) and diff state_unreferenced / risk_api_exposure for lib/curlx/base64.c against the captured values. If single-worker is stable (3/3, risk_tech_debt≈41.27 both), it's the race (1); if it still varies single-threaded, it's branch-resolution variance (2).
Pointers
_calc_api_exposure/_calc_tech_debtingitgalaxy/metrics/signal_processor.py(pure-function expectation that's being violated).- Full audit + exact SHAs: temporal-crucible
docs/instrument_controls_forensics.md(PR Forensics: +47.1 outlier & spillover max are instrument artifacts (#5) temporal-crucible#10). - Epic: Epic: exposure deltas vs independently identified events — risk over Git history (Rung 6; the validation.md harness) #2982 (rung-6 validation).
Why it matters
raw_state_unreferenced holding the correct value while state_unreferenced drifts means the persisted risk vector is corrupted post-extraction. Any delta/ranking over these columns (and the whole score-contract program) inherits the nondeterminism; raw_state_unreferenced may be the trustworthy source to reconcile against.
Activity
squid-protocol commentedon Sep 13, 2026
Diagnosis update — this is NOT a multi-worker race. Ran the single-worker confirmation (scanned
2dfe421a6/e1f65937a9with one worker); the child'sstate_unreferenced=0/risk_api_exposure=13.9454/risk_tech_debt=0.0reproduce deterministically single-threaded (4/4 runs stable). Hypothesis (1) is disproven.Real cause: a cross-language import edge. The child commit added
import base64(Python stdlib) totests/http/testenv/certs.py. The resolver's FAST PATH 1 exact-matched the extensionless token'base64'against the extensionless suffix key — which lumps every same-stemmed file across languages — and FAST PATH 1 had no language guard (the #2684 stem fallback does). So Python'simport base64credited curl's Clib/curlx/base64.cwithpopularity=1, which fired the Contextual Baseline Fix (unreferenced_by_name3→0,tech_debt→0) and_calc_api_exposure's network multiplier (2.4495→13.9454)._calc_api_exposurewas pure all along — it just received apopularitythe recorded column didn't reflect.Fix in #3001: guard FAST PATH 1 (and the fallback's extensionless case) by the importing file's language. base64.c now reports
state_unreferenced=3,risk_api_exposure=2.4495,risk_tech_debt=41.2713identically across both commit pairs.fix(#2988): deterministic typosquat anchor selection + regen golden m…
fix(#2988): cross-language import edge corrupts popularity / risk vec…