refactor(patterns): 100% emit consolidation, drop wrappers#523
Merged
Conversation
Hoists Confidence onto VerdictCommon so the generic emitAll path handles partial-gating + real-confidence-label IncVerdict uniformly. Deletes emitPodEvicted + emitIBLinkFlap (the last 2 typed wrappers left after PR #521's appendVerdict consolidation) and routes both callsites through emitAll directly. Behavior-identical: the 5 emitAll-path detectors without a Confidence field (NCCLHang, XidCorrelation, HBMECC, ThermalThrottle, PCIeAER) return the zero-value Confidence from Common(), so IncVerdict still ticks with the legacy empty-string label pinned by TestNoopFallback_IncVerdict_TableDriven. PodEvicted + IBLinkFlap now flow through emitAll with their real Confidence label — same gating + telemetry shape the deleted wrappers provided. success criteria: - grep '^func emit[A-Z]' returns only emitAll - go test ./... green (module) - make lint clean (0 issues) Signed-off-by: Tri Lam <tree@lumalabs.ai>
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
Closes the loop on PR #521 (Lane N). #521's body claimed "full appendVerdict consolidation" but left two typed wrappers in place —
emitPodEvictedandemitIBLinkFlap— because the reviewer correctly flagged the gating + telemetry-label divergence as a behavior risk, and the original carve-out comment justified them with "Go generics cannot abstract over a struct field." That's an 85% consolidation, not 100%.This PR removes both wrappers and routes their callsites through the generic
emitAll[V verdictAttrer]directly.Root cause of the wrapper residue
The wrappers existed because
PodEvictedVerdict.ConfidenceandIBLinkFlapVerdict.Confidenceare exported struct fields, and adding aConfidence()method to theverdictAttrerinterface would have shadowed the field name on the same type. The fix is one level up:VerdictCommon(the existing shared-boilerplate carrier returned by every verdict'sCommon()method) was the right place for Confidence all along. It's already the interface seamemitAllreads through — moving Confidence there lets the generic path gate partial verdicts and stamp the real confidence label onIncVerdictwithout touching field names on individual verdict types.What changes
module/pkg/patterns/verdict.go— addConfidence ConfidencetoVerdictCommon.Common()methods — populateConfidence: v.Confidence(PodEvicted, IBLinkFlap, CUDAOOM, Checkpointer, DataLoader, NCCLBootstrap, SilentDataCorruption). The other 5 detectors (NCCLHang, XidCorrelation, HBMECC, ThermalThrottle, PCIeAER) have noConfidencefield, so theirCommon()returns the zero value ("") — byte-identical to today'sIncVerdict(patternID, "")tick.patterndetector.go—emitAllnow readsc := v.Common(), gatesc.Confidence == ConfidencePartial && !emitPartial, and ticksIncVerdict(c.PatternID, string(c.Confidence)). Both wrapper funcs deleted; both callsites callemitAlldirectly.Behavior-identical proof
emitPodEvictedemitAllstring(v.Confidence)string(c.Confidence)— sameemitIBLinkFlapemitAllstring(v.Confidence)string(c.Confidence)— sameemitAllemitAll""""(zero-value Confidence) — samerun*helper (unchanged)run*helper (unchanged)Partial-gating preserved:
TestPatternDetector_IBLinkFlapWiringPartialSuppressed,TestPatternDetector_PodEvictedWiringPartial*,TestPatternDetector_CUDAOOMWiringPartialVerdictWhenFBMissingall pass.Pinned by
TestNoopFallback_IncVerdict_TableDriven(15 sub-cases covering every pattern × confidence combination) — green.Success criteria
Only
emitAllremains.Test plan
cd module && go build ./...— cleancd module && go test ./...— 12 packages greenmake lint— 0 issuesgrep '^func emit[A-Z]' module/processor/patterndetectorprocessor/patterndetector.goreturns onlyemitAllTestNoopFallback_IncVerdict_TableDriven— 15/15 pass (pins per-pattern confidence labels)TestPatternDetector_IBLinkFlapWiring*(3 cases) — passTestPatternDetector_PodEvicted*— passTestPatternDetector_CUDAOOMWiringPartialVerdictWhenFBMissing— pass