Skip to content

refactor: split gateway classes to remove structural suppressions - #26

Merged
jorisjonkers-dev-agents[bot] merged 10 commits into
mainfrom
refactor/issue-11
Jul 13, 2026
Merged

refactor: split gateway classes to remove structural suppressions#26
jorisjonkers-dev-agents[bot] merged 10 commits into
mainfrom
refactor/issue-11

Conversation

@jorisjonkers-dev-agents

Copy link
Copy Markdown
Contributor

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.

…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.
@jorisjonkers-dev-agents
jorisjonkers-dev-agents Bot merged commit 798fb87 into main Jul 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: split large agent-gateway classes to remove structural suppressions

1 participant