refactor: decompose 3 shipping high-complexity functions under the gocyclo cap#418
Open
ion-alpha-dev wants to merge 3 commits into
Open
refactor: decompose 3 shipping high-complexity functions under the gocyclo cap#418ion-alpha-dev wants to merge 3 commits into
ion-alpha-dev wants to merge 3 commits into
Conversation
…d methods Schedule was 39/65 (cyclo/cog), over the gocyclo cap. Lift the indexed inputs and the mutable keep/budget accumulators onto a scheduler value and split the decision into keepForced -> candidates -> admit -> actions. Logic is moved byte-for-byte; the plan is the same deterministic fixed point.
…phases runServeContext was 35/76, over the gocyclo cap. Extract parseServeConfig (flags + env fallbacks folded into a serveConfig), startControlPlaneAPI (the read-only API bring-up and drain), and serveChannels (the message-answering loop). Behavior is unchanged; secured-by-default API auth and the ctx-driven shutdown are preserved.
run was 35/75, over the gocyclo cap. Move the resolved command-line state into an invocation struct and split the command table out as routeCommand, with a shared invocation.exit tail mapping err -> exit code. The if-chain becomes a switch; the dataDirCommands fallback and the exit-code contract (0/1/2 and exitChangesRequested for review) are unchanged. dataDirCommands keys are disjoint from the switch cases, so ordering is behavior-preserving.
ion-alpha-dev
force-pushed
the
worktree-quality-cleanup-b
branch
from
July 17, 2026 15:16
76eae29 to
ce5ff7d
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
What
Brings the three production functions that ship above the repo's
gocyclocomplexity cap back under it, without changing behavior. Part of the quality-cleanup epic (task B), one commit per function.Scheduleinternal/inference/orchestrate/schedule.goschedulerstruct withkeepForced→candidates→admit→actionsphasesrunServeContextcmd/flynn/serve.goparseServeConfig+startControlPlaneAPI+serveChannelsruncmd/flynn/main.gorouteCommandover aninvocationstruct + sharedexittailWhy
These are the shipping (non-test) functions over the complexity cap — the real maintenance risk. The extractions flatten nesting/branching (the cognitive-score driver); logic is lifted essentially byte-for-byte onto the new helpers, control flow is unchanged.
main.go: the if-chain becomes aswitch; thedataDirCommandsfallback keys are disjoint from the switch cases, so movingserve/watch/review/helpahead of the map lookup changes nothing. Exit-code contract (0/1/2 +exitChangesRequested) preserved.serve.go: secured-by-default API auth and the ctx-driven drain preserved.schedule.go: same deterministic fixed-point plan.How to verify
The
golangci-lintrun is what enforces the gocyclo cap — 0 issues means the complexity drop is proven, not asserted. Behavior is covered by the existingcmd/flynnandorchestratesuites (no test changes needed).Notes for reviewers
spawnConfined(sandbox/appcontainer_windows.go, 42/98) is the 4th high-complexity function from task B. It's app-container code and is being handled as a separate PR/track — deliberately out of scope here.