chore(rust): enforce command-tree file structure; split oversized modules - #192
Open
jpage-godaddy wants to merge 7 commits into
Open
chore(rust): enforce command-tree file structure; split oversized modules#192jpage-godaddy wants to merge 7 commits into
jpage-godaddy wants to merge 7 commits into
Conversation
dns set's reconciliation logic (plan/outcome/write) lived in one
1107-line file. Split into set/{mod,plan,outcome,write}.rs so each
concern has its own file, matching the domain/dns file-per-subcommand
convention.
nodejs/mod.rs held every nested group (app/job/deployment/source/ github/secrets) inline in one 1088-line file. app/ and source/ get their own subdirectories (multiple substantial leaf commands each); job/deployment/github/secrets stay flat files. mod.rs keeps only the two bare top-level commands and the shared client/terminal-status helpers.
api_explorer/mod.rs mixed the catalog data model, schema introspection, parameter/response summarization, module wiring, and every command handler in one 4199-line file. Split into catalog/schema/schema_tree/ summary/http helper files plus one file per leaf command (domain_cmd/operation/parameter/response/schema_cmd/search/call), following the domain/dns file-per-subcommand convention.
extension/mod.rs bundled types, sandboxing, the runtime wrapper, the esbuild bundler, and the SEC101-SEC115 security scanner in one 2713-line file. Split by concern into types/sandbox/runtime_wrapper/ bundler.rs and a security/ module (rule data in rules.rs, detection tests split by rule range). mod.rs re-exports the same public surface so no caller needs to change.
application/commands/mod.rs held every app-registry command (list/info/init/validate/update/lifecycle/release/add/deploy) in one 2272-line file. Split into one file per command, with deploy/ and add_extension/ as subdirectories for the larger nested groups, plus a shared schemas.rs for the output_schema! definitions.
The catalog-generation tool's main.rs mixed GitHub discovery, $ref dereferencing, OpenAPI operation processing, and GraphQL schema synthesis in one 2407-line file. Split into manifest/github/ dereference/openapi/graphql.rs by pipeline stage; main.rs keeps only the top-level orchestration.
AI agents kept growing single files into multi-thousand-line modules (api_explorer/mod.rs alone reached 4199 lines), making review and navigation harder over time. Document the desired file-per-subcommand structure in docs/code-structure.md, point to it from AGENTS.md, and add rust/scripts/check-module-size.sh as a CI gate so no hand-written .rs file can cross 1000 lines again without being split first.
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
domain/dnsas the reference shape) indocs/code-structure.md, with a pointer fromAGENTS.md.rust/scripts/check-module-size.sh, wired into CI, which fails the build if any hand-written.rsfile exceeds 1000 lines. No allowlist.dns/set.rs,hosting/nodejs/mod.rs,api_explorer/mod.rs,extension/mod.rs,application/commands/mod.rs, andtools/generate-api-catalog/src/main.rs.Test plan
cargo check— cleancargo clippy --all-targets -- -D warnings— cleancargo test— 550 passed, same count as before the refactor across every touched modulecargo fmt --check— clean./rust/scripts/check-module-size.sh— zero violationsdns set,hosting nodejs app list,platform app list,api search,api callagainst a live environment to confirm the refactored wiring/auth/client code behaves identically🤖 Generated with Claude Code