Summary
Add a vibe-check analyze command that computes package-level structural quality metrics for Go codebases using the Go-native toolchain.
RFC : https://github.com/orgs/unbound-force/discussions/483 — Group 1
Phase : P0 (Foundation)
Context
The metrics package (merged via PR #17 ) provides the universal coupling model — named metric types, the Adapter interface, ExternalAdapter with JSON-RPC 2.0 protocol, Registry, and JSON Schema validation. This issue builds the Go-native adapter and CLI on top of that foundation, making the metrics computable and accessible.
Architecture
vibe-check analyze [packages...]
│
├── cmd/vibe-check/ CLI entry point (cobra)
├── internal/go/ Go-native adapter (implements metrics.Adapter)
│ └── uses golang.org/x/tools/go/packages
└── metrics/ Universal model (already merged)
├── adapter.go Adapter interface
├── compute.go ComputeInstability, ComputeAbstractness, etc.
├── graph.go ModuleGraph, ModuleResult
└── values.go Instability, Abstractness, Distance, LCOM
Metrics to Compute
Metric
Symbol
Description
Afferent Coupling
Ca
Number of packages that depend on this package
Efferent Coupling
Ce
Number of packages this package depends on
Instability
I
Ce / (Ca + Ce) — ranges from 0 (stable) to 1 (unstable)
Abstractness
A
Ratio of abstract types (interfaces) to total types
Distance from Main Sequence
D
|A + I − 1| — proximity to the ideal balance
Cohesion
LCOM
LCOM4 variant (Hitz & Montazeri, 1995)
Circular Dependencies
—
Detection of import cycles
Implementation
Go adapter : Implements metrics.Adapter interface using golang.org/x/tools/go/packages for type-aware dependency resolution
CLI : vibe-check analyze [packages...] using cobra
Output : JSON conforming to metrics.ModuleGraph schema (validated by metrics.Validate)
Registration : Go adapter registered in metrics.Registry at startup
CI Gate Flags
vibe-check analyze ./... \
--max-instability=0.67 \
--max-distance=0.3 \
--no-circular-deps \
--min-cohesion=0.5
Exit code non-zero if any threshold is violated.
JSON Output
{
"schemaVersion" : " 1.0" ,
"language" : " go" ,
"projectPath" : " ./..." ,
"status" : " complete" ,
"modules" : [
{
"path" : " internal/analyzer" ,
"afferentCoupling" : 5 ,
"efferentCoupling" : 3 ,
"instability" : 0.375 ,
"abstractness" : 0.2 ,
"distance" : 0.425 ,
"lcom" : 2 ,
"cycles" : []
}
],
"warnings" : []
}
Acceptance Criteria
vibe-check analyze command implemented using cobra
Go adapter implements metrics.Adapter interface
Uses golang.org/x/tools/go/packages for dependency resolution
All 7 metrics computed correctly (Ca, Ce, I, A, D, LCOM, circular deps)
JSON output conforms to metrics.ModuleGraph schema (passes metrics.Validate)
CI gate flags work (--max-instability, --max-distance, --no-circular-deps, --min-cohesion)
Non-zero exit code on threshold violations
Tests covering metric computation accuracy
go build ./..., go test -race -count=1 ./..., golangci-lint run ./... all pass
Dependencies
Summary
Add a
vibe-check analyzecommand that computes package-level structural quality metrics for Go codebases using the Go-native toolchain.RFC: https://github.com/orgs/unbound-force/discussions/483 — Group 1
Phase: P0 (Foundation)
Context
The
metricspackage (merged via PR #17) provides the universal coupling model — named metric types, theAdapterinterface,ExternalAdapterwith JSON-RPC 2.0 protocol,Registry, and JSON Schema validation. This issue builds the Go-native adapter and CLI on top of that foundation, making the metrics computable and accessible.Architecture
Metrics to Compute
Implementation
metrics.Adapterinterface usinggolang.org/x/tools/go/packagesfor type-aware dependency resolutionvibe-check analyze [packages...]usingcobrametrics.ModuleGraphschema (validated bymetrics.Validate)metrics.Registryat startupCI Gate Flags
Exit code non-zero if any threshold is violated.
JSON Output
{ "schemaVersion": "1.0", "language": "go", "projectPath": "./...", "status": "complete", "modules": [ { "path": "internal/analyzer", "afferentCoupling": 5, "efferentCoupling": 3, "instability": 0.375, "abstractness": 0.2, "distance": 0.425, "lcom": 2, "cycles": [] } ], "warnings": [] }Acceptance Criteria
vibe-check analyzecommand implemented using cobrametrics.Adapterinterfacegolang.org/x/tools/go/packagesfor dependency resolutionmetrics.ModuleGraphschema (passesmetrics.Validate)--max-instability,--max-distance,--no-circular-deps,--min-cohesion)go build ./...,go test -race -count=1 ./...,golangci-lint run ./...all passDependencies
metricspackage)