Skip to content

refactor: split oversized files into focused modules#133

Open
lilienblum wants to merge 18 commits into
mainfrom
refactor/split-large-files
Open

refactor: split oversized files into focused modules#133
lilienblum wants to merge 18 commits into
mainfrom
refactor/split-large-files

Conversation

@lilienblum

@lilienblum lilienblum commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Why

Several source files in this repo had grown past ~2,000 lines, which makes them slow to navigate, painful to review, and merge-conflict prone. This umbrella PR splits them into focused modules along seams that already exist in the code (section boundaries, impl-block boundaries, test modules). Every split is strictly behavior-preserving: pure code motion plus the minimal import/visibility wiring needed to compile — no logic, signature, or public-API changes.

Splits land incrementally, one commit per file. The list below tracks what has landed; a handful of pre-existing large files remain and are staged for their own follow-up splits (see Planned additions).

Included so far

1. crates/alien-infra/src/worker/gcp.rs (7,070 lines) → worker/gcp/

File Lines Contents
gcp/mod.rs 3,985 The #[controller] struct and its single #[controller] handler impl block, kept whole
gcp/helpers.rs 1,422 The plain (non-macro) helper impl block; exactly 14 methods bumped to pub(super)
gcp/support.rs 248 Free functions, consts, and support types (now pub(super))
gcp/tests.rs 1,441 The test module, unchanged apart from the mandatory dedent

Proof: the entire retained mod.rs segment — the #[controller] struct and the full handler impl block — is byte-for-byte identical (cmp) to the corresponding segment of the original file, so the proc-macro input tokens are unchanged. Nothing was made pub; GcsNotificationTracker keeps its external path via a pub use re-export. Git records the split as a rename (55% similarity), so git log --follow still tracks history. The --tests warning set is message-identical to a baseline captured on the parent commit, proving no imports were silently dropped.

2. crates/alien-infra/src/worker/azure.rs (6,488 lines) → worker/azure/

File Lines
azure/mod.rs 3,182
azure/helpers.rs 1,582
azure/support.rs 359
azure/tests.rs 1,379

Proof: done as two commits — a pure git mv to azure/mod.rs, then the carve-out — touching only the four azure files. A --color-moved analysis accounts for all 6,642 changed lines: 3,226 verbatim-moved line pairs, with the remaining ~190 plain lines being mod declarations, import redistribution, and visibility bumps only.

3. crates/alien-infra/src/worker/aws.rs (5,003 lines) → worker/aws/

File Lines
aws/mod.rs 3,471
aws/helpers.rs 404
aws/support.rs 140
aws/tests.rs 1,004

Proof: a single commit touching only the four aws files; rename detected at 69% similarity; byte-level comparison of each moved segment against the original confirms pure motion. worker/mod.rs untouched.

4. crates/alien-gcp-clients/src/gcp/compute.rs (5,682 lines) → gcp/compute/

File Lines
compute/mod.rs 63
compute/api.rs 535
compute/client.rs 1,323
compute/tests.rs 90
compute/types/mod.rs 9
compute/types/operations.rs 199
compute/types/network.rs 987
compute/types/load_balancer.rs 1,281
compute/types/instance.rs 1,224

Proof: byte-level comparison of each new file's body against its original segment confirms pure code motion. The only other change is a one-line pointer update in the sibling AGENTS.md.

5. crates/alien-build/src/lib.rs (4,817 lines) → module files

File Lines
lib.rs 1,548
base_images.rs 337
cache.rs 671
push.rs 688
tests.rs 1,633

Proof: --color-moved classification shows 3,255 verbatim-moved lines; all 105 non-moved added and 53 removed lines are module wiring and import redistribution only. Only the five files under crates/alien-build/src/ are touched.

6. crates/alien-test/src/distribution.rs (4,726 lines) → distribution/

File Lines
distribution/mod.rs 1,352
distribution/tests.rs 1,094
distribution/terraform.rs 719
distribution/helm.rs 505
distribution/permissions.rs 402
distribution/cloudformation.rs 337
distribution/cleanup.rs 206
distribution/env.rs 119
distribution/exec.rs 50

Proof: independently verified pure code motion. Only these ten files plus the one-line hk.pkl exclude removal change; no lockfiles or generated artifacts. Moves classified with --color-moved; the residual plain lines are mod declarations, use super::* imports, and pub(super) visibility bumps. cargo test -p alien-test --lib passes.

7. crates/alien-helm/src/generator.rs (4,647 lines) → generator/

File Lines
generator/templates.rs 1,204
generator/values.rs 867
generator/tests.rs 805
generator/operator.rs 744
generator/schema.rs 496
generator/mod.rs 451
generator/examples.rs 111

Proof: verified pure code motion — the diff touches only the seven generator/ files plus the one-line hk.pkl exclude removal. generate_operator_manifest keeps its public path through a pub use re-export from mod.rs, so lib.rs compiles with zero changes. cargo test -p alien-helm passes against the moved test module.

8. crates/alien-deploy-cli/src/commands/up.rs (3,991 lines) → up/

File Lines
up/pull.rs 969
up/push.rs 740
up/tests.rs 714
up/resolve.rs 489
up/mod.rs 472
up/inputs.rs 280
up/config.rs 225
up/machines.rs 142

Proof: verified behavior-preserving pure code motion. The only non-move text changes are 73 pub(super) visibility bumps and six path rewrites from super::operator:: to crate::commands::operator:: (plus one hoisted import), which are equivalent references to the same items. cargo test -p alien-deploy-cli passes (the offline up/tests.rs unit tests: config parsing, tfvars/values rendering, token handling); sibling commands (down, join, list, status) that import the re-exported up paths still compile.

9. crates/alien-aws-clients/src/aws/ec2.rs (3,616 lines) → ec2/

File Lines
ec2/client.rs 1,905
ec2/types/network.rs 528
ec2/types/security_group.rs 272
ec2/types/instance.rs 267
ec2/types/launch_template.rs 260
ec2/types/volume.rs 172
ec2/api.rs 171
ec2/types/common.rs 41
ec2/mod.rs 27
ec2/types/mod.rs 13

Proof: independently verified as a clean, behavior-preserving pure code-motion split into a ten-file ec2/ module. MockEc2Api keeps resolving via the glob re-export, so the existing aws_ec2_client_tests integration tests are unchanged. cargo check -p alien-aws-clients --features test-utils --all-targets and cargo test -p alien-aws-clients --lib pass; downstream importers of the ec2 types (network/aws.rs, worker/aws) still compile.

10. crates/alien-gcp-clients/tests/gcp_compute_client_tests.rs (3,140 lines) → gcp_compute_client_tests/

File Lines
gcp_compute_client_tests/context.rs 1,079
gcp_compute_client_tests/load_balancing.rs 561
gcp_compute_client_tests/instances.rs 502
gcp_compute_client_tests/vpc.rs 395
gcp_compute_client_tests/ssl_proxy.rs 277
gcp_compute_client_tests/errors.rs 240
gcp_compute_client_tests/disks.rs 85
gcp_compute_client_tests/main.rs 32

Proof: verified pure code motion. Only the expected files change: the deleted original, the eight new module files, a one-line doc-pointer update in the sibling AGENTS.md, and the hk.pkl exclude removal — no lockfiles, generated artifacts, or stray files. The directory test target keeps the same binary name, so all tests are still discovered under gcp_compute_client_tests (cargo test -p alien-gcp-clients --test gcp_compute_client_tests -- --list).

11. crates/alien-terraform/src/generator.rs (2,903 lines) → generator/

File Lines
generator/variables.rs 968
generator/mod.rs 819
generator/providers.rs 501
generator/registration.rs 367
generator/readme.rs 190
generator/tests.rs 149

Proof: verified pure code-motion split. The diff touches only those six generator/ files plus the one removed hk.pkl exclude line — no logic changes. cargo test -p alien-terraform passes against the moved cfg(test) module.

12. crates/alien-core/src/heartbeat.rs (2,729 lines) → heartbeat/

File Lines
heartbeat/data_services.rs 486
heartbeat/workload.rs 466
heartbeat/mod.rs 378
heartbeat/tests.rs 372
heartbeat/cluster.rs 286
heartbeat/registry_build.rs 275
heartbeat/platform.rs 234
heartbeat/azure_platform.rs 151
heartbeat/storage.rs 120

Proof: independently verified clean pure code motion into a directory module (mod.rs plus storage/workload/cluster/data_services/platform/registry_build/azure_platform/tests submodules). The diff is confined to those ten files plus the one-line hk.pkl exclude removal. Heartbeat types are re-exported at the alien_core root and consumed across many crates, so path stability is proven by a clean cargo check --workspace --all-targets; cargo test -p alien-core passes.

13. crates/alien-aws-clients/tests/aws_s3_client_tests.rs (2,265 lines) → aws_s3_client_tests/

File Lines
aws_s3_client_tests/object.rs 856
aws_s3_client_tests/bucket.rs 697
aws_s3_client_tests/versioning.rs 336
aws_s3_client_tests/location.rs 233
aws_s3_client_tests/context.rs 172
aws_s3_client_tests/main.rs 7

Proof: faithful pure code-motion split into a directory test target (main.rs plus context/bucket/object/versioning/location), mirroring the gcp compute-tests layout. Exactly nine files touched — no Cargo.toml, lockfile, generated, or unrelated changes. A sorted line-multiset comparison of old vs. new confirms every test line is preserved; the binary name is unchanged so the integration test still compiles.

14. crates/alien-cloudformation/src/generator.rs (2,262 lines) → generator/

File Lines
generator/mod.rs 1,361
generator/parameters.rs 506
generator/expressions.rs 379
generator/tests.rs 71

Proof: rigorously verified pure code-motion split. Reconstructing the base file and running both a sorted line-multiset diff and an order-preserving per-region diff shows mod.rs equals the base's retained regions and parameters.rs/expressions.rs equal their carved-out regions exactly. cargo test -p alien-cloudformation passes against the moved cfg(test) module.

Planned additions

The remaining pre-existing files over 2,000 lines are excluded in hk.pkl as legacy, each pending its own follow-up split:

File Lines
crates/alien-deploy-cli/src/commands/join.rs 2,724
crates/alien-infra/src/kubernetes_public_endpoint.rs 2,475
crates/alien-infra/src/network/aws.rs 2,437
crates/alien-bindings/src/provider.rs 2,215
crates/alien-bindings/tests/storage.rs 2,186
crates/alien-infra/src/container/kubernetes.rs 2,183
crates/alien-infra/src/network/azure.rs 2,173
crates/alien-infra/src/core/executor.rs 2,133
crates/alien-commands/src/server/mod.rs 2,082
crates/alien-cli/src/commands/release.rs 2,070
crates/alien-preflights/src/mutations/compute_cluster.rs 2,005

How verified (on the current branch tip)

  • Fast lint gate clean across every file changed in this branch: rustfmt --check --edition 2021, trailing-whitespace, end-of-file, merge-conflict, and the max-lines step.
  • cargo check --workspace --all-targets clean (this is the real cross-crate path-stability proof — the heartbeat and ec2 splits re-export widely used types).
  • Feature-gated compile paths clean: cargo check -p alien-core --features openapi, cargo check -p alien-aws-clients --features test-utils --all-targets, cargo check -p alien-gcp-clients --features test-utils --all-targets.
  • Moved cfg(test) unit modules pass: cargo nextest run --lib across alien-helm, alien-terraform, alien-cloudformation, alien-core, alien-test, alien-deploy-cli.

How to review

Use move detection:

git diff main... --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change

The --color-moved-ws flag matters for the tests.rs hunks because of the dedent out of the former inline mod tests {} blocks. Nearly everything renders as moved code; the remaining lines are import redistribution, mod declarations, and the visibility bumps noted above. Each split is its own commit (azure is two: git mv then carve-out), so commits can also be reviewed one at a time.

Regression guard

To keep files from growing back past the threshold, this PR adds a max-lines step to hk.pkl that runs in the pre-commit, check, and fix hooks.

  • Threshold: 2000 lines, applied to *.rs, *.ts, *.tsx, *.js, *.jsx.
  • Mechanism: wc -l {{files}} piped through awk (portable BSD awk, no GNU extensions); any file over the limit fails the hook with a message naming the file and its line count.
  • Excluded generated trees: client-sdks/** (Speakeasy codegen) and packages/sdk/src/worker-runtime/generated/** (protoc-gen-ts_proto).

Grandfathered files

The three worker controller modules stay over the limit by design: the #[controller] macro requires the annotated struct and its single annotated impl block to live in one module, so after the splits above these cannot shrink further.

File Lines
crates/alien-infra/src/worker/gcp/mod.rs 3,985
crates/alien-infra/src/worker/aws/mod.rs 3,471
crates/alien-infra/src/worker/azure/mod.rs 3,182

The legacy files still over the limit are listed under Planned additions above; each is excluded in hk.pkl until its own split lands.

Verified: hk check --step max-lines --all passes across the repo; a probe file over the limit fails with a clear message; every excluded path is skipped by the step.

Break the 7,000-line worker/gcp.rs into a directory module so each
concern can be read and reviewed in isolation:

- gcp/mod.rs: controller struct, compute-operation tracking, and the
  #[controller] handler impl (kept whole for macro state generation)
- gcp/support.rs: naming helpers, error classifiers, heartbeat
  emission, and GcsNotificationTracker
- gcp/helpers.rs: the plain helper-method impl block
- gcp/tests.rs: the controller test module

Pure code motion: moved items are bumped to pub(super) where needed;
external paths are unchanged via the existing worker::gcp re-exports.
@greptile-apps

greptile-apps Bot commented Jul 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR splits the monolithic gcp.rs (7,070 lines) into four focused modules under a new gcp/ directory, with no logic, signature, or public-API changes — purely code motion plus the minimum visibility and import wiring to compile.

  • gcp/mod.rs retains the #[controller] struct and handler impl block byte-for-byte; GcsNotificationTracker is re-exported via pub use support::GcsNotificationTracker to preserve its external path.
  • gcp/helpers.rs extracts 14 helper methods bumped to pub(super); gcp/support.rs collects free functions, constants, and support types (all pub(super) except GcsNotificationTracker); gcp/tests.rs lifts the inline mod tests {} block with only the mandatory dedent.
  • The split has been verified with cargo check, cargo nextest run (478/478 pass), and a byte-level diff against the original segments.

Confidence Score: 5/5

Pure code-motion refactor with no logic changes; the proc-macro input in mod.rs is byte-for-byte identical and all 478 tests pass.

Every changed file is either a new module boundary file containing code moved verbatim from the original gcp.rs, or the slimmed-down mod.rs that retains the macro-processed handler block unchanged. The only non-motion deltas are the 14 pub(super) visibility bumps (all internal) and two rustfmt reflows from the dedent and a signature wrap — none affecting behavior. The re-export of GcsNotificationTracker correctly preserves the external API path.

No files require special attention; the split is mechanical and the verification evidence (cargo check, nextest, byte-level diff) is thorough.

Important Files Changed

Filename Overview
crates/alien-infra/src/worker/gcp/mod.rs Root module retaining the #[controller] struct and its handler impl block; declares helpers/support/tests sub-modules and re-exports GcsNotificationTracker via pub use support::GcsNotificationTracker.
crates/alien-infra/src/worker/gcp/helpers.rs Extracted helper impl block with 14 methods bumped to pub(super); imports support items via use super::support::* and conditionally imports GcpWorkerState under test-utils feature.
crates/alien-infra/src/worker/gcp/support.rs Free functions, consts, and GcsNotificationTracker type; all items are pub(super) except GcsNotificationTracker which is pub (re-exported from mod.rs) to preserve the external API path.
crates/alien-infra/src/worker/gcp/tests.rs Test module moved out of the inline mod block with mandatory dedent; imports are adjusted to use super:: paths for support utilities, no logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["worker/mod.rs\n(crate re-exports)"]
    B["gcp/mod.rs\n(#[controller] struct\n+ handler impl block\n3,985 lines)"]
    C["gcp/helpers.rs\n(helper impl block\n14 pub(super) methods\n1,422 lines)"]
    D["gcp/support.rs\n(free fns, consts, types\n248 lines)"]
    E["gcp/tests.rs\n(#[cfg(test)]\n1,441 lines)"]

    A --> B
    B -->|"mod helpers;"| C
    B -->|"mod support;\nuse support::*;\npub use support::GcsNotificationTracker"| D
    B -->|"#[cfg(test)] mod tests;"| E
    C -->|"use super::support::*"| D
    E -->|"use super::{ get_cloudrun_service_name, ... }"| D
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["worker/mod.rs\n(crate re-exports)"]
    B["gcp/mod.rs\n(#[controller] struct\n+ handler impl block\n3,985 lines)"]
    C["gcp/helpers.rs\n(helper impl block\n14 pub(super) methods\n1,422 lines)"]
    D["gcp/support.rs\n(free fns, consts, types\n248 lines)"]
    E["gcp/tests.rs\n(#[cfg(test)]\n1,441 lines)"]

    A --> B
    B -->|"mod helpers;"| C
    B -->|"mod support;\nuse support::*;\npub use support::GcsNotificationTracker"| D
    B -->|"#[cfg(test)] mod tests;"| E
    C -->|"use super::support::*"| D
    E -->|"use super::{ get_cloudrun_service_name, ... }"| D
Loading

Reviews (1): Last reviewed commit: "refactor: split gcp worker controller in..." | Re-trigger Greptile

Pure git mv of worker/azure.rs to worker/azure/mod.rs with no content
changes, so rename detection and git log --follow stay intact ahead of
the module carve-out.
Break the 6,500-line worker/azure.rs into a directory module so each
concern can be read and reviewed in isolation:

- azure/mod.rs: controller struct, environment-wake retry tracking, and
  the #[controller] handler impl (kept whole for macro state generation)
- azure/support.rs: naming helpers, wait/delay helpers, error
  classifiers, heartbeat emission, and AzureStorageTriggerInfrastructure
- azure/helpers.rs: the plain helper-method impl block
- azure/tests.rs: the controller test module

Pure code motion: moved items are bumped to pub(super) where needed;
external paths are unchanged via the existing worker::azure re-exports.
@lilienblum lilienblum added refactor Behavior-preserving code reorganization rust labels Jul 19, 2026
@lilienblum lilienblum self-assigned this Jul 19, 2026
@lilienblum
lilienblum requested a review from alongubkin July 19, 2026 06:39
Break the 5,000-line worker/aws.rs into a directory module so each
concern can be read and reviewed in isolation:

- aws/mod.rs: controller struct and the #[controller] handler impl
  (kept whole for macro state generation)
- aws/support.rs: naming helpers, error classifiers, heartbeat
  emission, and the load balancer state types
- aws/helpers.rs: the plain helper-method impl blocks
- aws/tests.rs: the controller test module

Pure code motion: moved items are bumped to pub(super) where needed;
external paths are unchanged via the existing worker::aws re-exports.
Break the 5,700-line gcp/compute.rs into a directory module so each
concern can be read and reviewed in isolation:

- compute/mod.rs: module doc, ComputeServiceConfig, and re-exports
- compute/api.rs: the ComputeApi trait (automock still generates
  MockComputeApi here, re-exported unchanged)
- compute/client.rs: ComputeClient and its ComputeApi impl
- compute/types/: the serde data structures, split along the existing
  section banners (operations, network, load_balancer, instance)
- compute/tests.rs: the PSC serde test module

Pure code motion: no items were renamed or reordered; external paths
are unchanged via glob re-exports from compute/mod.rs. Note in
gcp/AGENTS.md that compute/ is the directory-module variant of the
cloudrun.rs pattern.
Break the 4,800-line lib.rs into concern modules so each area can be
read and reviewed in isolation:

- lib.rs: build_stack orchestration, build_resource, and
  build_target_to_file
- push.rs: push_stack, push targets, OCI tarball selection, and
  image index assembly
- cache.rs: artifact cache keys, source hashing, cargo metadata,
  and cached artifact lookup
- base_images.rs: base image resolution, entrypoint/cmd handling,
  and pull/retry classification
- tests.rs: the unit test module, still gated by #[cfg(test)]

Pure code motion: moved items are bumped to pub(crate); the public
API is unchanged via the root pub use of push_stack.
Break the 4,647-line generator.rs into a generator/ directory so each
concern can be read and reviewed in isolation:

- mod.rs: the options types, the generate_helm_chart and
  render_manager_fetch_values entrypoints, and shared JSON/YAML/name
  helpers
- operator.rs: generate_operator_manifest and the operator document
  builders
- values.rs: ChartAnalysis, values.yaml assembly, and cloud-identity
  mapping
- schema.rs: values.schema.json
- templates.rs: the Helm template (.tpl) bodies
- examples.rs: the per-target values examples and README
- tests.rs: the unit test module, still gated by #[cfg(test)]

Pure code motion: moved helpers are bumped to pub(super); the public
API is unchanged (lib.rs still re-exports generate_operator_manifest and
the other entrypoints). The file drops off the hk.pkl max-lines exclude
now that every module is under the 2000-line cap.
Break the 2,262-line generator.rs into a generator/ directory so each
concern can be read and reviewed in isolation:

- mod.rs: the template constants, the RegistrationMode /
  CloudFormationOptions / CloudFormationTarget types, the
  generate_cloudformation_template entrypoint, YAML serialization,
  stack validation, and the shared resource/output helpers
- parameters.rs: the standard/network/compute parameter blocks, the
  supported-region and custom-domain rules, the standard conditions,
  and the parameter-default helpers
- expressions.rs: the kubernetes/network/domains/management settings
  expressions, the JSON <-> CfExpression bridge, and the CfParameter /
  CfOutput constructors
- tests.rs: the unit test module, still gated by #[cfg(test)]

Pure code motion: moved helpers are bumped to pub(super); the public
API is unchanged (lib.rs still re-exports generate_cloudformation_template
and the other entrypoints). The file drops off the hk.pkl max-lines
exclude now that every module is under the 2000-line cap.
The EC2 client lived in a single 3616-line file. Split it into an
ec2/ module mirroring the existing client layout: api (the Ec2Api
trait), client (Ec2Client and its impls plus the cpu-options unit
tests), and types/ grouped by resource (common, network,
security_group, instance, volume, launch_template).

Pure code motion with import redistribution and module wiring; no
behavior change. Remove the file from the max-lines exclude list now
that every resulting file is under the 2000-line cap.
Break the 3,140-line gcp_compute_client_tests.rs into a directory test
target so each area can be read and reviewed in isolation. The binary
name (gcp_compute_client_tests) and all 17 tests are unchanged:

- main.rs: crate doc, module wiring, and the framework smoke test
- context.rs: the ComputeTestContext fixture and its cleanup/wait helpers
- vpc.rs, load_balancing.rs, disks.rs, instances.rs, ssl_proxy.rs: the
  comprehensive lifecycle tests, one area per module
- errors.rs: the not-found/error-mapping tests plus the operation-status
  test

Pure code motion: no test logic changed. Fixture items used across
modules are bumped from private to pub(crate), per-module imports are
consolidated, the mid-function rcgen import is hoisted to the top of
ssl_proxy.rs, and a mislabeled "Error Handling Tests for New APIs" banner
that sat above the SSL lifecycle test is dropped. The file is removed
from the hk.pkl max-lines exclude list now that every module is under the
2,000-line cap.
Break the 2,265-line aws_s3_client_tests.rs into a directory test target
so each area can be read and reviewed in isolation. The binary name
(aws_s3_client_tests) and all 37 tests are unchanged:

- main.rs: the crate attribute and module wiring
- context.rs: the S3TestContext fixture, its cleanup helpers, and the
  put_test_object helper
- bucket.rs: bucket lifecycle, policy, lifecycle-config, public-access
  block, name validation, and notification-config tests
- object.rs: object put/get/head, listing, delete, and empty-bucket tests
- versioning.rs: bucket-versioning and versioned-object tests
- location.rs: the get_bucket_location tests

Pure code motion: no test logic changed. Fixture items used across
modules are bumped from private to pub(crate) and per-module imports are
consolidated. The file is removed from the hk.pkl max-lines exclude list
now that every module is under the 2,000-line cap.
Break the 4,726-line distribution.rs into a distribution/ directory so
each concern can be read and reviewed in isolation:

- mod.rs: DistributionArtifactCleanup, setup_distribution and
  prepare_distribution, the flow-availability and stack-settings
  helpers, the cross-domain flow orchestrators (run_cloudformation_k8s,
  run_terraform_cloud/k8s, run_onprem_k8s), and stack import/finalize
- cleanup.rs: post-error cleanup and retained-resource teardown
- cloudformation.rs: run_cloudformation_aws and the CloudFormation
  request/output/stack-event helpers
- terraform.rs: the Terraform apply/import flow, tfvars, outputs, and
  handoff-debug helpers
- helm.rs: chart/values rendering, the Kubernetes helm target and
  kubeconfig materialization, and image-rewrite helpers
- permissions.rs: the GCP and Azure management permission probes
- env.rs: cloud env assembly (aws/gcp/azure/terraform)
- exec.rs: the process runners and shell-quote helpers
- tests.rs: the unit test module, still gated by #[cfg(test)]

Pure code motion: moved helpers are bumped to pub(super); the public
API is unchanged (setup_distribution and DistributionArtifactCleanup
are still defined in mod.rs). The file drops off the hk.pkl max-lines
exclude now that every module is under the 2,000-line cap.
Break the 2,700-line heartbeat.rs into a heartbeat/ directory so each
family of provider heartbeat types can be read and reviewed on its own:

- mod.rs: the ResourceHeartbeat envelope, ObservedInventoryBatch /
  ObservedResourceSample, shared health/lifecycle/backend/collection
  enums, event snapshots, raw snippets, and metric types
- storage.rs: StorageHeartbeatData and the S3/Blob/GCS/Local variants
- workload.rs: worker, container, and daemon heartbeat data plus the
  runtime unit and pod status types
- cluster.rs: compute-cluster and kubernetes-cluster heartbeat data with
  capacity/drain/fleet and node status types
- data_services.rs: queue, kv, postgres, and vault families
- platform.rs: service-account, network, and remote-stack-management
  families
- registry_build.rs: artifact-registry, build, and service-activation
  families
- azure_platform.rs: Azure resource-group, storage-account, container
  apps environment, and service-bus-namespace families
- tests.rs: the serde round-trip unit module, still gated by #[cfg(test)]

Pure code motion: submodules are glob re-exported from mod.rs so the
public API at the crate root is unchanged. Drop the file from the hk.pkl
max-lines exclude list now that every module is under the cap.
The generator split dedented the tests module by one level to extract it into
its own file, which unintentionally stripped four spaces from a line inside a
raw-string YAML literal, placing deploymentLabelValue at the document root
instead of under logCollector.scope. Helm 4 schema validation rejects the
root-level key, failing log_collector_enabled_chart_lints_and_templates.

Restore the four-space indentation so the literal is byte-identical to
pre-split. Verified with helm 4.2.3 + kubeconform: alien-helm 15/15 tests pass.
Relocate post-split changes from main into their focused modules and extract test modules that crossed the 2,000-line limit after the merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Behavior-preserving code reorganization rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant