Repository navigation
Description
Residue of #2540. Found while giving verdicts to keyword-rosetta's six unexplained cells
(keyword-rosetta#100); measured at engine 7fa0e41, corpus f473bb1, full precision.
Symptom
data/haskell/{a,b,c}.hs score risk_tech_debt 97.07 / 97.07 / 100.00 where java, rust and
swift — same stratum, same four-file layout, same planted debt — read 0.00 / 0.00 / 81.76.
The whole gap is one input: haskell's imported files keep unreferenced_by_name at 3, where
every other language's are wiped to 0. _calc_tech_debt returns 0.0 only when planted_debt,
fragile_debt, orphans and duplicates are all zero; with three orphans surviving,
slop_stress = 3 * 2.0 = 6 over a ~12-line mass and the sigmoid saturates.
Two dependency resolvers disagree
The wipe is the Contextual Baseline Fix (galaxyscope.py L2224-2262), gated solely on
self.popularity_scores.get(rel_path, 0) > 0. Instrumented at that line:
| language | CBF popularity_scores |
recorded popularity column |
|---|---|---|
| haskell a/b/c/main | 0 / 0 / 0 / 0 | 1 / 1 / 1 / 0 |
| java a/b/c/main | 1 / 1 / 1 / 0 | 1 / 1 / 1 / 0 |
Every column a reviewer can see says the chain resolved — popularity 1, and
pagerank_score 0.192525 / 0.267714 / 0.331625 / 0.104068, identical to java's — because
network_risk_sensor.py:441 overwrites telemetry["popularity"] with the networkx
in-degree, which resolves import B to b.hs perfectly well. The one consumer that decides
whether the debt is wiped reads the other, weaker resolver. That is why this was invisible to
an input audit: the visible inputs are all on the median.
Root cause
_resolve_dependency_graph's stem fallback, galaxyscope.py:1947:
if guess_stem in stem_to_paths and guess_stem not in stop_stems and len(guess_stem) >= 3:Haskell module names must be capitalised, so import B yields clean_path = "B". That misses
the case-sensitive O(1) suffix-map fast path (the key is "b"), falls through to the fallback,
where Path("B").stem.lower() is "b" and len("b") >= 3 is False. Every other corpus
language writes its import in lower case (import b;, use b;, (import b), . ./b.sh) and
is caught by the fast path, where length is never tested.
So the fast path's case sensitivity and the fallback's length guard are jointly necessary —
neither is sufficient alone.
Micro-repro
Two 2-file haskell repos, identical bodies, scanned for real. Only the module/file name length
differs:
| CBF popularity | state_unreferenced |
risk_tech_debt |
|
|---|---|---|---|
module B in b.hs, imported as import B |
0 | 1 | 37.7541 |
module Bbb in bbb.hs, imported as import Bbb |
1 | 0 | 0.0 |
The uppercase import resolves fine at three characters, which isolates the length guard as the
discriminator.
Why #2540 did not cover it
#2540 added exactly this case-folded fallback for fortran/cobol/haskell and closed against the
fortran corpus — whose USE targets had been lowercased as the workaround (ledger
fortran-use-case-insensitive-dag). The fast path therefore handled every fortran case and the
length guard was never exercised.
Suggested fix
Either case-fold the suffix-map lookup for the languages #2540 already named, or drop the length
guard when the stem resolves uniquely. The deeper fix is for the Contextual Baseline Fix to read
the same graph network_risk_sensor already builds, rather than a second resolver that can
disagree with every column the result is audited by.
Corpus side
Not corpus-fixable without breaking the identical-shell layout every language shares (the module
would have to be renamed to 3+ characters). Baked in meanwhile per keyword-rosetta's GATING.md,
ledgered as haskell-module-name-invisible-to-popularity-tally.
One correction this forces upstream of itself: haskell is not the control proving
api_declared_orphans suppresses correctly (recorded in data/haskell/expected_signals.json
on 2026-09-06). Its api_declared_orphans does read 3, but the fix that would consume it never
runs — a genuine suppression still wipes unreferenced_by_name to 0 (step 2 of the fix is
unconditional), and haskell's stays at 3. Both paths give api_orphan_credit 0, which is why
the distinction was invisible from that column alone.
🤖 Generated with Claude Code
Activity
Contextual Baseline Fix: case-fold the resolver for case-insensitive-…