Skip to content

refactor: provider cleanup — remove deprecated fields, generalize taxonomy, add streaming protocol - #180

Merged
em-redhat merged 7 commits into
unbound-force:mainfrom
em-redhat:opsx/provider-cleanup
Jul 2, 2026
Merged

em-redhat merged 7 commits into
unbound-force:mainfrom
em-redhat:opsx/provider-cleanup

Conversation

@em-redhat

@em-redhat em-redhat commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Completes the external analyzer protocol initiative (Phase 3 of #95) by removing backward-compatibility shims, deduplicating code, generalizing the taxonomy for multi-language support, and adding an optional streaming protocol mode.

Changes

  • Deprecated field removal: Removed ContractCoverageFunc and SSADegradedPackages from crap.Options. Contract coverage now flows exclusively through ContractCoverageProvider. Removed the fallback dispatch path in crap.Analyze.
  • isMainPkg deduplication: Replaced local copy in goprovider/sideeffect.go with canonical loader.IsMainPkg. The copy in crap/contract.go was also eliminated by the relocation below.
  • BuildContractCoverageFunc relocation: Moved from internal/crap/contract.go to internal/provider/goprovider/contract.go. internal/crap/ now has zero Go-specific imports (internal/analysis, internal/classify, internal/quality, internal/loader, golang.org/x/tools/go/packages).
  • Taxonomy generalization: Renamed Metadata.GoVersion to LanguageVersion (JSON tag language_version), added Language field (JSON tag language). Updated JSON schemas. Breaking JSON change: go_version → language_version.
  • Neutral side effect type aliases: Added 7 language-neutral SideEffectType constants (AsyncTaskSpawn, AsyncMessageSend, AsyncChannelClose, BarrierOp, PanicRecovery, FFICall, ObjectPoolOp).
  • Streaming protocol: Added Streaming capability flag, analyze/stream method constant, CallStream on protocol client, streaming JSONL support in ExternalSideEffectAnalyzer, fake analyzer --hang-stream mode.

Testing

  • All 16 packages pass: go test -race -count=1 -short ./...
  • Streaming parity test verifies batch and streaming produce identical results
  • Alias equivalence tests verify neutral names equal Go-specific names
  • CRAPload at 38/38 (tests added for findModuleRoot and CallStream to maintain threshold)

Related Issues

Partially addresses #96 (generalize side effect taxonomy):

  • ✅ Renamed Metadata.GoVersion → LanguageVersion, added Language field
  • ✅ Added 7 language-neutral SideEffectType aliases with backward-compatible Go names preserved
  • ✅ Updated JSON schemas for language and language_version
  • ✅ Added LanguageVersion to protocol.InitializeResult and adapter.Providers
  • ❌ Not done: ~25 universal abstract types (e.g., ErrorSignal, ContainerMutation, GeneratorYield)
  • ❌ Not done: Layer 2 detail field for language-specific context
  • ❌ Not done: Full tier reassignment to universal types
  • ❌ Not done: New types with no Go equivalent (GeneratorYield, MetaprogrammingMutation, etc.)

Partially addresses #139 (consolidate duplicated package helpers):

  • ✅ isMainPkg: Eliminated 2 of 3 copies — goprovider now uses loader.IsMainPkg, crap copy removed with contract.go relocation. Only the canonical loader.IsMainPkg remains.
  • ✅ resolvePackagePaths: Was already consolidated to loader.ResolvePackagePaths prior to this branch.
  • ⚠️ loadTestPackage: Moved crap copy to goprovider (not consolidated). Still 3 copies: cmd/gaze, aireport, goprovider. The aireport version still lacks the pkg.Errors check noted in Refactor: Consolidate duplicated package helpers from aireport/crap into internal/loader #139.
  • ⚠️ loadGazeConfigBestEffort: Moved crap copy to goprovider (not consolidated). Still 3 copies: cmd/gaze, aireport, goprovider.

yvonnedevlinrh
yvonnedevlinrh previously approved these changes Jul 1, 2026

@yvonnedevlinrh yvonnedevlinrh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI Status

Check Status
Unit + Integration Tests (Go 1.24) ✅ PASS
Unit + Integration Tests (Go 1.25) ✅ PASS
E2E Tests (Go 1.24) ✅ PASS
E2E Tests (Go 1.25) ✅ PASS
MegaLinter ✅ PASS

Summary

Well-structured cleanup PR completing Phase 3 of the external analyzer protocol initiative (#95). Removes deprecated backward-compatibility shims (ContractCoverageFunc, SSADegradedPackages), deduplicates isMainPkg, relocates BuildContractCoverageFunc to goprovider/, generalizes the taxonomy for multi-language support (GoVersion → LanguageVersion, Language field, 7 neutral SideEffectType aliases), and adds optional streaming protocol mode (analyze/stream with JSONL). All spec capabilities delivered, all CI checks pass, constitution compliance verified.

Findings

[MEDIUM] findModuleRoot duplication (CS-004/DRY) — internal/crap/coverage.go:257 introduces a local copy of findModuleRoot to avoid importing internal/loader. However, internal/loader is not Go-specific — it provides module root discovery, a language-neutral filesystem operation. This creates a second copy alongside the canonical loader.FindModuleRoot (internal/loader/loader.go:136). Consider keeping the loader.FindModuleRoot import instead, or documenting a stronger justification for the duplication in the design.

[LOW] Trailing blank lines — internal/provider/goprovider/sideeffect.go ends with two extra blank lines (108-109) after removing the local isMainPkg function.

[LOW] Missing trailing newline — openspec/changes/provider-cleanup/design.md and proposal.md lack a trailing newline at EOF.

Verdict

APPROVE — Spec-aligned, all CI green, no security or constitution concerns. The MEDIUM DRY finding is worth considering but does not block merge.


This review was generated by /review-pr (AI-assisted).

Reviewed-by: OpenCode (claude-opus-4-6)

em-redhat added a commit to em-redhat/gaze that referenced this pull request Jul 1, 2026
… EOF newlines

Addresses PR unbound-force#180 review feedback from @yvonnedevlinrh.

- Remove 2 trailing blank lines in goprovider/sideeffect.go
- Add missing trailing newline in design.md and proposal.md
@em-redhat

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Addressed the LOW findings in 2d33769:

[LOW] Trailing blank lines — Fixed. Removed the 2 trailing blank lines in goprovider/sideeffect.go.

[LOW] Missing trailing newline — Fixed. Added trailing newlines to design.md and proposal.md.

[MEDIUM] findModuleRoot duplication — Keeping the local copy intentionally. While FindModuleRoot itself is a pure filesystem walk, internal/loader imports golang.org/x/tools/go/packages and go/token, so importing loader into internal/crap would reintroduce Go-specific transitive dependencies — defeating the spec goal of zero Go-specific imports in internal/crap/ (task 3.2). The local copy is 10 lines with a comment explaining the rationale. A future option is extracting it to a dependency-free utility package, but that's out of scope for this change.

@em-redhat em-redhat self-assigned this Jul 1, 2026
@em-redhat em-redhat moved this to In Review 👀 in Unbound Force Planning Jul 1, 2026
@em-redhat
em-redhat requested a review from yvonnedevlinrh July 1, 2026 11:17

@gxmiranda gxmiranda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-structured Phase 3 cleanup completing the external analyzer protocol initiative (#95). Removes deprecated backward-compat shims, relocates Go-specific code to goprovider, generalizes taxonomy for multi-language support, and adds optional streaming protocol. All CI green, constitution compliance verified, no security concerns. Two MEDIUM findings worth considering but non-blocking.

This review was generated by /review-pr (AI-assisted).

Reviewed-by: OpenCode (claude-opus-4-6)

Comment thread internal/crap/coverage.go
if parent == dir {
return "", fmt.Errorf("no go.mod found in %q or any parent directory", startDir)
}
dir = parent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] findModuleRoot duplication (CS-004/DRY) — This introduces a local copy of findModuleRoot to avoid importing internal/loader. However, internal/loader provides module root discovery (a language-neutral filesystem operation). This creates a second copy alongside loader.FindModuleRoot. The comment says "local copy to avoid importing internal/loader" but the architectural motivation is not documented. Previously raised by @yvonnedevlinrh.

Consider either using loader.FindModuleRoot directly, or adding a comment explaining why internal/crap/ must avoid the loader dependency.


// Return the stdout scanner for the caller to read JSONL lines.
// The caller is responsible for reading until EOF.
return c.stdout, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] Shared scanner returned after mutex release — CallStream returns c.stdout (the shared *bufio.Scanner) to the caller after releasing c.mu. The current design is safe because the protocol is documented as sequential and loadStreaming holds its own mutex. However, the API now exposes the internal scanner — if a future caller reads from the scanner while another goroutine calls Call/Close, there's a data race.

Consider adding a doc-level warning: "The returned scanner MUST be fully consumed before any subsequent Call, CallStream, or Close invocation."

// silently skipping the package.
return nil, fmt.Errorf("no test files found for %q", pkgPath)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] Missing sync comment — The original crap/contract.go version had // NOTE: keep in sync with internal/aireport/runner_steps.go:loadGazeConfigBestEffort. This copy omits the note. Until #139 consolidates these, the sync comment helps maintainers find all copies.

@yvonnedevlinrh yvonnedevlinrh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTGM

Medium finding to be addressed in #139. Other findings are low,related to documentation and non blocking

em-redhat added 7 commits July 2, 2026 13:01
…und-force#95)

Cleanup phase removing deprecated backward-compat shims from
Phases 1-2:

- Remove ContractCoverageFunc and SSADegradedPackages from crap.Options
- Remove backward-compat fallback path in crap.Analyze
- Deduplicate isMainPkg (use loader.IsMainPkg)
- Move BuildContractCoverageFunc from crap/ to goprovider/

Pure cleanup — zero user-facing changes, zero behavioral changes.

Ref: unbound-force#95
Phase 3 now covers the full remaining scope of Issue unbound-force#95:

1. Cleanup: deprecated field removal, isMainPkg dedup,
   BuildContractCoverageFunc relocation
2. Taxonomy: GoVersion → LanguageVersion rename, Language field,
   neutral SideEffectType aliases (AsyncTaskSpawn, FFICall, etc.)
3. Streaming: analyze/stream JSONL protocol method for large
   codebases

8 task groups, 27 tasks total.

Ref: unbound-force#95
… add streaming protocol

- Remove ContractCoverageFunc and SSADegradedPackages from crap.Options;
  contract coverage flows exclusively through ContractCoverageProvider
- Deduplicate isMainPkg by replacing goprovider local copy with loader.IsMainPkg
- Relocate BuildContractCoverageFunc and helpers from internal/crap/contract.go
  to internal/provider/goprovider/contract.go (zero Go-specific imports in crap)
- Rename Metadata.GoVersion to LanguageVersion, add Language field, update schemas
- Add 7 language-neutral SideEffectType aliases (AsyncTaskSpawn, FFICall, etc.)
- Add streaming protocol: Streaming capability, analyze/stream method, CallStream,
  JSONL support in ExternalSideEffectAnalyzer, fake analyzer --hang-stream mode
- Add LanguageVersion to protocol.InitializeResult and adapter.Providers
…regression

- Add 3 tests for crap.findModuleRoot (found, not-found, at-start-dir)
- Add TestCallStream_ReturnsScanner for protocol.CallStream
- Fix streaming test hang: add --crash-after=analyze/stream to fake
  analyzer so it exits after writing JSONL (enables scanner EOF)
- CRAPload back to 38 (was 40 due to untested new functions)
… EOF newlines

Addresses PR unbound-force#180 review feedback from @yvonnedevlinrh.

- Remove 2 trailing blank lines in goprovider/sideeffect.go
- Add missing trailing newline in design.md and proposal.md
@em-redhat
em-redhat force-pushed the opsx/provider-cleanup branch from 2d33769 to 40d90fd Compare July 2, 2026 12:01
@em-redhat
em-redhat merged commit 5283ed3 into unbound-force:main Jul 2, 2026
5 checks passed
@em-redhat
em-redhat deleted the opsx/provider-cleanup branch July 2, 2026 12:50
@em-redhat em-redhat moved this from In Review 👀 to Done ✔️ in Unbound Force Planning Jul 2, 2026
yvonnedevlinrh added a commit to yvonnedevlinrh/gaze that referenced this pull request Jul 9, 2026
Fix two gofmt formatting issues introduced by recent PRs:
- internal/adapter/sideeffect.go: trailing blank line (PR unbound-force#180)
- internal/taxonomy/types_test.go: misaligned struct field tags (PR unbound-force#184)

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: Yvonne Devlin <[email protected]>
jflowers pushed a commit to jflowers/gaze that referenced this pull request Jul 24, 2026
… EOF newlines

Addresses PR unbound-force#180 review feedback from @yvonnedevlinrh.

- Remove 2 trailing blank lines in goprovider/sideeffect.go
- Add missing trailing newline in design.md and proposal.md
jflowers pushed a commit to jflowers/gaze that referenced this pull request Jul 24, 2026
Fix two gofmt formatting issues introduced by recent PRs:
- internal/adapter/sideeffect.go: trailing blank line (PR unbound-force#180)
- internal/taxonomy/types_test.go: misaligned struct field tags (PR unbound-force#184)

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: Yvonne Devlin <[email protected]>
sonupreetam pushed a commit to sonupreetam/gaze that referenced this pull request Aug 12, 2026
… EOF newlines

Addresses PR unbound-force#180 review feedback from @yvonnedevlinrh.

- Remove 2 trailing blank lines in goprovider/sideeffect.go
- Add missing trailing newline in design.md and proposal.md

Signed-off-by: sonupreetam <[email protected]>
sonupreetam pushed a commit to sonupreetam/gaze that referenced this pull request Aug 12, 2026
Fix two gofmt formatting issues introduced by recent PRs:
- internal/adapter/sideeffect.go: trailing blank line (PR unbound-force#180)
- internal/taxonomy/types_test.go: misaligned struct field tags (PR unbound-force#184)

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: Yvonne Devlin <[email protected]>
Signed-off-by: sonupreetam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

3 participants