Repository navigation
feat/issue-46: Go ids use the bare member name; artifact discovery and init fixes - #55
Merged
Merged
Conversation
This was referenced Nov 29, 2026
Closed
Closed
Spec from the design loop: types <module>/<Type>, methods <module>/<Type>/<Method>, functions <module>/<Name>, closures keep closure_N, external ids <app>/@external/<import-path>/<Type>/<Member>, Neo4j signature from the JSON field. Follows codeanalyzer-typescript idFromSig and codeanalyzer-python child_id.
…on convention) Type <module>/<Type>, method <module>/<Type>/<Method>, function <module>/<Name>, closure <enclosing>/closure_N; the package import path is dropped (the member is the signature part after its last dot). External ids <app>/@external/<import-path>/<Type>/<Member>. Type nodes gain a signature field (full import-qualified name) so the Neo4j :GoType signature no longer depends on the id. Projector copies signature from the JSON field. Refs #46
Remove the fID and pkg constants left unused by the bare-member id expectations; golangci-lint's unused check failed CI on them. Refs #46
eval_e2e.sh runs cango -a 2 on an app, pushes the Neo4j projection live, and checks analysis.json and the loaded graph (app-scoped GoCanNode rows plus :Package nodes). EAGER=1 reloads: the push runs with --eager, purging the application's subgraph first.
…roject EAGER_FLAG is a plain string, since an empty array trips set -u on macOS bash 3.2. The default cango build goes to the temp dir, not the project, so the binary is not captured as an artifact.
Skips the Neo4j push and the graph check, so no password or running database is needed. The build and the analysis.json check still run.
A method declared in another file than its receiver type now gets an id under the
declaring module: <declaring-module>/<Type>/<Method>. The node stays in the receiver's
callables{}; source_file is kept; Neo4j adds GO_DECLARES from the declaring module.
Refs #46
A method declared in a file other than its receiver type now nests under that file's
module: <declaring-module>/<Type>/<Method>. The JSON node stays in the receiver type's
callables{}, and source_file is kept. The Neo4j projector adds GO_DECLARES from the
declaring module to the method, beside GO_HAS_METHOD. 22 frontend methods change, e.g.
handlers.go/frontendServer/logoutHandler (was main.go/frontendServer/logoutHandler).
Refs #46
Additive v2 field with the same value as application_name, which is kept (renaming a shared field is forbidden). Neo4j :GoApplication gets the same name property. Spec: docs/design/specs/v2-application-name-field.md
Additive v2 field with the same value as application_name, which is kept. The Neo4j :GoApplication node carries the same name property. Spec: docs/design/specs/v2-application-name-field.md Refs #50
Additive top-level keys next to span on Import, Parameter, Callable, Type, Field and BodyNode, for parity with codeanalyzer-python. No code_start_line. Neo4j nodes carry the same properties beside span_json. Spec: docs/design/specs/v2-span-lines.md
Top-level start_line and end_line next to span on Import, Parameter, Callable, Type, Field and BodyNode (equal to span.start[0] and span.end[0]). Neo4j nodes carry the same properties beside span_json; the synthetic body nodes omit them. Spec: docs/design/specs/v2-span-lines.md Refs #51
The module gains the two keys, equal to its whole-file span, so the JSON and Neo4j modules match. Spec amended: docs/design/specs/v2-span-lines.md. Refs #51
A file may declare any number of func init(), and all share the signature "<pkgpath>.init". The symbol table keyed functions by signature, so the second init overwrote the first. The first init's body, its call sites and its call-graph edges were then missing from the analysis, with no warning. The second and later same-signature functions in a file now get a ":N" suffix (N = 2, 3, ...). That gives each init its own map key, its own can:// id (init, init:2, ...), and its own call-graph source. The first init keeps the bare name, so the ids of every file with one init are unchanged. A colon cannot appear in a Go identifier and no call site can name an init, so the suffix collides with nothing. Signature is therefore no longer exactly signatureOf() for the duplicate inits. That is a visible schema change and is recorded in CLAUDE.md. Adds TestInit_EveryInitSurvivesWithDistinctID, which fails on the old code (2 init callables instead of 3) and passes on the fix. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
…covery filepath.WalkDir does not follow a symlink at its root. It lstats the root and sees one non-directory entry, so a project reached through a symlink (a checkout under ~/work linked into a workspace, for example) produced an empty application.artifacts. The dependencies were still parsed through the link, so every dependency's declared_in named an artifact that was never emitted, and the Neo4j DECLARES_DEPENDENCY and LOCKS edges that MATCH on those ids were dropped without a warning. The same bug disabled the self-exclusion. A symlinked --output or --cache path was compared against walked paths that used the real location, so a previous run's analysis.json inside the project was captured as an artifact. Discover now resolves the root, OutputDir and CacheDir through symlinks before the walk. resolveDir handles a path that does not exist yet (an output directory created later) by resolving its longest existing ancestor. Any resolution error other than "does not exist" is now returned, where absOrEmpty used to return "" and silently disable the exclusion. That is the fail-closed choice. Symlinks inside the tree are still not followed, so discovery cannot leave the project root. A probe with an in-tree link to a file outside the project confirms the outside file is not captured. Tests: TestDiscover_SymlinkedRootMatchesRealRoot fails on the old code (no artifacts), TestDiscover_SymlinkedOutputDirIsExcluded fails on the old code (analysis.json captured), and TestResolveDir_MissingTailIsKept covers the not-yet-created output path. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
A method declared in b.go on a type in a.go was projected as owned by a.go: its node and body rows took the receiver module's owner. The lazy push upserts a module's rows only when that module's content_hash changes, and the hash is the file's own content. So editing only b.go left a.go's hash alone, the method was never re-upserted, and the graph kept the old span and body. A method added to b.go was never upserted at all. Its GO_HAS_METHOD and GO_DECLARES MERGEs then matched no node and were dropped silently. The owner is now the declaring file, which matches the method's id prefix. The node id is unchanged, and so are the JSON and the edges. Only the owning module moves, so the purge-by-prefix and the content-hash diff now agree about every row. The change-detection comparison moved out of changedModules into the pure changedAgainst, so the lazy-push selection is testable without a database. Tests run the real symbol-table builder and emitter on real source and project each version. They fail on the old projector and pass on the fix: - TestLazyPush_EditingDeclaringFileUpsertsCrossFileMethod - TestLazyPush_NewCrossFileMethodIsUpserted (also checks both edge endpoints) - TestLazyPush_OwnerIsIdPrefixForEveryRow (the invariant the fix relies on) Not verified against a live Neo4j: the local instance has a password I do not have, so the integration test (neo4j_it tag) was not run. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
…s; hash in constant memory Item 3. One unreadable directory or file aborted the whole analysis. WalkDir's error and readArtifact's ReadFile error were both returned, so Analyze failed with "repository layer: artifact discovery: ...", and no analysis.json was written, although the Go analysis had succeeded. A file that vanished between the walk and the read had the same effect. Now an entry that cannot be listed, stat'ed, opened or read is skipped with a warning that names it. The root stays fatal: without it there is nothing to analyze. go.mod and go.sum failures other than "does not exist" also warn, where they used to drop the dependencies or the locked versions silently. Item 5. Every non-Go file was read whole with os.ReadFile, only to hash it and sniff it for binary. A 1 GB binary in the tree peaked at 1.09 GB resident; the same tree without it peaked at 27 MB. Discovery now streams each file once through sniff, which hashes it and decides binary-ness in constant memory. Its answers equal the whole-file ones: binary means a NUL byte or invalid UTF-8 anywhere, and a rune split across two chunks is validated correctly. The 1 GB tree now peaks at 27.8 MB. Text is read a second time, and only with --artifact-text. That second read must hash to the first pass's hash, or the file is skipped with a warning, so captured source always matches the recorded hash. Security. readArtifact opens the file and checks that it is the file the walk recorded (os.SameFile, and a regular file). A path swapped for a symlink or a device after the walk is refused, not read. The walk still never follows a symlink inside the tree. Behavior change. The name rules (Dockerfile*, requirements*.txt) used to run before the binary check, so a binary with such a name was classified as text and, with --artifact-text, its raw bytes were captured. Binary now wins over the name rules, so binary bytes are never captured as text. Tests reproduce both items against the old code. They fail there (abort on an unreadable directory and on an unreadable file; 64 MiB allocated for a 64 MiB file; a Dockerfile-named binary captured as text) and pass now. A chunk-boundary test checks sniff against the whole-file answer for every chunk size. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The streaming push staged every row of a module with the module that was projected. After the cross-file id change (dd9349b, 355b567), a cross-file method has its declaring file's id prefix and owner, but it was still staged with its receiver's module. An eager push then wrote the method and deleted it again in the declaring module's purge (TestBolt_StreamPushOrder/eager), and a lazy push checked the receiver's hash instead of the declaring file's. Pass 1 now holds the rows of a module that has no stage yet and adds them to that module's stage. Rows of a module that already has a stage go to the new stager step owned, which uses that module's change decision. The bolt writer records the decision per module; the snapshot writer writes the rows. This replaces 19c862a (purge every changed module before any upsert), which the rebase onto the streaming push dropped: the streaming push stages one module at a time, so it cannot purge every changed module first. Tests: TestStreamPush_EagerKeepsCrossFileMethod and TestStreamPush_LazyFollowsDeclaringFile, for both file orders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rahlk
force-pushed
the
fix/artifact-discovery-robustness
branch
from
November 29, 2026 19:46
d2ae0e4 to
c001e1d
Compare
…osures and L3 unit (#75, #76) 205b7cd gave the second and later func init() in a file a ":N" suffix, but only after buildCallable had named its closures and only in the symbol table: - #75: the closures of init:2 kept "<pkg>.init.closure_N", the signature of the first init's closures. Their L3 units, call-graph edges and signature index entries merged: init:2/closure_1 got the first closure's cfg and a body node outside its span, and init's call to its own closure resolved to init:2/closure_1. - #76: L3Units keyed the second init as "<pkg>.init", found the first init's callable, failed the start-line check and skipped it. init:2 had no L3 or L4 output, and only an unmapped_ssa degraded entry hinted at it. func _() has the same problem: Go permits any number of them per file, and generated code (stringer) uses them. fileDeclSignature now computes the suffix from the FuncDecl's position in its file. buildCallable names the callable and its closures with it, and L3Units keys the unit with it, so all three agree. It replaces uniqueFuncSignature. Test: TestRepeatedFunc_ClosuresAndL3AreTheirOwn (two init, two _, each with a closure, at -a 4). It fails on the old code and passes on the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rahlk
pushed a commit
that referenced
this pull request
Nov 29, 2026
This was referenced Nov 29, 2026
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #46, #47, #50, #51, #65, #66, #74, #75, #76.
Go callable and type ids now use the bare member name, as the TypeScript and Python analyzers do. This PR also adds
application.nameandstart_line/end_line, and fixes artifact discovery and repeatedfunc init()/func _().Motivation and Context
…/Hasher/Hash(string)uint64). It is now the bare name (…/Hasher/Hash). External ids split the signature on dots (@external/strings/Builder/WriteString). A cross-file method gets its id under its declaring file, and the Neo4j projection makes that file its owner.application.nameis added next toapplication_name. Span-bearing models and the JSON module getstart_lineandend_line.initand_(Closures of a second function init() or _() happens to merge with the closures of the first #75, Second (or later)init()or_()gets no L3 or L4 output #76). Go permits manyfunc init()andfunc _()in one file. The second and later ones get a:Nsuffix (init:2). The suffix is now computed in one function, so the callable, its closures and its L3 unit agree. Before, the closures ofinit:2merged with the closures ofinit, andinit:2had no L3 or L4 output.--eagerpush deleted a cross-file method after it wrote it, and a lazy push did not see an edit in the declaring file.How Has This Been Tested?
TestLazyPush_*(cross-file method owner);TestStreamPush_EagerKeepsCrossFileMethodandTestStreamPush_LazyFollowsDeclaringFile(both file orders);TestRepeatedFunc_ClosuresAndL3AreTheirOwn(twoinit, two_, at-a 4);TestInit_EveryInitSurvivesWithDistinctID, and tests for the id format, the new schema fields and artifact discovery.go test ./...and golangci-lint pass. CI passed on this head as part of Fix/external id collision #57.neo4j_it) pass, exceptTestIntegration_LazyPushNeverDeletes, which also fails onmain(TestIntegration_LazyPushNeverDeletes fails: validateIdentity rejects an empty GraphRows #60).scripts/eval_e2erunsanalysis.json→ Neo4j projection → load from end to end.Breaking Changes
Yes. Almost every
can://id changes (types, methods, functions, closures, externals).schema_versionstays2.0.0, because no consumer reads these ids yet.A graph pushed by an older build keeps its old-id nodes after a lazy push. Push it once with
--eager, or clear it.Types of changes
Checklist
Additional context
19c862a(purge every changed module before any upsert): the streaming push stages one module at a time.c001e1dreplaces it.docs/design/specs/(id format, cross-file method ids,application.name,start_line/end_line).CLAUDE.mdrecords the:Nsuffix exception.graph.cypherin the working directory is captured as an artifact #77–Neo4j:Artifactnode has no source and other key fields that the JSON has #81.🤖 Generated with Claude Code