Skip to content

C import graph: <sys/types.h> resolves to an unrelated repo header (include/curl/types.h); Stage 1 ignores the include's directory #7827

Closed

Description

@squid-protocol

What's wrong. A system include such as #include <sys/types.h> gets an edge to a repository header that merely shares the basename. In curl 7.10.8 (2003), every file under ares/ that includes <sys/types.h> links to include/curl/types.h: 46 false edges out of 479 (import precision 90.4%; 99.6–100% on every other snapshot measured). It reproduces on current main (79b13e354).

Where. gitgalaxy/core/network_risk_sensor.py, Stage 1 of import resolution. When exactly one file matches the token's last segment, it's returned with no check that the token's path context (sys/) is a suffix of the candidate's path. #3544 added exactly that check, but gated on MODULE_PATH_MIRROR_LANGS, so C-family includes skip it. Stage 2 already compares path context when there are several candidates; the single-candidate case is the gap.

Repro.

git -C <curl clone> worktree add /tmp/c7108 curl-7_10_8
galaxyscope /tmp/c7108 --db-only
sqlite3 <db> "select count(*) from edge_data e join file_data s on s.id=e.src_file_id join file_data d on d.id=e.dst_file_id where d.file_path='include/curl/types.h' and s.file_path like 'ares/%'"

ares/ares_init.c:18 is #include <sys/types.h>.

Suggested fix shape. For languages with include_names_file_literally, a token containing / names a file only if the candidate's path ends with that token's path. This is #3544's rule, applied to C/C++/ObjC. A bare "types.h" keeps today's behaviour.

Impact. False in-degree on the matched header, so PageRank, blast radius and the centrality measures are inflated for it. It shows up on any C repo whose headers share names with system headers (types.h, time.h, string.h, signal.h, …).

How it was found. temporal-crucible validated the engine's C function, include and call extraction on curl and nDPI snapshots (2003–2026), running gitgalaxy's own import_graph_accuracy.score_group against each snapshot. Write-up: squid-protocol/temporal-crucible branch validate/engine-c, docs/engine_validation.md.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Nov 5, 2026
  2. squid-protocol commented on Nov 5, 2026

    @squid-protocol
    OwnerAuthor

    A second repo confirms this, and a counterexample constrains the fix (openssl, same validation harness).

    Confirmed again. In openssl 3.5.0, <sys/time.h> resolves to the repo's include/internal/time.h: 15 edges. Examples are crypto/bio/bio_sock.c:29 and include/openssl/e_ostime.h:35. It's the same mechanism: the token's sys/ isn't checked against the lone same-named candidate.

    But a strict "the include's directory must be a suffix of the repo path" rule would break correct edges:

    • OpenSSL 1.0.2: include/openssl/ is not in git. The build creates it (make links, util/mklink.pl) as links to crypto/<x>/<x>.h. The engine's 2,825 edges such as apps/apps.c <openssl/rsa.h> → crypto/rsa/rsa.h are what the compiler sees, and the import-accuracy reference wrongly scores all of them false (precision 25.5%).
    • 1.1.1 / 3.5.0: <openssl/x.h> → include/openssl/x.h.in (128 and 1,023 edges). The real header is generated from that template, so the edge is defensible.

    Suggested narrower rule. A token whose leading directory is a standard system include directory (sys/, netinet/, arpa/, net/, linux/, bits/, machine/, …) resolves only to a repo file with exactly that relative path. Other tokens keep today's basename fallback.

    That removes curl's <sys/types.h> → include/curl/types.h and openssl's <sys/time.h> → include/internal/time.h, and keeps openssl's build-linked and generated headers. It might also be worth teaching import_graph_accuracy that a .h.in template, or a basename match whose token directory is absent from the tree, isn't a plain false positive.

    🤖 Generated with Claude Code

  3. squid-protocol commented on Nov 12, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-12T15:55Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  4. squid-protocol commented on Nov 12, 2026

    @squid-protocol
    OwnerAuthor

    Acceptance met: C/C++ fixed by #8161, Objective-C and the extra system prefixes (machine/, os/, netinet6/, net80211/) by #8365. A repo that owns the prefixed path keeps its edge; a bare "types.h" keeps the basename fallback. The scoring-only follow-up (.h.in / build-linked headers in import_graph_accuracy) is outside this issue.

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

    bugclaim:melek

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions