Skip to content

Restructure the crates directory into role-based subdirectories #784

@jwrosewell

Description

@jwrosewell

Overview

The crates/ directory is flat. It currently holds the core library, three adapters, and supporting crates, and the pluggable provider model will soon add per-vendor provider crates (Edge Cookie, device, and geo, each potentially with multiple vendor implementations). A flat crates/ root will not scale and is already harder to navigate than it needs to be.

This proposes grouping crates by role using subdirectories. Cargo workspaces support nested member paths, so this is a file move plus a workspace-member path update, with no change to crate names or runtime behaviour.

Proposed structure

Exact naming is open for discussion, but the shape would be:

crates/
  core/                       # trusted-server-core
  adapters/
    fastly/                   # trusted-server-adapter-fastly
    axum/                     # trusted-server-adapter-axum
    cloudflare/               # trusted-server-adapter-cloudflare
  providers/
    edgecookie/<vendor>/      # e.g. providers/edgecookie/51degrees (future)
    device/<vendor>/
    geo/<vendor>/
  support/
    openrtb/                  # trusted-server-openrtb
    js/                       # trusted-server-js
    integration-tests/

Package names (for example trusted-server-adapter-fastly) stay the same. Only the directory layout and the workspace member paths change.

Rationale

  • Discoverability: a crate's role is obvious from its path.
  • Room to grow: per-vendor provider crates get a clear home under providers/<type>/<vendor> without crowding the root.
  • Clean separation: adapters, core, providers, and supporting crates become visually distinct.

Tasks

  • Agree the target structure and directory naming.
  • Move the adapter crates under crates/adapters/.
  • Introduce crates/providers/<type>/<vendor> (placeholders where only the in-core default exists).
  • Relocate supporting crates (openrtb, js, integration-tests) as agreed.
  • Update Cargo.toml workspace members, default-members, and all path dependencies.
  • Update .cargo/config.toml aliases and fastly.toml build paths where they reference crate locations.
  • Update CI workflow path filters and any docs that reference crate paths.
  • Confirm builds and tests on all three targets (wasm32-wasip1, wasm32-unknown-unknown, native) and the JS build.

Notes

  • Purely a move: no runtime behaviour changes. Best landed as a standalone, mechanical PR so it stays reviewable and does not collide with feature work.
  • default-members must continue to point at the Fastly adapter so Viceroy can locate the binary via cargo run --bin.
  • Timing should be coordinated to minimise rebase pain for in-flight branches.
  • Related to the pluggable provider model work, which is what motivates the providers/ subtree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions