Skip to content

improve code quality and separation of concerns#75

Open
Bechma wants to merge 101 commits into
constructorfabric:mainfrom
Bechma:dev
Open

improve code quality and separation of concerns#75
Bechma wants to merge 101 commits into
constructorfabric:mainfrom
Bechma:dev

Conversation

@Bechma

@Bechma Bechma commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added builder-based resolution for build/run with dry-run JSON output and support for explicit generated-name overrides.
  • Behavior Changes
    • Manifest-based commands are now resolved in the CLI layer (build/run/test/lint).
    • deploy now requires --manifest (no fallback generation).
    • Module configuration has moved from modules to gears, and gears annotations now use #[toolkit::gear(...)].
    • config mod add now uses --dep and only adds local modules.
  • Documentation
    • Updated lint guidance and snapshots to use cf_gears_toolkit_macros::api_dto.
  • Chores
    • Updated CI triggers/workflows for pull requests.

Bechma and others added 20 commits June 12, 2026 13:07
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Core (cargo-gears-core) refactor:

- LintParams — now takes workspace_root, resolved booleans, dylint_skip
- TestParams — now takes resolved workspace_root, config_path, runner, modules, dependencies, feature_set
- BuildParams — now takes resolved paths, flags, dependencies
- RunParams — now takes resolved paths, flags, watch_policy; returns RunOutcome enum
- GearsCommand — removed Lint, Test, Build, Run variants (manifest-based commands no longer route through it)
- BuildRunParams and its override helpers (otel_enabled, fips_enabled, release_build, clean_build) — deleted

CLI (cargo-gears) refactor:

- Cli::run() — dispatches manifest-based commands directly via resolve()?.run() / resolve_and_run()
- LintArgs::resolve() — manifest resolution + effective selection logic (moved from core)
- TestArgs::resolve() — manifest resolution + runner override (moved from core)
- BuildRunArgs::resolve() — manifest resolution + boolean overrides → ResolvedBuildRun
- RunArgs::resolve_and_run() — owns the watch re-resolve loop

- Integration tests updated to verify CLI parsing directly via Cli::command()

Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
New resolution tests (14 unit tests in CLI crate):

- common/mod.rs — 4 tests: CLI overrides vs manifest defaults, clean-defaults-to-release logic
- lint.rs — 8 tests: manifest policy fallback, explicit selection overrides, --all, strict validation, dylint skip
- testing.rs — 2 tests: manifest runner default, CLI runner override

Removed leftovers:

- cmd_test.rs — deleted entirely (only had field-inspection tests)
- cmd_build.rs — removed 2 field-inspection tests, kept conflict test
- cmd_run.rs — removed 3 field-inspection tests, kept conflict test
- cmd_lint.rs — removed field-inspection test, kept path side-effect test
- parse_cli helper — removed (no longer needed)

Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Also, changed all fields from pub to pub(crate), and added public getter methods

Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
refactor: Simplify / consolidate TestParams and TestPlan
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Manifest-based commands now resolve in the CLI before execution. Core command and run/test/lint data structures now store resolved values, lint references switch to cf_gears_toolkit_macros::api_dto, gear annotations change to toolkit::gear, and the config namespace moves from modules to gears. CI trigger filters and a new dylint workflow are also updated.

Changes

Command Resolution Lifted to CLI Layer

Layer / File(s) Summary
Resolved core models
crates/cargo-gears-core/src/common.rs, crates/cargo-gears-core/src/run/mod.rs, crates/cargo-gears-core/src/lint/mod.rs, crates/cargo-gears-core/src/test/mod.rs, crates/cargo-gears-core/src/lib.rs
BuildRunParams, RunParams, LintParams, TestPlan, and GearsCommand now use resolved values and omit manifest-based command variants.
Build resolution and execution
crates/cargo-gears-core/src/build/mod.rs, crates/cargo-gears/src/build.rs, crates/cargo-gears/src/common/mod.rs
BuildParamsBuilder resolves manifest input and CLI overrides; BuildParams::run uses resolved fields directly; BuildArgs::resolve replaces the prior conversion path; build CLI argument fields are made crate-visible.
Lint resolution and execution
crates/cargo-gears-core/src/lint/mod.rs, crates/cargo-gears/src/lint.rs
LintParams now carries resolved workspace_root and dylint_skip values; LintParams::run executes directly from resolved booleans; LintArgs::resolve computes manifest defaults, explicit CLI overrides, and strict-mode validation.
Run resolution and outcome loop
crates/cargo-gears-core/src/run/mod.rs, crates/cargo-gears-core/src/run/run_loop.rs, crates/cargo-gears/src/run.rs
RunParams becomes a resolved per-iteration struct with watch policy and dependencies; RunParamsBuilder resolves overrides and produces RunOutcome; RunParams::run handles one iteration; RunArgs::resolve_and_run loops on rerun signals.
Test resolution and plan execution
crates/cargo-gears-core/src/test/mod.rs, crates/cargo-gears-core/src/test/cargo.rs, crates/cargo-gears-core/src/test/llvm-cov.rs, crates/cargo-gears/src/testing.rs
TestPlan becomes the public execution model with runner, coverage, custom_command, and runs; TestArgs::resolve builds the plan and expands feature sets; runner and command tests are updated to the new resolution flow.
CLI dispatch and conversion wiring
crates/cargo-gears/src/lib.rs, crates/cargo-gears/src/common/mod.rs, crates/cargo-gears/tests/*, crates/cargo-gears/tests/common/mod.rs
Cli::run dispatches manifest commands through resolve methods and converts non-manifest commands through TryFrom; Commands becomes private; ManifestTargetArgs adds into_selection; command helper parsing uses try_from.

Lint Macro Path Rename

Layer / File(s) Summary
Lint source and docs
crates/cargo-gears-lints/src/de01_domain_layer/de0104_no_api_dto_in_domain.rs, crates/cargo-gears-lints/src/de02_api_layer/de0203_dtos_must_use_api_dto.rs, crates/cargo-gears-lints/src/lint_utils.rs, crates/cargo-gears-lints/README.md, crates/cargo-gears-lints/docs/...
DE0104 detection logic, DE0203 help text, shared lint comments, and lint README docs now reference the cf_gears_toolkit_macros macro path.
UI test sources and stderr
crates/cargo-gears-lints/tests/ui/de0104_no_api_dto_in_domain/*, crates/cargo-gears-lints/tests/ui/de02*/*, crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/*
UI test sources register cf_gears_toolkit_macros and update attribute paths; all affected stderr fixtures update DE0203 help text to the new macro path.

Gear Annotation Path Update

Layer / File(s) Summary
Parser recognition and list scaffolds
crates/cargo-gears-core/src/gears_parser/module_rs.rs, crates/cargo-gears-core/src/list/mod.rs, crates/cargo-gears-core/src/list/modules.rs
The module parser recognizes toolkit::gear paths, and parser and list tests update their embedded source annotations and generated scaffolds to match.

Gears Config Namespace Rename

Layer / File(s) Summary
AppConfig and dependency collection
crates/cargo-gears-core/src/app_config.rs, crates/cargo-gears-core/src/common.rs
AppConfig now stores gears_dir and gears, and dependency collection iterates over the renamed map.
Module config storage and lookup
crates/cargo-gears-core/src/config/modules/add.rs, crates/cargo-gears-core/src/config/modules/db.rs, crates/cargo-gears-core/src/config/modules/remove.rs
Module config insert, lookup, and removal paths now use config.gears instead of config.modules.
Schema help text
crates/cargo-gears-core/src/help/mod.rs
schema_config recognizes gears and the section-resolution test now includes gears instead of modules.

CI Workflow Updates

Layer / File(s) Summary
CI workflow rules
.github/workflows/ci.yml, .github/workflows/dylint.yml, crates/cargo-gears-lints/rust-toolchain.toml
pull_request branches and paths in ci.yml are updated, a new dylint workflow runs formatting and tests for crates/cargo-gears-lints, and the lints toolchain adds rustfmt.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Poem

🐇 Hop, hop—new paths are set in stone,
The CLI now resolves what once was unknown.
cf_gears_toolkit_macros shines bright and clean,
While gears, watches, and workflows all align the scene.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is generic and doesn't identify the main change, so it’s hard to tell what this PR actually does. Rename it to summarize the core refactor, e.g. "Refactor command resolution into builders and resolved params".
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 86.49% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Bechma added 3 commits June 23, 2026 11:50
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
# Conflicts:
#	crates/cargo-gears-lints/tests/ui/de0104_no_api_dto_in_domain/with_api_dto.stderr

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/cargo-gears-core/src/build/mod.rs`:
- Around line 13-27: The BuildParamsBuilder struct is missing a field to capture
the name override that can be passed via the --name command line argument. Add
an optional String field (following the pattern of existing optional fields like
app, env, etc.) to store the generated_name override in BuildParamsBuilder,
create a corresponding setter method for it, and ensure this field is used when
constructing the final BuildParams to allow the name override to be properly
carried through instead of always using the manifest name.

In `@crates/cargo-gears/src/common/mod.rs`:
- Around line 75-77: The `name` field from `BuildRunArgs` is not being passed
through to `BuildParamsBuilder` and `RunParamsBuilder`, which causes the CLI
`--name` override to be ignored. Add a `name` field and corresponding setter
method to both `BuildParamsBuilder` and `RunParamsBuilder`. Then in the
resolution paths where these builders are finalized (in both build and run
flows), apply the pattern `self.name.unwrap_or(resolved.generated_name)` to use
the CLI-provided name if available, otherwise use the manifest-derived generated
name. Finally, add a regression test that verifies the `cargo gears build --name
custom_name` and `cargo gears run --name custom_name` CLI overrides work
correctly and override the manifest-derived names.

In `@crates/cargo-gears/src/testing.rs`:
- Around line 70-78: The feature policy lookup at feature_set.get(module) uses
the raw CLI input (module parameter), but when the user provides a package name
instead of a module name, the lookup key doesn't match the module name stored in
the feature_set, causing the configured feature matrix to be skipped. Modify the
code to use the actual resolved module name for the feature_set lookup instead
of the raw CLI input. The module name should be determined from the modules map
using the package that was resolved by package_for_module, ensuring the feature
policy lookup succeeds regardless of whether the user provided a module name or
package alias.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4728e86-0f3e-4b63-937c-898199916ee8

📥 Commits

Reviewing files that changed from the base of the PR and between 20cc5ec and 07f0382.

📒 Files selected for processing (57)
  • crates/cargo-gears-core/src/build/mod.rs
  • crates/cargo-gears-core/src/common.rs
  • crates/cargo-gears-core/src/lib.rs
  • crates/cargo-gears-core/src/lint/mod.rs
  • crates/cargo-gears-core/src/run/mod.rs
  • crates/cargo-gears-core/src/test/cargo.rs
  • crates/cargo-gears-core/src/test/llvm-cov.rs
  • crates/cargo-gears-core/src/test/mod.rs
  • crates/cargo-gears-lints/README.md
  • crates/cargo-gears-lints/docs/de01_domain_layer/de0104_no_api_dto_in_domain/README.md
  • crates/cargo-gears-lints/docs/de02_api_layer/de0203_dtos_must_use_api_dto/README.md
  • crates/cargo-gears-lints/src/de01_domain_layer/de0104_no_api_dto_in_domain.rs
  • crates/cargo-gears-lints/src/de02_api_layer/de0203_dtos_must_use_api_dto.rs
  • crates/cargo-gears-lints/src/lint_utils.rs
  • crates/cargo-gears-lints/tests/ui/de0104_no_api_dto_in_domain/with_api_dto.rs
  • crates/cargo-gears-lints/tests/ui/de0104_no_api_dto_in_domain/with_api_dto.stderr
  • crates/cargo-gears-lints/tests/ui/de0104_no_api_dto_in_domain/without_api_dto.rs
  • crates/cargo-gears-lints/tests/ui/de0201_dtos_only_in_api_rest/dto_in_api_rest.stderr
  • crates/cargo-gears-lints/tests/ui/de0202_dtos_not_referenced_outside_api/import_dto_in_api.stderr
  • crates/cargo-gears-lints/tests/ui/de0203_dtos_must_use_api_dto/missing_api_dto.stderr
  • crates/cargo-gears-lints/tests/ui/de0204_dtos_must_have_toschema_derive/has_toschema.stderr
  • crates/cargo-gears-lints/tests/ui/de0204_dtos_must_have_toschema_derive/missing_toschema.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_camel_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_enum_variant_rename_camel_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_field_camel_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_field_kebab_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_field_name_camel_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_field_pascal_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_field_rename_nested_camel_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_field_screaming_kebab_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_field_screaming_snake_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_field_uppercase.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_kebab_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_lowercase.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_pascal_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_rename_all_nested_camel_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_screaming_kebab_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_screaming_snake_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/fail_uppercase.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/pass.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/pass_enum_variant_rename_snake_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/pass_field_lowercase.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/pass_field_name_with_snake_rename.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/pass_field_rename_nested_snake_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/pass_field_snake_case.stderr
  • crates/cargo-gears-lints/tests/ui/de0803_api_snake_case/pass_rename_all_nested_snake_case.stderr
  • crates/cargo-gears/src/build.rs
  • crates/cargo-gears/src/common/mod.rs
  • crates/cargo-gears/src/lib.rs
  • crates/cargo-gears/src/lint.rs
  • crates/cargo-gears/src/run.rs
  • crates/cargo-gears/src/testing.rs
  • crates/cargo-gears/tests/cmd_build.rs
  • crates/cargo-gears/tests/cmd_lint.rs
  • crates/cargo-gears/tests/cmd_run.rs
  • crates/cargo-gears/tests/cmd_test.rs
  • crates/cargo-gears/tests/common/mod.rs
💤 Files with no reviewable changes (1)
  • crates/cargo-gears/tests/cmd_test.rs

Comment thread crates/cargo-gears-core/src/build/mod.rs
Comment thread crates/cargo-gears/src/common/mod.rs
Comment thread crates/cargo-gears/src/testing.rs
Bechma and others added 3 commits June 23, 2026 12:23
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
maurolacy and others added 21 commits July 3, 2026 09:08
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Clean up unused imports and empty impl block after removal

Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
maurolacy and others added 8 commits July 3, 2026 11:16
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
fix: run hangs on child exit
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
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.

3 participants