refactor: consolidate safeSSABuild into shared internal/ssaguard package - #240
Merged
jflowers merged 1 commit intoAug 31, 2026
Merged
Conversation
jflowers
approved these changes
Aug 31, 2026
jflowers
left a comment
Collaborator
There was a problem hiding this comment.
PR Review: #240 — refactor: consolidate safeSSABuild into shared internal/ssaguard package
Clean, well-scoped DRY consolidation. All 8 acceptance criteria from #238 satisfied. No alignment, security, or constitution compliance findings.
CI: All 5 checks green (MegaLinter, Unit+Integration Go 1.24/1.25, E2E Go 1.24/1.25).
Key verifications: GoDoc correctly documents the BuildSerially goroutine-scoping invariant (spec-033). Logging retained at call sites (preserves pkg.PkgPath diagnostic context). stdlib-only — zero external dependencies. 100% branch coverage in canonical tests.
This review was generated by /uf.review-pr (AI-assisted).
Extract the byte-identical safeSSABuild recover-guard (duplicated in internal/analysis/mutation.go and internal/quality/pairing.go) into a new stdlib-only package internal/ssaguard with exported SafeSSABuild. Reverses spec-021 R3 (duplication-for-dependency-lightness) since the guard has zero external dependencies. - Add internal/ssaguard with GoDoc documenting the ssa.BuildSerially caller precondition and goroutine-scoped recover() rationale (spec 033) - Update BuildSSA and BuildTestSSA to call ssaguard.SafeSSABuild, retaining caller-side log.Warn/log.Debug (preserves pkg-path context) - Remove duplicated TestSafeSSABuild_* triads and export_test.go shims; delete now-empty internal/quality/pairing_test.go - Consolidate to 3 canonical tests (100% branch coverage); net test -3, behavioral coverage neutral - Add OpenSpec artifacts and AGENTS.md/docs updates Closes unbound-force#238 Assisted-by: claude-opus Generated with AI assistance (claude-opus)
jflowers
force-pushed
the
opsx/consolidate-ssa-guard
branch
from
August 31, 2026 18:37
c3d5f5a to
61f42c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extract the byte-identical
safeSSABuildrecover-guard — previously duplicated ininternal/analysis/mutation.goandinternal/quality/pairing.go— into a new stdlib-only leaf packageinternal/ssaguardwith an exportedSafeSSABuild. Reverses spec-021 R3 (duplication-for-dependency-lightness), which no longer applies because the guard has zero external dependencies.Closes #238.
What changed
internal/ssaguard— exportedSafeSSABuild(buildFn func()) (panicVal any), zero imports. GoDoc documents thessa.BuildSeriallycaller precondition and the goroutine-scopedrecover()rationale (spec 033); the guard is documentation-only and does not validate build mode at runtime.analysis.BuildSSAandquality.BuildTestSSAcallssaguard.SafeSSABuild(prog.Build), retainingssa.BuildSeriallyin the mode flags and the caller-sidelog.Warn/log.Debugcalls (preservespkg.PkgPathdiagnostic context — logging deliberately not moved into the guard).safeSSABuilddefs, theSafeSSABuildexport_test.goshims, and the duplicatedTestSafeSSABuild_*test triads; deleted the now-emptyinternal/quality/pairing_test.go.internal/ssaguard/ssaguard_test.go(100% branch coverage). Net test count -3, behavioral coverage neutral.AGENTS.md(Architecture list + Recent Changes) anddocs/concepts/analysis-pipeline.md.How to Test
Verify duplication is gone:
Acceptance scenarios (from
openspec/changes/consolidate-ssa-guard/specs/ssaguard/spec.md):SafeSSABuildreturnsnilwhenbuildFndoes not panic.SafeSSABuildreturns the recovered value whenbuildFnpanics with a string.SafeSSABuildreturns the recovered value whenbuildFnpanics with an error.ssa.BuildSeriallyinvariant (documentation-only, no runtime validation).log.Warn/log.Debugcalls.How to Demo
Both run through
BuildSSA/BuildTestSSAand exercise the shared guard; a panicking SSA build for any package is recovered and logged with itspkg.PkgPathrather than crashing the process.Key Files Changed
internal/ssaguard/ssaguard.goSafeSSABuild, stdlib-only,BuildSeriallyGoDocinternal/ssaguard/ssaguard_test.gointernal/analysis/mutation.goBuildSSAdelegates tossaguard.SafeSSABuild; local guard removedinternal/quality/pairing.goBuildTestSSAdelegates; local guard + R3 lineage comment removedinternal/analysis/mutation_test.goTestSafeSSABuild_*; comment updatedinternal/analysis/export_test.goSafeSSABuildshiminternal/quality/export_test.goSafeSSABuildshiminternal/quality/pairing_test.goAGENTS.mddocs/concepts/analysis-pipeline.mdopenspec/changes/consolidate-ssa-guard/**This PR was generated by /uf.finale (AI-assisted).