Repository navigation
fix(#2988): cross-language import edge corrupts popularity / risk vectors (not a race) - #3001
Merged
Merged
Conversation
…risk vectors `state_unreferenced` (→ risk_tech_debt) and risk_api_exposure appeared non-deterministic on curl's lib/curlx/base64.c across byte-identical scans. Root cause is NOT a multi-worker race (reproduces deterministically single-worker): a bare `import base64` (Python stdlib) in tests/http/testenv/certs.py resolved to curl's C `lib/curlx/base64.c` via the resolver's FAST PATH 1 — the extensionless token "base64" exact-matches the extensionless suffix key, which lumps every same-stemmed file across languages. FAST PATH 1 (unlike the #2684 stem fallback) had no language guard, so the spurious Python→C edge gave base64.c popularity=1, firing the Contextual Baseline Fix (wiping unreferenced_by_name 3→0, tech_debt→0) and flipping _calc_api_exposure's network multiplier (2.4495→13.9454). - galaxyscope: guard FAST PATH 1 by the IMPORTING file's extension via the existing _extensions_can_name_the_same_file (#2684), and extend the stem fallback's guard to fall back to the importer extension when the token itself is extensionless (bare module imports carry no extension, so the token-ext guard alone can't catch the cross-language case). A .py import can no longer credit a .c file. - galaxyscope: add GALAXYSCOPE_MAX_WORKERS env override (pin worker count / force serial extraction) — used to confirm this is deterministic, not a race. - tests: regression test (Python `import base64` must not credit C base64.c; same-language bare import still resolves); allowlist the new env var in the dead-key auditor (os.environ.get, not a repo-produced dict). Verified: base64.c now reports state_unreferenced=3, risk_api_exposure=2.4495, risk_tech_debt=41.2713 identically across both curl commit pairs. Full suite: 8798 passed. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HqtNR72fsoL5g57yBBYGX3
squid-protocol
marked this pull request as draft
September 13, 2026 20:12
Contributor
…asters Follow-on to the cross-language resolver fix. Two things surfaced by regenerating the Golden Crucible baseline: 1. Typosquat anchor selection was non-deterministic: the candidate anchors were iterated as a set and the loop breaks on the first within-threshold match, so a token equidistant from two anchors recorded "mimics <anchor>" differently across runs (e.g. 'string:' -> 'string' vs 'strings'). Iterate sorted(candidates) so the first qualifying anchor is stable. (Same determinism class as the main fix; it became reachable because the resolver fix correctly reclassifies some previously-internal imports as external, so more tokens reach the typosquat check -- typosquat_hits 11 -> 13 on the crucible corpus.) 2. Regenerated tests/golden_master_audit.json and tests/golden_master_zero_dep_audit.json against the fixed engine. The drift is the intended effect of removing spurious cross-language popularity edges: api_exposure drops and tech_debt rises in lockstep across the same-stemmed cross-language corpus (e.g. rust/syn api 18.71->11.77 / debt 48.54->51.36). Both legs regenerated in their own venv with GITGALAXY_DISABLE_GIT_HISTORY=1 (matches the test); both pass deterministically (2/2). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HqtNR72fsoL5g57yBBYGX3
squid-protocol
marked this pull request as ready for review
September 13, 2026 20:40
4 tasks
squid-protocol
added a commit
that referenced
this pull request
Oct 4, 2026
…porter's language (part of #4265) The #3199 language rule for source-member imports (COBOL COPY, PL/I %INCLUDE, HLASM COPY) ran only when several files matched. A single match in another language was taken. Examples: COBOL `COPY A` -> A.hlasm (che4z lsp fixtures), DSF PL/I `%INCLUDE DFHBMSCA` -> carddemo's COBOL copybook, and zopeneditor PSAM1LIB.pli -> COBOL DATETIME.cpy / REPTTOTL.cpy. This is the same class as #3001's Python `import base64` -> base64.c. A BMS mapset stays a valid COBOL member source (new language key `source_members_generated_from`). Its symbolic map is a COBOL copybook generated from it, so `COPY CUSTMS` may name CUSTMS.bms when the mapset is the only CUSTMS. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FNWHcUSn5p7eMxFTsB5rFo
squid-protocol
added a commit
that referenced
this pull request
Oct 4, 2026
…porter's language (part of #4265) (#4366) The #3199 language rule for source-member imports (COBOL COPY, PL/I %INCLUDE, HLASM COPY) ran only when several files matched. A single match in another language was taken. Examples: COBOL `COPY A` -> A.hlasm (che4z lsp fixtures), DSF PL/I `%INCLUDE DFHBMSCA` -> carddemo's COBOL copybook, and zopeneditor PSAM1LIB.pli -> COBOL DATETIME.cpy / REPTTOTL.cpy. This is the same class as #3001's Python `import base64` -> base64.c. A BMS mapset stays a valid COBOL member source (new language key `source_members_generated_from`). Its symbolic map is a COBOL copybook generated from it, so `COPY CUSTMS` may name CUSTMS.bms when the mapset is the only CUSTMS. Claude-Session: https://claude.ai/code/session_01FNWHcUSn5p7eMxFTsB5rFo Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Closes #2988.
The issue's hypothesis was wrong — it's not a multi-worker race
I ran the confirmation the issue asked for (single-worker re-scan of
2dfe421a6/e1f65937a9) and the "corrupted" child values reproduce deterministically with one worker (4/4 runs stable):state_unrefrisk_api_exposurerisk_tech_debtNo concurrency involved.
Actual root cause: a cross-language import edge
_calc_api_exposureis pure over{api, encapsulation, total_loc, popularity}; the math shows the only differing input ispopularity(parent hit thepopularity==0branch → ×0.2; child hitpopularity==1→ ×1.14). That samepopularity>0also fires the Contextual Baseline Fix that wipesstate_unreferenced3→0 /tech_debt→0.base64.cis a.cfile — nothing#includes it. Its spuriouspopularity=1in the child comes fromtests/http/testenv/certs.py, which the child commit gave animport base64(Python stdlib). 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, unlike the #2684 stem fallback, had no language guard. So Python'simport base64credited curl's Clib/curlx/base64.c.(base64 is referenced by 22 files in both commits; the diff touches only
wolfssl/vquic-tls/tests — the flip was purely the newly-added Pythonimport base64.)Fix
_extensions_can_name_the_same_file(galaxyscope popularity tally: a bare filename import raises popularity on every same-stemmed file in the repo, unscoped by language or directory (#2540's shape, in the tally instead of the DAG) #2684) — a.pyimport can't credit a.c/.hfile.GALAXYSCOPE_MAX_WORKERSenv override (pin workers / force serial) — the lever used to prove determinism.Verified
base64.cnow reportsstate_unreferenced=3, risk_api_exposure=2.4495, risk_tech_debt=41.2713identically across both commit pairs — the "impossible delta" is gone.test_resolver_rejects_cross_language_extensionless_import) passes; full suite 8798 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_01HqtNR72fsoL5g57yBBYGX3
Follow-on (golden crucible)
Regenerating the Golden Crucible baseline surfaced a second determinism bug: typosquat anchor selection iterated a
set, so a token equidistant from two anchors recordedmimics <anchor>differently per run (string:→stringvsstrings). Fixed by iteratingsorted(candidates). Both golden masters (full-precision + zero-dependency) regenerated against the fixed engine (api_exposure↓ / tech_debt↑ from removing spurious cross-language edges;typosquat_hits11→13 as previously-masked externals now reach the check). Both legs pass deterministically (2/2 local runs each).