Skip to content

refactor(libsy): tighten public api boundaries - #292

Draft
nachiketb-nvidia wants to merge 1 commit into
mainfrom
agent/public-api-cleanup
Draft

refactor(libsy): tighten public api boundaries#292
nachiketb-nvidia wants to merge 1 commit into
mainfrom
agent/public-api-cleanup

Conversation

@nachiketb-nvidia

@nachiketb-nvidia nachiketb-nvidia commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What

Tightens the Rust public API boundary for libsy/protocol cleanup from SWITCH-1179:

Linear: https://linear.app/nvidia/issue/SWITCH-1179/refine-libsy-and-protocol-public-api-boundaries

  • Makes libsy Classifier, Processor, State, and related internal data types crate-visible instead of root-public SDK surface.
  • Stops exporting concrete decision internals (NoopDecision, PassthroughDecision, and the RandomDecision alias) from libsy.
  • Removes lossy protocol convenience helpers (text_request, prompt_text, text_response, completion_text) from the public switchyard_protocol API.
  • Moves helper usage into crate-local, test-local, or example-local support code where it is actually needed.
  • Removes slice_to_header_map from the public metadata API and keeps it as a test helper.
  • Updates libsy client README examples to construct protocol IR directly.

Why

These helpers and implementation traits were convenient while the SDK surface was still forming, but they are not stable public contracts. Keeping them public makes downstream users depend on internals we should be free to reshape.

The public surface should stay centered on the protocol types, algorithms/configs, driver API, and observable routing behavior. Test fixture builders, lossy text extraction helpers, classifier/processor plumbing, and concrete decision implementation details should not be part of that contract.

How

  • Uses pub(crate) for libsy internals that are only needed inside the crate.
  • Adds crates/libsy/src/text.rs for crate-local text helpers used by internal code/tests.
  • Adds crates/libsy/examples/support/mod.rs so examples remain readable without relying on protocol-level fixture helpers.
  • Updates integration tests and downstream crate tests to build protocol values locally.
  • Leaves public algorithm/config exports in place where external callers still need them.

What To Review

  • Confirm the remaining public exports in crates/libsy/src/lib.rs are the intended SDK surface.
  • Confirm switchyard_protocol no longer exposes lossy text/header test helpers.
  • Confirm examples and docs now demonstrate direct protocol construction where appropriate.

Validation

  • cargo fmt --all
  • cargo check --workspace --all-targets
  • Commit hooks: cargo fmt, cargo clippy, commitlint

No tests were added; this is intentionally a public API cleanup only.

Signed-off-by: nachiketb <nachiketb@nvidia.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

🚀 View preview at
https://NVIDIA-NeMo.github.io/Switchyard/pr-preview/pr-292/

Built to branch gh-pages at 2026-08-04 20:24 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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.

1 participant