You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(extract): give Go build-constrained twin files distinct QNs
Go build-constrained twin files (//go:build lines, GOOS/GOARCH filename
suffixes) legally define the same symbols in one package. The indexer
ignored the constraints, so the graph upsert kept ONE node per QN by the
smallest-file-path rule: a 2-line stub beat the 63-line real
implementation and took all 25 inbound CALLS; a bpf2go GOARCH twin pair
lost 39 of 40 nodes; parse coverage stayed clean so nothing flagged it.
Fold the per-file build constraint tau into Go func/method QNs with the
same #-suffix move Rust cfg twins got in #495: tau is the compacted
//go:build expression when present, else the official GOOS/GOARCH
filename suffix (cbm_go_build_tau in helpers.c, computed once per file
in cbm_extract_file). The scope builder mirrors the def formula
(go_tau_scope_qn) so body calls in constrained files stay attributed.
Types and vars stay plain, keeping parent_class / DEFINES_METHOD joins
intact.
Two #-aware seams make the suffixed defs resolvable (both also close a
latent gap for Rust cfg twins, which already carry such QNs):
- cbm_registry_add indexes the simple name as the part before '#'
(identifiers cannot contain one), so callers keep resolving by name.
- The LSP registry's exact pkg.name lookup falls back to a SOLE
#-suffixed variant (lookup_func_sole_tau_variant) - the dominant
real-world shape is a constrained file with no in-tree twin, and its
callers must keep their lsp_direct/lsp_strategy_cross_file edges. Two
or more variants are genuinely ambiguous without the caller's build
configuration and fail closed; tau-aware preference for the caller's
own constraint is the declared follow-up. The pipeline's LSP-join
leaf gate learns the same rule.
Reproduce-first tests: extract_go_buildtag_tau_in_func_qns
(//go:build compaction, GOOS_GOARCH and _test filename forms, types
stay plain, unconstrained files carry no '#') and
pipeline_go_buildtag_twins_both_survive (RED on main:
count_nodes_named == 1, expected 2; plus the sole-variant caller edge
staying alive). 854 tests green across extraction/pipeline/registry/
lsp probes/go_lsp/parallel suites.
Part of #1911 (minimal PR: QN disambiguation; tau-aware same-module
resolution is the follow-up)
Signed-off-by: Ilya Brykau <ilya.brykau@orca.security>
0 commit comments