Repository navigation
🔥 refactor(collect): remove dead Engine.Stop() (HYG-01-FUP) - #180
Merged
Merged
Conversation
Engine.Stop() had zero callers. REL-04 made dispatch workers exit on
engine ctx cancel (Start wires the manager ctx into stopFn via a
watcher goroutine), which is the real shutdown path. The dead method
carried latent hazards if ever wired: a producer blocked on a full
dispatchCh only selects on the manager runCtx, so Stop() without a
manager-ctx cancel would block that goroutine forever; and a Stop()
racing the first dispatch() before dispatchOnce could panic
"WaitGroup is reused before previous Wait has returned".
Zero-callers evidence (origin/main worktree):
rg 'Engine\.Stop|\.Stop\(\)' internal/ cmd/
-> only timer.Stop / testEnv.Stop / consumeCtx.Stop / webhookEnv.Stop
(envtest + timers); no Engine.Stop caller anywhere.
stopFn, stopCtx, and workersWG remain used by the live ctx-cancel path
(Start goroutine, dispatchWorker, startDispatchWorkers) and are kept.
The ctx-cancel shutdown test (engine_shutdown_test.go) drives
workersWG.Wait() directly and never called Stop(), so live-path
coverage is unchanged. gosec G118 no longer sees the direct stopFn()
call inside Stop(); the remaining call lives in Start's goroutine
closure, so an honest //nolint:gosec documents that stopFn is invoked
there.
There was a problem hiding this comment.
Pull request overview
This PR removes the exported but unused Engine.Stop() from the collection engine, relying solely on the established manager-context cancellation path for shutdown (REL-04) and documenting the remaining stopFn invocation for gosec.
Changes:
- Deleted the dead
(*Engine).Stop()method and its doc comment. - Updated the constructor comment to describe only the ctx-cancel shutdown path.
- Added an inline
//nolint:gosecannotation oncontext.WithCancelto document gosec’s G118 trace behavior aroundstopFn.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This was referenced Aug 3, 2026
konih
added a commit
that referenced
this pull request
Aug 3, 2026
…nches (COV-90-S03) Lock the collector's lifecycle and filtering edges with behavior-asserting table tests: - runner: NewRunner discovery-mapper construction + invalid rest.Config, ExtractionFailure.Error() identity formats, profile-not-found/transient skips, fatal per-target namespace-resolution errors, cluster-scoped (namespace-less) list path, redactExtractionReason truncation, sortExtractionFailures full key order, labelSelectorString determinism (sorted output, fail-safe empty on nil/invalid selector) - prune: nil object, malformed RFC 6901 pointers as no-ops, slice-index pointer semantics (nil-in-place, out-of-range/non-numeric/negative no-ops, recursion into elements), unsupported JSONPath wildcards and filters as deliberate no-ops, rejected jsonPathTokens shapes - helmdecode: structural secret errors, legacy uncompressed-JSON fallback, EDGE: every malformed payload (corrupt/truncated gzip, non-JSON) yields a wrapped decode error and never panics, denied-path prefixes, absent fields return nil without error - collection_filter: MatchIntentNamespaces include/selector/exclude gates, CompileResourceRules error table, per-rule skip branches (GVR/namespace mismatch, unknown namespace, cluster-scoped default fallback), legacy selector fail-closed, evalMatchPolicy result shapes via stub cel.Program, sortedUniqueStrings, ScopeCeilingFromClusterScope copy semantics - extractor: optional-attribute error skip, empty CEL expression wrapping, JSONPath eval-error wrapping vs not-found, empty range result, celValueToGo null handling internal/collect coverage 89.2% -> 95.6%; uncovered lines 139 -> 58. Spec note: the tasks.md item for idempotent double Engine.Stop() is obsolete - Engine.Stop() was removed in PR #180 (HYG-01-FUP); skipped.
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.



Lane HYG-01-FUP (P3) — remove the dead, hazardous
Engine.Stop()internal/collect/engine.gohad an exportedEngine.Stop()with zero callers. Post-REL-04 the real shutdown path is engine ctx-cancel:Start()wires the manager context intostopFnvia a watcher goroutine, which drains and terminates every dispatch worker.Zero-callers evidence (from the origin/main worktree)
No caller of
Engine.Stop()anywhere ininternal/orcmd/.Latent hazards removed (were it ever wired)
dispatchChselects only on the managerrunCtx;Stop()without a manager-ctx cancel would block that goroutine forever.Stop()racing the firstdispatch()beforedispatchOncecould panicWaitGroup is reused before previous Wait has returned.Scope
Stop()and trimmed the constructor comment's "explicit Stop()" clause.stopFn,stopCtx,workersWGare kept — all used by the live ctx-cancel path (Start goroutine,dispatchWorker,startDispatchWorkers).engine_shutdown_test.go(REL-04) drivesworkersWG.Wait()directly and never calledStop().stopFn()call inStop()gone, gosec no longer traces the remaining call (inside Start's goroutine closure), so an honest//nolint:gosecdocuments thatstopFnis invoked there.Gate matrix (all green)
go build ./...OK ·go vet ./...OKtask lint0 issues + arch-lint OKtask testall pass (collect 89.2%)task verifyoktask coverage85.6% (floor 85%)Minimal diff: +2 / -11 in one file. No changes to worker/dispatch/ctx-cancel behavior.