Skip to content

refactor(agent,scout): adopt style guide rules for pub/module visibility - #4660

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4551
Aug 6, 2026
Merged

refactor(agent,scout): adopt style guide rules for pub/module visibility#4660
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4551

Conversation

@chet

@chet chet commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

This adopts the new style guide rules around module visibility introduced in #4522, applying the correct visibility throughout Agent and Scout.

Primary callouts are:

  • Replace unrestricted pub throughout crates/agent/src/** and crates/scout/src/** with private, pub(super), or pub(crate) visibility based on actual callers.
  • Keep the Agent exported duppet logging macro, generated clients owned by VSC-01, and existing cross-crate entry points public where they are still consumed.
  • Keep Scout command-line, deprovisioning, firmware-upgrade, and metric internals inside the crate while narrowing sibling and parent boundaries to their actual callers.
  • Remove the unused Scout Rebuild parser, the unused Agent sysfs address helper, and stale dead-code suppression exposed during the cleanup.
  • Leave CLI parsing, gRPC contracts, wire data, generated client code, and runtime behavior unchanged.

Tests updated!

Related issues

This supports #4551.

This supports the updated Rust visibility scoping guidelines in STYLE_GUIDE.md, established in #4522.

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

All 199 Agent tests and 56 Scout tests passed. I also ran:

cargo test --locked -p carbide-agent -p carbide-scout --all-features
cargo clippy --locked -p carbide-agent -p carbide-scout --all-targets --all-features -- --force-warn unreachable-pub
cargo make format-nightly
cargo make clippy
cargo make carbide-lints
git diff --check

Additional Notes

The current main baseline identified 177 overbroad declarations across Agent and Scout. The final 45-file diff leaves no checked-in Agent or Scout source finding; the strict command still reports 24 generated tonic declarations under the Agent build output, which are intentionally untouched here as part of the generated client boundary owned by VSC-01.

Local CodeRabbit and read-only Claude reviews completed over the full diff. The applicable private-helper, stale-comment, unused-helper, and private-test-field findings are incorporated.

The review also proposed spelling crate-root child visibility as pub(crate) instead of pub(super). Those boundaries stay pub(super) because the STYLE_GUIDE.md caller table maps parent-module callers to pub(super); although both spellings reach the same modules for a crate-root child, pub(super) records the actual caller relationship. A helper used by a sibling test module also stays pub(super) for the same reason, and the exported duppet logging macro remains public as required by the issue.

Closes #4551

This adopts the new style guide rules around module visibility introduced in NVIDIA#4522, applying the correct visibility throughout Agent and Scout.

Primary callouts are:
- Replace unrestricted `pub` throughout `crates/agent/src/**` and `crates/scout/src/**` with private, `pub(super)`, or `pub(crate)` visibility based on actual callers.
- Keep the Agent exported `duppet` logging macro, generated clients owned by VSC-01, and existing cross-crate entry points public where they are still consumed.
- Keep Scout command-line, deprovisioning, firmware-upgrade, and metric internals inside the crate while narrowing sibling and parent boundaries to their actual callers.
- Remove the unused Scout `Rebuild` parser, the unused Agent sysfs address helper, and stale dead-code suppression exposed during the cleanup.
- Leave CLI parsing, gRPC contracts, wire data, generated client code, and runtime behavior unchanged.

Tests updated!

This supports NVIDIA#4551.

This supports the updated Rust visibility scoping guidelines in `STYLE_GUIDE.md`, established in NVIDIA#4522.

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet
chet requested a review from a team as a code owner August 6, 2026 07:44
@chet

chet commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@chet: I will perform a complete review of pull request #4660.

ᕱᕱ

⚠️ Action not completed

Review rate limited.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@chet, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a45f61d7-a6be-4f8f-8a68-00d652121739

📥 Commits

Reviewing files that changed from the base of the PR and between 4f0e11f and 35ff4e9.

📒 Files selected for processing (45)
  • crates/agent/src/acl_rules.rs
  • crates/agent/src/astra_weave.rs
  • crates/agent/src/command_line.rs
  • crates/agent/src/dhcp.rs
  • crates/agent/src/dhcp_server_grpc_client.rs
  • crates/agent/src/dpu/interface.rs
  • crates/agent/src/duppet/log.rs
  • crates/agent/src/duppet/sync.rs
  • crates/agent/src/ethernet_virtualization.rs
  • crates/agent/src/fmds_client.rs
  • crates/agent/src/hbn.rs
  • crates/agent/src/health.rs
  • crates/agent/src/health/bgp.rs
  • crates/agent/src/host_machine_id.rs
  • crates/agent/src/instance_metadata_endpoint.rs
  • crates/agent/src/lib.rs
  • crates/agent/src/machine_inventory_updater.rs
  • crates/agent/src/main_loop.rs
  • crates/agent/src/managed_files.rs
  • crates/agent/src/metadata_service.rs
  • crates/agent/src/mtu.rs
  • crates/agent/src/ovs.rs
  • crates/agent/src/periodic_config_fetcher.rs
  • crates/agent/src/sysfs.rs
  • crates/agent/src/tests/common/mod.rs
  • crates/agent/src/tests/full.rs
  • crates/agent/src/tests/test_network_monitor.rs
  • crates/agent/src/util.rs
  • crates/scout/src/attestation.rs
  • crates/scout/src/cfg/command_line.rs
  • crates/scout/src/cfg/mod.rs
  • crates/scout/src/client.rs
  • crates/scout/src/deprovision/cmdrun.rs
  • crates/scout/src/deprovision/mod.rs
  • crates/scout/src/deprovision/scrabbing.rs
  • crates/scout/src/discovery.rs
  • crates/scout/src/firmware_upgrade.rs
  • crates/scout/src/machine_validation.rs
  • crates/scout/src/main.rs
  • crates/scout/src/metrics.rs
  • crates/scout/src/mlx_device.rs
  • crates/scout/src/platform.rs
  • crates/scout/src/register.rs
  • crates/scout/src/stream.rs
  • crates/scout/src/tpm.rs

Summary by CodeRabbit

  • Refactor
    • Restricted internal APIs, helpers, constants, types, and test utilities to narrower visibility scopes.
    • Removed several unnecessary public exports and an obsolete command option.
    • No runtime behavior or user-facing functionality changed.

Walkthrough

The PR narrows Rust visibility across the agent and scout crates. It changes public items to private, pub(super), or pub(crate) scope, removes selected re-exports, removes the obsolete Rebuild command, and deletes one unused sysfs method. Runtime behavior remains unchanged.

Changes

Internal API visibility cleanup

Layer / File(s) Summary
Agent production API surface
crates/agent/src/*.rs, crates/agent/src/health/*
Agent constants, functions, types, fields, methods, and modules use narrower visibility. One unused sysfs address-reading method and its imports were removed.
Agent test API surface
crates/agent/src/dpu/interface.rs, crates/agent/src/tests/*
Test helpers, test functions, metric helpers, and mock types are no longer publicly visible.
Scout API surface and command model
crates/scout/src/*.rs, crates/scout/src/cfg/*, crates/scout/src/deprovision/*
Scout APIs and re-exports use narrower visibility. The obsolete Rebuild command was removed, and MachineValidation now requires context.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the visibility refactor across Agent and Scout modules.
Description check ✅ Passed The description explains the visibility changes, preserved interfaces, removed unused code, and testing performed.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
crates/scout/src/deprovision/scrabbing.rs (1)

1148-1148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Narrow declarations to their actual caller boundaries.

Both declarations remain broader than the supplied caller graph requires.

  • crates/scout/src/deprovision/scrabbing.rs#L1148-L1148: change run_no_api from pub(crate) to pub(super) because crates/scout/src/deprovision/mod.rs re-exports it.
  • crates/scout/src/tpm.rs#L28-L28: make TPM_RECOVERY_ATTEMPTED_PATH private if the repository-wide search finds no caller outside crates/scout/src/tpm.rs.
🤖 Prompt for 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.

In `@crates/scout/src/deprovision/scrabbing.rs` at line 1148, Narrow the
visibility of deprovision::scrabbing::run_no_api in
crates/scout/src/deprovision/scrabbing.rs:1148-1148 from pub(crate) to
pub(super), preserving access through deprovision/mod.rs. In
crates/scout/src/tpm.rs:28-28, make TPM_RECOVERY_ATTEMPTED_PATH private only if
repository-wide usage confirms no callers outside tpm.rs.

Sources: Coding guidelines, Path instructions

🤖 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.

Nitpick comments:
In `@crates/scout/src/deprovision/scrabbing.rs`:
- Line 1148: Narrow the visibility of deprovision::scrabbing::run_no_api in
crates/scout/src/deprovision/scrabbing.rs:1148-1148 from pub(crate) to
pub(super), preserving access through deprovision/mod.rs. In
crates/scout/src/tpm.rs:28-28, make TPM_RECOVERY_ATTEMPTED_PATH private only if
repository-wide usage confirms no callers outside tpm.rs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4484eb7c-add2-4a3c-8a6a-4e5fd30699c2

📥 Commits

Reviewing files that changed from the base of the PR and between 4f0e11f and 35ff4e9.

📒 Files selected for processing (45)
  • crates/agent/src/acl_rules.rs
  • crates/agent/src/astra_weave.rs
  • crates/agent/src/command_line.rs
  • crates/agent/src/dhcp.rs
  • crates/agent/src/dhcp_server_grpc_client.rs
  • crates/agent/src/dpu/interface.rs
  • crates/agent/src/duppet/log.rs
  • crates/agent/src/duppet/sync.rs
  • crates/agent/src/ethernet_virtualization.rs
  • crates/agent/src/fmds_client.rs
  • crates/agent/src/hbn.rs
  • crates/agent/src/health.rs
  • crates/agent/src/health/bgp.rs
  • crates/agent/src/host_machine_id.rs
  • crates/agent/src/instance_metadata_endpoint.rs
  • crates/agent/src/lib.rs
  • crates/agent/src/machine_inventory_updater.rs
  • crates/agent/src/main_loop.rs
  • crates/agent/src/managed_files.rs
  • crates/agent/src/metadata_service.rs
  • crates/agent/src/mtu.rs
  • crates/agent/src/ovs.rs
  • crates/agent/src/periodic_config_fetcher.rs
  • crates/agent/src/sysfs.rs
  • crates/agent/src/tests/common/mod.rs
  • crates/agent/src/tests/full.rs
  • crates/agent/src/tests/test_network_monitor.rs
  • crates/agent/src/util.rs
  • crates/scout/src/attestation.rs
  • crates/scout/src/cfg/command_line.rs
  • crates/scout/src/cfg/mod.rs
  • crates/scout/src/client.rs
  • crates/scout/src/deprovision/cmdrun.rs
  • crates/scout/src/deprovision/mod.rs
  • crates/scout/src/deprovision/scrabbing.rs
  • crates/scout/src/discovery.rs
  • crates/scout/src/firmware_upgrade.rs
  • crates/scout/src/machine_validation.rs
  • crates/scout/src/main.rs
  • crates/scout/src/metrics.rs
  • crates/scout/src/mlx_device.rs
  • crates/scout/src/platform.rs
  • crates/scout/src/register.rs
  • crates/scout/src/stream.rs
  • crates/scout/src/tpm.rs

@chet
chet merged commit c4c0a5e into NVIDIA:main Aug 6, 2026
64 checks passed
@chet
chet deleted the gh-issue-4551 branch August 6, 2026 16:40
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.

Tighten Agent and Scout Visibility

2 participants