Skip to content

Go: multiple init() per package collapse onto one QN — bodies and registration edges silently dropped #1910

Closed

Description

@ilyabrykau-orca

Status: fix open — PR #1915 (file-stem+line #-suffix QNs for Go init, #495 pattern; stacked on #1913). Post-fix: init nodes 7 → 29, matching source exactly (source count: 29).

Version

codebase-memory-mcp 0.10.8 (also reproduced on a source build @ d706c33)

Platform

macOS (Apple Silicon)

Install channel

Built from source

Binary variant

standard

What happened, and what did you expect?

Go allows any number of func init() per package (several per file included); all run at program start. Every one gets the same QN (proj.pkg.init), so the upsert keeps one node per package and silently drops the rest with their bodies.

Measured: an event-source package registering each decoder in its own file's init() — 21 init functions collapsed into 1 node; repo-wide 29 in source, 7 in the graph. The registration topology (which decoder handles which event) is invisible; the surviving node's edges are a blend of merged bodies.

Reproduction

// a.go
package reg

var handlers = map[string]func(){}

func init() { handlers["a"] = handleA }

func handleA() {}
// b.go
package reg

func init() { handlers["b"] = handleB }

func handleB() {}

Actual: one node reg.init (a.go); b.go's body and its handleB edge gone or misattributed. Expected: two nodes.

Fix (existing #495 pattern)

Rust cfg twins already fold a #-suffix into the QN (rust_cfg_qualified_name); GoogleTest macros derive unique names (#1266). Same move: proj.pkg.init#a.go:L5, mirrored on the call-scope side. Nothing joins on the plain QN — calling init explicitly is illegal in Go — so no resolution path is affected.

Related: #1909, #1911 (same silent-upsert-collapse family); tracked in #1932.

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Activity

  1. added 5 commits that reference this issue on Aug 30, 2026
    4e03c2b
    0f2024c
    6aac10c
    27d4d34
    ac46c17
  2. added
    bugSomething isn't working
    priority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.
    on Sep 5, 2026
  3. DeusData commented on Oct 25, 2026

    @DeusData
    Owner

    Thank you for the multi-init fixture and measured recovery in #1915. The proposed identity change remains subject to review; I have no new verification to add. Sorry for the delay; this is waiting on maintainer follow-up, and I’ll follow up soon.

  4. DeusData commented on Oct 31, 2026

    @DeusData
    Owner

    Fixed on main by #1915 (merge commit 9faa3e5): multiple init() functions in one Go package now each get their own qualified name per file, so their bodies and registration edges are no longer dropped. After updating, please re-index the project once. Thank you, Ilya, for the report and the fix!

  5. added a commit that references this issue on Oct 31, 2026
    adff62e
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

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions