Skip to content

refactor(api-web): adopt style guide rules for pub/module visibility - #4630

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4548
Aug 5, 2026
Merged

refactor(api-web): adopt style guide rules for pub/module visibility#4630
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4548

Conversation

@chet

@chet chet commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

Primary callouts are:

  • Replace unrestricted pub throughout crates/api-web/src/** with private, pub(super), or test-only pub(crate) visibility based on real call sites.
  • Keep carbide_api_web::routes public as the crate's HTTP integration point while scoping handlers and helpers to their actual parents and siblings.
  • Keep managed-host row-display coverage without widening production APIs by colocating that test with its private implementation.
  • Remove the unused managed-host time_in_state display field exposed during dead-code cleanup.
  • Leave HTTP routes, templates, serialized responses, RPC calls, and runtime behavior unchanged.

Tests updated!

Related issues

This supports #4548.

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 59 API Web tests passed during implementation. The focused managed-host row-display test also passed against an isolated PostgreSQL instance after the clean rebase that brought in #4600. I also ran:

make core/tests TEST_ARGS="-p carbide-api-web test_managed_host_row_display"
cargo check --locked -p carbide-api-web --all-targets --all-features
cargo make format-nightly
cargo make clippy
cargo make carbide-lints
git diff --check

Additional Notes

The initial visibility lint identified 280 overbroad declarations across 51 files. The final 55-file diff also includes the root and test-module boundaries exposed by that cleanup, and the only unrestricted source pub left is the intentional carbide_api_web::routes crate API. Most hunks are visibility tokens plus the resulting rustfmt reflow.

Local CodeRabbit and read-only Claude reviews completed over the full diff. All applicable findings are incorporated.

Closes #4548

This adopts the new style guide rules around `pub` and module visibility introduced in NVIDIA#4522, applying the correct visibility throughout API Web.

Primary callouts are:
- Replace unrestricted `pub` throughout `crates/api-web/src/**` with private, `pub(super)`, or test-only `pub(crate)` visibility based on real call sites.
- Keep `carbide_api_web::routes` public as the crate's HTTP integration point while scoping handlers and helpers to their actual parents and siblings.
- Keep managed-host row-display coverage without widening production APIs by colocating that test with its private implementation.
- Remove the unused managed-host `time_in_state` display field exposed during dead-code cleanup.
- Leave HTTP routes, templates, serialized responses, RPC calls, and runtime behavior unchanged.

Tests updated!

This supports NVIDIA#4548.

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 5, 2026 21:44
@chet

chet commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c0fda8f0-d08a-4f7c-8be5-b27cf00d10da

📥 Commits

Reviewing files that changed from the base of the PR and between 8577e2f and f81a4f3.

📒 Files selected for processing (55)
  • crates/api-web/src/action_status.rs
  • crates/api-web/src/attestation.rs
  • crates/api-web/src/auth.rs
  • crates/api-web/src/compute_allocation.rs
  • crates/api-web/src/configuration.rs
  • crates/api-web/src/domain.rs
  • crates/api-web/src/dpa.rs
  • crates/api-web/src/dpu_versions.rs
  • crates/api-web/src/expected_machine.rs
  • crates/api-web/src/expected_power_shelf.rs
  • crates/api-web/src/expected_rack.rs
  • crates/api-web/src/expected_switch.rs
  • crates/api-web/src/explored_endpoint.rs
  • crates/api-web/src/filters.rs
  • crates/api-web/src/firmware.rs
  • crates/api-web/src/health.rs
  • crates/api-web/src/health_history.rs
  • crates/api-web/src/ib_fabric.rs
  • crates/api-web/src/ib_partition.rs
  • crates/api-web/src/instance.rs
  • crates/api-web/src/instance_type.rs
  • crates/api-web/src/interface.rs
  • crates/api-web/src/ipam.rs
  • crates/api-web/src/ipxe_template.rs
  • crates/api-web/src/lib.rs
  • crates/api-web/src/logs.rs
  • crates/api-web/src/machine.rs
  • crates/api-web/src/machine_validation.rs
  • crates/api-web/src/managed_host.rs
  • crates/api-web/src/network_device.rs
  • crates/api-web/src/network_security_group.rs
  • crates/api-web/src/network_segment.rs
  • crates/api-web/src/network_status.rs
  • crates/api-web/src/nmxc_browser.rs
  • crates/api-web/src/nvlink.rs
  • crates/api-web/src/operating_system.rs
  • crates/api-web/src/pagination.rs
  • crates/api-web/src/power_shelf.rs
  • crates/api-web/src/rack.rs
  • crates/api-web/src/redfish_actions.rs
  • crates/api-web/src/redfish_browser.rs
  • crates/api-web/src/resource_pool.rs
  • crates/api-web/src/search.rs
  • crates/api-web/src/site_explorer_run_status.rs
  • crates/api-web/src/sku.rs
  • crates/api-web/src/spx_partition.rs
  • crates/api-web/src/state_history.rs
  • crates/api-web/src/switch.rs
  • crates/api-web/src/tenant.rs
  • crates/api-web/src/tenant_keyset.rs
  • crates/api-web/src/tests/env.rs
  • crates/api-web/src/tests/managed_host.rs
  • crates/api-web/src/tests/mod.rs
  • crates/api-web/src/ufm_browser.rs
  • crates/api-web/src/vpc.rs

Summary by CodeRabbit

  • Refactor

    • Improved encapsulation across web interface components by limiting access to internal handlers, helpers, data structures, and formatting utilities.
    • Preserved existing page behavior, responses, routing, authentication, and error handling.
    • Reduced exposure of internal modules and APIs beyond their intended scope.
  • Tests

    • Updated test visibility boundaries and streamlined managed-host test coverage.
    • Added validation for managed-host and attached-device display information.

Walkthrough

The PR narrows visibility across crates/api-web. Handlers, data types, helpers, modules, and test utilities now use pub(super), private, or pub(crate) visibility. Runtime behavior remains unchanged except for the managed-host display test removal and time_in_state field removal.

Changes

API web visibility narrowing

Layer / File(s) Summary
Visibility contracts and runtime support
crates/api-web/src/*.rs
Shared types, handlers, helpers, route modules, pagination, filters, state-history generation, and test utilities use narrower visibility.
Managed-host display model
crates/api-web/src/managed_host.rs
ManagedHostRowDisplay and AttachedDpuRowDisplay are private. time_in_state was removed.
Managed-host test cleanup
crates/api-web/src/tests/*
The managed-host display SQLx test and its unused imports were removed. Test environment visibility was narrowed.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.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 and concisely describes the visibility refactor across the API Web module.
Description check ✅ Passed The description directly explains the visibility changes, preserved behavior, testing, and related objectives.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.45.0)
crates/api-web/src/lib.rs

ast-grep timed out on this file


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

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

🐇🔍

✅ Action performed

Full review finished.

@chet
chet merged commit 424d38e into NVIDIA:main Aug 5, 2026
63 checks passed
@chet
chet deleted the gh-issue-4548 branch August 5, 2026 22:44
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 API Web Visibility

2 participants