Skip to content

chore: Tidy up the imports - #231

Merged
grahamking merged 1 commit into
mainfrom
gk-libsy-pub-cleanup
Jul 31, 2026
Merged

chore: Tidy up the imports#231
grahamking merged 1 commit into
mainfrom
gk-libsy-pub-cleanup

Conversation

@grahamking

@grahamking grahamking commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
  1. libsy exports everything public at libsy:: and names the types
    explicity, no use module::*.

None of the internal modules are visible. This should give us the
ability to move things around later.

  1. Normalize imports so that inside a crate:
    • Structs are imported and used directly. use crate::thing::Thing; let t = Thing{ .. }
    • Functions have one level of prefix. thing::do_it()

That's probably the most common way to do it in Rust, although there's
all ways. I find it makes it easier to read, and having a standard is
better than a bit of everything like before.

Assisted-by: Claude:Opus 5 medium
Signed-off-by: Graham King grahamk@nvidia.com

Summary by CodeRabbit

  • Refactor
    • Streamlined the public API with clearer, more direct imports.
    • Separated protocol types from library-specific types for improved consistency.
    • Removed legacy module paths and consolidated commonly used algorithm and routing exports.
    • Updated examples, server components, Python bindings, observability, and tests to use the revised API.
  • Documentation
    • Updated module guidance and API references to reflect the new import structure.

@grahamking
grahamking force-pushed the gk-libsy-pub-cleanup branch 2 times, most recently from c673b15 to efa9df2 Compare July 31, 2026 19:06
1. `libsy` exports everything public at `libsy::` and names the types
explicity, no `use module::*`.

None of the internal modules are visible. This should give us the
ability to move things around later.

2. Normalize imports so that inside a crate:
   - Structs are imported and used directly. `use crate::thing::Thing; let t = Thing{ .. }`
   - Functions have one level of prefix. `thing::do_it()`

That's probably the most common way to do it in Rust, although there's
all ways. I find it makes it easier to read, and having a standard is
better than a bit of everything like before.

Signed-off-by: Graham King <grahamk@nvidia.com>
@grahamking
grahamking force-pushed the gk-libsy-pub-cleanup branch from efa9df2 to 29c93a9 Compare July 31, 2026 19:08
@grahamking
grahamking marked this pull request as ready for review July 31, 2026 19:16
@grahamking
grahamking requested a review from a team as a code owner July 31, 2026 19:16
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The change reorganizes switchyard_libsy exports and moves protocol types to switchyard_protocol. Internal modules, examples, bindings, components, server code, and tests now use the updated paths.

Changes

Libsy API migration

Layer / File(s) Summary
Module and export topology
crates/libsy/src/lib.rs, crates/libsy/src/core.rs, crates/libsy/src/algorithms.rs, crates/libsy/src/algorithms/util.rs, crates/libsy/src/core/algorithm.rs
Libsy now exposes selected types through explicit root re-exports. The public algorithms and stage_router exports changed, and protocol types are no longer broadly re-exported.
Internal module path migration
crates/libsy/src/algorithms/..., crates/libsy/src/core/..., crates/libsy/src/observability.rs, crates/libsy/tests/observability.rs
Algorithm, core, observability, and test imports now use explicit libsy modules and direct switchyard_protocol types.
Downstream import updates
crates/libsy/examples/*, crates/switchyard-components/src/stage_router.rs, crates/switchyard-py/src/libsy_bindings.rs, crates/switchyard-server/...
Examples, bindings, components, and server code now use the reorganized exports. The server adds its workspace protocol dependency.

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

Poem

I’m a rabbit with imports to mend,
Libsy paths now neatly extend.
Protocols hop free,
Through modules and tree,
While clean exports make compile-time friends.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: reorganizing imports and exports across the crates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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.

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

@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/libsy/src/algorithms.rs`:
- Line 9: Add concise /// purpose documentation above the public module
declarations: document fall_through in crates/libsy/src/algorithms.rs at lines
9-9, affinity and escalation in crates/libsy/src/algorithms/util.rs at lines
4-5, and subagent in crates/libsy/src/algorithms/util.rs at line 9. Ensure each
public module has its own documentation comment.

In `@crates/libsy/src/lib.rs`:
- Around line 80-109: Restore public compatibility modules for the previously
exposed switchyard_libsy::algorithms and switchyard_libsy::stage_router paths,
re-exporting the corresponding current APIs from the existing algorithms and
stage-router implementations. Mark these modules deprecated if appropriate,
while preserving their public accessibility; do not add a crate-root re-export
for the internal FallThrough type.

In `@crates/switchyard-components/src/stage_router.rs`:
- Around line 12-15: Update the module documentation link associated with the
stage-router re-exports to reference the public switchyard_libsy root or another
publicly available root item instead of switchyard_libsy::stage_router; leave
the re-export list unchanged.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 18699be5-9b5b-4772-8495-36160968a437

📥 Commits

Reviewing files that changed from the base of the PR and between 02d3f23 and 29c93a9.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (37)
  • crates/libsy/examples/ensemble.rs
  • crates/libsy/examples/research_agent.rs
  • crates/libsy/examples/research_agent_core.rs
  • crates/libsy/examples/streaming_agent.rs
  • crates/libsy/src/algorithms.rs
  • crates/libsy/src/algorithms/fall_through.rs
  • crates/libsy/src/algorithms/llm_class.rs
  • crates/libsy/src/algorithms/noop.rs
  • crates/libsy/src/algorithms/passthrough.rs
  • crates/libsy/src/algorithms/rand.rs
  • crates/libsy/src/algorithms/stage.rs
  • crates/libsy/src/algorithms/subagent_affinity_tests.rs
  • crates/libsy/src/algorithms/util.rs
  • crates/libsy/src/algorithms/util/affinity.rs
  • crates/libsy/src/algorithms/util/escalation.rs
  • crates/libsy/src/algorithms/util/llm_judge.rs
  • crates/libsy/src/algorithms/util/prompts.rs
  • crates/libsy/src/algorithms/util/stage.rs
  • crates/libsy/src/algorithms/util/subagent.rs
  • crates/libsy/src/algorithms/util/tool_signals.rs
  • crates/libsy/src/core.rs
  • crates/libsy/src/core/algorithm.rs
  • crates/libsy/src/core/classifier.rs
  • crates/libsy/src/core/driver.rs
  • crates/libsy/src/core/state.rs
  • crates/libsy/src/lib.rs
  • crates/libsy/src/observability.rs
  • crates/libsy/tests/observability.rs
  • crates/switchyard-components/src/stage_router.rs
  • crates/switchyard-py/src/libsy_bindings.rs
  • crates/switchyard-server/Cargo.toml
  • crates/switchyard-server/src/config.rs
  • crates/switchyard-server/src/lib.rs
  • crates/switchyard-server/src/response.rs
  • crates/switchyard-server/src/routing_log.rs
  • crates/switchyard-server/src/usage_metrics.rs
  • crates/switchyard-server/tests/server.rs

Comment thread crates/libsy/src/algorithms.rs
Comment thread crates/libsy/src/lib.rs
Comment thread crates/switchyard-components/src/stage_router.rs
@grahamking
grahamking merged commit dd60d79 into main Jul 31, 2026
19 checks passed
@grahamking
grahamking deleted the gk-libsy-pub-cleanup branch July 31, 2026 19:26
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