Repository navigation
Closed
Labels
P0Critical priority — Phase 1 foundation
Description
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.Adapterinterface usinggolang.org/x/tools/go/packagesfor type-aware dependency resolution - CLI:
vibe-check analyze [packages...]usingcobra - Output: JSON conforming to
metrics.ModuleGraphschema (validated bymetrics.Validate) - Registration: Go adapter registered in
metrics.Registryat 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 analyzecommand implemented using cobra - Go adapter implements
metrics.Adapterinterface - Uses
golang.org/x/tools/go/packagesfor dependency resolution - All 7 metrics computed correctly (Ca, Ce, I, A, D, LCOM, circular deps)
- JSON output conforms to
metrics.ModuleGraphschema (passesmetrics.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
- Depends on: Design universal multi-language coupling metrics model (Group 10 — architecture) #1 (completed) — universal coupling model (
metricspackage)
Metadata
Metadata
Assignees
Labels
P0Critical priority — Phase 1 foundation
Activity
[-]gaze coupling — Go-native package-level coupling metrics (Group 1)[/-][+]vibe-check analyze — Go-native package-level coupling metrics[/+]jflowers commentedon Aug 29, 2026
Amendment: Language-Specific Extensions (Go Adapter)
Background
A gap analysis against the comprehensive Martin metrics framework identified two Go-specific metrics that are absent from the current scope but valuable for Go codebases:
Proposed Integration
These metrics are language-specific and do not belong in the universal
ModuleResultschema. Instead, they should be carried via an extensions mechanism:1. Schema Change (prerequisite — applies to all adapters)
Add an optional
extensionsfield to the module item inmodulegraph.schema.json:Remove
"additionalProperties": falsefrom the module item (or change it to allowextensionsexplicitly). The top-levelModuleGraphandWarningschemas remain strict.2. Go Struct Change
Add to
ModuleResultinmetrics/graph.go:3. Go Adapter Populates Extensions
The Go adapter (in
internal/go/) populates:go.interfaceWidth—map[string]intmapping interface name to method count. Enables linting rules like "flag interfaces with >5 methods."go.interfaceProximity—map[string]stringmapping interface name to"consumer"or"producer", based on whether the interface is declared in the same package as its primary implementation.4. New Capability Constants
These are optional capabilities — declared by the Go adapter but not required by the universal model.
Additional Acceptance Criteria
Appended to the existing criteria:
ModuleResult.Extensionsfield added withomitemptyJSON tagextensionsobject on module itemsgo.interfaceWidthfor all exported interfacesgo.interfaceProximityfor all exported interfacesgo.interfaceWidthandgo.interfaceProximitycapabilities declaredNon-Goals
ModuleorModuleResultfields beyondExtensionsfeat: add go-analyze OpenSpec change artifacts
feat: add Extensions field to ModuleResult and bump schema to v1.1
feat: implement Go language adapter with coupling metrics
feat: add vibe-check analyze CLI command
docs: update AGENTS.md, add CHANGELOG, pin CI actions
fix: resolve code review findings — Ce stdlib counting, test assertio…