Skip to content

feat(review): golangci-lint sarif adapter for go in scan and review #603

Closed

Description

@dan-petty

Context & Rationale

The review's static stage picks analyzers by file suffix in _run_static_scanners (ai/review/pipeline.py:1165-1229). Bandit runs on .py, Kube-linter and Pluto on YAML, Trivy on container files and lockfiles, and Gitleaks and Semgrep p/default on every file. _STATIC_ANALYZERS (pipeline.py:849-856) has no Go entry, and neither do the registry's 11 scanners (security/registry.py:16-42), so a .go file gets only generic rules. SARIF ingestion already exists (security/sarif.py:311, security/normalization.py:308). The review already reports a missing binary as not run (#516, pipeline.py:860-872). .devops/review.md already carries per-repo rules into persona prompts (ai/review/review_environment.py:74). vibes wrote its own pprof goroutine classifier. Its survey lists uber-go/goleak as the maintained alternative (docs/landscape/SURVEY.md:36), and its roadmap plans a golangci-lint integration (docs/ROADMAP.md:63).

Scope & Deliverables

  • Context & Rationale*: The review's static stage picks analyzers by file suffix in _run_static_scanners (ai/review/pipeline.py:1165-1229). Bandit runs on .py, Kube-linter and Pluto on YAML, Trivy on container files and lockfiles, and Gitleaks and Semgrep p/default on every file. _STATIC_ANALYZERS (pipeline.py:849-856) has no Go entry, and neither do the registry's 11 scanners (security/registry.py:16-42), so a .go file gets only generic rules. SARIF ingestion already exists (security/sarif.py:311, security/normalization.py:308). The review already reports a missing binary as not run (fix(review): the static scan reports a clean result when its scanners are not installed #516, pipeline.py:860-872). .devops/review.md already carries per-repo rules into persona prompts (ai/review/review_environment.py:74). vibes wrote its own pprof goroutine classifier. Its survey lists uber-go/goleak as the maintained alternative (docs/landscape/SURVEY.md:36), and its roadmap plans a golangci-lint integration (docs/ROADMAP.md:63).
  • Deliverable*: Add a GolangciLintScanner to the registry. It requests SARIF output and converts it with from_sarif and to_finding, so no bespoke parser is needed. Default linters are errcheck, govet (with lostcancel) and staticcheck; contextcheck is opt-in. Add a go kind and a golangci-lint row to _STATIC_ANALYZERS. Add a .go branch in _run_static_scanners that runs once per nearest go.mod root and keeps only findings in reviewed files, using _match_static_findings_to_files. Add a golangci-lint entry in commands/install_tools.py. Keep the suffix dispatch and do not reroute the stage through the registry. Do not port the vibes classifier or tools/cpp_lifetime_sentinel.py. File two follow-ups separately. The first is a Go persona addendum that recommends goleak. It is blocked on Model-in-the-Loop Prompt Benchmarking and on a goroutine defect template, which ai/review/defects.py does not have. The second is clang-tidy with a compile_commands.json, only once the fmt sample shows a recall gap.
  • Constraint*: golangci-lint loads packages through the Go toolchain. It needs go on PATH and module dependencies it can resolve, and it runs per module, not per file list. A missing go, a package-load or typecheck failure, and a missing binary must each record their own analyzer state, never zero findings. The registry path still returns [] for a missing binary (security/base.py:93-97), so devops scan report needs the same guard for this scanner. A first run on an existing tree floods the review. Branch reviews should use golangci-lint's own --new-from-merge-base rather than a hand-rolled baseline. Measure before claiming value: run devops review samples validate --review on the go category (cobra) before and after the change.
  • Measured*: The vibes classifier reports CLEAN at 100.0 on a hand-built dump that has a chan send goroutine under runtime.gopark (python3 -B probe/probe_leak.py). One managed repository holds 359 non-vendored .go files (find <repo> -name '*.go' -not -path '*/vendor/*' | wc -l), and it tracks none of them (git -C <repo> ls-files '*.go' | wc -l gives 0). All 3 saved Go sample validations have review: null (.data/reviews/sample-validations/*/go.json), so Go review recall has never been measured.
  • Source*: vibes examples/go-leak-sentinel/README.md, examples/go-leak-sentinel/sentinel.go, examples/go-leak-sentinel/go_leak_sentinel.py, observations/polyglot/03-go-goroutine-leakage-and-context-lifecycles.md, observations/polyglot/04-cpp-raii-and-lifetime-invariants-under-llm-synthesis.md, tools/cpp_lifetime_sentinel.py, docs/ROADMAP.md, docs/landscape/SURVEY.md

Update 2026-10-08: refinement

Nothing runs golangci-lint. A Go bucket goes in _run_static_scanners (ai/review/pipeline.py:2574), and findings pass #871's admission. #871's base-revision scan (:2238) replaces --new-from-merge-base, but it writes only reviewed files (:2253-2258), so a Go base scan also needs go.mod. The version goes in #1142's lock, not install_tools.py; it runs through #772's executor and counts after #1143's canary. Depends on #1142, #772 and #1143.

Proposed design

Problem statement

The review's static analysis stage does not include support for Go files, meaning that .go files only receive generic rule checks instead of language-specific linting. This issue aims to add golangci-lint as a scanner for Go files using SARIF output conversion.

Acceptance criteria

  • Criterion 1: A GolangciLintScanner is added to the security registry
    Verification: Verify that GolangciLintScanner class exists in security/registry.py and is registered with the scanner registry.
  • Criterion 2: Go files are analyzed using golangci-lint with SARIF output conversion
    Verification: Run devops review on a Go repository and confirm that findings from golangci-lint appear in the review results for .go files.
  • Criterion 3: The scanner runs once per nearest go.mod root and filters findings to reviewed files
    Verification: Verify that _run_static_scanners function in pipeline.py includes a branch for '.go' files that calls _match_static_findings_to_files to filter findings.
  • Criterion 4: Default linters include errcheck, govet (with lostcancel), and staticcheck with contextcheck as opt-in
    Verification: Check that the GolangciLintScanner's default configuration includes these linters in the correct order and that contextcheck is properly configured as optional.
  • Criterion 5: The golangci-lint binary is installed via commands/install_tools.py
    Verification: Run devops install tools and confirm that golangci-lint appears in the list of installed tools.

Key questions

  • What are the default linters for golangci-lint that should be enabled?: Default linters are errcheck, govet (with lostcancel) and staticcheck; contextcheck is opt-in. [sources: docs/agent/tasks/task-603-golangci-lint-sarif-adapter-for-go-in-scan-and-review.md:17]
  • How should the scanner integrate with existing SARIF ingestion capabilities?: The scanner should request SARIF output and convert it using from_sarif and to_finding functions, so no bespoke parser is needed. [sources: docs/agent/tasks/task-603-golangci-lint-sarif-adapter-for-go-in-scan-and-review.md:17]
  • Should the Go scanner run per file or per module?: It should run once per nearest go.mod root, not per file list. [sources: docs/agent/tasks/task-603-golangci-lint-sarif-adapter-for-go-in-scan-and-review.md:17]
  • What is the expected behavior when golangci-lint binary is not available?: A missing binary must record its own analyzer state, never zero findings, and the registry path still returns [] for a missing binary. [sources: docs/agent/tasks/task-603-golangci-lint-sarif-adapter-for-go-in-scan-and-review.md:18]
  • Should the implementation port the vibes classifier or cpp_lifetime_sentinel.py?: No, these should not be ported. [sources: docs/agent/tasks/task-603-golangci-lint-sarif-adapter-for-go-in-scan-and-review.md:17]
  • Should the implementation use the registry path or maintain suffix dispatch?: Keep the suffix dispatch and do not reroute the stage through the registry. [sources: docs/agent/tasks/task-603-golangci-lint-sarif-adapter-for-go-in-scan-and-review.md:17]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#772, #1143

Activity

  1. added this to the v0.2.23 milestone on Sep 25, 2026
  2. added
    type/feature
    scope/review
    priority/p2-medium
    on Sep 25, 2026
  3. modified the milestones: v0.2.23, v0.2.24 on Sep 28, 2026
  4. removed this from the v0.2.23 milestone on Oct 1, 2026
  5. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Moved from the shipped v0.2.23 to the backlog. It is still valid (checked 2026-10-01), and P2 items don't displace P1 work in the planned releases.

  6. added this to the v0.2.39 milestone on Oct 17, 2026
  7. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at 25e2cda (see proposed design in issue body).

  8. modified the milestones: v0.2.39, on Oct 20, 2026
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

    priority/p2-mediumscope/reviewtype/feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions