Repository navigation
Description
Why
Gaze currently analyzes Go code exclusively, but its core value proposition — side effect detection, contract classification, CRAP scoring, test quality assessment — is language-agnostic. The taxonomy, scoring formulas, classification engine, reporting, TUI, and AI pipeline all work on abstract data structures that have no inherent dependency on Go.
There is active demand for Python analysis (the snake-eyes project), and the same architecture would support TypeScript, Rust, and other languages in the future.
Rather than reimplementing the entire gaze stack per language, gaze should become a universal core that delegates language-specific analysis to external analyzer processes via a well-defined protocol.
What Changes
New Capability: External Analyzer Protocol
Gaze gains the ability to spawn an external language analyzer process and communicate via JSON-RPC 2.0 over stdin/stdout — the same transport pattern used by the Language Server Protocol (LSP), but with gaze-specific methods.
Lifecycle:
gaze analyze --analyzer snake-eyes ./src
│
├─ 1. Find analyzer binary in PATH (or from .gaze.yaml config)
├─ 2. Spawn: snake-eyes --stdio
├─ 3. initialize → capabilities handshake
├─ 4. discover → find source + test files
├─ 5. analyze → detect side effects per function
├─ 6. complexity → cyclomatic complexity per function
├─ 7. coverage → parse language-specific coverage data
├─ 8. test_mapping → map assertions to effects (optional)
├─ 9. classify_signals → language-specific classification signals (optional)
├─ 10. shutdown → clean exit
└─ 11. Gaze computes CRAP, GazeCRAP, quadrants, fix strategies, renders reports
Protocol methods:
| Method | Required | Direction | Purpose |
|---|---|---|---|
initialize |
Yes | gaze → analyzer | Handshake: root path, config, capabilities |
discover |
Yes | gaze → analyzer | Find source files, test files, framework |
analyze |
Yes | gaze → analyzer | Detect side effects per function |
complexity |
Yes | gaze → analyzer | Cyclomatic complexity per function |
coverage |
Yes | gaze → analyzer | Parse coverage data |
test_mapping |
No | gaze → analyzer | Map test assertions to side effects |
classify_signals |
No | gaze → analyzer | Language-specific classification signals |
shutdown |
Yes | gaze → analyzer | Clean process exit |
Capability negotiation: The initialize response declares which optional methods the analyzer supports. Gaze adapts its pipeline accordingly (e.g., skips test quality assessment if test_mapping is not supported).
New Capability: Analyzer Discovery
Analyzers are discovered via:
- CLI flag:
--analyzer <name>explicitly names the binary - Config:
.gaze.yamlmaps languages to analyzer binaries - PATH convention:
gaze-analyzer-<language>naming convention (fallback)
Example .gaze.yaml:
analyzers:
python:
command: snake-eyes
args: ["--stdio"]Internal Refactoring Required
To support external analyzers, several internal packages need their language-specific logic separated from their universal logic:
| Package | Universal (keep) | Language-specific (extract) |
|---|---|---|
taxonomy |
Effect types, tiers, priorities | — (already universal) |
classify |
Score computation, tier boosts, thresholds | Signal detection (interface, visibility, callers, naming, godoc) |
crap |
Formula, quadrants, fix strategies | Coverage parsing (Go coverage format) |
quality |
Contract coverage, over-spec scoring | Assertion detection, assertion mapping, test pairing |
analysis |
AnalysisResult assembly | AST walking, SSA analysis |
The Go-specific analysis becomes the built-in analyzer — gaze's existing behavior is preserved as the default when no external analyzer is specified. External analyzers provide the same data through the JSON-RPC protocol.
Impact
- New packages:
internal/protocol(JSON-RPC client),internal/adapter(external analyzer adapter) - Modified packages:
cmd/gaze(CLI flags, analyzer dispatch),classify(separate scoring from signal detection),crap(separate formula from coverage parsing),quality(separate scoring from assertion detection) - New config options:
analyzerssection in.gaze.yaml - CLI changes: New
--analyzerand--languageflags onanalyze,crap,quality,reportcommands - Backward compatible: When no external analyzer is configured, gaze behaves exactly as it does today (built-in Go analysis)
Constitution Alignment
I. Accuracy
Assessment: PASS — The protocol transmits raw analysis data (effects, coverage, complexity) to gaze's existing scoring engine. Accuracy of the universal scoring is preserved. Language-specific accuracy depends on the quality of the external analyzer, which is tested independently.
II. Minimal Assumptions
Assessment: PASS — The protocol makes minimal assumptions about the analyzer's language or implementation. Analyzers report standardized effect types, coverage data, and complexity metrics. No language-specific knowledge is required in gaze's core.
III. Actionable Output
Assessment: PASS — Reports produced from external analyzer data use the same formatting, fix strategies, and quadrant classification as Go analysis. The output is equally actionable regardless of source language.
IV. Testability
Assessment: PASS — The JSON-RPC protocol is inherently testable: mock analyzers can be written as simple scripts that emit canned responses. Each protocol method can be tested in isolation. The adapter layer can be tested without spawning real analyzer processes.
Open Questions
- Taxonomy evolution: Should the side effect taxonomy be generalized to accommodate language-specific effect types? (See related issue on taxonomy.)
- Protocol versioning: How should protocol versions be negotiated? Semantic versioning in the
initializehandshake? - Error handling: How should analyzer crashes, malformed responses, and partial results be handled? Graceful degradation (like SSA failures today) or hard errors?
- Streaming: Should
analyzesupport streaming results (one function at a time) for large codebases, or batch response only?
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✔️
Activity
feat: scaffold snake-eyes project with tooling, docs, and constitution
em-redhat commentedon Jun 23, 2026
Implementation Progress
Phase 1: Provider Interface Extraction (PR #165) -- MERGED
internal/crap/provider.go(ComplexityProvider,LineCoverageProvider,SideEffectAnalyzer,ContractCoverageProvider)FunctionComplexitytype replacinggocyclo.Statinternal/provider/goprovider/(complexity, coverage, sideeffect, contract)computeScoresandlookupCoverageto acceptFunctionComplexitycrap.Analyzeto use provider interfaces fromOptionscmd/gaze/main.go,internal/aireport/runner.go) to construct providers at call sitesinternal/provider/mockprovider/(13 tests)coverageFunctest injection from deprecatedContractCoverageFunctoContractCoverageProviderTestSC002to useGoContractCoverageProviderinstead ofBuildContractCoverageFunc+ deprecated fieldgenerateCoverProfileto reduce CRAPload from 41 to <=38Phase 2: JSON-RPC Protocol + External Adapters (PR #178) -- MERGED
internal/protocol/) — subprocess spawn, stdin/stdout communication, request/response matchinginternal/protocol/testdata/fake_analyzer/) for testinginternal/adapter/) — 4 types implementing Phase 1 interfaces via protocol translationinitializeresponse declares optional methods, adapters skip unsupported methods.gaze.yamlconfig →gaze-analyzer-<language>PATH convention.gaze.yamlanalyzersconfig section--analyzerand--languageon crap, quality, report commandsdocs/protocol.md) for analyzer authorsgaze crap --analyzer fake_analyzerPhase 3: Cleanup + Taxonomy Generalization + Streaming (PR #180) -- MERGED
ContractCoverageFuncandSSADegradedPackagesfromcrap.Optionscrap.AnalyzeContractCoverageProviderexclusivelyTestMockProviders_ProviderPrecedence) — no longer has a subjectisMainPkgingoprovider/sideeffect.go— useloader.IsMainPkgBuildContractCoverageFuncand helpers frominternal/crap/contract.gotointernal/provider/goprovider/contract.gointernal/crap/has zero Go-specific analysis importsMetadata.GoVersion→LanguageVersion, addLanguagefield, update JSON schemasSideEffectTypealiases (AsyncTaskSpawn,AsyncMessageSend,AsyncChannelClose,BarrierOp,PanicRecovery,FFICall,ObjectPoolOp)LanguageVersiontoprotocol.InitializeResultandadapter.ProvidersStreamingcapability flag,analyze/streammethod,CallStreamon protocol client, JSONL support inExternalSideEffectAnalyzer, fake analyzer--hang-streammodedocs/protocol.mdwith streaming method and neutral type aliasesStatus: All 3 phases complete
All planned work for the external analyzer protocol is implemented and merged. The open questions from the original issue:
Language/LanguageVersionfields). Full universal taxonomy overhaul tracked separately in feat: generalize side effect taxonomy for multi-language support #96.protocol_versionfield ininitializeresponse.analyze/streammethod with JSONL format (Phase 3).This issue can be closed. Remaining taxonomy work (universal abstract types,
detailfield) is tracked in #96.docs: add provider-interfaces OpenSpec change artifacts
docs: add provider-interfaces OpenSpec change artifacts
docs: add provider-interfaces OpenSpec change artifacts
docs: add provider-interfaces OpenSpec change artifacts
Merge pull request #165 from em-redhat/opsx/provider-interfaces
docs: add external-analyzer-protocol OpenSpec change artifacts (Phase…
feat: add --analyzer and --language flags for external analyzer suppo…
docs: add external-analyzer-protocol OpenSpec change artifacts (Phase…
4 remaining items
Merge pull request #178 from em-redhat/opsx/external-analyzer-protocol
docs: add taxonomy generalization and streaming protocol to Phase 3 spec
docs: add provider-cleanup OpenSpec change artifacts (Phase 3 of unbo…
docs: add taxonomy generalization and streaming protocol to Phase 3 spec
em-redhat commentedon Jul 2, 2026
All 3 phases merged: Phase 1 (PR #165 — provider interfaces), Phase 2 (PR #178 — JSON-RPC protocol + adapters), Phase 3 (PR #180 — cleanup, taxonomy generalization, streaming). Remaining taxonomy work (universal abstract types, detail field) tracked in #96.
docs: add provider-cleanup OpenSpec change artifacts (Phase 3 of unbo…
docs: add taxonomy generalization and streaming protocol to Phase 3 spec
docs: add provider-interfaces OpenSpec change artifacts
docs: add external-analyzer-protocol OpenSpec change artifacts (Phase…
feat: add --analyzer and --language flags for external analyzer suppo…
docs: add provider-cleanup OpenSpec change artifacts (Phase 3 of unbo…
docs: add taxonomy generalization and streaming protocol to Phase 3 spec