Skip to content

chore(rust): enforce command-tree file structure; split oversized modules - #192

Open
jpage-godaddy wants to merge 7 commits into
mainfrom
command-file-structure
Open

chore(rust): enforce command-tree file structure; split oversized modules#192
jpage-godaddy wants to merge 7 commits into
mainfrom
command-file-structure

Conversation

@jpage-godaddy

Copy link
Copy Markdown
Collaborator

Summary

  • Documents the desired file structure (one file per subcommand, mirroring the CLI command tree — see domain/dns as the reference shape) in docs/code-structure.md, with a pointer from AGENTS.md.
  • Adds rust/scripts/check-module-size.sh, wired into CI, which fails the build if any hand-written .rs file exceeds 1000 lines. No allowlist.
  • Splits every file that was already over that limit into per-subcommand/per-concern files: dns/set.rs, hosting/nodejs/mod.rs, api_explorer/mod.rs, extension/mod.rs, application/commands/mod.rs, and tools/generate-api-catalog/src/main.rs.

Test plan

  • cargo check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo test — 550 passed, same count as before the refactor across every touched module
  • cargo fmt --check — clean
  • ./rust/scripts/check-module-size.sh — zero violations
  • Manually exercised dns set, hosting nodejs app list, platform app list, api search, api call against a live environment to confirm the refactored wiring/auth/client code behaves identically

🤖 Generated with Claude Code

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.
Copilot AI lite review requested due to automatic review settings August 7, 2026 21:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@jpage-godaddy jpage-godaddy changed the title Enforce command-tree file structure; split oversized Rust modules chore(rust): enforce command-tree file structure; split oversized modules Aug 7, 2026
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.

2 participants