Skip to content

feat(plugins): add built-in Go Language plugin and calibrated Reference ranges - #431

Merged
avidianity merged 10 commits into
mainfrom
feat/228-go-language
Nov 24, 2026
Merged

avidianity merged 10 commits into
mainfrom
feat/228-go-language

Conversation

@avidianity

@avidianity avidianity commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the built-in Go Language plugin (codeint-lang-go, plugins/languages/go/, plugin name go) supporting Go 1.27 source files (.go), module and workspace discovery (go.mod, go.work), multi-file package import resolution, five idiomatic Go Flagged line rules, public non-internal entry-point reporting, program_start marking on package main files, calibrated Go Reference ranges across 20 pre-2023 public Go repositories (proposed ADR 0021), and full user documentation.

Closes #228
Closes #394
Closes #395
Closes #396
Closes #397
Closes #398
Closes #399
Closes #400
Closes #401
Closes #402
Closes #403
Closes #404
Closes #405
Closes #406
Closes #407
Closes #408
Closes #409
Closes #410
Closes #411
Closes #412
Closes #413
Closes #414
Closes #415
Closes #416
Closes #417
Closes #418
Closes #419
Closes #420
Closes #421
Closes #422
Closes #423
Closes #424
Closes #425
Closes #426
Closes #427
Closes #428
Closes #429

Tier

Tier 3 from the tier check (cargo run --locked -p xtask -- risk-tier --base origin/main): touches .rules (tier map rule ".rules"), crates/plugin-host/Cargo.toml and crates/plugin-host/tests/conformance.rs (tier map rule "crates/plugin-host/**", registering Go Seam 2 conformance), and crates/cli/tests/check.rs (updating the expected built-in language list to include go and adding a Reference range test). Adds docs/adr/0021-go-reference-ranges.md (status: proposed, awaiting Owner acceptance).

Task

Spec #228 (Spec: Go Language plugin) and sub-issues #394 through #429:

  • Core plugin crate (plugins/languages/go/, Go Language plugin shell with the lexer #394-Each folder with a go.mod file is a Workspace package #412): zero external parser dependencies built on codeint_model::scan, full Go 1.27 lexer with semicolon insertion, functions/methods/type parameters/function literals, decision points and Cognitive complexity, Source sets (*_test.go, testdata/, vendor/, // Code generated ... DO NOT EDIT.), five Flagged line rules (empty-branch, else-after-return, unused-return-blank, empty-defer, bare-recover), import collection and multi-file package resolution (including stdlib, "C", go.mod module/require/// indirect/tool/replace, go.work), program_start on package main, public non-internal entry points, Seam 2 conformance, and CLI registration.
  • Integration tests and documentation (Import cycles on Go #413-// indirect lines of go.mod are optional dependencies #422, The go Language plugin publishes its Reference range #429): 9 process-boundary integration tests in crates/cli/tests/integration/go.rs, docs/guide/go.md, updates to docs/guide/languages.md, docs/guide/README.md, docs/guide/configuration.md, docs/reference.md, docs/plugins.md, README.md, llms.txt, GLOSSARY.md, and .rules.
  • Reference range calibration (tool lines of go.mod are development dependencies #423-Go Reference range ADR #428): measured 20 pre-2023 public Go repositories per ADR 0008 (12,052 Go files, 1,189,802 Go Production lines, 0 unparsable Go files; go-gitea/gitea in 0.51s / 242.0 MiB RSS), hand-checked 113 Flagged lines across all 5 rules with 0 false positives, published calibrated Reference ranges in plugins/languages/go/src/lib.rs and docs/adr/0021-go-reference-ranges.md.

Fail-first test

  • Test: plugins/languages/go/tests/conformance.rs (7 conformance suites), plugins/languages/go/tests/entry_points.rs (2 suites), crates/plugin-host/tests/conformance.rs (built_in_go_plugin_passes_seam_2_conformance), crates/cli/tests/integration/go.rs (9 process-boundary integration tests), and crates/cli/tests/check.rs (go_check_displays_calibrated_reference_ranges_next_to_go_values).
  • Before the change: failed before implementation and on earlier Prove rounds (go.mod escaped multi-byte UTF-8 panic, parenthesized method receiver func (w (*Widget)) M(), local+versioned replace mismatch between resolution and dependencies, and composite function types with nested func return types, pointer prefixes, and chained brackets like [2][3]*func() func() int{...}).
  • After the change: passed.

Checks

Check Result
cargo fmt --all --check passed
cargo clippy --workspace --all-targets --locked -- -D warnings passed
cargo test --locked -p codeint-lang-go passed (7 conformance, 2 entry_points)
cargo test --locked -p codeint-plugin-host passed (3 unit, 9 conformance, 33 load)
cargo test --locked -p codeint-cli --test integration -- go:: passed (9 integration tests)
cargo test --locked -p codeint-cli --test reference passed (5 reference tests)
cargo run --locked -p codeint-cli -- diff origin/main --format toon passed (0 regressions)
cargo run --locked -p xtask -- merged-result passed

Safety proof

  • Safety fact: Adding the zero-dependency built-in Go Language plugin does not regress any existing built-in Language plugin, external WASM plugin contract, or CLI/MCP output, and safely handles untrusted/malformed Go source and go.mod/go.work manifests without panics, unbounded loops, or I/O side effects.
  • Proof: Blast Radius Verifier on commit bfe403a proved Safety Fact 1 (all 9 Seam 2 conformance suites and 33 plugin-host load tests pass; existing TypeScript/JavaScript/Vue/Svelte, Rust, PHP, Dart, and Python behavior unchanged) and Safety Fact 2 (Go plugin has zero external parser crates, uses checked arithmetic and bounded scans, performs no filesystem/network/env I/O, and surfaces malformed go.mod as exit code 2).
  • interrogate:
    • Round 1 (commit bfe403a): 4 Go plugin edge cases (go.mod escaped multi-byte UTF-8 panic, []func(...){...} cognitive complexity inflation, local+versioned replace disagreement, parenthesized method receivers) and missing Go ranges/rules in docs/reference.md. All 5 fixed in 11c5976 with regression tests.
    • Round 2 (commit 11c5976): verified 4/5 fixes and found 1 residual case ([]func() func() int{...}, map[K]func() func() int{...}, []*func() int{...}). Fixed in 8b2b8ce.
    • Round 3 (commit 8b2b8ce): verified single-bracket composite function types and arithmetic expressions, and found 1 residual case (chained bracket prefixes before *func such as [2][3]*func() func() int{...} and multi-row rule drops in [2][1]*func() int{ {row1}, {row2} }). Fixed in 407ad00.
    • Round 4 clean rerun (commit 407ad00): PASS (0 open verified findings across chained composite function types, index-multiplication expressions, multi-row flagged-line rules, loop termination, and all targeted Go and plugin-host conformance suites).

Runtime evidence

  • Build revision: 407ad00
  • Verdict: PASS
  • Feature map: Go file lowering, module and workspace discovery, multi-file package import resolution, 5 Flagged line rules, public non-internal entry points, program_start on package main, and calibrated Reference ranges.
  • Calibrated against 20 pre-2023 public Go repositories (docs/adr/0021-go-reference-ranges.md): 12,052 Go files, 1,189,802 Go Production lines, 0 unparsable Go files; largest repository (go-gitea/gitea) checked in 0.51s with 242.0 MiB peak RSS.
  • Published Go Reference ranges (10th to 90th percentile): Erosion 0.379..0.692, Duplication 0.044..0.181, Verbosity 0.045..0.183, Import cycles 0.000..0.000, source "codeint panel of 20 Go repositories, ADR 0021, codeint 0.6.0".
  • Hand-checked 113 Flagged lines across all 5 Go rules on the calibration panel with 0 false positives; fixed two real defects discovered during panel runs (else-after-return chain handling and self-import cycle filtering in ethereum/go-ethereum).

Gaps

  • Deferred coverage: none.
  • Pre-existing failures: none.
  • Environmental failures: none.

Calibrate Go Reference ranges from 20 pre-2023 public Go repositories
following ADR 0008 and record the panel, exclusions, timing, peak RSS,
Flagged line hand check, and 10th-to-90th percentile ranges in ADR 0021.

Fix two defects uncovered during calibration with synthetic regression
tests and re-measure all 20 panel repositories:
- Keep else-after-return silent when an earlier if branch in an
  if/else if/else chain does not return.
- Exclude the importing file from resolved Go package targets so
  build-constrained generator files in a package folder do not create
  spurious single-file import cycles.

Publish the calibrated Reference ranges in the Go Language plugin,
enable the Seam 2 conformance check for Go Erosion Reference ranges,
and verify Go Reference ranges in codeint check output.

Closes #425
Closes #426
Closes #427
Closes #428
Closes #429
@github-actions github-actions Bot added the tier-3 Tier 3 from the tier check label Nov 24, 2026
@avidianity
avidianity marked this pull request as ready for review November 24, 2026 10:12
@avidianity
avidianity merged commit cb4185a into main Nov 24, 2026
13 of 14 checks passed
@avidianity
avidianity deleted the feat/228-go-language branch November 24, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment