Skip to content

_dependency_capture reads comments and docstrings: example imports become real edges (Dart, Perl, TS, Python) #3600

Closed

Description

@squid-protocol

Problem

galaxyscope runs each language's _dependency_capture over the raw file, comments included, so an import written in documentation becomes an edge:

language example effect
Dart /// import "package:http/http.dart"; in base_response.dart 5 false edges on dart-lang/http
Perl # ... (no warning will be issued) in ExifTool.pm a token warning, now the one false typosquat alert (warning mimics warnings, #3589)
TypeScript // import { metabench } from "./metabench.js"; in zod's object-setup.ts 1 false edge
Python from fastapi import BackgroundTasks inside a usage docstring in fastapi/background.py false edges to fastapi/__init__.py

Why it isn't simply code_stream

PRISM's code_stream strips comments but also blanks string literals. Most import paths are string literals ('package:x/y.dart', "./a.js", require('x')), so capturing against it would lose them.

Fix direction

Capture against a stream with comments and docstrings removed but string literals kept. PRISM already locates both. One option: derive it from positional_comment_stream, blanking comment spans to whitespace (same length and line numbers) in the raw buffer. Python docstrings are string literals by syntax, so they need PRISM's doc-surface classification rather than the string shield.

Measure the effect with import_graph_accuracy.py (all 20 languages) plus the typosquat and imports_unknown totals in the golden masters.

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-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions