From 2469548e9a198bccb6994c9a7dbd77a282ce1908 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 13:59:31 -0600 Subject: [PATCH] =?UTF-8?q?pkgs/id=20crate=20split=20step=205b:=20extract?= =?UTF-8?q?=20id-worlds=20core=20=E2=80=94=20world,=20sessions,=20sandbox,?= =?UTF-8?q?=20directory=20cluster=20(#4408)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/id/Cargo.lock | 21 ++++- pkgs/id/Cargo.toml | 9 +- pkgs/id/crates/id-core/Cargo.toml | 3 + pkgs/id/crates/id-core/src/lib.rs | 3 + .../id-core}/src/test_forgeries.rs | 0 pkgs/id/crates/id-worlds/Cargo.toml | 72 +++++++++++++--- .../{ => crates/id-worlds}/src/directory.rs | 4 +- .../id-worlds}/src/directory_auth.rs | 0 .../id-worlds}/src/directory_mail.rs | 0 .../id-worlds}/src/directory_view.rs | 0 pkgs/id/crates/id-worlds/src/lib.rs | 75 ++++++++++++++--- pkgs/id/{ => crates/id-worlds}/src/sandbox.rs | 82 +++++++++---------- .../id-worlds}/src/session_host.rs | 0 .../id-worlds}/src/shell_contract.rs | 2 +- .../id-worlds}/src/shell_contract/tests.rs | 0 .../{ => crates/id-worlds}/src/world/actor.rs | 0 .../{ => crates/id-worlds}/src/world/clock.rs | 0 .../{ => crates/id-worlds}/src/world/core.rs | 0 .../src/world/core/checkpoint_parts.rs | 0 .../id-worlds}/src/world/handle.rs | 2 +- .../id-worlds}/src/world/hotness.rs | 0 .../id-worlds}/src/world/metrics.rs | 0 .../{ => crates/id-worlds}/src/world/mod.rs | 2 +- .../id-worlds}/src/world/replica.rs | 0 .../id-worlds}/src/world/replication.rs | 0 .../src/world/replication_receiver.rs | 0 .../id-worlds}/src/world/signed.rs | 0 .../{ => crates/id-worlds}/src/world/tests.rs | 0 .../id-worlds}/src/world/upgrade.rs | 0 .../{ => crates/id-worlds}/src/world/util.rs | 0 .../id-worlds}/src/world_compile.rs | 12 +-- .../id-worlds}/src/world_fixture.rs | 12 +-- .../{ => crates/id-worlds}/src/world_hub.rs | 0 .../id-worlds}/src/world_native.rs | 2 +- .../{ => crates/id-worlds}/src/world_net.rs | 12 +-- .../id-worlds}/src/world_records.rs | 0 .../src/world_session/contract_tests.rs | 0 .../id-worlds}/src/world_session/mod.rs | 3 +- .../id-worlds}/src/world_session/service.rs | 0 .../id-worlds}/src/world_session/tests.rs | 20 ++--- .../id-worlds}/src/world_session/types.rs | 2 +- .../{ => crates/id-worlds}/src/world_store.rs | 16 ++-- pkgs/id/src/lib.rs | 34 ++++---- 43 files changed, 258 insertions(+), 130 deletions(-) rename pkgs/id/{ => crates/id-core}/src/test_forgeries.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/directory.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/directory_auth.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/directory_mail.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/directory_view.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/sandbox.rs (97%) rename pkgs/id/{ => crates/id-worlds}/src/session_host.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/shell_contract.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/shell_contract/tests.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/actor.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/clock.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/core.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/core/checkpoint_parts.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/handle.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world/hotness.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/metrics.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/mod.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world/replica.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/replication.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/replication_receiver.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/signed.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/tests.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/upgrade.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world/util.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world_compile.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world_fixture.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world_hub.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world_native.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world_net.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world_records.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world_session/contract_tests.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world_session/mod.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world_session/service.rs (100%) rename pkgs/id/{ => crates/id-worlds}/src/world_session/tests.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world_session/types.rs (99%) rename pkgs/id/{ => crates/id-worlds}/src/world_store.rs (99%) diff --git a/pkgs/id/Cargo.lock b/pkgs/id/Cargo.lock index 2e8e6babf7..8f784791f9 100644 --- a/pkgs/id/Cargo.lock +++ b/pkgs/id/Cargo.lock @@ -3956,7 +3956,6 @@ dependencies = [ "unicode-width", "urlencoding", "vt100", - "wasmtime", "wat", "webpki-roots", "zeroize", @@ -3980,6 +3979,7 @@ dependencies = [ "anyhow", "blake3", "cbor-core", + "ed25519-dalek 3.0.0", "futures-lite", "iroh", "iroh-base", @@ -4131,16 +4131,35 @@ version = "0.1.0" dependencies = [ "anyhow", "blake3", + "ed25519-dalek 3.0.0", + "futures-lite", + "id-caps", + "id-core", "id-events", "id-groups", + "id-store", + "id-sync", + "iroh", "iroh-base", "iroh-blobs", + "iroh-docs", + "iroh-gossip", "libc", "p2panda-core", + "postcard", "proptest", + "rand 0.10.3", "serde", "serde_json", + "sha2 0.11.0", + "subtle", "tempfile", + "thiserror 2.0.21", + "tokio", + "tracing", + "tracing-subscriber", + "wasmtime", + "wat", ] [[package]] diff --git a/pkgs/id/Cargo.toml b/pkgs/id/Cargo.toml index db00bca275..c5b5448d0f 100644 --- a/pkgs/id/Cargo.toml +++ b/pkgs/id/Cargo.toml @@ -31,7 +31,7 @@ default-members = [".", "crates/id-core", "crates/id-caps", "crates/id-store", " [features] default = ["sandbox", "world"] -sandbox = ["dep:wasmtime", "world", "id-core/sandbox", "id-caps/sandbox"] +sandbox = ["world", "id-core/sandbox", "id-caps/sandbox", "id-worlds/sandbox"] world = [ "dep:subtle", "dep:hmac", @@ -179,11 +179,8 @@ hmac = { version = "0.13", optional = true } # scrypt for the Seitan V2 stretch (P6.1). Already in the lock as a transitive dependency. scrypt = { version = "0.12", optional = true } subtle = { version = "2", optional = true } -wasmtime = { version = "=48.0.7", default-features = false, features = [ - "cranelift", - "runtime", - "std", -], optional = true } +# wasmtime moved to id-worlds in step 5b of the crate split (#4408): +# the `sandbox` feature above forwards to `id-worlds/sandbox`. russh = { version = "=0.65.0", optional = true } [dev-dependencies] diff --git a/pkgs/id/crates/id-core/Cargo.toml b/pkgs/id/crates/id-core/Cargo.toml index fb519d2da6..1e918014c3 100644 --- a/pkgs/id/crates/id-core/Cargo.toml +++ b/pkgs/id/crates/id-core/Cargo.toml @@ -54,6 +54,9 @@ vt100 = "=0.16.2" iroh = { version = "1", features = ["test-utils"] } # Narrowing-only property test for boundary composition (boundary.rs, #7782). proptest = "1.12" +# The test_forgeries fixtures' own tests sign and verify (test_forgeries.rs, +# moved here in step 5 of the crate split, #4408). Dev only. +ed25519-dalek = { version = "3", features = ["rand_core"] } [lints.rust] # Rust compiler lints diff --git a/pkgs/id/crates/id-core/src/lib.rs b/pkgs/id/crates/id-core/src/lib.rs index 2d9071ee44..ce757ddc0d 100644 --- a/pkgs/id/crates/id-core/src/lib.rs +++ b/pkgs/id/crates/id-core/src/lib.rs @@ -41,6 +41,9 @@ mod unicode; pub use unicode::is_format_char; pub mod waiting; +#[cfg(any(test, feature = "test-utils"))] +pub mod test_forgeries; + #[cfg(feature = "world")] pub mod petname; #[cfg(feature = "world")] diff --git a/pkgs/id/src/test_forgeries.rs b/pkgs/id/crates/id-core/src/test_forgeries.rs similarity index 100% rename from pkgs/id/src/test_forgeries.rs rename to pkgs/id/crates/id-core/src/test_forgeries.rs diff --git a/pkgs/id/crates/id-worlds/Cargo.toml b/pkgs/id/crates/id-worlds/Cargo.toml index cc5c7d5639..a4e0612135 100644 --- a/pkgs/id/crates/id-worlds/Cargo.toml +++ b/pkgs/id/crates/id-worlds/Cargo.toml @@ -8,33 +8,85 @@ license = "MIT OR Apache-2.0" # Step 5 of the pkgs/id crate split (#3447 umbrella, #4408): the world # family lives here. Dependencies per the design map: id-core, id-caps, -# id-store, id-events, id-groups, id-sync. This first step-5 PR brings -# the leaves that name nothing above them (the compiled-world cache, -# the line/terminal helpers), seam 6's cross-world bridge -# (`groups::worlds` — the consumer side of the groups/worlds -# relationship, per the design), and the blob gate's `FoldedWorlds` -# adapter over that bridge (parked in the facade by step 4 to move -# together with the bridge). The world core, sessions and the rest of -# the family follow in later step-5 PRs. +# id-store, id-events, id-groups, id-sync. +# +# Step 5a brought the leaves, seam 6's cross-world bridge +# (`groups::worlds`) and the blob gate's `FoldedWorlds` adapter. +# Step 5b brings the runtime core: `world`, `world_session`, the +# sandbox and its compile/fixture/native paths, the hub, net and +# store, `world_records` and `shell_contract` — and, with them, the +# directory cluster (`directory`, `directory_auth`, `directory_view`, +# `directory_mail`). The directory is the world runtime's own state: +# `WorldCore` holds it, the world actor executes directory actions +# against it, and `world_store` persists it beside the journal, so +# the cluster moves as the consumer side of the relationship (the +# seam-6 pattern). Seam 10's remaining half is unchanged by this: +# step 6's `id-directory` extraction must still invert or re-home +# `WorldCore`'s hold on the directory, exactly as it would have had +# to from the facade. The facade re-exports the directory modules at +# their historical `id::` paths until then. +# +# `session_host` also lands here: it implements `id_sync::host:: +# SessionHost` for the hub and `id_sync::artifact::ArtifactSink` for +# the directory, and the orphan rule puts those impls in the crate +# that owns the types (they sat in the facade only while the hub and +# directory did). [features] default = [] +# The wasmtime dependency lives inside id-worlds (design feature +# mapping); the facade's `sandbox` feature forwards here. +sandbox = ["dep:wasmtime", "id-caps/sandbox", "id-core/sandbox"] [dependencies] anyhow = "1" blake3 = "1" +ed25519-dalek = { version = "3", features = ["rand_core"] } +futures-lite = "2" +id-caps = { path = "../id-caps", default-features = false } +id-core = { path = "../id-core", default-features = false, features = [ + "world", +] } id-events = { path = "../id-events", default-features = false } id-groups = { path = "../id-groups", default-features = false } +id-store = { path = "../id-store", default-features = false } +id-sync = { path = "../id-sync", default-features = false } +iroh = "1" iroh-base = "1" iroh-blobs = "0.103" +iroh-docs = "0.101" +iroh-gossip = { version = "0.101", features = ["net"] } libc = "0.2" +p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } +postcard = { version = "1", features = ["alloc"] } +rand = "0.10" serde = { version = "1", features = ["derive"] } serde_json = "1" +sha2 = "0.11" +subtle = "2" +tempfile = "3" +thiserror = "2" +tokio = { version = "1", features = ["full"] } +tracing = "0.1" +wasmtime = { version = "=48.0.7", default-features = false, features = [ + "cranelift", + "runtime", + "std", +], optional = true } [dev-dependencies] -p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } +id-core = { path = "../id-core", default-features = false, features = [ + "test-utils", +] } +# The directory tests sign artifacts through the id-sync test seam +# (SignedArtifact::sign_unchecked), as the facade dev build did. +id-sync = { path = "../id-sync", default-features = false, features = [ + "test-utils", +] } proptest = "1.12" -tempfile = "3" +tokio = { version = "1", features = ["test-util"] } +tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] } +wat = "=1.261.0" [lints.rust] unsafe_code = "warn" diff --git a/pkgs/id/src/directory.rs b/pkgs/id/crates/id-worlds/src/directory.rs similarity index 99% rename from pkgs/id/src/directory.rs rename to pkgs/id/crates/id-worlds/src/directory.rs index 1ce91a041c..977612687d 100644 --- a/pkgs/id/src/directory.rs +++ b/pkgs/id/crates/id-worlds/src/directory.rs @@ -1821,7 +1821,7 @@ impl Directory { } } - pub(crate) fn apply(&mut self, entry: &DirectoryEntry) -> Result<()> { + pub fn apply(&mut self, entry: &DirectoryEntry) -> Result<()> { self.apply_mode(entry, true) } @@ -2494,7 +2494,7 @@ fn clean_description_mode(description: &str, refuse_format: bool) -> Result(text: &str) -> Option<[u8; N]> { +pub fn hex_to_array(text: &str) -> Option<[u8; N]> { // Every byte must be an ASCII hex digit (#2517): u8::from_str_radix // also accepts a leading '+', so without this gate a byte 0x00-0x0f // has two accepted spellings ('0x' and '+x') and key strings stop diff --git a/pkgs/id/src/directory_auth.rs b/pkgs/id/crates/id-worlds/src/directory_auth.rs similarity index 100% rename from pkgs/id/src/directory_auth.rs rename to pkgs/id/crates/id-worlds/src/directory_auth.rs diff --git a/pkgs/id/src/directory_mail.rs b/pkgs/id/crates/id-worlds/src/directory_mail.rs similarity index 100% rename from pkgs/id/src/directory_mail.rs rename to pkgs/id/crates/id-worlds/src/directory_mail.rs diff --git a/pkgs/id/src/directory_view.rs b/pkgs/id/crates/id-worlds/src/directory_view.rs similarity index 100% rename from pkgs/id/src/directory_view.rs rename to pkgs/id/crates/id-worlds/src/directory_view.rs diff --git a/pkgs/id/crates/id-worlds/src/lib.rs b/pkgs/id/crates/id-worlds/src/lib.rs index 33c2e3a5a2..29d1835ed8 100644 --- a/pkgs/id/crates/id-worlds/src/lib.rs +++ b/pkgs/id/crates/id-worlds/src/lib.rs @@ -4,24 +4,79 @@ //! world family lives here, over `id-core`, `id-caps`, `id-store`, //! `id-events`, `id-groups` and `id-sync`. //! -//! This first step-5 PR brings: +//! Contents: //! -//! - [`blob_gate`]: the blob gate's folded-worlds adapter -//! ([`blob_gate::FoldedWorlds`]), parked in the facade by step 4 so -//! it could move together with the cross-world bridge it folds. +//! - The runtime: [`world`] (core, actor, replica, replication, +//! handle), [`world_session`], [`world_hub`], [`world_net`], +//! [`world_store`], [`world_records`], [`world_compile`], +//! [`world_native`], [`world_fixture`], [`world_cache`] and, under +//! the `sandbox` feature, [`sandbox`] — the wasmtime guest runner +//! whose fuel budgets are the split's determinism canary. +//! - [`shell_contract`]: the F13.1 shell contract the native shell +//! speaks. //! - [`groups::worlds`]: seam 6 of the design — the groups→worlds //! bridge is the consumer side of the relationship, so it lives in //! the worlds crate, over the group model in `id-events`. -//! - [`world_cache`], [`world_line`], [`world_terminal`]: the family -//! leaves that name nothing above them. +//! - [`blob_gate`]: the blob gate's folded-worlds adapter, which +//! folds through the bridge above (step 4 parked it in the facade +//! to move together with the bridge; it cannot live in `id-groups`, +//! which is below this crate and must not name world types). +//! - The directory cluster — [`directory`], [`directory_auth`], +//! [`directory_view`], [`directory_mail`] — the world runtime's own +//! state: `WorldCore` holds the directory, the world actor executes +//! directory actions against it, and `world_store` persists it +//! beside the journal, so the cluster moves as the consumer side +//! (the seam-6 pattern). Seam 10's remaining half is unchanged: +//! step 6's `id-directory` extraction must still invert or re-home +//! `WorldCore`'s hold on the directory, exactly as it would have +//! had to from the facade. The facade re-exports these modules at +//! their historical `id::` paths until then. //! -//! The world core, sessions, sandbox and the rest of the family -//! follow in later step-5 PRs. The facade re-exports each module at -//! its historical `id::` path, so no call site outside the moved -//! modules changed. +//! The facade re-exports each module at its historical `id::` path, +//! so no call site outside the moved modules changed. The module +//! aliases below (`frames`, `world_caps`, …) exist so the moved +//! modules' `crate::` paths resolve exactly as they did in the +//! facade; they name the lower crates that own those modules. pub mod blob_gate; +pub mod directory; +pub mod directory_auth; +pub mod directory_mail; +pub mod directory_view; pub mod groups; +#[cfg(feature = "sandbox")] +pub mod sandbox; +mod session_host; +pub mod shell_contract; +pub mod world; pub mod world_cache; +pub mod world_compile; +pub mod world_fixture; +pub mod world_hub; pub mod world_line; +pub mod world_native; +pub mod world_net; +pub mod world_records; +pub mod world_session; +pub mod world_store; pub mod world_terminal; + +pub use id_sync::artifact; +pub use id_core::abuse; +pub use id_store::chain; +pub use id_core::connectivity; +pub use id_sync::envelope_outbox; +pub use id_events::event_store; +pub use id_core::frames; +pub(crate) use id_core::is_format_char; +pub use id_core::petname; +pub use id_store::store; +pub use id_store::tags; +pub(crate) use id_core::text; +pub(crate) use id_core::time; +pub use id_caps::world_caps; +pub use id_caps::world_limits; +pub use id_core::world_presentation; + +#[cfg(test)] +pub(crate) use id_core::test_forgeries; diff --git a/pkgs/id/src/sandbox.rs b/pkgs/id/crates/id-worlds/src/sandbox.rs similarity index 97% rename from pkgs/id/src/sandbox.rs rename to pkgs/id/crates/id-worlds/src/sandbox.rs index 09367dd069..cc8e0b9998 100644 --- a/pkgs/id/src/sandbox.rs +++ b/pkgs/id/crates/id-worlds/src/sandbox.rs @@ -939,8 +939,8 @@ mod tests { #[test] fn checked_in_roc_examples_export_abi_version_one() { for wasm in [ - include_bytes!("../examples/roc-counter/counter.wasm").as_slice(), - include_bytes!("../apps/tic-tac-toe/program/tic-tac-toe.wasm").as_slice(), + include_bytes!("../../../examples/roc-counter/counter.wasm").as_slice(), + include_bytes!("../../../apps/tic-tac-toe/program/tic-tac-toe.wasm").as_slice(), ] { let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut store = Store::new(&runner.engine, ()); @@ -967,20 +967,20 @@ mod tests { // Every failure names the offending export or module so a future ABI // change fails loudly instead of drifting silently. - const ABI_MD: &str = include_str!("../examples/roc-world/ABI.md"); + const ABI_MD: &str = include_str!("../../../examples/roc-world/ABI.md"); const CONFORMANCE_MODULES: [(&str, &[u8]); 3] = [ ( "roc-counter", - include_bytes!("../examples/roc-counter/counter.wasm"), + include_bytes!("../../../examples/roc-counter/counter.wasm"), ), ( "rust-counter", - include_bytes!("../examples/rust-counter/counter.wasm"), + include_bytes!("../../../examples/rust-counter/counter.wasm"), ), ( "tic-tac-toe", - include_bytes!("../apps/tic-tac-toe/program/tic-tac-toe.wasm"), + include_bytes!("../../../apps/tic-tac-toe/program/tic-tac-toe.wasm"), ), ]; @@ -1105,7 +1105,7 @@ mod tests { // allocates guest-owned input, writes the event, frees the exact // allocation after the call, and reads outputs through the one // shared pointer + `plaza_out_len` slot. - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let (mut store, instance) = conformance_raw_instance(&runner); let memory = instance.get_memory(&mut store, "memory").unwrap(); @@ -1278,7 +1278,7 @@ mod tests { use crate::world::{WorldEvent, WorldEventKind, WorldProgram}; use crate::world_fixture::{Fixture, FixtureEvent, FixtureHeader, Verdict}; - let wasm = include_bytes!("../examples/roc-chat/roc-chat.wasm"); + let wasm = include_bytes!("../../../examples/roc-chat/roc-chat.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut live = runner.instantiate(7).unwrap(); let mut events: Vec = Vec::new(); @@ -1399,7 +1399,7 @@ mod tests { #[test] fn checked_in_roc_counter_compiles_and_initializes_in_the_import_free_sandbox() { - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut world = runner.instantiate(7).unwrap(); assert!( @@ -1425,7 +1425,7 @@ mod tests { async fn checked_in_roc_counter_runs_as_the_authoritative_world_program() { use crate::world::{WorldCore, WorldHandle, WorldLimits, WorldScopes}; - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let guest = runner.instantiate(7).unwrap(); let actor = WorldHandle::spawn_with_program( @@ -1470,7 +1470,7 @@ mod tests { #[test] fn checked_in_roc_counter_publishes_records() { - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut world = runner.instantiate(7).unwrap(); assert_eq!(world.records().unwrap().unwrap(), br#"{"count":0}"#); @@ -1488,7 +1488,7 @@ mod tests { #[test] fn checked_in_tic_tac_toe_plays_a_full_game() { - let wasm = include_bytes!("../apps/tic-tac-toe/program/tic-tac-toe.wasm"); + let wasm = include_bytes!("../../../apps/tic-tac-toe/program/tic-tac-toe.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut world = runner.instantiate(7).unwrap(); let records = |world: &mut WorldInstance| { @@ -1535,7 +1535,7 @@ mod tests { #[test] fn checked_in_apps_snapshot_and_restore_faithfully() { // Counter: the model is its count. - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut live = runner.instantiate(7).unwrap(); for _ in 0..3 { @@ -1567,7 +1567,7 @@ mod tests { ); // Tic-tac-toe: the board alone carries the ply count and the winner. - let wasm = include_bytes!("../apps/tic-tac-toe/program/tic-tac-toe.wasm"); + let wasm = include_bytes!("../../../apps/tic-tac-toe/program/tic-tac-toe.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut live = runner.instantiate(7).unwrap(); for (participant, cell) in [(1u64, "0"), (2, "3"), (1, "1"), (2, "4"), (1, "2")] { @@ -1594,7 +1594,7 @@ mod tests { #[test] fn checked_in_roc_screen_renders_structured_surface() { - let wasm = include_bytes!("../examples/roc-screen/roc-screen.wasm"); + let wasm = include_bytes!("../../../examples/roc-screen/roc-screen.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut live = runner.instantiate(7).unwrap(); live.update(1, b"+").unwrap(); @@ -1618,7 +1618,7 @@ mod tests { #[test] fn checked_in_grid_example_uses_bounded_get_set() { - let wasm = include_bytes!("../examples/roc-grid/roc-grid.wasm"); + let wasm = include_bytes!("../../../examples/roc-grid/roc-grid.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut live = runner.instantiate(7).unwrap(); let render = |world: &mut WorldInstance| -> String { @@ -1656,7 +1656,7 @@ mod tests { fn checked_in_chat_example_sends_and_reads_history() { use crate::world::{WorldEvent, WorldEventKind}; - let wasm = include_bytes!("../examples/roc-chat/roc-chat.wasm"); + let wasm = include_bytes!("../../../examples/roc-chat/roc-chat.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut chat = runner.instantiate(7).unwrap(); fn wants_of(chat: &mut WorldInstance) -> String { @@ -1735,7 +1735,7 @@ mod tests { #[test] fn checked_in_roc_screen_reflows_for_a_wider_viewport() { - let wasm = include_bytes!("../examples/roc-screen/roc-screen.wasm"); + let wasm = include_bytes!("../../../examples/roc-screen/roc-screen.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut live = runner.instantiate(7).unwrap(); let width_of = |bytes: Vec| -> u16 { @@ -1765,30 +1765,30 @@ mod tests { // Rerun with: // cd pkgs/id && cargo test --lib bytes_per_frame_baseline -- --nocapture const EXAMPLES: [(&str, &[u8]); 7] = [ - ("lounge", include_bytes!("../examples/lounge/lounge.wasm")), + ("lounge", include_bytes!("../../../examples/lounge/lounge.wasm")), ( "roc-chat", - include_bytes!("../examples/roc-chat/roc-chat.wasm"), + include_bytes!("../../../examples/roc-chat/roc-chat.wasm"), ), ( "roc-counter", - include_bytes!("../examples/roc-counter/counter.wasm"), + include_bytes!("../../../examples/roc-counter/counter.wasm"), ), ( "roc-grid", - include_bytes!("../examples/roc-grid/roc-grid.wasm"), + include_bytes!("../../../examples/roc-grid/roc-grid.wasm"), ), ( "roc-screen", - include_bytes!("../examples/roc-screen/roc-screen.wasm"), + include_bytes!("../../../examples/roc-screen/roc-screen.wasm"), ), ( "territory", - include_bytes!("../examples/territory/territory.wasm"), + include_bytes!("../../../examples/territory/territory.wasm"), ), ( "tic-tac-toe", - include_bytes!("../apps/tic-tac-toe/program/tic-tac-toe.wasm"), + include_bytes!("../../../apps/tic-tac-toe/program/tic-tac-toe.wasm"), ), ]; println!("| example | plaza_layout | bytes @ 80x24 | bytes @ 200x60 |"); @@ -1819,7 +1819,7 @@ mod tests { #[test] fn checked_in_territory_renders_a_styled_screen_within_the_default_fuel() { - let wasm = include_bytes!("../examples/territory/territory.wasm"); + let wasm = include_bytes!("../../../examples/territory/territory.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut live = runner.instantiate(7).unwrap(); live.update(1, b"l ").unwrap(); @@ -1837,7 +1837,7 @@ mod tests { #[test] fn checked_in_territory_plays_persists_and_rejoins() { - let wasm = include_bytes!("../examples/territory/territory.wasm"); + let wasm = include_bytes!("../../../examples/territory/territory.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let joined = |id: u64, name: &str| { format!( @@ -1940,7 +1940,7 @@ mod tests { #[test] fn wasm_actor_call_order_records_update_records_view() { use crate::world::{WorldEvent, WorldEventKind}; - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut program = runner.instantiate(7).unwrap(); let view = @@ -1966,7 +1966,7 @@ mod tests { fn the_lounge_uses_the_capability_protocol() { use crate::world::{WorldEvent, WorldEventKind}; - let wasm = include_bytes!("../examples/lounge/lounge.wasm"); + let wasm = include_bytes!("../../../examples/lounge/lounge.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut lounge = runner.instantiate(7).unwrap(); fn wants_of(lounge: &mut WorldInstance) -> String { @@ -2449,47 +2449,47 @@ mod tests { [ Example { name: "roc-counter", - wasm: include_bytes!("../examples/roc-counter/counter.wasm"), + wasm: include_bytes!("../../../examples/roc-counter/counter.wasm"), drive: drive_counter, }, Example { name: "roc-text-counter", - wasm: include_bytes!("../examples/roc-text-counter/text-counter.wasm"), + wasm: include_bytes!("../../../examples/roc-text-counter/text-counter.wasm"), drive: drive_text_counter, }, Example { name: "tic-tac-toe", - wasm: include_bytes!("../apps/tic-tac-toe/program/tic-tac-toe.wasm"), + wasm: include_bytes!("../../../apps/tic-tac-toe/program/tic-tac-toe.wasm"), drive: drive_tic_tac_toe, }, Example { name: "roc-screen", - wasm: include_bytes!("../examples/roc-screen/roc-screen.wasm"), + wasm: include_bytes!("../../../examples/roc-screen/roc-screen.wasm"), drive: drive_screen, }, Example { name: "roc-grid", - wasm: include_bytes!("../examples/roc-grid/roc-grid.wasm"), + wasm: include_bytes!("../../../examples/roc-grid/roc-grid.wasm"), drive: drive_grid, }, Example { name: "roc-chat", - wasm: include_bytes!("../examples/roc-chat/roc-chat.wasm"), + wasm: include_bytes!("../../../examples/roc-chat/roc-chat.wasm"), drive: drive_chat, }, Example { name: "lounge", - wasm: include_bytes!("../examples/lounge/lounge.wasm"), + wasm: include_bytes!("../../../examples/lounge/lounge.wasm"), drive: drive_lounge, }, Example { name: "territory", - wasm: include_bytes!("../examples/territory/territory.wasm"), + wasm: include_bytes!("../../../examples/territory/territory.wasm"), drive: drive_territory, }, Example { name: "territory-full", - wasm: include_bytes!("../examples/territory/territory.wasm"), + wasm: include_bytes!("../../../examples/territory/territory.wasm"), drive: drive_territory_full, }, ] @@ -2640,7 +2640,7 @@ mod tests { #[test] fn territory_view_fits_the_default_fuel_with_every_seat_taken() { - let wasm = include_bytes!("../examples/territory/territory.wasm"); + let wasm = include_bytes!("../../../examples/territory/territory.wasm"); let limits = SandboxLimits::default(); let runner = Sandbox::compile(wasm, limits).unwrap(); let mut live = runner.instantiate(7).unwrap(); @@ -2673,7 +2673,7 @@ mod tests { #[test] fn territory_scoreboard_lines_are_cut_at_the_screen_width() { - let wasm = include_bytes!("../examples/territory/territory.wasm"); + let wasm = include_bytes!("../../../examples/territory/territory.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let mut live = runner.instantiate(7).unwrap(); host_event( @@ -2706,7 +2706,7 @@ mod tests { // `TERRITORY_WASM=FILE` measures a variant build instead. let wasm = match std::env::var_os("TERRITORY_WASM") { Some(path) => std::fs::read(path).unwrap(), - None => include_bytes!("../examples/territory/territory.wasm").to_vec(), + None => include_bytes!("../../../examples/territory/territory.wasm").to_vec(), }; let runner = Sandbox::compile(&wasm, SandboxLimits::default()).unwrap(); for (seats, per_seat) in [(0, 0), (1, 1), (2, 14), (4, 14), (8, 1), (8, 14)] { diff --git a/pkgs/id/src/session_host.rs b/pkgs/id/crates/id-worlds/src/session_host.rs similarity index 100% rename from pkgs/id/src/session_host.rs rename to pkgs/id/crates/id-worlds/src/session_host.rs diff --git a/pkgs/id/src/shell_contract.rs b/pkgs/id/crates/id-worlds/src/shell_contract.rs similarity index 99% rename from pkgs/id/src/shell_contract.rs rename to pkgs/id/crates/id-worlds/src/shell_contract.rs index 0d5f71d7d8..9891ec3898 100644 --- a/pkgs/id/src/shell_contract.rs +++ b/pkgs/id/crates/id-worlds/src/shell_contract.rs @@ -26,7 +26,7 @@ use serde::Deserialize; use serde_json::Value; /// The contract document, embedded at build time. -pub const SHELL_CONTRACT_JSON: &str = include_str!("../contract/shell-contract.v1.json"); +pub const SHELL_CONTRACT_JSON: &str = include_str!("../../../contract/shell-contract.v1.json"); /// The contract's wire version; it matches the `/id-world/1` ALPN. pub const SHELL_CONTRACT_VERSION: u32 = 1; diff --git a/pkgs/id/src/shell_contract/tests.rs b/pkgs/id/crates/id-worlds/src/shell_contract/tests.rs similarity index 100% rename from pkgs/id/src/shell_contract/tests.rs rename to pkgs/id/crates/id-worlds/src/shell_contract/tests.rs diff --git a/pkgs/id/src/world/actor.rs b/pkgs/id/crates/id-worlds/src/world/actor.rs similarity index 100% rename from pkgs/id/src/world/actor.rs rename to pkgs/id/crates/id-worlds/src/world/actor.rs diff --git a/pkgs/id/src/world/clock.rs b/pkgs/id/crates/id-worlds/src/world/clock.rs similarity index 100% rename from pkgs/id/src/world/clock.rs rename to pkgs/id/crates/id-worlds/src/world/clock.rs diff --git a/pkgs/id/src/world/core.rs b/pkgs/id/crates/id-worlds/src/world/core.rs similarity index 100% rename from pkgs/id/src/world/core.rs rename to pkgs/id/crates/id-worlds/src/world/core.rs diff --git a/pkgs/id/src/world/core/checkpoint_parts.rs b/pkgs/id/crates/id-worlds/src/world/core/checkpoint_parts.rs similarity index 100% rename from pkgs/id/src/world/core/checkpoint_parts.rs rename to pkgs/id/crates/id-worlds/src/world/core/checkpoint_parts.rs diff --git a/pkgs/id/src/world/handle.rs b/pkgs/id/crates/id-worlds/src/world/handle.rs similarity index 99% rename from pkgs/id/src/world/handle.rs rename to pkgs/id/crates/id-worlds/src/world/handle.rs index 3b22b4494c..87d0592d96 100644 --- a/pkgs/id/src/world/handle.rs +++ b/pkgs/id/crates/id-worlds/src/world/handle.rs @@ -340,7 +340,7 @@ impl WorldHandle { /// ([`WorldCommand::ReplicationCompact`]); the feed is then rebuilt from /// the compacted image (the compaction publishes a reset to the first /// subscription, so it is replaced, exactly as the in-actor flow did). - pub(crate) async fn replication_feed( + pub async fn replication_feed( &self, ) -> Result<( String, diff --git a/pkgs/id/src/world/hotness.rs b/pkgs/id/crates/id-worlds/src/world/hotness.rs similarity index 100% rename from pkgs/id/src/world/hotness.rs rename to pkgs/id/crates/id-worlds/src/world/hotness.rs diff --git a/pkgs/id/src/world/metrics.rs b/pkgs/id/crates/id-worlds/src/world/metrics.rs similarity index 100% rename from pkgs/id/src/world/metrics.rs rename to pkgs/id/crates/id-worlds/src/world/metrics.rs diff --git a/pkgs/id/src/world/mod.rs b/pkgs/id/crates/id-worlds/src/world/mod.rs similarity index 99% rename from pkgs/id/src/world/mod.rs rename to pkgs/id/crates/id-worlds/src/world/mod.rs index 3ba39bc954..54de7c709b 100644 --- a/pkgs/id/src/world/mod.rs +++ b/pkgs/id/crates/id-worlds/src/world/mod.rs @@ -2252,7 +2252,7 @@ pub trait WorldProgram: Send + 'static { } #[derive(Debug, Default)] -pub(crate) struct EmptyWorldProgram; +pub struct EmptyWorldProgram; impl WorldProgram for EmptyWorldProgram {} diff --git a/pkgs/id/src/world/replica.rs b/pkgs/id/crates/id-worlds/src/world/replica.rs similarity index 100% rename from pkgs/id/src/world/replica.rs rename to pkgs/id/crates/id-worlds/src/world/replica.rs diff --git a/pkgs/id/src/world/replication.rs b/pkgs/id/crates/id-worlds/src/world/replication.rs similarity index 100% rename from pkgs/id/src/world/replication.rs rename to pkgs/id/crates/id-worlds/src/world/replication.rs diff --git a/pkgs/id/src/world/replication_receiver.rs b/pkgs/id/crates/id-worlds/src/world/replication_receiver.rs similarity index 100% rename from pkgs/id/src/world/replication_receiver.rs rename to pkgs/id/crates/id-worlds/src/world/replication_receiver.rs diff --git a/pkgs/id/src/world/signed.rs b/pkgs/id/crates/id-worlds/src/world/signed.rs similarity index 100% rename from pkgs/id/src/world/signed.rs rename to pkgs/id/crates/id-worlds/src/world/signed.rs diff --git a/pkgs/id/src/world/tests.rs b/pkgs/id/crates/id-worlds/src/world/tests.rs similarity index 100% rename from pkgs/id/src/world/tests.rs rename to pkgs/id/crates/id-worlds/src/world/tests.rs diff --git a/pkgs/id/src/world/upgrade.rs b/pkgs/id/crates/id-worlds/src/world/upgrade.rs similarity index 100% rename from pkgs/id/src/world/upgrade.rs rename to pkgs/id/crates/id-worlds/src/world/upgrade.rs diff --git a/pkgs/id/src/world/util.rs b/pkgs/id/crates/id-worlds/src/world/util.rs similarity index 100% rename from pkgs/id/src/world/util.rs rename to pkgs/id/crates/id-worlds/src/world/util.rs diff --git a/pkgs/id/src/world_compile.rs b/pkgs/id/crates/id-worlds/src/world_compile.rs similarity index 99% rename from pkgs/id/src/world_compile.rs rename to pkgs/id/crates/id-worlds/src/world_compile.rs index c27f16bfbf..f3adab9b06 100644 --- a/pkgs/id/src/world_compile.rs +++ b/pkgs/id/crates/id-worlds/src/world_compile.rs @@ -1094,7 +1094,7 @@ mod tests { .with_cache(cache.clone()); let counter = std::fs::read_to_string(concat!( env!("CARGO_MANIFEST_DIR"), - "/examples/roc-counter/main.roc" + "/../../examples/roc-counter/main.roc" )) .unwrap(); let granted = ["Screen".to_owned(), "RocText".to_owned()]; @@ -1784,7 +1784,7 @@ restore = |text| match U64.from_str(text) { let compiler = Compiler::new(platform_dir, roc_bin).unwrap(); let counter = std::fs::read_to_string(concat!( env!("CARGO_MANIFEST_DIR"), - "/examples/roc-counter/main.roc" + "/../../examples/roc-counter/main.roc" )) .unwrap(); eprintln!("PROBE roc={}", compiler.roc_bin); @@ -1845,7 +1845,7 @@ restore = |text| match U64.from_str(text) { let compiler = Compiler::new(platform_dir, roc_bin).unwrap(); let app = std::fs::read_to_string(concat!( env!("CARGO_MANIFEST_DIR"), - "/examples/roc-screen/main.roc" + "/../../examples/roc-screen/main.roc" )) .unwrap(); let (wasm, _diagnostics, provenance) = compile( @@ -1914,7 +1914,7 @@ restore = |text| match U64.from_str(text) { let compiler = Compiler::new(platform_dir, roc_bin).unwrap(); let counter = std::fs::read_to_string(concat!( env!("CARGO_MANIFEST_DIR"), - "/examples/roc-counter/main.roc" + "/../../examples/roc-counter/main.roc" )) .unwrap(); let (native, _diagnostics, provenance) = compile( @@ -2051,7 +2051,7 @@ restore = |text| match U64.from_str(text) { let compiler = Compiler::new(platform_dir, "/nonexistent/roc".to_owned()).unwrap(); let app = std::fs::read_to_string(concat!( env!("CARGO_MANIFEST_DIR"), - "/examples/roc-screen/main.roc" + "/../../examples/roc-screen/main.roc" )) .unwrap(); let error = compile( @@ -2083,7 +2083,7 @@ restore = |text| match U64.from_str(text) { fn default_platform_dir() -> Option { let candidates = [ - PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/roc-world")), + PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/../../examples/roc-world")), PathBuf::from("examples/roc-world"), PathBuf::from("../examples/roc-world"), ]; diff --git a/pkgs/id/src/world_fixture.rs b/pkgs/id/crates/id-worlds/src/world_fixture.rs similarity index 99% rename from pkgs/id/src/world_fixture.rs rename to pkgs/id/crates/id-worlds/src/world_fixture.rs index 443f1738d3..7ad5a229db 100644 --- a/pkgs/id/src/world_fixture.rs +++ b/pkgs/id/crates/id-worlds/src/world_fixture.rs @@ -1105,8 +1105,8 @@ mod tests { #[test] fn check_module_refuses_a_different_module() { - let wasm: &[u8] = include_bytes!("../apps/tic-tac-toe/program/tic-tac-toe.wasm"); - let other: &[u8] = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm: &[u8] = include_bytes!("../../../apps/tic-tac-toe/program/tic-tac-toe.wasm"); + let other: &[u8] = include_bytes!("../../../examples/roc-counter/counter.wasm"); let mut recorded = header(0, true); assert!(check_module(&recorded, wasm).is_err(), "no module recorded"); recorded.module_hash = Some(module_hash(wasm)); @@ -1129,7 +1129,7 @@ mod tests { use crate::world_net::{WORLD_ALPN, WorldProtocol}; use crate::world_session::WorldService; - const TIC_TAC_TOE: &[u8] = include_bytes!("../apps/tic-tac-toe/program/tic-tac-toe.wasm"); + const TIC_TAC_TOE: &[u8] = include_bytes!("../../../apps/tic-tac-toe/program/tic-tac-toe.wasm"); /// A tic-tac-toe game as a live instance plays it: a leading install, /// one chat line, and five moves. Returns the runner and the fixture a @@ -1220,7 +1220,7 @@ mod tests { ), ]; - let fixture_text = include_str!("../tests/fixtures/tic-tac-toe-determinism.jsonl"); + let fixture_text = include_str!("../../../tests/fixtures/tic-tac-toe-determinism.jsonl"); let fixture = decode(fixture_text).unwrap(); check_module(&fixture.header, TIC_TAC_TOE).unwrap(); let runner = Sandbox::compile(TIC_TAC_TOE, SandboxLimits::default()).unwrap(); @@ -1481,7 +1481,7 @@ mod tests { #[test] fn territory_fixture_replays_host_events_interleaved_with_inputs() { - let wasm: &[u8] = include_bytes!("../examples/territory/territory.wasm"); + let wasm: &[u8] = include_bytes!("../../../examples/territory/territory.wasm"); let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap(); let joined = |id: u64, name: &str| { format!( @@ -1612,7 +1612,7 @@ mod tests { #[tokio::test] async fn recording_replays_host_presence_from_admin_history() { - let wasm: &[u8] = include_bytes!("../examples/territory/territory.wasm"); + let wasm: &[u8] = include_bytes!("../../../examples/territory/territory.wasm"); let mut core = WorldCore::new("lobby", WorldLimits::default()).unwrap(); core.ledger .set_granted(std::collections::BTreeSet::from(["players".to_owned()])); diff --git a/pkgs/id/src/world_hub.rs b/pkgs/id/crates/id-worlds/src/world_hub.rs similarity index 100% rename from pkgs/id/src/world_hub.rs rename to pkgs/id/crates/id-worlds/src/world_hub.rs diff --git a/pkgs/id/src/world_native.rs b/pkgs/id/crates/id-worlds/src/world_native.rs similarity index 99% rename from pkgs/id/src/world_native.rs rename to pkgs/id/crates/id-worlds/src/world_native.rs index 881f16d482..6a993842b8 100644 --- a/pkgs/id/src/world_native.rs +++ b/pkgs/id/crates/id-worlds/src/world_native.rs @@ -761,7 +761,7 @@ mod tests { fn counter_path() -> Option { let path = PathBuf::from(concat!( env!("CARGO_MANIFEST_DIR"), - "/examples/roc-counter/counter-native" + "/../../examples/roc-counter/counter-native" )); path.is_file().then_some(path) } diff --git a/pkgs/id/src/world_net.rs b/pkgs/id/crates/id-worlds/src/world_net.rs similarity index 99% rename from pkgs/id/src/world_net.rs rename to pkgs/id/crates/id-worlds/src/world_net.rs index 112ef525cf..bf46810442 100644 --- a/pkgs/id/src/world_net.rs +++ b/pkgs/id/crates/id-worlds/src/world_net.rs @@ -223,7 +223,7 @@ impl WorldProtocol { /// the aggregate snapshot: the meta protocol's `AbuseCounters` /// request reads the per-direction split and the policy from it. #[must_use] - pub(crate) fn abuse_handle(&self) -> Arc> { + pub fn abuse_handle(&self) -> Arc> { Arc::clone(&self.abuse) } @@ -3651,7 +3651,7 @@ mod tests { #[cfg(feature = "sandbox")] #[tokio::test] async fn roc_guest_updates_authoritative_state_over_iroh() { - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); let sandbox = crate::sandbox::Sandbox::compile(wasm, crate::sandbox::SandboxLimits::default()) .unwrap(); @@ -3724,8 +3724,8 @@ mod tests { #[cfg(feature = "sandbox")] #[tokio::test] async fn apply_hash_path_sequences_fresh_sessions_on_one_connection() { - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); - let wasm2 = include_bytes!("../examples/roc-chat/roc-chat.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); + let wasm2 = include_bytes!("../../../examples/roc-chat/roc-chat.wasm"); let ep = endpoint().await; let world = WorldHandle::spawn(WorldCore::new("lobby", WorldLimits::default()).unwrap()); let blobs: iroh_blobs::api::Store = iroh_blobs::store::mem::MemStore::new().into(); @@ -3792,7 +3792,7 @@ mod tests { #[cfg(feature = "sandbox")] #[tokio::test] async fn peers_install_then_download_the_active_module_by_hash() { - let wasm = include_bytes!("../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm"); let ep = endpoint().await; let world = WorldHandle::spawn(WorldCore::new("lobby", WorldLimits::default()).unwrap()); let blobs: iroh_blobs::api::Store = iroh_blobs::store::mem::MemStore::new().into(); @@ -3869,7 +3869,7 @@ mod tests { // participant download then refuses it, but an admin can still fetch // the stored bytes by hash - the path `id world apply` uses to // install the module a manifest names. - let wasm2 = include_bytes!("../examples/roc-chat/roc-chat.wasm"); + let wasm2 = include_bytes!("../../../examples/roc-chat/roc-chat.wasm"); let mut admin2 = WorldClient::connect(&client_ep, addr.clone()) .await .unwrap(); diff --git a/pkgs/id/src/world_records.rs b/pkgs/id/crates/id-worlds/src/world_records.rs similarity index 100% rename from pkgs/id/src/world_records.rs rename to pkgs/id/crates/id-worlds/src/world_records.rs diff --git a/pkgs/id/src/world_session/contract_tests.rs b/pkgs/id/crates/id-worlds/src/world_session/contract_tests.rs similarity index 100% rename from pkgs/id/src/world_session/contract_tests.rs rename to pkgs/id/crates/id-worlds/src/world_session/contract_tests.rs diff --git a/pkgs/id/src/world_session/mod.rs b/pkgs/id/crates/id-worlds/src/world_session/mod.rs similarity index 99% rename from pkgs/id/src/world_session/mod.rs rename to pkgs/id/crates/id-worlds/src/world_session/mod.rs index d8502e2f18..acff70bc78 100644 --- a/pkgs/id/src/world_session/mod.rs +++ b/pkgs/id/crates/id-worlds/src/world_session/mod.rs @@ -50,8 +50,9 @@ mod types; /// World-service constructors and module lifecycle (split from this module, #4717). mod service; +pub use types::MAX_ADMIN_TOKEN_BYTES; pub(crate) use types::{ - CAPS_CEILING_NOTICE, ClientFrame, MAX_ADMIN_TOKEN_BYTES, MAX_CAPABILITY_BYTES, + CAPS_CEILING_NOTICE, ClientFrame, MAX_CAPABILITY_BYTES, MAX_CONCURRENT_MODULE_UPLOADS, ServerFrame, invite_bounds, }; pub use types::{ diff --git a/pkgs/id/src/world_session/service.rs b/pkgs/id/crates/id-worlds/src/world_session/service.rs similarity index 100% rename from pkgs/id/src/world_session/service.rs rename to pkgs/id/crates/id-worlds/src/world_session/service.rs diff --git a/pkgs/id/src/world_session/tests.rs b/pkgs/id/crates/id-worlds/src/world_session/tests.rs similarity index 99% rename from pkgs/id/src/world_session/tests.rs rename to pkgs/id/crates/id-worlds/src/world_session/tests.rs index 186246758e..1c04f23621 100644 --- a/pkgs/id/src/world_session/tests.rs +++ b/pkgs/id/crates/id-worlds/src/world_session/tests.rs @@ -1994,7 +1994,7 @@ mod tests { let blobs: Store = MemStore::new().into(); let svc = WorldService::new(world.clone(), Some("admin".to_owned())) .with_blob_store(blobs.clone()); - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm"); let hash = module_hash(wasm); let mut peer = Peer::connect(svc.clone(), SessionConfig::default()); @@ -2147,7 +2147,7 @@ mod tests { async fn admin_fuel_limit_applies_to_installed_programs() { use iroh_blobs::store::mem::MemStore; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm").to_vec(); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm").to_vec(); let hash = module_hash(&wasm); let starved = crate::world_limits::RuntimeLimits { sandbox: crate::sandbox::SandboxLimits { @@ -2197,7 +2197,7 @@ mod tests { async fn source_only_policy_rejects_raw_modules_but_preserves_normal_mode() { use iroh_blobs::store::mem::MemStore; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm").to_vec(); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm").to_vec(); let hash = module_hash(&wasm); let world = WorldHandle::spawn(WorldCore::new("lobby", WorldLimits::default()).unwrap()); let service = WorldService::new(world.clone(), Some("admin".to_owned())) @@ -2235,7 +2235,7 @@ mod tests { async fn module_trust_list_allows_empty_refuses_unsigned_and_accepts_trusted_signer() { use iroh_blobs::store::mem::MemStore; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm").to_vec(); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm").to_vec(); let hash = module_hash(&wasm); let empty = WorldService::new( @@ -2299,7 +2299,7 @@ mod tests { async fn bad_module_replacement_preserves_the_active_program() { use iroh_blobs::store::mem::MemStore; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm"); let sandbox = crate::sandbox::Sandbox::compile(wasm, crate::sandbox::SandboxLimits::default()) .unwrap(); @@ -2655,7 +2655,7 @@ mod tests { .unwrap(); let mut peer = join_as(&service, &builder_token).await; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm"); let hash = module_hash(wasm); // No `admin_token` field at all: the joined path must not need // one, and serde must accept its absence. @@ -2732,7 +2732,7 @@ mod tests { .unwrap(); let mut peer = join_as(&service, &builder_token).await; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm"); let hash = module_hash(wasm); let mut message = b"developing-today/id-world-module/v1\0".to_vec(); message.extend_from_slice(blake3::hash(wasm).as_bytes()); @@ -2783,7 +2783,7 @@ mod tests { .unwrap(); let mut peer = join_as(&service, &guest_token).await; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm"); peer.say(serde_json::json!({ "type": "install_begin", "total_bytes": wasm.len(), @@ -2826,7 +2826,7 @@ mod tests { .unwrap(); let mut peer = join_as(&service, &builder_token).await; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm"); peer.say(serde_json::json!({ "type": "install_begin", "admin_token": "admin", @@ -2866,7 +2866,7 @@ mod tests { .unwrap(); let mut peer = join_as(&service, &builder_token).await; - let wasm = include_bytes!("../../examples/roc-counter/counter.wasm"); + let wasm = include_bytes!("../../../../examples/roc-counter/counter.wasm"); peer.say(serde_json::json!({ "type": "install_begin", "total_bytes": wasm.len(), diff --git a/pkgs/id/src/world_session/types.rs b/pkgs/id/crates/id-worlds/src/world_session/types.rs similarity index 99% rename from pkgs/id/src/world_session/types.rs rename to pkgs/id/crates/id-worlds/src/world_session/types.rs index 64336ea9bb..4d97266e19 100644 --- a/pkgs/id/src/world_session/types.rs +++ b/pkgs/id/crates/id-worlds/src/world_session/types.rs @@ -28,7 +28,7 @@ pub const MAX_WORLD_MODULE_CHUNK_BYTES: usize = 6 * 1024; pub(crate) const MAX_CAPABILITY_BYTES: usize = 256; /// Longest accepted admin secret, in bytes. -pub(crate) const MAX_ADMIN_TOKEN_BYTES: usize = 256; +pub const MAX_ADMIN_TOKEN_BYTES: usize = 256; /// Sent with a capability ceiling change: unlike a profile, it takes effect now. pub(crate) const CAPS_CEILING_NOTICE: &str = "ceiling saved; it applies immediately to new uses and active subscriptions"; diff --git a/pkgs/id/src/world_store.rs b/pkgs/id/crates/id-worlds/src/world_store.rs similarity index 99% rename from pkgs/id/src/world_store.rs rename to pkgs/id/crates/id-worlds/src/world_store.rs index a01638b5a1..93327d546f 100644 --- a/pkgs/id/src/world_store.rs +++ b/pkgs/id/crates/id-worlds/src/world_store.rs @@ -1172,7 +1172,7 @@ mod tests { ) .await .unwrap(); - let wasm = include_bytes!("../examples/roc-counter/counter.wasm").to_vec(); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm").to_vec(); let hash = module_hash(&wasm); writer .install_wasm(Some("writer-admin"), wasm, 42, &hash) @@ -1273,7 +1273,7 @@ mod tests { // module is served read-only from the replica's module // directory, while uploads stay refused (the writer admin token // was stripped at replica open). - let expected_wasm = include_bytes!("../examples/roc-counter/counter.wasm").to_vec(); + let expected_wasm = include_bytes!("../../../examples/roc-counter/counter.wasm").to_vec(); assert_eq!(replica.module_bytes(&hash).await.unwrap(), expected_wasm); assert!( replica @@ -1666,7 +1666,7 @@ mod tests { .unwrap(); service } - let wasm = include_bytes!("../examples/lounge/lounge.wasm").to_vec(); + let wasm = include_bytes!("../../../examples/lounge/lounge.wasm").to_vec(); let hash = module_hash(&wasm); let dir = TempDir::new().unwrap(); @@ -1724,7 +1724,7 @@ mod tests { async fn restored_program_uses_the_current_server_runtime_ceiling() { use iroh_blobs::store::mem::MemStore; - let wasm = include_bytes!("../examples/roc-counter/counter.wasm").to_vec(); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm").to_vec(); let hash = module_hash(&wasm); let dir = TempDir::new().unwrap(); let blobs: iroh_blobs::api::Store = MemStore::new().into(); @@ -2057,7 +2057,7 @@ mod tests { #[cfg(feature = "sandbox")] #[tokio::test] async fn roc_program_state_is_rebuilt_by_replay() { - let wasm = include_bytes!("../examples/roc-counter/counter.wasm").to_vec(); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm").to_vec(); let dir = TempDir::new().unwrap(); let blobs: iroh_blobs::api::Store = iroh_blobs::store::mem::MemStore::new().into(); let make = |blobs: iroh_blobs::api::Store| { @@ -2119,7 +2119,7 @@ mod tests { #[cfg(feature = "sandbox")] #[tokio::test] async fn a_native_world_installs_and_plays_in_process() { - let wasm = include_bytes!("../examples/roc-counter/counter-native").to_vec(); + let wasm = include_bytes!("../../../examples/roc-counter/counter-native").to_vec(); let dir = TempDir::new().unwrap(); let blobs: iroh_blobs::api::Store = iroh_blobs::store::mem::MemStore::new().into(); let make = |blobs: iroh_blobs::api::Store| { @@ -2170,7 +2170,7 @@ mod tests { #[cfg(feature = "sandbox")] #[tokio::test] async fn the_journal_is_trimmed_behind_a_checkpoint_and_restart_resumes_from_it() { - let wasm = include_bytes!("../examples/roc-counter/counter.wasm").to_vec(); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm").to_vec(); let dir = TempDir::new().unwrap(); let blobs: iroh_blobs::api::Store = iroh_blobs::store::mem::MemStore::new().into(); let limits = WorldLimits { @@ -2666,7 +2666,7 @@ mod tests { #[cfg(feature = "sandbox")] #[tokio::test] async fn a_missing_module_leaves_chat_working_and_the_program_unavailable() { - let wasm = include_bytes!("../examples/roc-counter/counter.wasm").to_vec(); + let wasm = include_bytes!("../../../examples/roc-counter/counter.wasm").to_vec(); let dir = TempDir::new().unwrap(); let blobs: iroh_blobs::api::Store = iroh_blobs::store::mem::MemStore::new().into(); let (svc, _) = open_world( diff --git a/pkgs/id/src/lib.rs b/pkgs/id/src/lib.rs index f168420b54..9aa0f12fff 100644 --- a/pkgs/id/src/lib.rs +++ b/pkgs/id/src/lib.rs @@ -174,15 +174,15 @@ pub mod currency; pub mod currency_poc; pub use id_sync::dht; #[cfg(feature = "world")] -pub mod directory; +pub use id_worlds::directory; #[cfg(feature = "world")] -pub mod directory_auth; +pub use id_worlds::directory_auth; #[cfg(feature = "world")] pub mod directory_log; #[cfg(feature = "world")] -pub mod directory_mail; +pub use id_worlds::directory_mail; #[cfg(feature = "world")] -pub mod directory_view; +pub use id_worlds::directory_view; pub use id_core::discovery; pub mod didit; pub use id_store::documents; @@ -230,7 +230,7 @@ pub mod references; pub use id_core::rejection; pub mod repl; #[cfg(feature = "sandbox")] -pub mod sandbox; +pub use id_worlds::sandbox; #[cfg(feature = "sandbox")] pub mod world_dev; pub use id_store::search; @@ -240,7 +240,7 @@ pub mod seitan; pub mod server_config; pub use id_store::session_checkpoint; #[cfg(feature = "world")] -pub mod shell_contract; +pub use id_worlds::shell_contract; pub use id_store::store; pub mod store_traits; pub mod structured_logging; @@ -249,48 +249,46 @@ pub use id_store::tag_claims; pub use id_store::tag_index; pub use id_store::tags; #[cfg(test)] -mod test_forgeries; +pub(crate) use id_core::test_forgeries; pub(crate) use id_core::text; pub(crate) use id_core::is_format_char; pub(crate) use id_core::time; pub use id_core::tuple; pub use id_core::waiting; #[cfg(feature = "world")] -pub mod world; +pub use id_worlds::world; #[cfg(feature = "world")] pub use id_caps::world_caps; #[cfg(feature = "world")] pub use id_worlds::world_cache; -pub mod world_compile; +pub use id_worlds::world_compile; #[cfg(feature = "world")] pub mod world_doctor; #[cfg(feature = "world")] -pub mod world_fixture; -#[cfg(feature = "world")] -mod session_host; +pub use id_worlds::world_fixture; -pub mod world_hub; +pub use id_worlds::world_hub; #[cfg(feature = "world")] pub use id_caps::world_limits; pub(crate) use id_worlds::world_line; #[cfg(feature = "world")] pub use id_caps::world_manifest; #[cfg(feature = "world")] -pub mod world_native; +pub use id_worlds::world_native; #[cfg(feature = "world")] -pub mod world_net; +pub use id_worlds::world_net; #[cfg(feature = "world")] pub mod world_replication_net; #[cfg(feature = "world")] pub use id_core::world_presentation; #[cfg(feature = "world")] -pub mod world_records; +pub use id_worlds::world_records; #[cfg(feature = "world")] -pub mod world_session; +pub use id_worlds::world_session; #[cfg(feature = "ssh")] pub mod world_ssh; #[cfg(feature = "world")] -pub mod world_store; +pub use id_worlds::world_store; #[cfg(feature = "world")] pub(crate) use id_worlds::world_terminal;