refactor: split gateway classes to remove structural suppressions - #26
Merged
Conversation
…ManyFunctions/LargeClass Extract RunnerBindingMetrics, RunnerSetupResolver, RunnerAgentSpawner, and RunnerProvisioningCoordinator so RunnerSessionBinder drops from 36 functions to 15 and under 200 lines, removing @Suppress("TooManyFunctions","LargeClass"). MAX_SPAWN_ATTEMPTS remains on RunnerSessionBinder.companion as a delegating constant for backward compatibility with existing tests. Add RunnerAgentSpawnerTest and RunnerBindingMetricsTest.
…e TooManyFunctions/LargeClass Move headless-job logic (startHeadlessJob, pollHeadlessJob, private helpers, extension functions and DTOs) to HeadlessJobGateway. HttpAgentGatewayClient drops from 22 functions to 13, removing @file:Suppress("LargeClass") and @Suppress("TooManyFunctions"). Public API unchanged; headless field delegates.
…helpers to remove TooManyFunctions/LargeClass Extract RunnerCredentialSecretManager (credential secret lifecycle), RunnerPodSpecBuilder (pod/pvc/service spec construction), and RunnerStateReader (pod label → RunnerState mapping). Orchestrator drops from 42 functions to 13, removing @Suppress("TooManyFunctions","LargeClass"). Update AgentRunnerObservabilityContractTest to read RunnerPodSpecBuilder.kt (where env/probe code now lives). Add RunnerStateReaderTest.
…remove TooManyFunctions/LargeClass Move session lookup, workspace checks, rebind attempt, and attach recording to AttachPreconditionChecker. SessionAttachHandler drops from 25 outer-class functions to 13, removing @file:Suppress("TooManyFunctions","LargeClass"). outcomeOf/failureReasonOf moved to UpstreamHandler.companion. Add AttachPreconditionCheckerTest.
- Restore the AgentRunnerOrchestrator import in RunnerSessionBinder (referenced by RunnerSessionBindingDependencies). - Remove the retained @Suppress("LongMethod") on RunnerPodSpecBuilder.pod() by extracting completed fabric8 model objects (podMetadata, podSecurityContext, agentRunnerContainer, shared httpProbe, containerResources), and split env/volume building into RunnerContainerEnvBuilder and RunnerVolumeSpecBuilder so every class in the file stays under the 15-function detekt threshold. - Extract RunnerBindingGuards from RunnerSessionBinder (guard predicates and readiness checks), bringing the binder to 14 functions. - Decompose AttachPreconditionChecker.checkPreconditions into rebindIfUnbound, checkWorkspaceAndGateway, and gatewayOutcome to satisfy LongMethod and ReturnCount; resolveAttach now uses the companion sessionIdOf directly (a ClassName::companionMember reference does not compile). - Wrap the five over-120-column lines in RunnerSessionBinder. - Add the missing RunnerState import and drop the now-unused Pod import in the k8s adapters; drop unused PodSpec/ContainerBuilder test imports. - Update AgentRunnerObservabilityContractTest probe assertions to the shared httpProbe helper (single /healthz literal wired into all three probes).
…shold Decompose env assembly into baseEnv (identity, OTLP transport, sandbox flag), setupEnv (MCP profile/files, GitHub MCP toolsets, runner setup identity), and repoEnv (boot-time clone URLs); podEnv becomes a short buildList coordinator. Env var order and content are unchanged.
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.
Closes #11. The four gateway classes carrying documented TooManyFunctions/LargeClass suppressions are split along single-responsibility seams: metrics, setup, spawn and provisioning move out of RunnerSessionBinder (plus extracted binding guards); headless-job HTTP out of HttpAgentGatewayClient; credential, pod-spec (with container-env and volume builders) and state-reader out of Fabric8AgentRunnerOrchestrator; precondition checking out of SessionAttachHandler. Every suppression in the touched files is deleted — including the initially retained LongMethod on the fabric8 pod builder, which is now composed from completed section objects, and the container-env assembly decomposed with byte-identical env ordering. New unit tests cover the spawner, binding metrics, state reader and precondition checker. The branch went through two adversarial cross-provider review rounds (compile-substitute import checks, detekt-threshold verification, control-flow comparison on the precondition decomposition) before push; CI is the final arbiter since local Gradle lacks registry credentials.