Skip to content

Restructure into a cargo workspace and refresh GitHub Actions - #2

Merged
senamakel merged 24 commits into
mainfrom
restructure-crates
Aug 21, 2026
Merged

Restructure into a cargo workspace and refresh GitHub Actions#2
senamakel merged 24 commits into
mainfrom
restructure-crates

Conversation

@senamakel

@senamakel senamakel commented Aug 21, 2026

Copy link
Copy Markdown
Member

What changed and why

The crate was a single root package that mixed the wire contract with the
implementation. A host that loads the cdylib cannot use anything out of it,
so it had no way to name the payload types without compiling the whole module —
tinybus, tokio and the module SDK included.

This splits the repository into a virtual cargo workspace under crates/:

  • crates/template-bus — the wire contract. The interface name, object
    path, and one constant per member (names); the Greet request/response
    payloads (greeting); and CONTRACT_VERSION plus the host bind rule
    (version). Two pure-Rust dependencies, serde and serde_json. No
    transport, no runtime, no behavior.
  • crates/template — the implementation: the greet behavior, the
    crate-wide error type, and the TinyBus adapter, built as both an rlib and
    the cdylib the loader consumes. It depends on template-bus and re-exports
    all of it, so template::GreetRequest and template_bus::GreetRequest are
    the same type rather than structural twins.

Shared metadata, dependencies, and the whole lint set now live once in the root
[workspace.package] / [workspace.dependencies] / [workspace.lints], and
members inherit them.

GitHub Actions move to their latest major versions: actions/checkout@v7,
actions/upload-artifact@v7 (from v4), actions/download-artifact@v8 (from
v4), taiki-e/install-action@v2 with an explicit tool:, and
submodules: recursive everywhere.

Public API and behavior changes

Yes — breaking, and deliberate for a template:

  • The package is renamed rust-templatetemplate, so the library is
    libtemplate.{so,dylib,dll} and release assets are
    template-<version>-<platform>.<tar.gz|zip>.
  • The bus interface is renamed ai.tinyhumans.rust_template.Greeting
    ai.tinyhumans.template.Greeting, and the object path with it.
  • Greet now takes a GreetRequest and returns a GreetResponse instead of a
    bare string on each side. That is the point of the contract crate: a host
    names the payload from a library instead of by string literal.
  • New crate template-bus on the public surface, re-exported from template.

CI and release

  • check-file-coverage.sh scans crates/ and runs cargo llvm-cov --workspace.
  • New CI step asserts template-bus never pulls in a transport, an async
    runtime, an HTTP client, or a native library — the forward cargo tree -p
    form, because the inverse form silently discards the -p scope.
  • New CI step runs the bundled example; --all-targets only compiles one.
  • deny.toml sets allow-wildcard-paths = true. Workspace-internal path
    dependencies deliberately carry no version: it would be a caret range, so
    the first bump past 0.1.x would stop resolving and the release workflow
    would discover it after the tag was pushed. The exemption is narrow — it
    applies only to path deps on crates with publish = false, and a wildcard on
    anything from a registry is still denied.
  • The release workflow selects its package by name (RELEASE_PACKAGE: template)
    rather than packages[0], whose order cargo does not promise, bumps the
    single [workspace.package] version, and verifies the bump took before
    tagging.

Validation

CI is green on this branch (run 32494741317): Rust, Docs, MSRV, Supply chain.

Locally:

Command Result
cargo fmt --all -- --check pass
cargo clippy --all-targets --all-features -- -D warnings pass
cargo build --all-targets --all-features pass
cargo test --all-features pass — 32 tests across both crates
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features pass
cargo deny check all pass
.github/scripts/check-file-coverage.sh 90 coverage.json pass — every file ≥ 93%
cargo build --locked --release --lib -p template pass
cargo run -p template --example verify_module -- target/release/libtemplate.so pass — loaded through the real dynamic loader and answered Greet

Notes

  • crates/template is an ordinary workspace member, not its own workspace root.
    The [workspace.package] inheritance failure that forces a separate root in
    other repositories does not reproduce here; it was checked rather than assumed.
  • Docs updated in the same change: README.md, AGENTS.md (and so CLAUDE.md),
    MODULE.md, docs/specs/, docs/plans/, and a new
    crates/template-bus/README.md explaining why the contract is its own crate.
  • No deliberately untested edge cases.

Summary by CodeRabbit

  • New Features

    • Reorganized the project into a workspace with separate contract and implementation packages.
    • Added typed greeting requests and responses, shared service naming, and contract version compatibility checks.
    • Added a TinyBus greeting service with improved typed calls and validation.
    • Added consistent error handling for empty names.
  • Documentation

    • Updated setup, API, module, and release documentation for the new package structure and naming.
  • Tests

    • Expanded coverage for serialization, compatibility, greeting behavior, service contracts, and release verification.

senamakel and others added 24 commits August 21, 2026 17:42
….rs,crates/template/examples/ve

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The single-root package layout is replaced with a virtual workspace whose members live under `crates/`, making every crate structurally uniform. Shared metadata and dependency entries are hoisted into `[workspace.package]` and `[workspace.dependencies]` so that version bumps and lint configuration apply to all members from one place, and the `exclude` list prevents cargo from walking into the vendor submodule or git worktrees.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Added a new dependency to the template-bus crate's Cargo.toml to support an upcoming feature that requires external library functionality.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce three new modules to the template-bus crate: greeting, names, and version, each with their own types and tests. This establishes the core domain logic for the bus template, enabling structured handling of greetings, name resolution, and versioning.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the test to verify that version comparison returns the expected ordering when comparing two different version strings. The previous assertion was checking the wrong direction, which would have caused the test to pass incorrectly for reversed comparisons.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
When parsing template version data, the code previously assumed the version field was always present. This caused a panic when encountering templates without a version field. The fix adds a check for the field's existence and returns a clear error message instead of panicking.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The template crate was missing its Cargo.toml manifest file, which prevented it from being built as a standalone package. This change adds the necessary manifest to enable proper compilation and dependency management.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The tinybus module and its test file were inadvertently removed during a previous refactor. This change restores the module structure and its associated tests to ensure the template crate compiles and functions correctly.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…dule

Remove three example files that were no longer referenced or maintained, and clean up the greeting module by removing unused code paths. This reduces maintenance burden and clarifies the public API surface.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the verify_github_release example to properly handle authentication and error cases that were causing failures during testing. The verify_module example was also adjusted to align with the corrected release verification logic, ensuring both examples demonstrate accurate usage patterns.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…pendency

The Cargo.lock file was updated to reflect the renaming of the `rust-template` package to `template`, and a new `template-bus` dependency was added to the project.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The test assertions now compare owned strings instead of references, ensuring the equality checks work correctly when the expected values are `Vec<&str>` and `&str` respectively.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformatted two multi-line assertions in the test module to use a more conventional Rust style with each argument on its own line, improving readability without changing any test logic.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Added a README.md file to the template-bus crate to provide an overview of its purpose and usage, helping developers understand how to integrate and work with the template bus functionality.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The version requirement was removed from the template-bus dependency because the workspace version changes with every release and a pinned version would prevent resolution. Since nothing in this workspace is published, the path specification alone is sufficient for addressing the crate.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The CI workflow configuration was updated to reference the latest versions of GitHub Actions, ensuring compatibility with current runner environments and avoiding deprecation warnings.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…pace-level versioning

Pin all third-party GitHub Actions to immutable commit SHAs with the release tag in a trailing comment, replacing mutable version tags to improve supply-chain security. Introduce a `RELEASE_PACKAGE` environment variable to identify the workspace member that ships as the loadable module, and update the version bump logic to operate on `[workspace.package]` so that the single version is inherited by all workspace members. Change `submodules: true` to `submodules: recursive` and adjust `cargo build` and `cargo run` invocations to target the specific package, ensuring the workflow correctly handles a multi-crate workspace.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Replace all third-party action references in CI and release workflows from pinned commit SHAs with their corresponding version tags, and remove the explanatory comments about SHA pinning. This simplifies maintenance while still using stable release references.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The coverage script now points to `crates/` instead of `src/` to match the actual workspace layout, and the `--workspace` flag is added to include all crates in the coverage report. The release workflow also fixes variable interpolation by switching from a quoted shell variable to the proper GitHub Actions expression syntax.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update all documentation and the module readme to reflect the crate's new name, changing `rust_template` and `rust-template` to `template` throughout. The module interface, archive names, and code examples now use the shorter identifier to match the renamed package.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…nd contract split for two-crate

The project has been restructured from a single crate into a workspace with two crates: `template-bus` for the wire contract and `template` for the module behavior. The AGENTS.md file now reflects the workspace layout, the two-crate split rationale, and updated conventions for dependencies, testing, releases, and error handling. The tinybus_module README clarifies that interface names and payload types come from the contract crate, making renames a compile error rather than a runtime failure.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add `allow-wildcard-paths = true` to the `[advisories]` section of deny.toml. Workspace-internal path dependencies on unpublished crates use wildcard versions by construction, and a caret range on such a dependency would break on the first minor or major release, causing a late failure in the release workflow. The exemption is narrow: it applies only to path dependencies on crates with `publish = false`, while wildcards from any registry remain denied.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel merged commit 3eaf3e7 into main Aug 21, 2026
9 of 10 checks passed
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f8b7109-b82f-418b-92d7-235af49987ac

📥 Commits

Reviewing files that changed from the base of the PR and between a31ff1b and 3dc4594.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (39)
  • .claude/settings.json
  • .github/scripts/check-file-coverage.sh
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • AGENTS.md
  • Cargo.toml
  • MODULE.md
  • README.md
  • crates/template-bus/Cargo.toml
  • crates/template-bus/README.md
  • crates/template-bus/src/greeting/mod.rs
  • crates/template-bus/src/greeting/test.rs
  • crates/template-bus/src/greeting/types.rs
  • crates/template-bus/src/lib.rs
  • crates/template-bus/src/names/mod.rs
  • crates/template-bus/src/names/test.rs
  • crates/template-bus/src/version/mod.rs
  • crates/template-bus/src/version/test.rs
  • crates/template/Cargo.toml
  • crates/template/examples/basic.rs
  • crates/template/examples/verify_github_release.rs
  • crates/template/examples/verify_module.rs
  • crates/template/src/error/mod.rs
  • crates/template/src/error/test.rs
  • crates/template/src/greeting/mod.rs
  • crates/template/src/greeting/test.rs
  • crates/template/src/lib.rs
  • crates/template/src/tinybus_module/README.md
  • crates/template/src/tinybus_module/mod.rs
  • crates/template/src/tinybus_module/test.rs
  • crates/template/tests/public_api.rs
  • deny.toml
  • docs/plans/example-retry-policy.md
  • docs/plans/tinybus-module-release.md
  • docs/specs/example-retry-policy.md
  • docs/specs/tinybus-module-release.md
  • src/lib.rs
  • src/tinybus_module/README.md
  • src/tinybus_module/mod.rs

📝 Walkthrough

Walkthrough

The project becomes a Cargo workspace with separate template-bus and template crates. The contract crate defines typed greeting payloads, names, and version checks. The module crate implements the TinyBus adapter. CI, release workflows, documentation, and examples now target the workspace.

Changes

Workspace split and typed TinyBus contract

Layer / File(s) Summary
Workspace configuration and package layout
Cargo.toml, crates/*/Cargo.toml, AGENTS.md, README.md, deny.toml
The root manifest now defines shared workspace metadata, dependencies, lints, and members. The documentation describes the separate contract and implementation crates.
Typed bus contract
crates/template-bus/src/*, crates/template-bus/README.md
template-bus exports typed greeting payloads, interface names, method metadata, and contract-version compatibility checks. Tests validate JSON shapes, names, and version rules.
Template API and TinyBus adapter
crates/template/src/*, crates/template/tests/*, crates/template/examples/*
template exposes greeting behavior and errors, implements the typed TinyBus service, and updates module verification to use generated contract values.
Workspace CI and release automation
.github/workflows/*, .github/scripts/check-file-coverage.sh, MODULE.md, docs/*, .claude/settings.json
Automation now selects the workspace package, checks workspace coverage and contract dependencies, uses recursive submodules, and publishes template-named artifacts.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant TinyBusModule as template TinyBus module
  participant Greeting as template::greet
  participant Contract as template-bus
  Caller->>TinyBusModule: Send typed GreetRequest
  TinyBusModule->>Contract: Decode contract payload
  TinyBusModule->>Greeting: Call greet(name)
  Greeting-->>TinyBusModule: Return greeting or Error
  TinyBusModule->>Contract: Encode GreetResponse
  TinyBusModule-->>Caller: Return typed response
Loading

Poem

I’m a rabbit with a workspace map,
Two crates now share the hop and path.
Typed greetings cross the TinyBus stream,
CI checks each contract seam.
Release wheels roll, names align—
A tidy burrow, build by design!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@tinysweeper tinysweeper 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.

tinysweeper found nothing blocking. Approving.

$0.0000 · 0 in / 0 out · 702 embedded · openrouter/openai/text-embedding-3-small

Comment thread .github/workflows/ci.yml
components: rustfmt, clippy

- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@v2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

priority medium security uncertain

taiki-e/install-action is pinned to v2, which is mutable

A tag or branch can be repointed by whoever owns taiki-e, and the new code runs with this workflow's secrets. Pin to a full commit SHA and let Dependabot bump it.

[RULE] unpinned-action ·

components: rustfmt, clippy

- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@v2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

priority medium security uncertain

taiki-e/install-action is pinned to v2, which is mutable

A tag or branch can be repointed by whoever owns taiki-e, and the new code runs with this workflow's secrets. Pin to a full commit SHA and let Dependabot bump it.

[RULE] unpinned-action ·

@tinysweeper

tinysweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown

How this change flows

0 changed behaviours across 2 relationships. 4 surrounding behaviours are shown (60 graph nodes walked). 56 further behaviours left out to keep the diagram readable.

flowchart LR
  n0["Error"]:::impacted
  n1["Result"]:::impacted
  n2["setup"]:::impacted
  n3["INTERFACE"]:::impacted
  n1 -->|uses| n0
  n2 -->|uses| n3
  classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
  classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
  classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
  classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Loading

Green: changed behaviour. Grey: surrounding behaviour. Arrows name the call, use, implementation, or test relationship. Orange: has findings. Red: has a finding that blocks the merge.

tinysweeper 0.1.0

@tinysweeper tinysweeper Bot added the priority: p2 Soon. Real but survivable — a rough edge, a gap, a thing that will bite later. label Aug 21, 2026
@senamakel
senamakel deleted the restructure-crates branch August 21, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p2 Soon. Real but survivable — a rough edge, a gap, a thing that will bite later.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant