Skip to content

network_risk_sensor: dependency resolver drops relative imports that carry an extension (./b.sh -> key 'sh'), zeroing every network metric for shell/powershell/yaml/javascript #2668

Closed

Description

@squid-protocol

Summary

NetworkRiskSensor._resolve_target (gitgalaxy/core/network_risk_sensor.py, ~L122) rewrites every
captured import token with target_token.replace(".", "/") before taking its last path
component. A relative import that carries its file extension — ./b.sh, ./b.ps1, ./b.yml,
'./c.js' — becomes //b/sh, so the Stage-1b fallback key is the extension (sh), nothing
resolves, and build_dependency_graph adds no edge. The file's dependency_links still reports the
capture count (it is len(raw_imports)), so the symptom is "links present, graph empty".

Found by the keyword-rosetta bias report (#2560): shell, powershell, yaml and javascript all record
dependency_links = 3 and popularity = betweenness = closeness = producer_ratio = 0, with pagerank
at the uniform 1/N of an edgeless graph (0.2 for 5 files; javascript 0.1667 because package.json
is a 6th node).

Evidence (real capture regexes, real corpus filenames, resolver driven in-process)

language planted import captured token bare_component resolved
shell . ./b.sh ./b.sh sh None
powershell . ./b.ps1 ./b.ps1 ps1 None
yaml uses: ./b.yml ./b.yml yml None
javascript import c from './c.js' ./c.js js None
typescript (control) import { c } from './c' ./c c c.ts via stem key
c / markdown (control) #include "b.c" / [b](b.md) b.c / b.md — Stage-1 exact name key

The two controls isolate the cause: ./ alone survives (dot-stripping leaves the stem) and an
extension alone survives (exact filename key), only ./ plus an extension is fatal.

Impact

Any real repository using relative imports with extensions — every ESM codebase (import x from './x.js'), every dot-sourced PowerShell module, every shell library sourced by path, every GitHub
Actions workflow calling a local reusable workflow — scores an empty dependency graph: no
popularity, no blast radius, no orphan→api conversion, producer_ratio 0. That silently
under-reports API exposure and over-reports orphaned logic on exactly the ecosystems where the
call graph matters most.

Fix shape

Normalise the token before the lookup, the way galaxyscope.py's external-import tally
(~L1870) already does: strip a leading ./ / ../, and skip the .→/ substitution when the
trailing segment is a known extension (ext_tally / the registry's extension set). Then Stage 1
hits b.sh as a filename key and Stage 1b hits b as a stem key, in that order.

Tests: a strict test with the four failing token forms plus the typescript and c controls, asserting
one resolved edge each; keep #2540's case-folded path unchanged.

Blast radius

Golden masters will gain edges on every language-crucible repo with extension-carrying relative
imports (javascript/typescript/shell/powershell folders at least). Expect graph-only movement:
popularity, blast radius, betweenness/closeness, api via orphan conversion, and the risk scores
downstream of those. No signal counts should move; the scoped-diff check should show nothing in
struct_* columns.

Companion corpus work: keyword-rosetta rebless for the four languages; m4 and yacc stay in the
no-dependency-capture-languages ledger entry until they get a _dependency_capture rule
(separate, #2652 shape).

Activity

  1. added
    bug
    core-engine
    metrics
    on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginemetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions