Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,33 @@ fn each_decision_model_is_selected_from_private_configuration() {
}
}

#[tokio::test]
async fn a_surplus_configuration_reaches_describe_over_a_real_bus() -> tinybus::Result<()> {
use crate::tinybus_module::setup;
use tinybus::Connection;
use tinybus::broker::Broker;
use tinybus::transport::memory::MemoryBus;
use tinycomputer_bus::agent::Capabilities;
use tinycomputer_bus::{JevProvider, names};

let bus = MemoryBus::new();
Broker::new().spawn(bus.clone());
let service = Connection::connect(bus.connect().await?).await?;
setup(
service.clone(),
json!({"jev": {"api_key": "k", "provider": "surplus"}}),
)
.await?;
let client = Connection::connect(bus.connect().await?).await?;
let proxy = client.proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)?;

let described: Capabilities = proxy.call(names::methods::DESCRIBE, json!([])).await?;
let model = described.decision_model.expect("a configured model");
assert_eq!(model.provider, JevProvider::Surplus);
assert_eq!(model.model, "jev-1.14");
Ok(())
}

#[test]
fn the_browser_configuration_is_read_or_refused() {
use crate::tinybus_module::config::BrowserDefaults;
Expand Down
11 changes: 6 additions & 5 deletions docs/crates/tinycomputer-bus/versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ code, so this page exists mostly to keep them apart.
## `CONTRACT_VERSION`: does this host understand this module

```rust,ignore
pub const CONTRACT_VERSION: (u32, u32) = (3, 2);
pub const CONTRACT_VERSION: (u32, u32) = (3, 3);
```

This describes the *vocabulary*: the member set and the payload shapes,
Expand Down Expand Up @@ -60,14 +60,15 @@ Two conditions, both necessary:
relies on changed shape or disappeared, so a mismatched major is refused
outright, in either direction.
2. **The module must be at least as new, minor-wise, as the host.** A host
built against `(3, 2)` expects at least the members and fields that
existed at `(3, 2)`. A newer module with the same major is accepted. On
built against `(3, 3)` expects at least the members and fields that
existed at `(3, 3)`. A newer module with the same major is accepted. On
the 2.x line, for example, a 2.29 host rejected a `(2, 28)` module, which
lacked the typed `ComputerConfig` and versioned response extraction.

```rust,ignore
assert!(is_compatible(CONTRACT_VERSION)); // (3, 2), the exact version this crate ships
assert!(is_compatible((3, 2))); // a newer, still-compatible module
assert!(is_compatible(CONTRACT_VERSION)); // (3, 3), the exact version this crate ships
assert!(is_compatible((3, 3))); // a newer, still-compatible module
assert!(!is_compatible((3, 2))); // an older minor: no `surplus` provider
assert!(!is_compatible((2, 29))); // a different major: plain BrowserReadOutput
assert!(!is_compatible((1, 10))); // a different major, all bets off
```
Expand Down
Loading