diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fc44b7..71682ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [0.4.0] - 2026-12-01 + +- Emit repository artifacts and `go.mod` dependencies (`application.artifacts`, `application.dependencies`) at every level. Artifact text is on by default; `--no-artifact-text` turns it off. The Neo4j artifact layer matches the Python and TypeScript analyzers. +- Callable and type ids use the bare member name (`//`), as in the Python and TypeScript analyzers. A method declared in another file than its type gets an id under its declaring file. A second `init()` or `_()` in a file gets `:2`, `:3`, …. +- Add `application.name`, and `start_line` / `end_line` beside every `span`. +- Library callees whose signatures collide get distinct ids. +- `--emit neo4j` streams the push in two passes and batches every transaction. On nats-server the peak drops from 21.2 GB to 6.6 GB. +- In a container, set Go's memory limit to 85 % of the container's. `-v` logs memory per stage. + +Regenerate existing analyses, and push existing graphs once with `--eager`: callable and type ids changed. + ## [0.3.0] - 2026-10-31 - Add `--namespace` and namespace-qualified application IDs. diff --git a/README.md b/README.md index 1e20f45..0113aec 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # codeanalyzer-go (`cango`) -**A Go static-analysis toolkit — the CLDK backend that emits a canonical symbol table and call graph as `analysis.json`.** +**The Go backend of [CLDK](https://github.com/codellm-devkit/python-sdk): a symbol table, call graph and dependence graphs for Go projects, as `analysis.json` or a Neo4j graph.** [![PyPI](https://img.shields.io/pypi/v/codeanalyzer-go?style=for-the-badge&logo=pypi&logoColor=white)](https://pypi.org/project/codeanalyzer-go/) [![Go](https://img.shields.io/github/go-mod/go-version/codellm-devkit/codeanalyzer-go?style=for-the-badge&logo=go&logoColor=white)](https://go.dev/) @@ -15,149 +15,72 @@ --- -`cango` is a static analyzer for Go built on [`golang.org/x/tools/go/packages`](https://pkg.go.dev/golang.org/x/tools/go/packages) -(AST + full type resolution). It produces the canonical CodeLLM-DevKit (CLDK) `analysis.json` — a -symbol table plus a resolver-based call graph — consumable by the Python SDK via -`CLDK(language="go").analysis(project_path=...)`. It is the Go backend behind -[CLDK](https://github.com/codellm-devkit/python-sdk), mirroring its -[Python](https://github.com/codellm-devkit/codeanalyzer-python), -[TypeScript](https://github.com/codellm-devkit/codeanalyzer-typescript), and -[Java](https://github.com/codellm-devkit/codeanalyzer-java) siblings. - -The binary is fully self-contained: a single static executable with no runtime dependencies. - -## Table of Contents - -- [Features](#features) -- [Installation](#installation) - - [Prerequisites](#prerequisites) - - [Install via shell script](#install-via-shell-script) - - [Install via Homebrew](#install-via-homebrew) - - [Install via pip (PyPI)](#install-via-pip-pypi) - - [Build from source](#build-from-source) - - [Toolchain](#toolchain) -- [Usage](#usage) - - [Command-line options](#command-line-options) - - [Examples](#examples) -- [Analysis levels](#analysis-levels) -- [Output schema](#output-schema) -- [Neo4j projection (`--emit neo4j`)](#neo4j-projection---emit-neo4j) - - [Emit a snapshot (`graph.cypher`)](#emit-a-snapshot-graphcypher) - - [Push live to a running Neo4j](#push-live-to-a-running-neo4j) - - [Load and query](#load-and-query) - - [Query reference](#query-reference) -- [Python SDK (CLDK) integration](#python-sdk-cldk-integration) -- [Upgrading](#upgrading) -- [Architecture & Tooling](#architecture--tooling) -- [Development](#development) -- [License](#license) - -## Features - -- **Symbol table** — packages, structs, interfaces, fields, methods, package-level functions, - imports, struct tags, and generic type parameters, with precise source spans. -- **Call graph** — a resolver-based call graph via `go/types`: each call site is resolved to its - full import-path signature. Level 2 emits edges to project callees and to library callees - (homed in `application.external_symbols` under `can:////@external//`). - Level 3 (`-a 3`) adds per-callable `cfg`, `cdg` and `ddg`. Level 4 (`-a 4`) adds the - interprocedural system dependence graph (SDG): parameter vertices, `param_in` / `param_out`, - call-site `summary` edges, VTA dispatch targets and library stand-ins — what the SDK's - slicing and `taint()` walk. -- **Generics-aware** — Go 1.18+ generics (`Set[T]`, union-constraint interfaces, multi-type-param - functions) are modeled in the unified type/callable schema. -- **Self-contained binary** — a single static executable (`go build`, `CGO_ENABLED=0`); no runtime - dependencies for SDK users. -- **CLDK canonical schema** — output is spine-compatible with the Java/Python/TypeScript analyzers, - loadable directly by the Python SDK. -- **Neo4j projection** — the same envelope projected into a property graph (`--emit neo4j`), - either as a replayable `graph.cypher` snapshot or pushed live over Bolt, keyed on the identical - `can://` ids so JSON and graph join on one string. - -## Installation - -### Prerequisites - -Running a prebuilt `cango` binary requires **nothing** — it is fully self-contained. To *analyze* a -project, that project should be a normal Go module (contain a `go.mod`) so the type checker can -resolve imports. Building `cango` from source requires [Go 1.26+](https://go.dev/dl/), and the -latest Go release is recommended — see [Toolchain](#toolchain). - -### Install via shell script - -Download and install the prebuilt binary for your platform from the latest release: +`cango` builds the symbol table, call graph, and control-flow and data-flow graphs of a Go module, with full type information from `go/types`. It writes them as JSON, in the same shape as the [Python](https://github.com/codellm-devkit/codeanalyzer-python), [TypeScript](https://github.com/codellm-devkit/codeanalyzer-typescript) and [Java](https://github.com/codellm-devkit/codeanalyzer-java) analyzers, or as a [Neo4j graph](#neo4j). + +## Install ```sh +# Shell installer (macOS, Linux) curl --proto '=https' --tlsv1.2 -LsSf https://github.com/codellm-devkit/codeanalyzer-go/releases/latest/download/cango-installer.sh | sh -``` - -The installer drops `cango` into `~/.local/bin` (override with `CANGO_INSTALL_DIR`) and can pin a -version with `CANGO_VERSION=vX.Y.Z`. It also creates a `codeanalyzer-go` alias symlink. Supports -macOS (arm64/x86_64) and Linux (x86_64/aarch64). - -### Install via Homebrew -```sh +# Homebrew brew install codellm-devkit/homebrew-tap/codeanalyzer-go -``` -### Install via pip (PyPI) +# PyPI (the package the CLDK Python SDK uses) +pip install codeanalyzer-go +``` -The wheel bundles the prebuilt, self-contained binary for your platform (no Go toolchain required): +From source (Go 1.26 or later): ```sh -pip install codeanalyzer-go -cango --help +go build -o cango ./cmd/codeanalyzer ``` -The wheel installs both a `cango` launcher and a `codeanalyzer-go` alias on `PATH`. This is also the -package CLDK's Python SDK depends on to locate the analyzer backend; it exposes -`codeanalyzer_go.bin_path()`. +> [!NOTE] +> `cango` type-checks with the `go/types` built into it. Build it with a Go at least as new as the newest Go that your projects need. The release binaries use the latest Go. A build with an older Go warns and leaves some callees unresolved. -### Build from source +## Neo4j + +Start Neo4j in Docker: ```sh -git clone https://github.com/codellm-devkit/codeanalyzer-go -cd codeanalyzer-go -go build -o cango ./cmd/codeanalyzer +docker run -d --name neo4j -p 7474:7474 -p 7687:7687 \ + -e NEO4J_AUTH=neo4j/your-password neo4j:5.26-community ``` -This produces a single static binary `cango` with no runtime dependencies. You can also run the -analyzer directly from source without compiling: +Push the analysis of a project into it: ```sh -go run ./cmd/codeanalyzer -i /path/to/project -a 2 +cango -i ./my-project --emit neo4j \ + --neo4j-uri bolt://127.0.0.1:7687 --neo4j-password your-password ``` -### Toolchain - -`cango` type-checks the projects it analyzes with the `go/types` package compiled into the -binary, so **the Go that builds `cango` must be at least as new as the newest `go` line of the -projects it analyzes**. Build with the latest Go release (the release binaries are). `go.mod`'s -`go 1.26.0` is only the minimum that compiles the analyzer (set by `golang.org/x/tools`, whose -recent releases require Go 1.26). +Then open and run a query, for example `MATCH (c:GoCallable) RETURN c.signature LIMIT 25`. -With a binary built by an older Go, every package that needs a newer Go type-checks only -partially, yet the run still exits 0: callees go unresolved, call edges and L3 defs are lost, -and nothing else looks wrong. `cango` prints one warning when this happens, naming the Go it was -built with, the highest version required and the number of affected packages: +Without `--neo4j-uri`, `cango` writes a Cypher snapshot that you can load later: -``` -[codeanalyzer-go WARN] 12 packages require a newer Go version (highest go1.27) than this analyzer was built with (go1.26.4); … +```sh +cango -i ./my-project --emit neo4j -o ./out # writes ./out/graph.cypher +docker exec -i neo4j cypher-shell -u neo4j -p your-password < ./out/graph.cypher ``` -Rebuild `cango` with that Go version or newer. (`-vv` lists the affected packages.) +`--emit neo4j` always projects level 4, with the same ids as the JSON output. A snapshot replaces the app's graph when loaded. A Bolt push only adds and updates. Pass `--eager` to rebuild the app's graph and drop stale nodes. Every write stays inside the app's `can://` prefix, so other apps in the same database keep their graphs. -## Usage +Labels start with `Go` (`:GoType`, `:GoCallable`, …) and relationships with `GO_` (`GO_CALLS`, `GO_DDG`, …). See [`neo4j-projection.md`](docs/design/Neo4j_projection/specs/neo4j-projection.md). [`scripts/load_and_query.sh`](scripts/load_and_query.sh) loads a snapshot and runs sample queries. -```bash -cango -i /path/to/go/project -``` +## Usage -### Command-line options +Point `-i` at the directory that holds the project's `go.mod`: +```sh +cango -i ./my-project # symbol table, to stdout +cango -i ./my-project -a 2 -o ./out # + call graph, to ./out/analysis.json +cango -i ./my-project -a 4 -o ./out # + intra- and interprocedural dataflow +cango -i ./my-project -t pkg/a.go # only these files (incremental; not at -a 4) ``` -codeanalyzer-go produces analysis.json (symbol table + call graph) for Go projects. +```text +$ cango --help Usage: cango [flags] @@ -167,16 +90,17 @@ Aliases: Flags: -a, --analysis-level int Analysis level: 1=symbol table, 2=+call graph, 3=+intraprocedural cfg/cdg/ddg, 4=+interprocedural SDG (default 1) --app-name string Application anchor name for can:// ids and Neo4j :Application (default: input dir name) + --artifact-text Capture each text artifact's whole source in the output (default true) -c, --cache-dir string Cache directory (default: ~/.cldk/go-cache) --eager Force clean rebuild (ignore cache) --emit string Output projection: json|neo4j|schema (default "json") -f, --format string Output format: json|msgpack (default "json") --graph-field-depth int Field-path depth bound for L3 dataflow nodes (k limit; applies at -a 3 and -a 4) (default 3) -h, --help help for cango - --artifact-text Capture each text artifact's whole source in the output (default true) -i, --input string Project root to analyze (required) -j, --jobs int Worker parallelism (default: CPU cores) --library-models string JSON file of library stand-in flows overriding the all-to-all default (-a 4 and --emit neo4j only) + --namespace string Identity namespace (default: application name) --neo4j-database string Neo4j database (env NEO4J_DATABASE, optional) --neo4j-password string Neo4j password (env NEO4J_PASSWORD, default neo4j) --neo4j-uri string Live Bolt push target (env NEO4J_URI); omit to write graph.cypher @@ -190,615 +114,100 @@ Flags: --version Print version and exit ``` -### Examples - -**Symbol table only (Level 1, default):** -```bash -cango -i ./my-go-project -``` -Prints `analysis.json` to stdout. +| Level | Adds | +|---|---| +| `-a 1` (default) | Symbol table: modules, types, callables, fields, call sites, repository artifacts and `go.mod` dependencies | +| `-a 2` | Call graph, including calls into libraries (`application.external_symbols`) | +| `-a 3` | Per-callable statement nodes and `cfg`, `cdg`, `ddg` | +| `-a 4` | System dependence graph: VTA dispatch, parameter vertices, `param_in` / `param_out`, `summary` edges, library stand-ins | -**Symbol table + call graph (Level 2):** -```bash -cango -i ./my-go-project -a 2 -``` +Every node has a `can:////…` id. `--app-name` (default: the input directory's name) and `--namespace` (default: the app name) set the two segments. If level 4 cannot build everything, it still writes its output and lists what it skipped in `degraded[]`. `--strict` makes that a non-zero exit. -**Write output to a directory:** -```bash -cango -i ./my-go-project -a 2 -o /path/to/output/ -# Writes: /path/to/output/analysis.json -``` +## Output -**Incremental analysis (specific files only):** -```bash -cango -i ./my-go-project -t pkg/server/server.go -t pkg/server/handler.go -``` +`cango -i testdata/greeter -a 2`, trimmed (`…` marks what the example leaves out): -**Force rebuild, ignore cache:** -```bash -cango -i ./my-go-project --eager -``` - -**Verbose output:** -```bash -cango -i ./my-go-project -a 2 -vv -``` - -## Generating `analysis.json` for a Go app - -The end-to-end steps to produce an `analysis.json` file for any Go project. - -**1. Make sure you have `cango`.** Either install a released binary (see -[Installation](#installation)) or build from source: - -```bash -git clone https://github.com/codellm-devkit/codeanalyzer-go -cd codeanalyzer-go -go build -o cango ./cmd/codeanalyzer -``` - -**2. Point it at the project root** (the directory containing the app's `go.mod`). -`cango` resolves imports with the Go type checker, so the target must be a normal Go -module. Write the output to a directory with `-o`; `cango` names the file -`analysis.json` inside it. - -```bash -# Level 2 (symbol table + call graph): -cango -i /path/to/go/app -a 2 -o /path/to/output/ -# → writes /path/to/output/analysis.json -``` - -> **Schema.** `cango` emits the **canonical CLDK** tree (the shape the Python SDK's -> loader and the sections below describe). Omit `-o` to stream the JSON to stdout instead -> of writing a file. - -**3. (Optional) name the application anchor.** `--app-name` sets the `` in every -`can:////…` id and defaults to the input directory's base name. Set it when the -directory name isn't the identity you want: - -```bash -cango -i /path/to/go/app -a 2 --app-name myapp -o ./out/ -``` - -**4. Verify.** A successful run exits `0` and produces a JSON document whose envelope -carries `"schema_version": "2.0.0"`, `"language": "go"`, `"max_level": 2`, and an -`application` tree under `application.symbol_table`: - -```bash -cango -i /path/to/go/app -a 2 -o ./out/ && echo "exit=$?" -python3 -c "import json; d=json.load(open('out/analysis.json')); print(d['schema_version'], d['max_level'], len(d['application']['symbol_table']), 'modules')" -``` - -**Notes for larger apps.** Analysis parallelism defaults to your CPU count (tune with -`-j`); a warm cache (`--cache-dir`, default `~/.cldk/go-cache`) makes re-runs fast, and -`--eager` forces a clean rebuild. Projects that use **cgo** (`import "C"`) are supported: -the toolchain-synthesized wrapper functions are correctly excluded from the output (they -are build artifacts, not project source), so only your own declarations are emitted. - -## Analysis levels - -| Level | Flag | What runs | Status | -|-------|------|-----------|--------| -| 1 | `-a 1` (default) | Symbol table only — types, functions, call sites | Implemented | -| 2 | `-a 2` | Level 1 + resolver-based call graph via `go/types` | Implemented | -| 3 | `-a 3` | Level 2 + per-callable statement nodes and `cfg` / `cdg` / `ddg` | Implemented | -| 4 | `-a 4` | Level 3 + interprocedural SDG: VTA dispatch, parameter vertices, `param_in` / `param_out`, `summary`, port and `points-to` `ddg`, library stand-ins | Implemented | - -**Level 1** loads each package with `packages.NeedSyntax | NeedTypes | NeedTypesInfo` and walks the AST file by file. Call sites are recorded with `callee_signature = null` at this stage. - -**Level 3** completes every callable's `body` with its statement, control (`branch`, `loop`, -`switch`, `return`) and synthetic (`@entry`, `@exit`) nodes around the L1 call nodes, and adds -three intra-callable edge lists: `cfg` (control flow, including the `defer` chain and panic -`exception` edges), `cdg` (control dependence from post-dominators) and `ddg` (syntactic -reaching definitions over k-limited access paths, `prov: ["ssa"]`). `--graph-field-depth ` -(default 3, minimum 1) bounds the access paths (`x.f.g.h` → `x.f.g.*` at k = 3) and is -recorded in the envelope as `k_limit`. It is a flag error below `-a 3` and with -`--emit neo4j`. Callables are analyzed in parallel (`-j`), and the output is byte-identical -for every `-j`. L3 only adds to the L2 output: every L2 fact stays as it is. - -**Level 4** is whole-program. It builds `go/ssa` for the project packages over the same load and -runs VTA (`golang.org/x/tools/go/callgraph/vta`) over the project's functions, so interface and -function-value calls get their concrete targets: `call_graph` gains those edges with -`prov: ["vta"]` (an L2 edge is never changed). Every callable gets `formal_in` / `formal_out` -vertices (parameters, receiver, closure captures, the package variables it reads or writes, -results), and every resolved call site gets `actual_in` / `actual_out` vertices, wired into the -body's `ddg` (`prov: ["reaching-defs"]`). `param_in` / `param_out` (application scope) join each -call site to every target, including the interface method itself for an interface call, and a -bottom-up pass over the call graph's SCCs puts `summary` edges (`actual_in` → `actual_out`) at -each call site. Library callees get a **stand-in** in `external_symbols` (`body` holds only its -formal vertices; summary all inputs → all outputs unless `--library-models` overrides it). A -type-based may-alias oracle adds `ddg` edges with `prov: ["points-to"]`. `-a 3` output is a -subset of `-a 4` output, and `-j 1` and `-j N` output are byte-identical. - -- **Degradation.** When L4 cannot build all it needs, it still emits and records why in the - envelope's `degraded[]`. Each entry has a `code`, an optional `detail`, and optional `packages[]` - and `callables[]`. The codes are: - - `no_ssa` / `partial_ssa`: SSA failed, in whole or for some packages; - - `no_vta`: VTA failed; - - `no_cha`: the CHA complement for library-originated values failed (its targets are dropped); - - `partial_types`: some packages have type errors; - - `unmapped_ssa`: SSA functions or calls that map to no callable; - - `l3_skipped`: callables without an L3 result, which get a pass-through summary; - - `range_func`: range-over-func, which is not modelled at L4. - - It also logs one warning per entry. `--strict` makes any degradation a non-zero exit. -- **`--library-models `** overrides stand-in summaries: - `{"strconv/Atoi": [], "strings/TrimSpace": [["s", ""]]}`. A key is the external id's - `/` tail, and a value is a list of `[in, out]` pairs of `of` names (`[]` = no - summary edges). A model changes summaries, **not statement-level reachability**: in - `n, err := strconv.Atoi(id)` the value assigned at the call site keeps its reaching-definition - edge from `id`, which is correct data flow. A model is therefore not a sanitizer. Cutting such - a flow is the SDK taint analysis's job - ([codellm-devkit/.github#103](https://github.com/codellm-devkit/.github/issues/103)). A variable - cut on `n` is also bypassed, by implicit flow through `err` and by the coarse host wiring. An - entry naming an `of` the external lacks falls back to all-to-all, with a warning. A key no call - site targets is ignored, with a warning. The flag is valid only at `-a 4` and with - `--emit neo4j`. -- **`-t` / `--target-files` is not supported at `-a 4`** (whole-program): it is an error. Use - `-a 3 -t`, or run without `-t`. -- **Known limits** (see `docs/design/notes/l3-dataflow-metrics.md` § L4): - - library code calling back into the project (`sort.Slice`, `http.HandleFunc`) is not an - edge; - - an interface call on a value that may have come out of library code (`ctx.Value(k).(Store)`, - `sync.Map.Load`, a library container), directly or through project code (results, - parameters, captures, fields, globals, container elements), binds every project type - implementing the interface (a CHA complement). Storage is tracked by container type (every - instance of a struct field), which is sound but coarser than VTA; - - range-over-func is not modelled (`range_func`); - - summaries are close to all-to-all, by design; - - `summary` edges whose two ends are both `:` vertices are omitted - (codeanalyzer-go#30). Reachability is unchanged, but a depth-bounded slice can stop earlier - than it would through that shortcut. - -**Level 2** adds a resolver pass: for each call site, `go/types` resolves the callee to its full import-path signature (`pkgImportPath.TypeName.MethodName`). A project callee becomes an edge to its callable; a **library callee** (stdlib, a dependency, or a package vendored under `vendor/`) becomes an edge to an `@external` symbol, recorded once in `application.external_symbols`. A callee that is neither (an interface method of a project type, a conversion, a builtin, a call through a function value) gets no edge. Every resolved call node's `callee` is backfilled. - -## Output schema - -`cango` emits the **canonical CLDK** shape — the shape the Python SDK loader consumes -and the [step-by-step section above](#generating-analysisjson-for-a-go-app) produces. - -### Canonical shape - -The document is a manifest envelope wrapping one `application` containment tree. Every -node carries a `can:////…` `id`, a `kind`, and a `span`: - -```json +```jsonc { - "identity_version": 2, "schema_version": "2.0.0", + "identity_version": 2, "language": "go", "max_level": 2, - "analyzer": { "name": "codeanalyzer-go", "version": "0.1.0" }, + "analyzer": { "name": "codeanalyzer-go", "version": "0.4.0" }, "application": { - "id": "can://myapp/myapp", - "identity_version": 2, - "application_name": "myapp", - "identity_namespace": "myapp", + "id": "can://greeter/greeter", "kind": "application", + "name": "greeter", "symbol_table": { "pkg/greeter/greeter.go": { - "id": "can://myapp/myapp/go/pkg/greeter/greeter.go", + "id": "can://greeter/greeter/go/pkg/greeter/greeter.go", "kind": "module", "package": "greeter", - "span": { "start": [1, 1], "end": [40, 2], "bytes": [0, 812] }, - "source": "package greeter\n\n...", - "content_hash": "…", - "imports": [ { "name": "fmt", "path": "fmt", "span": {…} } ], + "imports": [{ "name": "fmt", "path": "fmt", … }], "types": { "Greeter": { - "id": "can://myapp/myapp/go/pkg/greeter/greeter.go/example.com/pkg/greeter.Greeter", + "id": "can://greeter/greeter/go/pkg/greeter/greeter.go/Greeter", "kind": "struct", - "span": { "start": [5, 1], "end": [7, 2], "bytes": [17, 63] }, - "fields": { - "Prefix": { "id": "…/Prefix", "kind": "field", "type": "string", "span": {…} } - }, + "signature": "example.com/greeter/pkg/greeter.Greeter", + "fields": { "Prefix": { "kind": "field", "type": "string", … } }, "callables": { - "example.com/pkg/greeter.Greeter.Greet": { - "id": "can://myapp/myapp/go/pkg/greeter/greeter.go/example.com/pkg/greeter.Greeter/example.com/pkg/greeter.Greeter.Greet", + "example.com/greeter/pkg/greeter.Greeter.Greet": { + "id": "can://greeter/greeter/go/pkg/greeter/greeter.go/Greeter/Greet", "kind": "method", - "signature": "example.com/pkg/greeter.Greeter.Greet", - "span": { "start": [9, 1], "end": [11, 2], "bytes": [65, 140] }, - "parameters": [ { "name": "name", "type": "string", "span": {…} } ], + "parameters": [{ "name": "name", "type": "string", … }], "return_type": "string", - "error_channel": ["error"], - "metrics": { "cyclomatic": 1 }, "body": { - "10:2": { + "18:9": { "kind": "call", - "id": "can://myapp/myapp/go/pkg/greeter/greeter.go/…/example.com/pkg/greeter.Greeter.Greet@10:2", - "span": { "start": [10, 2], "end": [10, 30], "bytes": [90, 118] }, - "callee": "can://myapp/myapp/go/pkg/greeter/greeter.go/…/example.com/pkg/greeter.format" + "id": "can://greeter/greeter/go/pkg/greeter/greeter.go/Greeter/Greet@18:9", + "callee": "can://greeter/greeter/@external/fmt/Sprintf", + "span": { "start": [18, 9], "end": [18, 47], "bytes": [393, 431] }, + "start_line": 18, "end_line": 18 } - } + }, + … } } } }, - "functions": { - "example.com/main.main": { "id": "…", "kind": "function", "signature": "…", "body": {…} } - } + "functions": { "example.com/greeter/pkg/greeter.New": { … } }, + "source": "// Package greeter …" } }, "call_graph": [ { - "src": "can://myapp/myapp/go/main.go/…/example.com/main.main", - "dst": "can://myapp/myapp/go/pkg/greeter/greeter.go/…/example.com/pkg/greeter.Greeter.Greet", - "prov": ["go/types"], - "weight": 1 - } - ] + "src": "can://greeter/greeter/go/pkg/greeter/greeter.go/Greeter/Greet", + "dst": "can://greeter/greeter/@external/fmt/Sprintf", + "prov": ["go/types"], "weight": 1 + }, + … + ], + "external_symbols": { "can://greeter/greeter/@external/fmt/Sprintf": { "kind": "external", … } }, + "artifacts": { "go.mod": { "id": "can://greeter/greeter/artifact/go.mod", "format": "gomod", … } } } } ``` -Key schema properties: -- **Envelope** — `schema_version` (`"2.0.0"`), `language` (`"go"`), `max_level` (1–4), - `k_limit` (L3+: the `--graph-field-depth` value), `degraded[]` (L4, only when something - degraded) and `analyzer{name,version}` wrap a single `application` node. -- **One containment tree** — `application → module → type → callable → body`, keyed as - `symbol_table` (modules, by **project-relative file path**), `types`, `callables`, `body`. -- **`id`** — every node carries a durable `can:////go///` id; - `` is the `--app-name` anchor. A body node is keyed by `line:col` in its callable's `body` - map and carries `id` = `@` at every level, from `-a 1` on. -- **`kind`** — `module` · `type` kinds `struct | interface | alias | defined` · - `callable` kinds `function | method | lambda` · body `call`. -- **`base_types: []`** (type, optional) — embedded type ids (struct/interface embedding — the - explicit spine), as opposed to interfaces the type is *computed* to satisfy. -- **`span`** — `{start:[line,col], end:[line,col], bytes:[from,to]}`; `bytes` are **UTF-8 byte - offsets** into the owning `module.source` (source is stored once per module, every node slices it). -- **`source_file`** (callable, optional) — set when a method is declared in a *different file* - than its receiver type, and on every closure (nested ones too) inside such a method; the - callable stays nested under the type, and its `span.bytes` (and its body nodes' spans) index - `symbol_table[source_file].source` instead of the nesting module's. -- **`error_channel: []`** — populated from `error`-typed returns (the returns also stay in - `return_type`). **Closures** nest as `callables{}` on the enclosing callable. -- **`body` call nodes** — `callee` is the sanctioned `null → id` slot: `null` at L1; at L2 a - project callable's `can://` id, or for a library (stdlib or dependency) callee its - `can:////@external//` id, a key of `external_symbols`. It stays `null` - for conversions, builtins, calls through function values and unresolved sites. `is_goroutine` / `is_deferred` - are boolean flags emitted **only when true** (a plain call omits them), for `go f()` / `defer f()`. -- **`call_graph` edges** — `{src, dst, prov, weight}`; `src` is a callable id in the tree and - `dst` a callable id or an `external_symbols` key (never a raw signature); `prov` is resolver - provenance, e.g. `["go/types"]`. -- **`external_symbols`** (application, L2, optional) — one entry per library callee, keyed by - its `@external` id: `{id, kind: "external", name, module, signature, parameters[], return_type}` - (parameters carry no span). Absent when no library call was resolved. -- **L3 (`-a 3`)** — `body` gains `statement` / `branch` / `loop` / `switch` / `return` nodes - and the synthetic `@entry` / `@exit` (which have no `span`). Every body node carries `id` - (`@`). - A call nested in a statement carries `parent`, the statement's key. The callable gains - `cfg[] {src, dst, kind}`, `cdg[] {src, dst}` and `ddg[] {src, dst, var, prov}`, whose - endpoints are `body` keys. See `docs/design/specs/schema-structure.md`. -- **L4 (`-a 4`)** — `body` gains span-less vertices `@formal_in:`, `@formal_out[:]`, - `/actual_in:`, `/actual_out[:]`, each with `of` (the bound name: - a parameter or receiver name, `_`, `_recv`, ``, `:`, - `:`, `:::`); actuals carry `parent` = the call key. - `ddg` gains `prov: ["reaching-defs"]` (port wiring) and `["points-to"]` edges; a callable gains - `summary[] {src, dst}` (local keys); the application gains `param_in[]` / `param_out[]` - `{src, dst, var}` (global body-node ids, `var` = the callee formal's `of`); an external gains - `receiver {name, type}` and a stand-in `body` of its formal vertices (ids - `@formal_in:`). - -## Neo4j projection (`--emit neo4j`) - -`--emit neo4j` projects the **same envelope** into a Neo4j property graph. It is a *second -projection of the identical analysis* — JSON nodes and graph nodes carry the same `can:////…` -ids, so the two join on one string and are never recomposed. The graph vocabulary is `Go`-prefixed -labels (`:GoModule`, `:GoType`, `:GoCallable`, `:GoField`, `:GoBodyNode`, `:GoExternal`, plus the -shared merge label `:GoSymbol` and marker `:GoCanNode`) and `GO_`-prefixed relationships -(`GO_HAS_MODULE`, `GO_DECLARES`, `GO_HAS_METHOD`, `GO_HAS_FIELD`, `GO_CALLS`, `GO_RESOLVES_TO`, -`GO_IMPORTS`, `GO_EMBEDS`, `GO_SATISFIES`, …). - -There are two output paths, chosen by whether `--neo4j-uri` is set: - -| | `--neo4j-uri` unset | `--neo4j-uri` set | -|---|---|---| -| **What happens** | Writes a replayable `graph.cypher` snapshot | Pushes the graph live over Bolt into a running Neo4j | -| **Where** | `<-o dir>/graph.cypher` (or stdout) | The target database | -| **Use for** | Review, diffing, loading on your own schedule, CI | A DB you already have running | - -Both paths are **scoped to one application**: every destructive statement is anchored on -`:GoCanNode` and the `can:////` id prefix, so it never touches another app (or a -sibling-language graph) in the same database. The projection is **deterministic** — a second emit -is byte-identical. - -What a re-emit replaces depends on the path: - -- **`graph.cypher` snapshot** and **`--eager` Bolt push**: the app's subgraph is purged and - rebuilt, so re-emitting replaces exactly that app's subgraph. -- **Default (lazy) Bolt push**: purely additive. Changed modules are MERGE-upserted and nothing is - deleted. After source edits, nodes and edges that the new analysis no longer emits stay in the - database. For L3 this includes `:GoBodyNode`s and their `GO_CFG_NEXT` / `GO_CDG` / `GO_DDG` - edges, whose ids are keyed on `line:col`: once lines shift, the old body nodes and their edges - remain beside the new ones. Pass `--eager` when you push an L3 graph after editing source. - The purge needs a full run: with `--target-files` it is skipped, because the push carries only - the targeted packages. -- **L4 rows on a lazy push (D5).** L4 facts are not local to a module: editing a callee changes - its callers' summaries and vertices. So a lazy push upserts **every** L4 row (vertices, - `GO_PARAM_IN` / `GO_PARAM_OUT`, `GO_SUMMARY`, port `GO_DDG`) on every push, not only the changed - modules'. It still adds and never removes: stale L4 rows stay until an `--eager` full run. -- **Level changes.** A lazy push whose level is above the stored `:GoApplication.max_level` (a graph - last pushed at L3, or with `-t`), or whose stored level is unreadable, upserts every module, so - no L4 row is dropped for a missing L3 endpoint. A push at a *lower* level onto a higher graph - diffs as usual and leaves the old L4 rows in place (additive). An **interrupted** push can leave - `:GoApplication` at the new `max_level` while some modules still hold older rows; the next lazy - push then trusts the diff. Recover with an `--eager` full run. -- **`--target-files` (D9).** L4 is whole-program, so `--emit neo4j -t` projects the targeted modules - at **L3** and writes no L4 rows; they keep the last full run's facts until the next full run. It - warns once on stderr: `--target-files: projecting the graph at level 3 (level 4 is - whole-program); L4 rows keep the last full run's facts until a full run` (plus `; - --library-models is ignored at level 3` when that flag is set). - -> **`--emit neo4j` is always full depth.** The graph is projected at the max implemented level (L4 -> — symbol table, call graph, every callable's body nodes with `GO_CFG_NEXT` / `GO_CDG` / -> `GO_DDG`, and the SDG: vertex `:GoBodyNode`s with `var`, `GO_PARAM_IN` / `GO_PARAM_OUT {var}`, -> `GO_SUMMARY`, stand-in vertices under their `:GoExternal`, and `degraded_json` on -> `:GoApplication`) and the canonical schema. Do **not** pass `-a`/`--analysis-level` -> with it — an explicit level is a flag error (`--analysis-level does not apply to --emit neo4j`), -> because there is no shallower graph to ask for. - -### Emit a snapshot (`graph.cypher`) - -```bash -cango -i /path/to/go/app --emit neo4j -o ./out/ -# → writes ./out/graph.cypher -``` - -The snapshot is a self-contained script: constraints + indexes, a scoped wipe of this app's subgraph, -then `UNWIND … MERGE` batches for nodes and relationships. Replay it into any Neo4j with -`cypher-shell` (see below). Omit `-o` to stream the Cypher to stdout. +Levels 3 and 4 add `cfg`, `cdg`, `ddg` and `summary` to each callable, and `param_in` / `param_out` to the application. -### Push live to a running Neo4j - -Set `--neo4j-uri` (or the `NEO4J_URI` env var) to push directly over Bolt instead of writing a file: - -```bash -./cango -i /path/to/go/app --emit neo4j \ - --neo4j-uri bolt://127.0.0.1:7687 \ - --neo4j-user neo4j --neo4j-password -``` - -Credentials and target also read from the environment (`NEO4J_URI`, `NEO4J_USERNAME`, -`NEO4J_PASSWORD`, `NEO4J_DATABASE`), so you can keep them out of your shell history: - -```bash -export NEO4J_URI=bolt://127.0.0.1:7687 -export NEO4J_PASSWORD= -cango -i /path/to/go/app --emit neo4j -``` - -> Use `127.0.0.1` rather than `localhost` if anything else (an SSH tunnel, another DB) might also be -> listening on `7687` — `localhost` can resolve to the wrong listener. - -### Load and query - -If you emitted a `graph.cypher` snapshot, load it into a running Neo4j with `cypher-shell`: - -```bash -cypher-shell -a bolt://127.0.0.1:7687 -u neo4j -p < ./out/graph.cypher -``` - -A convenience harness, [`scripts/load_and_query.sh`](scripts/load_and_query.sh), loads the snapshot -and runs a set of sample queries — it auto-detects `cypher-shell` from a Neo4j Desktop or Homebrew -install. It reads `graph.cypher` from its own directory, so emit the snapshot into `scripts/` first -(`-o scripts`): - -```bash -# brew install neo4j && neo4j start # (or Neo4j Desktop) — then set a password -cango -i /path/to/go/app --emit neo4j -o scripts # writes scripts/graph.cypher - -NEO4J_PASSWORD= ./scripts/load_and_query.sh # load + query -NEO4J_PASSWORD= ./scripts/load_and_query.sh --query # queries only -NEO4J_PASSWORD= ./scripts/load_and_query.sh --check # just test the connection -``` - -Or explore visually in Neo4j Browser at `http://127.0.0.1:7474` (connect to `bolt://127.0.0.1:7687`), -paste a query, and swap `RETURN p` for `RETURN …` to draw the graph. - -### Query reference - -Always **scope by the `can://` id prefix** (an index-backed seek via the `gocannode_id` range index), -never by a bare label scan — replace `` with your `--app-name`: - -```cypher -// Node counts by label. -MATCH (n:GoCanNode) RETURN labels(n)[0] AS label, count(*) AS n ORDER BY n DESC; - -// Relationship counts by type. -MATCH ()-[r]->() RETURN type(r) AS rel, count(*) AS n ORDER BY n DESC; - -// Everything owned by one application (prefix seek). -MATCH (n:GoCanNode) WHERE n.id STARTS WITH 'can:////' RETURN count(n) AS app_nodes; - -// Types ranked by method count (the "god struct" finder). -MATCH (t:GoType) OPTIONAL MATCH (t)-[:GO_HAS_METHOD]->(m) -RETURN t.kind AS kind, t.signature AS type, count(m) AS methods ORDER BY methods DESC; - -// Most-called callables (in-degree) — the hot utilities. -MATCH (:GoCallable)-[:GO_CALLS]->(b:GoCallable) -RETURN b.signature AS callee, count(*) AS called_by ORDER BY called_by DESC LIMIT 15; - -// Everything Command.Execute reaches, transitively (any depth). -MATCH (:GoCallable {signature:'github.com/spf13/cobra.Command.Execute'})-[:GO_CALLS*]->(b) -RETURN DISTINCT b.signature AS reachable ORDER BY reachable; - -// External / stdlib packages reached via imports. -MATCH (:GoCanNode)-[:GO_IMPORTS]->(x:GoExternal) RETURN DISTINCT x.path AS import ORDER BY import; -``` - -The full, commented catalog — overview/sanity, containment tree, call graph (callers, callees, -reachability, shortest path, entry points, leaves), call-site resolution, imports, inheritance, -metrics, and scoped maintenance — lives in -[`Eval/Neo4j_eval/queries.cypher`](Eval/Neo4j_eval/queries.cypher), validated against the -`spf13/cobra` graph. - -## Python SDK (CLDK) integration +## Python SDK ```python from cldk import CLDK analysis = CLDK(language="go").analysis(project_path="/path/to/go/project") -for file_path, go_file in analysis.get_symbol_table().items(): - print(file_path, go_file.module_name) -``` - -The SDK locates the analyzer via the `codeanalyzer-go` command on `PATH` (installed by any of the -methods above, including `pip install codeanalyzer-go`). See -[python-sdk](https://github.com/codellm-devkit/python-sdk) for full API documentation. - -## Upgrading - -This release changes the output contract. If you consume `analysis.json` or the Neo4j graph, -check the following. - -- **Ids are app-outermost.** `can://go///…` is now `can:////go//…`. Library - callees are `can:////@external//`. -- **Body nodes carry `id` at every level.** Each body node has `id` = `@`, - from `-a 1` on, not only at `-a 3`. -- **L2 includes library calls.** The call graph now has edges to library (stdlib and dependency) - callees, and `application.external_symbols` describes them. A library call's `callee` is its - external id instead of `null`. A type conversion is still a call node, but its `callee` stays - `null`; it is no longer resolved to a `.__new__` pseudo-callee. -- **L1 records more.** - - A type's `kind` can now be `alias` or `defined`, not only `struct` or `interface`. - - Deferred calls carry `is_deferred: true`. - - Chained calls that start at the same position, such as `s.A().B()`, are now separate call - nodes keyed `l:c` and `l:c/2`. Previously the inner call was dropped. Do not parse body keys - as plain `line:col`. - - Calls inside `go` statement arguments, such as `g()` in `go f(g())`, are now call sites. - - Consumers that count call nodes will see more of them. -- **L4 (`-a 4`) is new.** It is additive: an `-a 3` consumer sees the same document plus new - keys (vertices, `of`, `summary`, `param_in` / `param_out`, `points-to` / `reaching-defs` `ddg`, - VTA `call_graph` edges, external `receiver` / `body`, `degraded`). Code that assumes every body - node has a `span`, or that every `ddg` edge has `prov: ["ssa"]`, must handle the L4 kinds. - `-a 4 -t` is an error (whole-program; D9). `--library-models` is new and valid only at L4. - **Measured cost** (2026-10-28, analyzer built with go1.27.3, eight real apps). On 7 of 8 - apps, the peak RSS of `-a 4` is 1.0–1.5× that of `-a 3`; Kubernetes takes 38 s at 7.9 GB. - nats-server is the outlier at 3.8×, because its globals fan out through one recursive 822-callable - SCC. The JSON output is 1.9–23× that of `-a 3`. Per-app figures are in - `docs/design/notes/l3-dataflow-metrics.md` § L4. -- **Neo4j:** - - `--emit neo4j` projects **L4** (D4), adding `GO_CFG_NEXT`, `GO_CDG` and `GO_DDG`, and the SDG - rows `GO_PARAM_IN`, `GO_PARAM_OUT`, `GO_SUMMARY`, vertex `:GoBodyNode`s with `var`, and - `degraded_json`. `-a` with it is still an error. - - A lazy push upserts every L4 row on every push and removes none (D5); use `--eager` to drop - stale ones. `--emit neo4j -t` projects at L3 with a warning (D9). A push at a higher level - than the stored graph upserts everything; a lower-level push leaves the old L4 rows. See - [Neo4j projection](#neo4j-projection---emit-neo4j). - - `:GoBodyNode.call_node` is the enclosing statement's local key (the JSON `parent`), not a - global id. - - `--eager` now works on Neo4j 5.x. -- **Build.** Building from source needs Go 1.26 or newer. Release binaries are built with the - latest Go (see [Toolchain](#toolchain)). - -## Architecture & Tooling - -| Slot | Choice | Rationale | -|------|--------|-----------| -| Runtime | Go binary | Self-contained; no runtime dep for SDK users | -| Structural parser | `go/ast` (stdlib) | Part of the standard toolchain; no external dep | -| Type resolver | `golang.org/x/tools/go/packages` | Single API for both AST + full type resolution; handles modules natively | -| Build/dep materialization | `go mod download` | Required before `packages.Load` so the module cache is warm; result cached by `go.sum` hash | -| Packaging | Native binary (`go build`) | Zero-runtime-dep distribution; matches Rust/C++ analyzers | -| Analysis depth | Levels 1–4 | Symbol table, resolver call graph, intraprocedural cfg/cdg/ddg, interprocedural SDG | -| Call-graph dispatch | Declared-type resolution via `go/types.Selections` | CHA-equivalent; sufficient for cross-package reachability at Level 1 | -| CFG (L3) | Hand-built from `go/ast` (`internal/dataflow`) | Adds what `go/cfg` does not model as edges: panic `exception` edges and the `defer` chain (`defer_resume`). A differential test checks reachability against `golang.org/x/tools/go/cfg` on every fixture body | -| Def-use / DDG (L3) | Syntactic reaching definitions over k-limited access paths | `go/types` objects as bases (shadowing-safe); weak defs through reference arguments; `prov: ["ssa"]` for parity with the Java and Python L3 | -| SSA (L4) | `golang.org/x/tools/go/ssa` via `ssautil.Packages` over the same load, project packages only, built per package under `recover` | Bodies only for the project (dependencies from types); a panic degrades instead of aborting | -| Dispatch oracle (L4) | VTA (`go/callgraph/vta`) over the project's functions, library targets included | Concrete targets for interface and function-value calls; an interface call also binds the interface method (pass-through) | -| Alias oracle (L4) | Type-based may-alias (structural pointee compatibility, interface pairs, address-taken values, one-level field offset) | Additive `points-to` `ddg` edges; an interface so Andersen points-to can replace it without a schema change | - -### Package structure - -``` -codeanalyzer-go/ -├── cmd/codeanalyzer/ # CLI entry point (cobra) — builds the `cango` binary -├── internal/ -│ ├── core/ # Orchestrator — delegates only, no inlined analysis -│ ├── schema/ # GoApplication, GoFile, GoType, GoCallable, … (schema.go) -│ ├── options/ # AnalysisOptions + AnalysisLevel constants -│ ├── syntactic_analysis/ # SymbolTableBuilder (packages.Load → AST walk) -│ ├── semantic_analysis/ # CallGraphBuilder (go/types resolver) -│ ├── dataflow/ # L3: body nodes, CFG, CDG, def-use, DDG; Run fans out per callable -│ ├── sdg/ # L4: SSA, VTA dispatch, footprints, vertices, port wiring, summaries, stand-ins, may-alias -│ ├── analysis/ # Pluggable pass interface + registry (topo-ordered pipeline) -│ ├── frameworks/ # BaseEntrypointFinder — extension seam for framework passes -│ └── utils/ # DiscoverGoFiles, IsVendored, IsTestFile, logging -├── packaging/ -│ ├── python/ # PyPI wheel wrapper (bundles the prebuilt binary per platform) -│ ├── homebrew/ # generate_formula.sh — Homebrew tap formula generator -│ └── install/ # cango-installer.sh — curl | sh installer -├── testdata/ -│ ├── greeter/ # Minimal two-package fixture (basic struct/interface/call sites) -│ ├── multipackage/ # Richer fixture covering embedded fields, variadic params, goroutines, … -│ ├── generics/ # Go 1.18+ generics fixture (Set[T], union-constraint interfaces, Map[T,U]) -│ └── chi/ # External-dep fixture (chi v5, vendored) for HTTP handler patterns ``` -The `core` package is a pure orchestrator: it calls `syntactic_analysis` → `semantic_analysis` → `analysis.RunPipeline` in sequence, with no inlined parsing logic. Framework-specific analysis extends through the `analysis/` + `frameworks/` layer without touching `core`. +Go support needs `cldk` 2.1.0 or later. Levels 3 and 4 need `cldk` 2.2.0rc1 or later. The SDK finds `codeanalyzer-go` on `PATH`. See [python-sdk](https://github.com/codellm-devkit/python-sdk). ## Development -### Running tests - -```bash +```sh go test ./... ``` -Tests run against four fixtures: `testdata/greeter/` (basic), `testdata/multipackage/` (multi-file packages, goroutines, variadic params), `testdata/generics/` (Go 1.18+ generics — `Set[T]`, union constraints, multi-type-param functions), and `testdata/chi/` (external dependency via vendored chi v5, HTTP handler patterns). All 105 tests cover symbol table correctness, generic receiver attribution, call graph edges, JSON round-trip, output format validation, caching behaviour, and error paths. - -`go test` caches passing results by source hash. To force a full re-run: - -```bash -go clean -testcache && go test ./... -``` - -The analyzer's own `CacheDir` (used inside tests for `analysis_cache.json` and `go_mod_hash`) is written to OS temp directories that are wiped automatically when the test binary exits — there is no persistent on-disk state between test runs. The chi fixture is fully vendored, so tests never require network access. - -### Clearing the production cache - -By default the CLI writes its cache to `~/.cldk/go-cache`. To bypass it for a single run: - -```bash -cango -i ./my-project --eager -``` - -To delete it entirely: - -```bash -rm -rf ~/.cldk/go-cache -``` - -If you pass a custom `--cache-dir`, remove that directory instead. - -### Releasing - -Releases are cut by pushing a `vX.Y.Z` tag. The [release workflow](.github/workflows/release.yml) -cross-compiles the `cango` binary for all supported platforms and publishes: - -1. the raw binaries + `cango-installer.sh` as **GitHub Release** assets, -2. platform-tagged wheels to **PyPI** as `codeanalyzer-go` (via Trusted Publishing/OIDC), and -3. a **Homebrew** formula pushed to `codellm-devkit/homebrew-tap`. - -The version is injected into the binary at build time via `-ldflags "-X main.version="`, so -`cango --version`, the wheel version, and the git tag always stay in lockstep. See -[packaging/](packaging/) for the build scripts. +The fixtures under `testdata/` include their dependencies, so tests need no network. To release, push a `vX.Y.Z` tag: the [release workflow](.github/workflows/release.yml) publishes the binaries, the PyPI wheels and the Homebrew formula. [CHANGELOG.md](CHANGELOG.md) lists the changes. ## License -Apache 2.0 — see [LICENSE](./LICENSE). - -Application identity uses `--namespace` (default: resolved application name) and -`--app-name` (default: input directory basename). Both segments are always present, -for example `can://team/inventory` or `can://inventory/inventory`. Names are raw, -case-sensitive Unicode strings; reserved UTF-8 bytes are percent encoded. Empty, -whitespace-only, control-containing names, slashes, backslashes, `.` and `..` are -rejected. Explicit empty flags are errors. Outputs and graph anchors carry integer -`identity_version: 2`; regenerate legacy outputs from source. The graph writer -rejects incompatible selected anchors before any DDL or graph write. - -Graph relationships retain existing `_k` values and additionally use private -`_fact` identity (declared as `relationship_fact_property` by `--emit schema`). -Both snapshot and Bolt writers derive it from SHA-256 of the canonical JSON of -the existing pruned relationship properties. Equal endpoint/type/key facts with -different site, context, or evidence properties therefore remain distinct. +Apache 2.0. See [LICENSE](./LICENSE). diff --git a/cmd/codeanalyzer/main.go b/cmd/codeanalyzer/main.go index 9079abe..bf4334d 100644 --- a/cmd/codeanalyzer/main.go +++ b/cmd/codeanalyzer/main.go @@ -24,7 +24,7 @@ import ( // version is the analyzer version. It defaults to a dev value and is overridden // at release time via -ldflags "-X main.version=" (see packaging/python/build_wheels.sh), // keeping the binary, the PyPI wheel, and the git tag in lockstep. -var version = "0.3.0" +var version = "0.4.0" func main() { if err := rootCmd().Execute(); err != nil { diff --git a/go.mod b/go.mod index e77b48d..4c9e5c0 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/ebitengine/purego v0.10.1 // indirect github.com/felixge/httpsnoop v1.1.0 // indirect - github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/google/uuid v1.6.0 // indirect @@ -56,9 +56,10 @@ require ( github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 // indirect - go.opentelemetry.io/otel v1.44.0 // indirect - go.opentelemetry.io/otel/metric v1.44.0 // indirect - go.opentelemetry.io/otel/trace v1.44.0 // indirect + go.opentelemetry.io/otel v1.47.0 // indirect + go.opentelemetry.io/otel/log v1.47.0 // indirect + go.opentelemetry.io/otel/metric v1.47.0 // indirect + go.opentelemetry.io/otel/trace v1.47.0 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect golang.org/x/crypto v0.58.0 // indirect golang.org/x/sync v0.24.0 // indirect diff --git a/go.sum b/go.sum index 44edb93..86518ef 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ github.com/ebitengine/purego v0.10.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLA github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc= github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= +github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -110,16 +110,18 @@ go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 h1:8tvICD4vSTOOsNrsI4Ljf6C+6UKvpTEH5XY3JMoyPoo= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0/go.mod h1:z9+yiacE0IHRqM4qFfkbt/JYlmYXgss8GY/jXoNuPJI= -go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU= -go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc= -go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc= -go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo= +go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM= +go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU= +go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI= +go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw= +go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY= +go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU= go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58= go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0= go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI= go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA= -go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk= -go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE= +go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= +go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54= diff --git a/packaging/python/build_wheels.sh b/packaging/python/build_wheels.sh index 02ea167..4339c1e 100755 --- a/packaging/python/build_wheels.sh +++ b/packaging/python/build_wheels.sh @@ -28,7 +28,7 @@ REPO_ROOT="$(cd "$HERE/../.." && pwd)" # codeanalyzer-go repo root (has # tag); the literal is only a local-dev fallback. It is written into __init__.py # (hatch's single source of truth for the wheel version) and injected into the # binary via -ldflags so `cango --version` matches the wheel version. -PKG_VERSION="${PKG_VERSION:-0.3.0}" +PKG_VERSION="${PKG_VERSION:-0.4.0}" # The wheel filename carries the PEP 440-normalized version, not the raw tag # version: a SemVer pre-release like 0.1.0-rc.1 is built as 0.1.0rc1, and # 0.0.0-dev as 0.0.0.dev0. Normalize the same way so the retag step below finds diff --git a/packaging/python/src/codeanalyzer_go/__init__.py b/packaging/python/src/codeanalyzer_go/__init__.py index 81e10ba..8e8c7bf 100644 --- a/packaging/python/src/codeanalyzer_go/__init__.py +++ b/packaging/python/src/codeanalyzer_go/__init__.py @@ -17,7 +17,7 @@ from importlib import resources from pathlib import Path -__version__ = "0.3.0" +__version__ = "0.4.0" __all__ = ["bin_path", "__version__"]