Repository navigation
refactor(agent): reduce cognitive complexity <=15 in cni server, hotrestart, spire (part of #556) - #561
Merged
Conversation
…otrestart, spire (part of #556) Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
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
Lane 3 of the cognitive-complexity reduction campaign (#556). Reduces all non-test functions in
agent/internal/cni/server/,agent/internal/proxy/hotrestart/, andagent/internal/spire/to ≤15 via pure structural extraction — no behavior changes.Per-function extraction summary
(*CNIServer).sweepGhostEndpointslistRegistryEndpoints,pruneStaleStoragePods,pruneOnePod,reportMissingStoragePods,classifyPods,deregisterGhostEndpoints,deregisterGhostEndpointsForService,registeredIPs,registerMissingEndpoints(*Supervisor).RunrestartLoopstruct withrun,handleSignal,handleDebounce,handleChildExitmethods; extractedhandleShutdown,handleDebounce,handleChildExit,retryBindCollisiononSupervisor(*CNIServer).reconcileLivenessapplyPodLiveness,registerHealthTransition,livenessWant,livenessPrev(*Supervisor).watchLivenessonLiveEpoch,onNotLiveEpoch,checkWedgeWatchdogs(*Bridge).StartrunBundleSubscriptionLoop,drainBundleStream,handleBundleSubscribeError,logBundleSubscribed(*Bridge).SubscribePodrunSVIDSubscriptionLoop,drainSVIDStream,resubscribeSVIDsVerification
make gazelle— no BUILD changes needed.make format— imports ordered; no additional changes.Notes
Supervisor.Run(originally 68): the event loop is complex by nature. Introduced arestartLoophelper struct to carry loop state (debounce timer, retry counters) so the select cases can be delegated to named methods without large parameter lists. The select case ordering is unchanged.watchLivenessstate transitions, channel ordering, and wedge watchdog sequence are preserved verbatim — only the dead-code blocks were moved to helpers.sweepGhostEndpointsdecision order (list → lock → prune stale → report missing → classify → deregister ghosts → register missing) is unchanged.Bridge.Start/SubscribePodsubscription/retry/cleanup ordering preserved exactly.Part of #556
🤖 Generated with Claude Code
https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR