lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

commit ef602f3f8040cd224c09de10d0d2f2159161461e
parent e62b84c2e03950176fdf0cd2694fc183dc453ea6
Author: triesap <tyson@radroots.org>
Date:   Wed, 21 Oct 2026 03:17:41 +0000

ffi: expose native shared-client bindings

- Delegate concrete native handles and typed values to the shared client
- Generate lifecycle-safe Swift and Kotlin bindings with pinned UniFFI
- Exercise real protected-host workflows and unchanged coverage gates
- Register source provenance, curated APIs and standalone fixture checks

Diffstat:
MCargo.lock | 200+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
MCargo.toml | 4+++-
Mcontracts/api_baselines/radroots.txt | 10++++++++++
Mcontracts/coverage-profiles.toml | 6++++++
Mcontracts/coverage.toml | 1+
Mcontracts/crates/catalog.v2.toml | 20+++++++++++++++++++-
Mcontracts/crates/generated/package_groups.v1.toml | 14+++++++-------
Mcontracts/crates/generated/platform_inventory.v1.toml | 4++--
Mcontracts/crates/generated/release_inventory.v2.toml | 4++--
Mcontracts/releases/publish_policy.toml | 1+
Mcontracts/releases/safety_matrix.toml | 1+
Mcrates/radroots/src/domain.rs | 5+++--
Mcrates/radroots/src/lib.rs | 3+++
Mcrates/radroots/tests/package_boundary.rs | 9++++++++-
Acrates/radroots_ffi/Cargo.toml | 28++++++++++++++++++++++++++++
Acrates/radroots_ffi/README.md | 33+++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/src/client.rs | 130+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/src/error.rs | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/src/inputs.rs | 114+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/src/lib.rs | 23+++++++++++++++++++++++
Acrates/radroots_ffi/src/receipt.rs | 293+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/src/states.rs | 121+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/src/values.rs | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/inputs.rs | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/Cargo.lock | 3276+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/Cargo.toml | 38++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/README.md | 38++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/Smoke.kt | 177+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/Smoke.swift | 196+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/qualify.mjs | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/src/lib.rs | 364+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/src/relay.rs | 179+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/src/signer.rs | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/radroots_ffi/tests/native/tests/flows.rs | 452+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/sdk_ffi/Cargo.toml | 2+-
Mtools/xtask/Cargo.toml | 8++++++++
Atools/xtask/src/bin/radroots_ffi_bindgen/async.swift | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/xtask/src/bin/radroots_ffi_bindgen/kotlin.rs | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/xtask/src/bin/radroots_ffi_bindgen/main.rs | 125+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/xtask/src/bin/radroots_ffi_bindgen/swift.rs | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtools/xtask/src/catalog.rs | 2++
Mtools/xtask/src/coverage.rs | 175++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mtools/xtask/src/sdk_generation/bindings.rs | 2+-
43 files changed, 6688 insertions(+), 76 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -132,7 +132,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -143,7 +143,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -160,11 +160,11 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "askama" -version = "0.13.1" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4744ed2eef2645831b441d8f5459689ade2ab27c854488fbab1fbe94fce1a7" +checksum = "6024d73179f43f15ccd2b881bfea6fee7f3a46ec53f33b52210dea749ebebaa4" dependencies = [ - "askama_derive", + "askama_macros", "itoa", "percent-encoding", "serde", @@ -173,31 +173,42 @@ dependencies = [ [[package]] name = "askama_derive" -version = "0.13.1" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d661e0f57be36a5c14c48f78d09011e67e0cb618f269cca9f2fd8d15b68c46ac" +checksum = "071ee5ebf2138e3ad180e0aacf6940c2cab5e6d8333741d9925c7bee2b153f39" dependencies = [ "askama_parser", "basic-toml", + "glob", "memchr", "proc-macro2", "quote", "rustc-hash 2.1.3", "serde", "serde_derive", - "syn 2.0.117", + "syn 3.0.2", +] + +[[package]] +name = "askama_macros" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643e1c7cbb6aec1d920332fe51a7c0d8219e273dcb8602db03f5263e4d16487b" +dependencies = [ + "askama_derive", ] [[package]] name = "askama_parser" -version = "0.13.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f" +checksum = "2c5ae75772275d268b03ab8bdccdd12117b6169ee23256942b34e46c9f476583" dependencies = [ - "memchr", + "rustc-hash 2.1.3", "serde", "serde_derive", - "winnow", + "unicode-ident", + "winnow 1.0.4", ] [[package]] @@ -240,6 +251,19 @@ dependencies = [ ] [[package]] +name = "async-compat" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ba85bc55464dcbf728b56d97e119d673f4cf9062be330a9a26f3acf504a590" +dependencies = [ + "futures-core", + "futures-io", + "once_cell", + "pin-project-lite", + "tokio", +] + +[[package]] name = "async-trait" version = "0.1.91" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -541,18 +565,19 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.9" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +checksum = "dd0061da739915fae12ea00e16397555ed4371a6bb285431aab930f61b0aa4ba" dependencies = [ "serde", + "serde_core", ] [[package]] name = "cargo_metadata" -version = "0.19.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" dependencies = [ "camino", "cargo-platform", @@ -1261,7 +1286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -1438,9 +1463,9 @@ dependencies = [ [[package]] name = "fs-err" -version = "2.11.0" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +checksum = "b5c95b673b8f6f7235229ae11c5642d81b04c2e64c1e2fb417bc0cf73ca45f29" dependencies = [ "autocfg", ] @@ -2598,7 +2623,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -3012,7 +3037,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -3208,6 +3233,17 @@ dependencies = [ ] [[package]] +name = "radroots_ffi" +version = "0.1.0-alpha" +dependencies = [ + "radroots", + "serde_json", + "thiserror 1.0.69", + "uniffi", + "zeroize", +] + +[[package]] name = "radroots_geonames" version = "0.1.0-alpha" dependencies = [ @@ -4179,7 +4215,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4453,6 +4489,15 @@ dependencies = [ ] [[package]] +name = "serde_spanned" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +dependencies = [ + "serde_core", +] + +[[package]] name = "serde_urlencoded" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4540,9 +4585,9 @@ checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" [[package]] name = "siphasher" -version = "0.3.11" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" [[package]] name = "slab" @@ -4583,7 +4628,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4811,7 +4856,7 @@ dependencies = [ "getrandom 0.3.4", "once_cell", "rustix 1.1.4", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -5023,23 +5068,29 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", + "toml_edit", ] [[package]] name = "toml" -version = "0.8.23" +version = "1.1.8+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", + "indexmap", + "serde_core", + "serde_spanned 1.1.2", + "toml_datetime 1.1.2+spec-1.1.0", + "toml_parser", + "toml_writer", + "winnow 1.0.4", ] [[package]] @@ -5052,6 +5103,15 @@ dependencies = [ ] [[package]] +name = "toml_datetime" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +dependencies = [ + "serde_core", +] + +[[package]] name = "toml_edit" version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -5059,10 +5119,19 @@ checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap", "serde", - "serde_spanned", - "toml_datetime", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", "toml_write", - "winnow", + "winnow 0.7.15", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow 1.0.4", ] [[package]] @@ -5072,6 +5141,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] +name = "toml_writer" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" + +[[package]] name = "tower" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -5220,9 +5295,9 @@ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "uniffi" -version = "0.29.5" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3291800a6b06569f7d3e15bdb6dc235e0f0c8bd3eb07177f430057feb076415f" +checksum = "76407f5f396a2c949a069eff4a9fca9ce462410eb872bffef4c2b7b89804a77a" dependencies = [ "anyhow", "camino", @@ -5236,9 +5311,9 @@ dependencies = [ [[package]] name = "uniffi_bindgen" -version = "0.29.5" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a04b99fa7796eaaa7b87976a0dbdd1178dc1ee702ea00aca2642003aef9b669e" +checksum = "3df3ced8f0eda3de99f6d50820e8628f443da8e4f447f477d1403ceba29dacbd" dependencies = [ "anyhow", "askama", @@ -5253,7 +5328,7 @@ dependencies = [ "serde", "tempfile", "textwrap", - "toml 0.5.11", + "toml 1.1.8+spec-1.1.0", "uniffi_internal_macros", "uniffi_meta", "uniffi_pipeline", @@ -5262,11 +5337,12 @@ dependencies = [ [[package]] name = "uniffi_core" -version = "0.29.5" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f38a9a27529ccff732f8efddb831b65b1e07f7dea3fd4cacd4a35a8c4b253b98" +checksum = "f7530ae8efeaaa488622865966763fe0294832779fff80508c36d69c6a874a6a" dependencies = [ "anyhow", + "async-compat", "bytes", "once_cell", "static_assertions", @@ -5274,9 +5350,9 @@ dependencies = [ [[package]] name = "uniffi_internal_macros" -version = "0.29.5" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09acd2ce09c777dd65ee97c251d33c8a972afc04873f1e3b21eb3492ade16933" +checksum = "0f4bad017164375d99450d70495014810d15a84ba9da6ed14b9628b1424223ba" dependencies = [ "anyhow", "indexmap", @@ -5287,9 +5363,9 @@ dependencies = [ [[package]] name = "uniffi_macros" -version = "0.29.5" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5596f178c4f7aafa1a501c4e0b96236a96bc2ef92bdb453d83e609dad0040152" +checksum = "5b855a58da153739ce6e863f6e296edc3716a093768c4d3d957f17f5e4317c60" dependencies = [ "camino", "fs-err", @@ -5298,15 +5374,15 @@ dependencies = [ "quote", "serde", "syn 2.0.117", - "toml 0.5.11", + "toml 1.1.8+spec-1.1.0", "uniffi_meta", ] [[package]] name = "uniffi_meta" -version = "0.29.5" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beadc1f460eb2e209263c49c4f5b19e9a02e00a3b2b393f78ad10d766346ecff" +checksum = "af0c88664a9cb9559856f5a250283c9708923b303170e2e5c7db8f4ad65e9459" dependencies = [ "anyhow", "siphasher", @@ -5316,9 +5392,9 @@ dependencies = [ [[package]] name = "uniffi_pipeline" -version = "0.29.5" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd76b3ac8a2d964ca9fce7df21c755afb4c77b054a85ad7a029ad179cc5abb8a" +checksum = "d00f5c044b4a3dca0b1226c92ddaeea626f337470e22180dd182160c87a06b0b" dependencies = [ "anyhow", "heck", @@ -5329,9 +5405,9 @@ dependencies = [ [[package]] name = "uniffi_udl" -version = "0.29.5" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319cf905911d70d5b97ce0f46f101619a22e9a189c8c46d797a9955e9233716" +checksum = "55dfd9c778d6b39cb5acd541d9ff63431974035d2bad83c897b766a6ee3152ac" dependencies = [ "anyhow", "textwrap", @@ -5737,7 +5813,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -5980,6 +6056,15 @@ dependencies = [ ] [[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" +dependencies = [ + "memchr", +] + +[[package]] name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -6143,6 +6228,8 @@ dependencies = [ name = "xtask" version = "0.1.0-alpha" dependencies = [ + "anyhow", + "camino", "clap", "dto_bindgen_backend_ts", "dto_bindgen_core", @@ -6170,6 +6257,7 @@ dependencies = [ "tar", "tempfile", "toml 0.8.23", + "uniffi_bindgen", "walkdir", ] diff --git a/Cargo.toml b/Cargo.toml @@ -49,6 +49,7 @@ members = [ "crates/identity_bindings", "crates/radroots", "crates/radroots_browser", + "crates/radroots_ffi", "crates/replica_schema_bindings", "crates/replica_store_wasm", "crates/replica_sync_wasm", @@ -142,6 +143,7 @@ radroots_transport_nostr = { package = "radroots_transport_nostr", path = "crate radroots_transport_nostr_native = { package = "radroots_transport_nostr_native", path = "crates/transport_nostr_native", version = "=0.1.0-alpha", default-features = false } radroots_transport_nostr_browser = { path = "crates/transport_nostr_browser", version = "=0.1.0-alpha", default-features = false } radroots_browser = { path = "crates/radroots_browser", version = "=0.1.0-alpha", default-features = false } +radroots_ffi = { path = "crates/radroots_ffi", version = "=0.1.0-alpha", default-features = false } radroots_transport_reticulum = { path = "crates/transport_reticulum", version = "=0.1.0-alpha", default-features = false } radroots_simplex_agent_proto = { path = "crates/simplex_agent_proto", version = "=0.1.0-alpha", default-features = false } radroots_simplex_chat_proto = { path = "crates/simplex_chat_proto", version = "=0.1.0-alpha", default-features = false } @@ -283,7 +285,7 @@ unicode-general-category = { version = "=1.1.0" } url = { version = "2" } url_nostd = { package = "url", version = "2", default-features = false } uuid = { version = "1.22.0", features = ["v4", "v7"] } -uniffi = { version = "0.29.4" } +uniffi = { version = "=0.32.2", default-features = false } wasm-bindgen = { version = "0.2" } wasm-bindgen-futures = { version = "0.4" } wasm-bindgen-test = { version = "0.3" } diff --git a/contracts/api_baselines/radroots.txt b/contracts/api_baselines/radroots.txt @@ -1,13 +1,17 @@ pub mod radroots +pub use radroots::Admission pub use radroots::ArtifactObservation pub use radroots::AttachmentInput pub use radroots::AttachmentProof pub use radroots::BusinessInstallation +pub use radroots::Code pub use radroots::CommandContext +pub use radroots::CommandError pub use radroots::Delivery pub use radroots::DeliveryObservation pub use radroots::Error pub use radroots::Issuance +pub use radroots::OperationContext pub use radroots::OperationId pub use radroots::OperationKind pub use radroots::OperationReceipt @@ -15,6 +19,8 @@ pub use radroots::OperationStatus pub use radroots::OperationValue pub use radroots::RecoveryRequirement pub use radroots::Result +pub use radroots::RetryClass +pub use radroots::SessionState pub use radroots::StartMode pub use radroots::TargetObservation pub use radroots::WaitTermination @@ -54,6 +60,8 @@ pub use radroots::domain::AmountError pub use radroots::domain::CHAT_MAX_BYTES pub use radroots::domain::ChatMessage pub use radroots::domain::ChatRelation +pub use radroots::domain::CommandDigest +pub use radroots::domain::CorrelationId pub use radroots::domain::Decimal pub use radroots::domain::ExecutorId pub use radroots::domain::IdentifierError @@ -62,7 +70,9 @@ pub use radroots::domain::MessageId pub use radroots::domain::OperationId pub use radroots::domain::OrderId pub use radroots::domain::PositiveDecimal +pub use radroots::domain::SourceId pub use radroots::domain::ThreadId +pub use radroots::domain::UnixSeconds pub use radroots::domain::WorkspaceId pub mod radroots::event pub use radroots::event::Error diff --git a/contracts/coverage-profiles.toml b/contracts/coverage-profiles.toml @@ -21,6 +21,12 @@ no_default_features = false features = ["native"] test_threads = 1 +[profiles.crates."radroots_ffi"] +features = [] +test_manifest = "crates/radroots_ffi/tests/native/Cargo.toml" +test_packages = ["radroots_native_binding_fixture"] +test_threads = 1 + [profiles.crates."radroots_log"] no_default_features = true features = [] diff --git a/contracts/coverage.toml b/contracts/coverage.toml @@ -54,6 +54,7 @@ crates = [ "radroots_core_bindings", "radroots_domain", "radroots_execution", + "radroots_ffi", "radroots_event", "radroots_event_bindings", "radroots_event_codec", diff --git a/contracts/crates/catalog.v2.toml b/contracts/crates/catalog.v2.toml @@ -7,7 +7,7 @@ rust_version = "1.99.0" edition = "2024" resolver = "3" public_package_count = 22 -package_count = 57 +package_count = 58 digest_algorithm = "sha256-raw-bytes-v1" source_tree_digest_algorithm = "sha256-git-ls-tree-r-v1" native_introduction_tree_digest_algorithm = "sha256-git-tree-records-z-v1" @@ -1426,6 +1426,24 @@ compatibility = ["wasm", "generated", "package_private"] replaces = [] [[package]] +name = "radroots_ffi" +path = "crates/radroots_ffi" +state = "active" +tier = "boundary" +visibility = "private_boundary" +publish = false +version = "0.1.0-alpha" +license = "MIT OR Apache-2.0" +platforms = ["native"] +groups = ["coverage_required", "sdk", "boundaries"] +owners = ["sdk"] +permitted_dependency_tiers = ["facade"] +provenance_kind = "native" +introduction_tree_sha256 = "06ea28181dbf5bcf2033b7d8a9b30f5a0f8ceb60e4953664c5fcf127d37f3aca" +compatibility = ["ffi", "generated", "package_private", "behavior"] +replaces = [] + +[[package]] name = "radroots_sdk_ffi" path = "crates/sdk_ffi" state = "active" diff --git a/contracts/crates/generated/package_groups.v1.toml b/contracts/crates/generated/package_groups.v1.toml @@ -1,16 +1,16 @@ schema = "radroots.workspace.package-groups.v1" -catalog_sha256 = "12fe6f5f020e988da3fa6f37319ffe17bc64d16acb4dce7a5d9d539c06f6b8cb" +catalog_sha256 = "424909855b2af1ffc8fa6bbfd5aa0e6d17642662c18212fef4660e71700fbfc8" [[group]] id = "boundaries" -packages = ["radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_identity_bindings", "radroots_replica_schema_bindings", "radroots_replica_store_wasm", "radroots_replica_sync_wasm", "radroots_sdk_ffi", "radroots_trade_bindings"] -active_packages = ["radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_identity_bindings", "radroots_replica_schema_bindings", "radroots_replica_store_wasm", "radroots_replica_sync_wasm", "radroots_sdk_ffi", "radroots_trade_bindings"] +packages = ["radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_ffi", "radroots_identity_bindings", "radroots_replica_schema_bindings", "radroots_replica_store_wasm", "radroots_replica_sync_wasm", "radroots_sdk_ffi", "radroots_trade_bindings"] +active_packages = ["radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_ffi", "radroots_identity_bindings", "radroots_replica_schema_bindings", "radroots_replica_store_wasm", "radroots_replica_sync_wasm", "radroots_sdk_ffi", "radroots_trade_bindings"] reserved_packages = [] [[group]] id = "coverage_required" -packages = ["radroots", "radroots_blossom", "radroots_browser", "radroots_core", "radroots_core_bindings", "radroots_domain", "radroots_event", "radroots_event_bindings", "radroots_event_codec", "radroots_event_codec_wasm", "radroots_execution", "radroots_geonames", "radroots_identity", "radroots_identity_bindings", "radroots_mesh", "radroots_mesh_agent_client", "radroots_mesh_agent_proto", "radroots_nostr", "radroots_nostr_connect", "radroots_nostrdb", "radroots_protocol", "radroots_replica_schema", "radroots_replica_schema_bindings", "radroots_replica_store", "radroots_replica_store_wasm", "radroots_replica_sync", "radroots_replica_sync_wasm", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", "radroots_sdk", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_secrets", "radroots_service_host", "radroots_service_sqlite", "radroots_signing", "radroots_sql_core", "radroots_storage", "radroots_storage_indexeddb", "radroots_storage_sqlite", "radroots_sync", "radroots_test_fixtures", "radroots_trade", "radroots_trade_bindings", "radroots_transport", "radroots_transport_nostr", "radroots_transport_nostr_browser", "radroots_transport_nostr_native", "radroots_transport_reticulum", "xtask"] -active_packages = ["radroots", "radroots_blossom", "radroots_browser", "radroots_core", "radroots_core_bindings", "radroots_domain", "radroots_event", "radroots_event_bindings", "radroots_event_codec", "radroots_event_codec_wasm", "radroots_execution", "radroots_geonames", "radroots_identity", "radroots_identity_bindings", "radroots_mesh", "radroots_mesh_agent_client", "radroots_mesh_agent_proto", "radroots_nostr", "radroots_nostr_connect", "radroots_nostrdb", "radroots_protocol", "radroots_replica_schema", "radroots_replica_schema_bindings", "radroots_replica_store", "radroots_replica_store_wasm", "radroots_replica_sync", "radroots_replica_sync_wasm", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", "radroots_sdk", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_secrets", "radroots_service_host", "radroots_service_sqlite", "radroots_signing", "radroots_sql_core", "radroots_storage", "radroots_storage_indexeddb", "radroots_storage_sqlite", "radroots_sync", "radroots_test_fixtures", "radroots_trade", "radroots_trade_bindings", "radroots_transport", "radroots_transport_nostr", "radroots_transport_nostr_browser", "radroots_transport_nostr_native", "radroots_transport_reticulum", "xtask"] +packages = ["radroots", "radroots_blossom", "radroots_browser", "radroots_core", "radroots_core_bindings", "radroots_domain", "radroots_event", "radroots_event_bindings", "radroots_event_codec", "radroots_event_codec_wasm", "radroots_execution", "radroots_ffi", "radroots_geonames", "radroots_identity", "radroots_identity_bindings", "radroots_mesh", "radroots_mesh_agent_client", "radroots_mesh_agent_proto", "radroots_nostr", "radroots_nostr_connect", "radroots_nostrdb", "radroots_protocol", "radroots_replica_schema", "radroots_replica_schema_bindings", "radroots_replica_store", "radroots_replica_store_wasm", "radroots_replica_sync", "radroots_replica_sync_wasm", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", "radroots_sdk", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_secrets", "radroots_service_host", "radroots_service_sqlite", "radroots_signing", "radroots_sql_core", "radroots_storage", "radroots_storage_indexeddb", "radroots_storage_sqlite", "radroots_sync", "radroots_test_fixtures", "radroots_trade", "radroots_trade_bindings", "radroots_transport", "radroots_transport_nostr", "radroots_transport_nostr_browser", "radroots_transport_nostr_native", "radroots_transport_reticulum", "xtask"] +active_packages = ["radroots", "radroots_blossom", "radroots_browser", "radroots_core", "radroots_core_bindings", "radroots_domain", "radroots_event", "radroots_event_bindings", "radroots_event_codec", "radroots_event_codec_wasm", "radroots_execution", "radroots_ffi", "radroots_geonames", "radroots_identity", "radroots_identity_bindings", "radroots_mesh", "radroots_mesh_agent_client", "radroots_mesh_agent_proto", "radroots_nostr", "radroots_nostr_connect", "radroots_nostrdb", "radroots_protocol", "radroots_replica_schema", "radroots_replica_schema_bindings", "radroots_replica_store", "radroots_replica_store_wasm", "radroots_replica_sync", "radroots_replica_sync_wasm", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", "radroots_sdk", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_secrets", "radroots_service_host", "radroots_service_sqlite", "radroots_signing", "radroots_sql_core", "radroots_storage", "radroots_storage_indexeddb", "radroots_storage_sqlite", "radroots_sync", "radroots_test_fixtures", "radroots_trade", "radroots_trade_bindings", "radroots_transport", "radroots_transport_nostr", "radroots_transport_nostr_browser", "radroots_transport_nostr_native", "radroots_transport_reticulum", "xtask"] reserved_packages = [] [[group]] @@ -33,8 +33,8 @@ reserved_packages = [] [[group]] id = "sdk" -packages = ["radroots", "radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_identity_bindings", "radroots_replica_schema_bindings", "radroots_replica_store_wasm", "radroots_replica_sync_wasm", "radroots_sdk", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_trade_bindings"] -active_packages = ["radroots", "radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_identity_bindings", "radroots_replica_schema_bindings", "radroots_replica_store_wasm", "radroots_replica_sync_wasm", "radroots_sdk", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_trade_bindings"] +packages = ["radroots", "radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_ffi", "radroots_identity_bindings", "radroots_replica_schema_bindings", "radroots_replica_store_wasm", "radroots_replica_sync_wasm", "radroots_sdk", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_trade_bindings"] +active_packages = ["radroots", "radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_ffi", "radroots_identity_bindings", "radroots_replica_schema_bindings", "radroots_replica_store_wasm", "radroots_replica_sync_wasm", "radroots_sdk", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_trade_bindings"] reserved_packages = [] [[group]] diff --git a/contracts/crates/generated/platform_inventory.v1.toml b/contracts/crates/generated/platform_inventory.v1.toml @@ -1,5 +1,5 @@ schema = "radroots.workspace.platform-inventory.v1" -catalog_sha256 = "12fe6f5f020e988da3fa6f37319ffe17bc64d16acb4dce7a5d9d539c06f6b8cb" +catalog_sha256 = "424909855b2af1ffc8fa6bbfd5aa0e6d17642662c18212fef4660e71700fbfc8" [[platform]] id = "any" @@ -7,7 +7,7 @@ packages = ["radroots", "radroots_blossom", "radroots_core", "radroots_domain", [[platform]] id = "native" -packages = ["radroots_core_bindings", "radroots_event_bindings", "radroots_geonames", "radroots_identity_bindings", "radroots_mesh", "radroots_mesh_agent_client", "radroots_nostrdb", "radroots_replica_schema_bindings", "radroots_replica_store", "radroots_replica_sync", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", "radroots_sdk_ffi", "radroots_secrets", "radroots_service_host", "radroots_service_sqlite", "radroots_simplex_app_store", "radroots_simplex_smp_transport", "radroots_sql_core", "radroots_storage", "radroots_storage_sqlite", "radroots_sync", "radroots_trade_bindings", "radroots_transport_nostr", "radroots_transport_nostr_native", "radroots_transport_reticulum", "xtask"] +packages = ["radroots_core_bindings", "radroots_event_bindings", "radroots_ffi", "radroots_geonames", "radroots_identity_bindings", "radroots_mesh", "radroots_mesh_agent_client", "radroots_nostrdb", "radroots_replica_schema_bindings", "radroots_replica_store", "radroots_replica_sync", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", "radroots_sdk_ffi", "radroots_secrets", "radroots_service_host", "radroots_service_sqlite", "radroots_simplex_app_store", "radroots_simplex_smp_transport", "radroots_sql_core", "radroots_storage", "radroots_storage_sqlite", "radroots_sync", "radroots_trade_bindings", "radroots_transport_nostr", "radroots_transport_nostr_native", "radroots_transport_reticulum", "xtask"] [[platform]] id = "wasm32" diff --git a/contracts/crates/generated/release_inventory.v2.toml b/contracts/crates/generated/release_inventory.v2.toml @@ -1,7 +1,7 @@ schema = "radroots.workspace.release-inventory.v2" -catalog_sha256 = "12fe6f5f020e988da3fa6f37319ffe17bc64d16acb4dce7a5d9d539c06f6b8cb" +catalog_sha256 = "424909855b2af1ffc8fa6bbfd5aa0e6d17642662c18212fef4660e71700fbfc8" architecture = "radroots.crates.release.v2" version = "0.1.0-alpha" public_packages = ["radroots", "radroots_blossom", "radroots_core", "radroots_domain", "radroots_event", "radroots_event_codec", "radroots_execution", "radroots_geonames", "radroots_identity", "radroots_nostr", "radroots_nostr_connect", "radroots_protocol", "radroots_sdk", "radroots_secrets", "radroots_signing", "radroots_storage", "radroots_storage_sqlite", "radroots_sync", "radroots_trade", "radroots_transport", "radroots_transport_nostr", "radroots_transport_nostr_native"] -private_packages = ["radroots_browser", "radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_identity_bindings", "radroots_mesh", "radroots_mesh_agent_client", "radroots_mesh_agent_proto", "radroots_nostrdb", "radroots_replica_schema", "radroots_replica_schema_bindings", "radroots_replica_store", "radroots_replica_store_wasm", "radroots_replica_sync", "radroots_replica_sync_wasm", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_service_host", "radroots_service_sqlite", "radroots_simplex_agent_proto", "radroots_simplex_app_store", "radroots_simplex_chat_proto", "radroots_simplex_smp_crypto", "radroots_simplex_smp_proto", "radroots_simplex_smp_transport", "radroots_sql_core", "radroots_storage_indexeddb", "radroots_test_fixtures", "radroots_trade_bindings", "radroots_transport_nostr_browser", "radroots_transport_reticulum", "xtask"] +private_packages = ["radroots_browser", "radroots_core_bindings", "radroots_event_bindings", "radroots_event_codec_wasm", "radroots_ffi", "radroots_identity_bindings", "radroots_mesh", "radroots_mesh_agent_client", "radroots_mesh_agent_proto", "radroots_nostrdb", "radroots_replica_schema", "radroots_replica_schema_bindings", "radroots_replica_store", "radroots_replica_store_wasm", "radroots_replica_sync", "radroots_replica_sync_wasm", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", "radroots_sdk_ffi", "radroots_sdk_sql_wasm_runtime", "radroots_service_host", "radroots_service_sqlite", "radroots_simplex_agent_proto", "radroots_simplex_app_store", "radroots_simplex_chat_proto", "radroots_simplex_smp_crypto", "radroots_simplex_smp_proto", "radroots_simplex_smp_transport", "radroots_sql_core", "radroots_storage_indexeddb", "radroots_test_fixtures", "radroots_trade_bindings", "radroots_transport_nostr_browser", "radroots_transport_reticulum", "xtask"] reserved_packages = [] diff --git a/contracts/releases/publish_policy.toml b/contracts/releases/publish_policy.toml @@ -59,6 +59,7 @@ external_packages = [] [workspace_classification] private = [ "radroots_browser", + "radroots_ffi", "radroots_runtime_distribution", "radroots_runtime_manager", "radroots_runtime_paths", diff --git a/contracts/releases/safety_matrix.toml b/contracts/releases/safety_matrix.toml @@ -51,6 +51,7 @@ targets = [ "x86_64-unknown-linux-gnu", ] packages = [ + "radroots_ffi", "radroots_sdk_ffi", "radroots_storage_sqlite", "radroots_runtime_manager", diff --git a/crates/radroots/src/domain.rs b/crates/radroots/src/domain.rs @@ -4,6 +4,7 @@ //! participant, select an executor or prove durable command admission. pub use radroots_domain::{ - AmountError, CHAT_MAX_BYTES, ChatMessage, ChatRelation, Decimal, ExecutorId, IdentifierError, - MessageError, MessageId, OperationId, OrderId, PositiveDecimal, ThreadId, WorkspaceId, + AmountError, CHAT_MAX_BYTES, ChatMessage, ChatRelation, CommandDigest, CorrelationId, Decimal, + ExecutorId, IdentifierError, MessageError, MessageId, OperationId, OrderId, PositiveDecimal, + SourceId, ThreadId, UnixSeconds, WorkspaceId, }; diff --git a/crates/radroots/src/lib.rs b/crates/radroots/src/lib.rs @@ -29,11 +29,14 @@ mod native_commands; pub use client::NativeConfig; pub use client::{Client, CloseReceipt, SessionStatus, StartMode}; pub use radroots_domain::OperationId; +pub use radroots_execution::session::SessionState; pub use radroots_execution::workspace::{CommandContext, WorkspaceSession}; +pub use radroots_execution::{Admission, Code, OperationContext, RetryClass}; pub use radroots_execution::{ ArtifactObservation, BusinessInstallation, Delivery, DeliveryObservation, Issuance, OperationKind, OperationReceipt, OperationStatus, OperationValue, RecoveryRequirement, TargetObservation, WaitTermination, }; pub use radroots_execution::{Error, Result}; +pub use radroots_protocol::command::CommandError; pub use radroots_storage::workspace::{AttachmentInput, AttachmentProof}; diff --git a/crates/radroots/tests/package_boundary.rs b/crates/radroots/tests/package_boundary.rs @@ -73,7 +73,14 @@ fn root_has_exact_exports_and_no_sdk_namespace() { "pub use radroots_execution::{\n ArtifactObservation, BusinessInstallation, Delivery, DeliveryObservation, Issuance,\n OperationKind, OperationReceipt, OperationStatus, OperationValue, RecoveryRequirement,\n TargetObservation, WaitTermination,\n};" )); assert!(ROOT.contains("pub mod listings;")); - assert_eq!(ROOT.matches("pub use ").count(), 7); + assert!(ROOT.contains("pub use radroots_execution::session::SessionState;")); + assert!( + ROOT.contains( + "pub use radroots_execution::{Admission, Code, OperationContext, RetryClass};" + ) + ); + assert!(ROOT.contains("pub use radroots_protocol::command::CommandError;")); + assert_eq!(ROOT.matches("pub use ").count(), 10); assert!(README.contains("```compile_fail\nuse radroots::sdk;\n```")); } diff --git a/crates/radroots_ffi/Cargo.toml b/crates/radroots_ffi/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "radroots_ffi" +description = "Concrete native language boundary over the Radroots client" +version = "0.1.0-alpha" +edition.workspace = true +rust-version.workspace = true +license.workspace = true +authors.workspace = true +repository.workspace = true +homepage.workspace = true +readme = "README.md" +publish = false + +[lib] +crate-type = ["lib", "staticlib", "cdylib"] + +[features] +default = [] + +[dependencies] +radroots = { path = "../radroots", version = "=0.1.0-alpha", default-features = false, features = ["native"] } +serde_json = { workspace = true, features = ["std"] } +thiserror = { workspace = true } +uniffi = { workspace = true, features = ["tokio"] } +zeroize = { workspace = true, features = ["alloc"] } + +[lints] +workspace = true diff --git a/crates/radroots_ffi/README.md b/crates/radroots_ffi/README.md @@ -0,0 +1,33 @@ +# Radroots native bindings + +This source owns the concrete UniFFI boundary over the current `radroots` +client. Native app startup supplies its actual configured client and actual +authenticated workspace through the Rust host constructors. Foreign input +cannot create a grant, signer claim or delivery permission. + +Known input validation and command execution remain in shared Rust. The +boundary owns language conversion, with exact identifiers and integer/decimal +strings, explicit optional values and tagged business results. It does not +implement a second command engine, storage adapter, signer or retry policy. + +Host injection is distinct from a general foreign-language open/enrollment +factory, platform custody and callback qualification. These additional surfaces +must be implemented and exercised before they are advertised. This package is +not a compatibility wrapper for `radroots_sdk_ffi`. + +Lib's private `xtask` tooling owns the `radroots_ffi_bindgen` executable. It +pins UniFFI0.32.2 and applies +the `radroots-close-v1` Kotlin generation policy. When the actual native +metadata declares `close`, generated `close` calls that method; the conflicting +automatic AutoCloseable destruction alias is omitted. `destroy` remains the +explicit generated handle-release operation. It is not asynchronous resource +closure. Other generated objects retain their ordinary AutoCloseable behavior. +Generation fails if the expected upstream template shape changes. Outputs are +produced in staging and must use a new output directory and `--no-format`. + +The `radroots-swift-cancellation-v1` policy also connects Swift task cancellation +to the existing Rust-future cancel ABI and converts its cancelled status into +`CancellationError`. A synchronized lifetime owner prevents cancellation from +using a released handle. Already-cancelled calls refuse before creating a Rust +future. Cancellation ends observation; the shared runtime retains admitted +work and obtained material. No command lifecycle is implemented in Swift. diff --git a/crates/radroots_ffi/src/client.rs b/crates/radroots_ffi/src/client.rs @@ -0,0 +1,130 @@ +use crate::{CommandRequest, Error, InquiryInput, ListingInput, Receipt, SessionState, StartMode}; +use radroots::domain::{CommandDigest, OperationId}; +use std::sync::Arc; + +/// Holds the actual native owner; no FFI runtime or outbox is added. +#[derive(uniffi::Object)] +pub struct NativeClient { + inner: radroots::Client, +} +impl NativeClient { + /// Native host startup supplies its explicitly configured shared client. + /// This Rust constructor performs no additional attachment or activation. + pub fn from_native(inner: radroots::Client) -> Arc<Self> { + Arc::new(Self { inner }) + } +} + +/// Holds an actual authenticated shared scope. Descriptors cannot construct it. +#[derive(uniffi::Object)] +pub struct Workspace { + inner: radroots::WorkspaceSession, +} +impl Workspace { + /// Injects a scope obtained by actual shared-client authentication. The + /// client still enforces that it owns this scope on every command/query. + pub fn from_session(inner: radroots::WorkspaceSession) -> Arc<Self> { + Arc::new(Self { inner }) + } +} +#[uniffi::export] +impl Workspace { + /// Releases this attachment's credential root without revoking its grant. + pub fn close(&self) { + self.inner.close(); + } +} + +#[uniffi::export(async_runtime = "tokio")] +impl NativeClient { + pub fn state(&self) -> SessionState { + self.inner.state().into() + } + pub async fn start(&self, mode: StartMode) -> Result<SessionState, Error> { + self.inner + .start(mode.into()) + .await + .map(|v| v.state().into()) + .map_err(Error::from) + } + /// Completion is the shared owner's actual confirmed resource closure. + pub async fn close(&self) -> Result<(), Error> { + self.inner.close().await.map(|_| ()).map_err(Error::from) + } + pub async fn publish_listing( + &self, + workspace: Arc<Workspace>, + request: CommandRequest, + input: Arc<ListingInput>, + ) -> Result<Receipt, Error> { + let context = request.capture(&workspace.inner)?; + let receipt = self + .inner + .listings() + .publish(context, input.inner.clone()) + .await + .map_err(Error::from)?; + Receipt::listing(&receipt) + } + pub async fn inquire( + &self, + workspace: Arc<Workspace>, + request: CommandRequest, + input: Arc<InquiryInput>, + ) -> Result<Receipt, Error> { + let context = request.capture(&workspace.inner)?; + let receipt = self + .inner + .inbox() + .inquire(context, input.captured_copy()?) + .await + .map_err(Error::from)?; + Receipt::chat(&receipt) + } + /// Scoped observation only; absence never proves safe nonissuance. + pub async fn operation( + &self, + workspace: Arc<Workspace>, + operation_id: String, + expected_digest: Option<String>, + ) -> Result<Option<Receipt>, Error> { + let (operation, expected) = selector(&operation_id, expected_digest.as_deref())?; + self.inner + .operations(&workspace.inner) + .get_matching(operation, expected) + .await + .map_err(Error::from)? + .as_ref() + .map(Receipt::status) + .transpose() + } + /// Explicit continuation through the original shared owner and policy. + pub async fn resume( + &self, + workspace: Arc<Workspace>, + operation_id: String, + expected_digest: Option<String>, + ) -> Result<Receipt, Error> { + let (operation, expected) = selector(&operation_id, expected_digest.as_deref())?; + let receipt = self + .inner + .operations(&workspace.inner) + .resume(operation, expected) + .await + .map_err(Error::from)?; + Receipt::status(&receipt) + } +} +fn selector( + operation: &str, + expected: Option<&str>, +) -> Result<(OperationId, Option<CommandDigest>), Error> { + let operation = operation + .parse() + .map_err(|_| Error::input("operation_id"))?; + let expected = expected + .map(str::parse) + .transpose() + .map_err(|_| Error::input("command_digest"))?; + Ok((operation, expected)) +} diff --git a/crates/radroots_ffi/src/error.rs b/crates/radroots_ffi/src/error.rs @@ -0,0 +1,81 @@ +use crate::Admission; + +/// Pure command-parser failures retained across the native boundary. +#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)] +pub enum InputFailure { + UnsupportedCommand, + UnsupportedProfile, + LimitExceeded, +} + +/// Input-free failures; native details never become dependency/debug prose. +#[derive(Clone, Debug, thiserror::Error, uniffi::Error)] +pub enum Error { + #[error("invalid {field}")] + InvalidInput { field: String }, + #[error("unsupported or bounded {field}: {kind:?}")] + CommandInput { field: String, kind: InputFailure }, + #[error("operation {code}")] + Operation { + code: String, + retry: String, + operation_id: Option<String>, + admission: Admission, + }, + #[error("unsupported boundary state {axis}")] + UnsupportedState { + axis: String, + operation_id: Option<String>, + }, +} +impl Error { + pub(crate) fn command(field: &'static str, error: radroots::CommandError) -> Self { + let kind = match error { + radroots::CommandError::InvalidInput => return Self::input(field), + radroots::CommandError::UnsupportedCommand => InputFailure::UnsupportedCommand, + radroots::CommandError::UnsupportedProfile => InputFailure::UnsupportedProfile, + radroots::CommandError::LimitExceeded => InputFailure::LimitExceeded, + _ => { + return Self::UnsupportedState { + axis: "command_input".to_owned(), + operation_id: None, + }; + } + }; + Self::CommandInput { + field: field.to_owned(), + kind, + } + } + pub(crate) fn input(field: &'static str) -> Self { + Self::InvalidInput { + field: field.to_owned(), + } + } + pub(crate) fn with_operation(self, id: String) -> Self { + match self { + Self::UnsupportedState { axis, .. } => Self::UnsupportedState { + axis, + operation_id: Some(id), + }, + value => value, + } + } +} +impl From<radroots::Error> for Error { + fn from(value: radroots::Error) -> Self { + let operation_id = value.context().operation_id().map(|v| v.to_string()); + match Admission::try_from(value.context().admission()) { + Ok(admission) => Self::Operation { + code: value.code().as_str().to_owned(), + retry: value.retry().as_str().to_owned(), + operation_id, + admission, + }, + Err(Self::UnsupportedState { axis, .. }) => { + Self::UnsupportedState { axis, operation_id } + } + Err(other) => other, + } + } +} diff --git a/crates/radroots_ffi/src/inputs.rs b/crates/radroots_ffi/src/inputs.rs @@ -0,0 +1,114 @@ +use crate::Error; +use radroots::domain::{CorrelationId, OperationId, SourceId, ThreadId, UnixSeconds}; +use std::sync::Arc; + +/// Explicit first-issue context for the currently supported known commands. +#[derive(Clone, uniffi::Record)] +pub struct CommandRequest { + pub operation_id: String, + pub first_issue_not_after: String, + pub correlation_id: Option<String>, +} +impl CommandRequest { + pub(crate) fn capture( + self, + scope: &radroots::WorkspaceSession, + ) -> Result<radroots::CommandContext, Error> { + let operation: OperationId = self + .operation_id + .parse() + .map_err(|_| Error::input("operation_id"))?; + let time: UnixSeconds = self + .first_issue_not_after + .parse() + .map_err(|_| Error::input("first_issue_not_after"))?; + let correlation = self + .correlation_id + .map(CorrelationId::new) + .transpose() + .map_err(|_| Error::input("correlation_id"))?; + scope + .command_context_with_correlation(operation, None, None, time, correlation) + .map_err(Error::from) + } +} + +/// Validated shared public input. No participant or installation is inferred. +#[derive(uniffi::Object)] +pub struct ListingInput { + pub(crate) inner: radroots::listings::PublishInput, +} +#[uniffi::export] +impl ListingInput { + /// Runs the existing bounded, closed shared parser, before host effects. + #[uniffi::constructor] + pub fn parse(input: Vec<u8>) -> Result<Arc<Self>, Error> { + let inner = radroots::listings::PublishInput::parse(&input) + .map_err(|error| Error::command("listing_input", error))?; + Ok(Arc::new(Self { inner })) + } +} + +/// Public reference descriptor; it authenticates no event, terms or stock. +#[derive(Clone, uniffi::Record)] +pub struct ListingReference { + pub author: String, + pub discriminator: String, + pub event_id: String, +} +impl ListingReference { + fn capture(&self) -> Result<radroots::inbox::ListingRevisionRef, Error> { + let author = public_key(&self.author, "listing_author")?; + let event: SourceId = self + .event_id + .parse() + .map_err(|_| Error::input("listing_event_id"))?; + radroots::inbox::ListingRevisionRef::new(author, &self.discriminator, event) + .map_err(|error| Error::command("listing_reference", error)) + } +} + +/// Shared bounded private input, retained with the source's zeroizing owner. +#[derive(uniffi::Object)] +pub struct InquiryInput { + inner: radroots::inbox::InquireInput, +} +#[uniffi::export] +impl InquiryInput { + #[uniffi::constructor] + pub fn new( + thread_id: String, + peer: String, + source: Option<ListingReference>, + text: String, + ) -> Result<Arc<Self>, Error> { + let text = zeroize::Zeroizing::new(text); + let thread: ThreadId = thread_id.parse().map_err(|_| Error::input("thread_id"))?; + let peer = public_key(&peer, "peer")?; + let source = source.as_ref().map(ListingReference::capture).transpose()?; + let inner = radroots::inbox::InquireInput::new(thread, peer, source, &text) + .map_err(|error| Error::command("inquiry_input", error))?; + Ok(Arc::new(Self { inner })) + } +} +impl InquiryInput { + // Explicit bounded copy into the one execution owner. The retained input + // keeps its own zeroizing storage; there is no unprotected string cache. + pub(crate) fn captured_copy(&self) -> Result<radroots::inbox::InquireInput, Error> { + radroots::inbox::InquireInput::new( + self.inner.thread_id(), + self.inner.peer(), + self.inner.source().cloned(), + self.inner.text(), + ) + .map_err(|error| Error::command("inquiry_input", error)) + } +} + +fn public_key(value: &str, field: &'static str) -> Result<radroots::identity::PublicKey, Error> { + let key = radroots::identity::PublicKey::from_hex(value).map_err(|_| Error::input(field))?; + if key.to_hex() != value { + return Err(Error::input(field)); + } + Ok(key) +} diff --git a/crates/radroots_ffi/src/lib.rs b/crates/radroots_ffi/src/lib.rs @@ -0,0 +1,23 @@ +//! Concrete generated native calls over the one shared Radroots client. +#![forbid(unsafe_code)] +#![doc = include_str!("../README.md")] + +mod client; +mod error; +mod inputs; +mod receipt; +mod states; +mod values; + +pub use client::{NativeClient, Workspace}; +pub use error::{Error, InputFailure}; +pub use inputs::{CommandRequest, InquiryInput, ListingInput, ListingReference}; +pub use receipt::{Artifact, DeliveryAttempt, Observation, Receipt, Target, TargetPolicy}; +pub use states::{ + Admission, ArtifactRole, BusinessInstallation, Delivery, Issuance, OperationKind, + RecoveryRequirement, SatisfactionClass, SessionState, StartMode, TargetObservation, + WaitTermination, +}; +pub use values::{ChatRelation, ChatValue, ListingValue, Value}; + +uniffi::setup_scaffolding!(); diff --git a/crates/radroots_ffi/src/receipt.rs b/crates/radroots_ffi/src/receipt.rs @@ -0,0 +1,293 @@ +use crate::{ + Admission, ArtifactRole, BusinessInstallation, ChatValue, Delivery, Error, Issuance, + ListingValue, OperationKind, RecoveryRequirement, SatisfactionClass, TargetObservation, Value, + WaitTermination, +}; + +/// Exact protected artifact references, without payload or invocation rights. +#[derive(Clone, uniffi::Record)] +pub struct Artifact { + pub role: ArtifactRole, + pub recipient: Option<String>, + pub expected_event: Option<String>, + pub issuance: Issuance, + pub attempt_id: Option<String>, + pub claim_transaction: Option<String>, + pub intent_digest: Option<String>, + pub capture_transaction: Option<String>, + pub obtained_digest: Option<String>, + pub publication_transaction: Option<String>, + pub observed_at_unix_ms: Option<String>, +} +#[derive(Clone, uniffi::Record)] +pub struct Observation { + pub event_id: String, + pub recipient: Option<String>, + pub target: String, + pub request_id: String, + pub target_fingerprint: String, + pub target_ordinal: u8, + pub outcome: TargetObservation, + pub observed_at_unix_ms: Option<String>, +} +#[derive(Clone, uniffi::Enum)] +pub enum TargetPolicy { + Any, + All, + Quorum { threshold: u16 }, + Required { fingerprints: Vec<String> }, +} +#[derive(Clone, uniffi::Record)] +pub struct Target { + pub uri: String, + pub kind: String, + pub fingerprint: String, +} +#[derive(Clone, uniffi::Record)] +pub struct DeliveryAttempt { + pub request_id: String, + pub event_id: String, + pub role: ArtifactRole, + pub recipient: Option<String>, + pub targets: Vec<Target>, + pub selected_fingerprints: Vec<String>, + pub satisfaction_class: SatisfactionClass, + pub policy: TargetPolicy, + pub publication_policy_digest: String, + pub intent_digest: String, + pub original_bytes_digest: String, + pub transaction_id: String, + pub work_transaction_id: String, + pub retained_at: String, + pub deadline_unix_ms: String, + pub target_ordinals: Vec<u8>, +} + +/// Source-projected current facts. This data is never an executable context or +/// a new authority to sign, install, dispatch or infer recipient delivery. +#[derive(Clone, uniffi::Record)] +pub struct Receipt { + pub kind: OperationKind, + pub operation_id: String, + pub captured_context_json: Vec<u8>, + pub command_digest: String, + pub admission: Admission, + pub admission_transaction_id: String, + pub plan_transaction_id: Option<String>, + pub installation_transaction_id: Option<String>, + pub installed_at: Option<String>, + pub prepared_at: String, + pub first_issue_not_after: String, + pub authority_checkpoint_json: Vec<u8>, + pub operation_checkpoint: String, + pub observed_at: String, + pub business_installation: BusinessInstallation, + pub business_result: Option<Value>, + pub issuance: Issuance, + pub delivery: Delivery, + pub wait_termination: WaitTermination, + pub message_id: Option<String>, + pub record_ids: Vec<String>, + pub missing_sources: Vec<String>, + pub conflicting_records: Vec<String>, + pub conflicting_sources: Vec<String>, + pub artifacts: Vec<Artifact>, + pub delivery_attempts: Vec<DeliveryAttempt>, + pub delivery_observations: Vec<Observation>, + pub recovery: Vec<RecoveryRequirement>, + pub error: Option<Error>, +} +impl Receipt { + pub(crate) fn listing( + value: &radroots::OperationReceipt<radroots::listings::Listing>, + ) -> Result<Self, Error> { + project( + value, + value.business_result().map(|v| Value::Listing { + listing: ListingValue::captured(v), + }), + ) + } + pub(crate) fn chat( + value: &radroots::OperationReceipt<radroots::domain::ChatMessage>, + ) -> Result<Self, Error> { + project( + value, + value.business_result().map(|v| Value::Chat { + message: ChatValue::captured(v), + }), + ) + } + pub(crate) fn status(value: &radroots::OperationStatus) -> Result<Self, Error> { + let result = value.business_result().map(|v| match v { + radroots::OperationValue::Listing(v) => Value::Listing { + listing: ListingValue::captured(v), + }, + radroots::OperationValue::Chat(v) => Value::Chat { + message: ChatValue::captured(v), + }, + }); + project(value, result) + } +} +fn project<T>( + value: &radroots::OperationReceipt<T>, + business_result: Option<Value>, +) -> Result<Receipt, Error> { + let operation = value.context().operation_id().to_string(); + project_inner(value, business_result).map_err(|v| v.with_operation(operation)) +} +fn project_inner<T>( + value: &radroots::OperationReceipt<T>, + business_result: Option<Value>, +) -> Result<Receipt, Error> { + let context = || Error::UnsupportedState { + axis: "receipt_data".to_owned(), + operation_id: Some(value.context().operation_id().to_string()), + }; + let artifacts = value + .artifacts() + .iter() + .map(|v| { + Ok(Artifact { + role: v.role().try_into()?, + recipient: v.recipient().map(|v| v.to_hex()), + expected_event: v.expected_event().map(|v| v.to_string()), + issuance: v.issuance().try_into()?, + attempt_id: v.attempt_id().map(|v| v.to_string()), + claim_transaction: v.claim_transaction_id().map(|v| v.to_string()), + intent_digest: v.intent_digest().map(|v| hex(&v)), + capture_transaction: v.capture_transaction_id().map(|v| v.to_string()), + obtained_digest: v.obtained_digest().map(|v| hex(&v)), + publication_transaction: v.publication_transaction_id().map(|v| v.to_string()), + observed_at_unix_ms: v.observed_at_unix_ms().map(|v| v.to_string()), + }) + }) + .collect::<Result<Vec<_>, Error>>()?; + let observations = value + .delivery_observations() + .iter() + .map(|v| { + Ok(Observation { + event_id: v.event_id().to_string(), + recipient: v.recipient().map(|v| v.to_hex()), + target: v.target().to_owned(), + request_id: v.request_id().to_owned(), + target_fingerprint: v.target_fingerprint().to_owned(), + target_ordinal: v.target_ordinal(), + outcome: v.outcome().try_into()?, + observed_at_unix_ms: v.observed_at_unix_ms().map(|v| v.to_string()), + }) + }) + .collect::<Result<Vec<_>, Error>>()?; + let attempts = value + .delivery_attempts() + .iter() + .map(|v| { + let intent = v.intent(); + let selected = intent.policy().targets(); + let policy = if selected.is_any() { + TargetPolicy::Any + } else if selected.is_all() { + TargetPolicy::All + } else if let Some(threshold) = selected.quorum_threshold() { + TargetPolicy::Quorum { threshold } + } else if let Some(required) = selected.required_targets() { + TargetPolicy::Required { + fingerprints: required.iter().map(|v| v.as_str().to_owned()).collect(), + } + } else { + return Err(context()); + }; + Ok(DeliveryAttempt { + request_id: intent.request_id().as_str().to_owned(), + event_id: intent.event_id().to_string(), + role: intent.role().try_into()?, + recipient: v.work().target().recipient().map(|v| v.to_hex()), + targets: intent + .targets() + .targets() + .iter() + .map(|v| Target { + uri: v.uri().as_str().to_owned(), + kind: v.kind().as_str().to_owned(), + fingerprint: v.fingerprint().as_str().to_owned(), + }) + .collect(), + selected_fingerprints: intent + .selection() + .iter() + .map(|v| v.as_str().to_owned()) + .collect(), + satisfaction_class: intent.policy().class().into(), + policy, + publication_policy_digest: hex(intent.publication_policy_digest()), + intent_digest: hex(intent.digest()), + original_bytes_digest: hex(v.envelope_digest()), + transaction_id: v.transaction_id().to_string(), + work_transaction_id: v.work().transaction_id().to_string(), + retained_at: v.retained_at().to_string(), + deadline_unix_ms: intent.deadline_unix_ms().to_string(), + target_ordinals: v.target_ordinals().to_vec(), + }) + }) + .collect::<Result<Vec<_>, Error>>()?; + Ok(Receipt { + kind: value.kind().try_into()?, + operation_id: value.context().operation_id().to_string(), + captured_context_json: serde_json::to_vec(value.context()).map_err(|_| context())?, + command_digest: value.command_digest().to_string(), + admission: value.admission().try_into()?, + admission_transaction_id: value.admission_transaction_id().to_string(), + plan_transaction_id: value.plan_transaction_id().map(|v| v.to_string()), + installation_transaction_id: value.installation_transaction_id().map(|v| v.to_string()), + installed_at: value.installed_at().map(|v| v.to_string()), + prepared_at: value.issuance_window().prepared_at().to_string(), + first_issue_not_after: value.issuance_window().first_issue_not_after().to_string(), + authority_checkpoint_json: serde_json::to_vec(value.authority_checkpoint()) + .map_err(|_| context())?, + operation_checkpoint: value.operation_checkpoint().to_string(), + observed_at: value.observed_at().to_string(), + business_installation: value.business_installation().try_into()?, + business_result, + issuance: value.issuance().try_into()?, + delivery: value.delivery().try_into()?, + wait_termination: value.wait_termination().try_into()?, + message_id: value.message_id().map(|v| v.to_string()), + record_ids: value.record_ids().iter().map(ToString::to_string).collect(), + missing_sources: value + .missing_sources() + .iter() + .map(ToString::to_string) + .collect(), + conflicting_records: value + .conflicting_records() + .iter() + .map(ToString::to_string) + .collect(), + conflicting_sources: value + .conflicting_sources() + .iter() + .map(ToString::to_string) + .collect(), + artifacts, + delivery_attempts: attempts, + delivery_observations: observations, + recovery: value + .recovery() + .iter() + .copied() + .map(TryInto::try_into) + .collect::<Result<Vec<_>, Error>>()?, + error: value.error().map(Error::from), + }) +} +fn hex(bytes: &[u8]) -> String { + const DIGITS: &[u8; 16] = b"0123456789abcdef"; + let mut result = String::with_capacity(bytes.len() * 2); + for byte in bytes { + result.push(DIGITS[(byte >> 4) as usize] as char); + result.push(DIGITS[(byte & 15) as usize] as char); + } + result +} diff --git a/crates/radroots_ffi/src/states.rs b/crates/radroots_ffi/src/states.rs @@ -0,0 +1,121 @@ +use crate::Error; + +#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)] +pub enum SatisfactionClass { + Accepted, + Delivered, +} +impl From<radroots::transport::SatisfactionClass> for SatisfactionClass { + fn from(value: radroots::transport::SatisfactionClass) -> Self { + match value { + radroots::transport::SatisfactionClass::Accepted => Self::Accepted, + radroots::transport::SatisfactionClass::Delivered => Self::Delivered, + } + } +} + +// These are generated-language representations, not another state machine. +// A future source state refuses projection instead of gaining a default. +macro_rules! bridge { + ($name:ident, $native:path, [$($variant:ident),+ $(,)?]) => { + #[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)] + pub enum $name { $($variant),+ } + impl TryFrom<$native> for $name { + type Error = Error; + fn try_from(value: $native) -> Result<Self, Error> { + use $native as Native; + match value { + $(Native::$variant => Ok(Self::$variant),)+ + _ => Err(Error::UnsupportedState { axis: stringify!($name).to_owned(), operation_id: None }), + } + } + } + }; +} +bridge!( + Admission, + radroots::Admission, + [NotAdmitted, Confirmed, Unknown] +); +bridge!( + BusinessInstallation, + radroots::BusinessInstallation, + [NotApplicable, NotInstalled, Installed, Uncertain] +); +bridge!( + Issuance, + radroots::Issuance, + [None, Pending, Obtained, Unknown, ProvablyUnissued] +); +bridge!( + Delivery, + radroots::Delivery, + [NotStarted, Pending, Observed, Unknown] +); +bridge!( + WaitTermination, + radroots::WaitTermination, + [Returned, Cancelled, DeadlineExceeded, ClientClosed] +); +bridge!( + RecoveryRequirement, + radroots::RecoveryRequirement, + [ + ContinueOriginalOperation, + ReconcileIssuance, + InstallObtainedEvidence, + ResumeDelivery, + ManualReconciliation + ] +); +bridge!( + TargetObservation, + radroots::TargetObservation, + [ + Accepted, + Rejected, + TimedOut, + Disconnected, + Unknown, + NotAttempted + ] +); +bridge!( + ArtifactRole, + radroots::signing::ArtifactRole, + [PublicEvent, BusinessSeal, GiftWrap] +); +bridge!(OperationKind, radroots::OperationKind, [Chat, Listing]); + +#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)] +pub enum StartMode { + LocalOnly, + Online, +} +impl From<StartMode> for radroots::StartMode { + fn from(value: StartMode) -> Self { + match value { + StartMode::LocalOnly => Self::LocalOnly, + StartMode::Online => Self::Online, + } + } +} +#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)] +pub enum SessionState { + Ready, + Starting, + Running, + Closing, + Closed, +} +impl From<radroots::SessionState> for SessionState { + fn from(value: radroots::SessionState) -> Self { + match value { + radroots::SessionState::Ready => Self::Ready, + radroots::SessionState::Starting => Self::Starting, + radroots::SessionState::Running => Self::Running, + radroots::SessionState::Closing => Self::Closing, + radroots::SessionState::Closed => Self::Closed, + } + } +} diff --git a/crates/radroots_ffi/src/values.rs b/crates/radroots_ffi/src/values.rs @@ -0,0 +1,109 @@ +use crate::Error; +use std::sync::Arc; + +#[derive(Clone, uniffi::Enum)] +pub enum ChatRelation { + Inquire { source: Option<String> }, + Reply { parent: String }, +} + +/// An actual installed family-specific shared value, never a private placeholder. +#[derive(Clone, uniffi::Enum)] +pub enum Value { + Chat { message: Arc<ChatValue> }, + Listing { listing: Arc<ListingValue> }, +} + +#[derive(uniffi::Object)] +pub struct ListingValue { + inner: radroots::listings::Listing, +} +impl ListingValue { + pub(crate) fn captured(inner: &radroots::listings::Listing) -> Arc<Self> { + Arc::new(Self { + inner: inner.clone(), + }) + } +} +#[uniffi::export] +impl ListingValue { + pub fn id(&self) -> String { + self.inner.id().to_string() + } + pub fn author(&self) -> String { + self.inner.author().to_hex() + } + pub fn revision(&self) -> String { + self.inner.revision().to_string() + } + pub fn created_at(&self) -> String { + self.inner.created_at().to_string() + } + pub fn published_at(&self) -> String { + self.inner.published_at().to_string() + } + pub fn title(&self) -> String { + self.inner.text().title().to_owned() + } + pub fn summary(&self) -> String { + self.inner.text().summary().to_owned() + } + pub fn description_markdown(&self) -> String { + self.inner.text().description_markdown().to_owned() + } + /// Source-owned validated terms data; this is not a new wire producer. + pub fn terms_json(&self) -> Result<Vec<u8>, Error> { + serde_json::to_vec(self.inner.terms()).map_err(|_| Error::UnsupportedState { + axis: "listing_terms".to_owned(), + operation_id: None, + }) + } +} + +#[derive(uniffi::Object)] +pub struct ChatValue { + inner: radroots::domain::ChatMessage, +} +impl ChatValue { + pub(crate) fn captured(inner: &radroots::domain::ChatMessage) -> Arc<Self> { + Arc::new(Self { + inner: inner.clone(), + }) + } +} +#[uniffi::export] +impl ChatValue { + pub fn id(&self) -> String { + self.inner.id().to_string() + } + pub fn thread_id(&self) -> String { + self.inner.thread_id().to_string() + } + pub fn author(&self) -> String { + self.inner.author().to_hex() + } + pub fn peer(&self) -> String { + self.inner.peer().to_hex() + } + pub fn created_at(&self) -> String { + self.inner.created_at().to_string() + } + pub fn relation(&self) -> Result<ChatRelation, Error> { + match self.inner.relation() { + radroots::domain::ChatRelation::Inquire { source } => Ok(ChatRelation::Inquire { + source: source.map(|v| v.to_string()), + }), + radroots::domain::ChatRelation::Reply { parent } => Ok(ChatRelation::Reply { + parent: parent.to_string(), + }), + _ => Err(Error::UnsupportedState { + axis: "chat_relation".to_owned(), + operation_id: None, + }), + } + } + /// Explicit authorized presentation copy; Rust retains zeroizing storage. + pub fn text(&self) -> String { + self.inner.text().to_owned() + } +} diff --git a/crates/radroots_ffi/tests/inputs.rs b/crates/radroots_ffi/tests/inputs.rs @@ -0,0 +1,94 @@ +use radroots_ffi::{Error, InputFailure, InquiryInput, ListingInput, ListingReference}; + +#[test] +fn actual_shared_parser_retains_invalid_unsupported_and_limit_failures() { + assert!( + matches!(ListingInput::parse(b"{}".to_vec()), Err(Error::InvalidInput { field }) if field == "listing_input") + ); + for input in [ + br#"{"profile":{"version":2}}"#.as_slice(), + br#"{"profile":{"profile":"unknown"}}"#, + ] { + assert!( + matches!(ListingInput::parse(input.to_vec()), Err(Error::CommandInput { field, kind: InputFailure::UnsupportedProfile }) if field == "listing_input") + ); + } + assert!( + matches!(ListingInput::parse(vec![b' '; 65_537]), Err(Error::CommandInput { field, kind: InputFailure::LimitExceeded }) if field == "listing_input") + ); +} + +#[test] +fn exact_keys_and_private_text_limits_fail_without_input_disclosure() { + let peer = "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"; + let secret_text = "private input must not enter the error"; + let error = InquiryInput::new( + "22".repeat(32), + peer.to_uppercase(), + None, + secret_text.into(), + ) + .err() + .unwrap(); + assert!(matches!(&error, Error::InvalidInput { field } if field == "peer")); + assert!(!format!("{error:?} {error}").contains(secret_text)); + assert!(matches!( + InquiryInput::new("22".repeat(32), peer.into(), None, "x".repeat(65_537)), + Err(Error::CommandInput { + kind: InputFailure::LimitExceeded, + .. + }) + )); +} + +#[test] +fn untrusted_listing_descriptors_validate_exact_source_fields_without_authority() { + let peer = "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"; + let reference = ListingReference { + author: peer.into(), + discriminator: "11".repeat(16), + event_id: "44".repeat(32), + }; + assert!( + InquiryInput::new( + "22".repeat(32), + peer.into(), + Some(reference.clone()), + "inquiry".into() + ) + .is_ok() + ); + for (changed, field) in [ + ( + ListingReference { + author: "bad".into(), + ..reference.clone() + }, + "listing_author", + ), + ( + ListingReference { + event_id: "BAD".into(), + ..reference.clone() + }, + "listing_event_id", + ), + ( + ListingReference { + discriminator: "bad".into(), + ..reference + }, + "listing_reference", + ), + ] { + assert!( + matches!(InquiryInput::new("22".repeat(32), peer.into(), Some(changed), "private text".into()), Err(Error::InvalidInput { field: actual }) if actual == field) + ); + } + assert!( + matches!(InquiryInput::new("invalid".into(), peer.into(), None, "private".into()), Err(Error::InvalidInput { field }) if field == "thread_id") + ); + assert!( + matches!(InquiryInput::new("22".repeat(32), "bad".into(), None, "private".into()), Err(Error::InvalidInput { field }) if field == "peer") + ); +} diff --git a/crates/radroots_ffi/tests/native/Cargo.lock b/crates/radroots_ffi/tests/native/Cargo.lock @@ -0,0 +1,3276 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "async-compat" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ba85bc55464dcbf728b56d97e119d673f4cf9062be330a9a26f3acf504a590" +dependencies = [ + "futures-core", + "futures-io", + "once_cell", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-utility" +version = "0.3.2" +source = "git+https://github.com/yukibtc/async-utility?rev=b323ae0c1c1424b78bf8bb8832b95e86771f1dee#b323ae0c1c1424b78bf8bb8832b95e86771f1dee" +dependencies = [ + "futures-util", + "gloo-timers", + "tokio", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-wsocket" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c713e1f14c7b82e32ea159af1c6e2f070cfadbdf23fb2512acce9af0a26f1a2" +dependencies = [ + "futures", + "futures-util", + "js-sys", + "tokio", + "tokio-happy-eyeballs", + "tokio-rustls", + "tokio-socks", + "tokio-tungstenite", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "backtrace" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-link", +] + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "bech32" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" + +[[package]] +name = "bech32" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbd3e1070bbdf4cd88a75264e18e8a26f7cb5c6949eadf0ceb85fb159cf08f8" + +[[package]] +name = "bip39" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbd31c98227229239363921e60fcf5e558e43ec69094d46fc4996f08d1d5bc" +dependencies = [ + "bitcoin_hashes 0.14.1", + "serde", + "unicode-normalization", +] + +[[package]] +name = "bitcoin-consensus-encoding" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9daa31138eb443d5751b207f3f64154e2bb09cd59960562ccc7a7112be38147f" +dependencies = [ + "bitcoin-internals 0.7.0", +] + +[[package]] +name = "bitcoin-internals" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d573f4cf32996a8dce612e4348cece65a241f1882ed594047c9ba348e8869fa5" + +[[package]] +name = "bitcoin-internals" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8bea3a9f0cfece4564e37cb49a38cc245ca5184719e50d7d0dda3268722c4e2" + +[[package]] +name = "bitcoin-io" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dee39a0ee5b4095224a0cfc6bf4cc1baf0f9624b96b367e53b66d974e51d953" + +[[package]] +name = "bitcoin_hashes" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26ec84b80c482df901772e931a9a681e26a1b9ee2302edeff23cb30328745c8b" +dependencies = [ + "bitcoin-io", + "hex-conservative 0.2.2", + "serde", +] + +[[package]] +name = "bitcoin_hashes" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5304e53726dbe5f93141535e102ed97b5bf4714fbecefdda8f9fb98d7fdaff0e" +dependencies = [ + "bitcoin-consensus-encoding", + "bitcoin-internals 0.6.0", + "hex-conservative 1.3.0", + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "camino" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1307f12aa967b5a58416e87b3653360e0fd614a016b6e970db08fecbb1b80d" + +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + +[[package]] +name = "cc" +version = "1.2.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", + "zeroize", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853" + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" + +[[package]] +name = "defmt" +version = "0.3.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4deef977660e373c458df605a913d4ab121db0ccd18d1ad6976dff7d37cddb53" +dependencies = [ + "defmt 1.2.0", +] + +[[package]] +name = "defmt" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366" +dependencies = [ + "defmt-parser", + "proc-macro2", + "quote", + "syn 3.0.2", +] + +[[package]] +name = "defmt-parser" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0" +dependencies = [ + "thiserror 2.0.18", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +dependencies = [ + "serde", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "ff", + "generic-array", + "group", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "5.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "faster-hex" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04839bdf9d8c10f66806fad16b852fc72aab80873aebc3cb69d85b4fa41543ed" +dependencies = [ + "autocfg", + "defmt 0.3.101", + "heapless", + "serde", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flume" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs-err" +version = "3.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5c95b673b8f6f7235229ae11c5642d81b04c2e64c1e2fb417bc0cf73ca45f29" +dependencies = [ + "autocfg", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.1", + "wasip2", + "wasip3", + "wasm-bindgen", +] + +[[package]] +name = "gimli" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" + +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + +[[package]] +name = "hashlink" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824e001ac4f3012dd16a264bec811403a67ca9deb6c102fc5049b32c4574b35f" +dependencies = [ + "hashbrown 0.16.1", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "stable_deref_trait", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-conservative" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda06d18ac606267c40c04e41b9947729bf8b9efe74bd4e82b61a5f26a510b9f" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "hex-conservative" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271e0d19bcb473b6675739a2b536076b24a082316cb5199ad918edce10c599e8" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "block-padding", + "generic-array", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "io-uring" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9080b15e63775b9a2ac7dca720f7050a8b955e092ea0f6020a4a80f69998cdc0" +dependencies = [ + "bitflags 2.11.0", + "cfg-if", + "libc", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jiff-tzdb" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e" + +[[package]] +name = "js-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "elliptic-curve", +] + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" + +[[package]] +name = "libsqlite3-sys" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f111c8c41e7c61a49cd34e44c7619462967221a6443b0ec299e0ac30cfb9b1" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "lru" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef9ac18847474e638e3702b76c65d4eb93428471a74778ef0f1be711717f89b5" + +[[package]] +name = "mediatype" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120fa187be19d9962f0926633453784691731018a2bf936ddb4e29101b79c4a7" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "negentropy" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d66662cb5ca384d4991509755ed5a42dd8e31c4282bf881938e506fc3146ec" + +[[package]] +name = "nostr" +version = "0.44.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d3d987ea7078dc36947cde532637c472a229426702e4331dd7667325378bd9" +dependencies = [ + "aes", + "base64", + "bech32 0.11.1", + "bip39", + "bitcoin_hashes 0.14.1", + "cbc", + "chacha20", + "chacha20poly1305", + "getrandom 0.2.17", + "hex", + "instant", + "scrypt", + "secp256k1 0.29.1", + "serde", + "serde_json", + "unicode-normalization", + "url", + "url-fork", +] + +[[package]] +name = "nostr" +version = "0.45.5" +source = "git+https://github.com/nostrdevkit/nostr.git?rev=de3031aa99986eb29b3f34580355f9a099e4c927#de3031aa99986eb29b3f34580355f9a099e4c927" +dependencies = [ + "base64", + "bech32 0.12.0", + "bip39", + "bitcoin_hashes 1.2.0", + "cbc", + "chacha20", + "chacha20poly1305", + "faster-hex", + "opaquerr", + "rand 0.10.1", + "secp256k1 0.30.0", + "serde", + "serde_json", + "unicode-normalization", + "universal-time", + "url", + "zeroize", +] + +[[package]] +name = "nostr-database" +version = "0.45.2" +source = "git+https://github.com/nostrdevkit/nostr.git?rev=de3031aa99986eb29b3f34580355f9a099e4c927#de3031aa99986eb29b3f34580355f9a099e4c927" +dependencies = [ + "nostr 0.45.5", + "opaquerr", +] + +[[package]] +name = "nostr-gossip" +version = "0.45.1" +source = "git+https://github.com/nostrdevkit/nostr.git?rev=de3031aa99986eb29b3f34580355f9a099e4c927#de3031aa99986eb29b3f34580355f9a099e4c927" +dependencies = [ + "nostr 0.45.5", + "opaquerr", +] + +[[package]] +name = "nostr-sdk" +version = "0.45.4" +source = "git+https://github.com/nostrdevkit/nostr.git?rev=de3031aa99986eb29b3f34580355f9a099e4c927#de3031aa99986eb29b3f34580355f9a099e4c927" +dependencies = [ + "async-utility", + "async-wsocket", + "faster-hex", + "futures", + "lru", + "negentropy", + "nostr 0.45.5", + "nostr-database", + "nostr-gossip", + "opaquerr", + "rand 0.10.1", + "tokio", + "tokio-stream", + "tracing", + "universal-time", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "opaquerr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f933a4265d5cdad61d19bbdfc972ea5726d56cd8d3d57b8f2d3c365dd42bee9" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest", + "hmac", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.117", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "radroots" +version = "0.1.0-alpha" +dependencies = [ + "futures", + "radroots_core", + "radroots_domain", + "radroots_event", + "radroots_execution", + "radroots_identity", + "radroots_nostr", + "radroots_protocol", + "radroots_sdk", + "radroots_signing", + "radroots_storage", + "radroots_storage_sqlite", + "radroots_trade", + "radroots_transport", + "radroots_transport_nostr", + "radroots_transport_nostr_native", + "tokio", +] + +[[package]] +name = "radroots_blossom" +version = "0.1.0-alpha" +dependencies = [ + "mediatype", + "serde", + "sha2", + "unicode-general-category", + "url", +] + +[[package]] +name = "radroots_core" +version = "0.1.0-alpha" +dependencies = [ + "rust_decimal", + "serde", +] + +[[package]] +name = "radroots_domain" +version = "0.1.0-alpha" +dependencies = [ + "radroots_identity", + "serde", + "zeroize", +] + +[[package]] +name = "radroots_event" +version = "0.1.0-alpha" +dependencies = [ + "hex", + "jiff-tzdb", + "radroots_blossom", + "radroots_core", + "radroots_identity", + "radroots_protocol", + "serde", + "serde_json", + "sha2", + "unicode-general-category", + "url", +] + +[[package]] +name = "radroots_event_codec" +version = "0.1.0-alpha" +dependencies = [ + "hex", + "radroots_blossom", + "radroots_core", + "radroots_event", + "radroots_identity", + "radroots_protocol", + "secp256k1 0.29.1", + "serde", + "serde_json", + "sha2", +] + +[[package]] +name = "radroots_execution" +version = "0.1.0-alpha" +dependencies = [ + "futures", + "radroots_domain", + "radroots_protocol", + "radroots_signing", + "radroots_storage", + "radroots_transport", +] + +[[package]] +name = "radroots_ffi" +version = "0.1.0-alpha" +dependencies = [ + "radroots", + "serde_json", + "thiserror 1.0.69", + "uniffi", + "zeroize", +] + +[[package]] +name = "radroots_identity" +version = "0.1.0-alpha" +dependencies = [ + "k256", + "serde", + "thiserror 2.0.18", +] + +[[package]] +name = "radroots_native_binding_fixture" +version = "0.0.0" +dependencies = [ + "futures", + "nostr 0.44.7", + "radroots", + "radroots_domain", + "radroots_ffi", + "radroots_nostr", + "radroots_secrets", + "radroots_signing", + "radroots_storage", + "radroots_storage_sqlite", + "radroots_transport", + "radroots_transport_nostr", + "serde_json", + "tempfile", + "thiserror 1.0.69", + "tokio", + "tokio-tungstenite", + "uniffi", +] + +[[package]] +name = "radroots_nostr" +version = "0.1.0-alpha" +dependencies = [ + "base64", + "nostr 0.44.7", + "radroots_event", + "radroots_event_codec", + "radroots_identity", + "radroots_protocol", + "radroots_signing", + "serde", + "serde_json", + "thiserror 2.0.18", + "zeroize", +] + +[[package]] +name = "radroots_protocol" +version = "0.1.0-alpha" +dependencies = [ + "radroots_domain", + "radroots_identity", + "serde", + "serde_json", + "sha2", + "zeroize", +] + +[[package]] +name = "radroots_sdk" +version = "0.1.0-alpha" +dependencies = [ + "radroots_core", + "radroots_event", + "radroots_event_codec", + "radroots_identity", + "radroots_nostr", + "radroots_protocol", + "radroots_secrets", + "radroots_signing", + "radroots_storage", + "radroots_storage_sqlite", + "radroots_sync", + "radroots_trade", + "radroots_transport", + "uuid", +] + +[[package]] +name = "radroots_secrets" +version = "0.1.0-alpha" +dependencies = [ + "chacha20poly1305", + "sha2", + "subtle", + "tempfile", + "zeroize", +] + +[[package]] +name = "radroots_signing" +version = "0.1.0-alpha" +dependencies = [ + "hex", + "radroots_domain", + "radroots_event", + "radroots_event_codec", + "radroots_identity", + "radroots_protocol", + "sha2", + "zeroize", +] + +[[package]] +name = "radroots_storage" +version = "0.1.0-alpha" +dependencies = [ + "radroots_domain", + "radroots_event", + "radroots_event_codec", + "radroots_protocol", + "radroots_trade", + "radroots_transport", + "serde", + "serde_json", + "sha2", + "subtle", + "zeroize", +] + +[[package]] +name = "radroots_storage_sqlite" +version = "0.1.0-alpha" +dependencies = [ + "fs2", + "getrandom 0.2.17", + "nostr 0.44.7", + "radroots_domain", + "radroots_event", + "radroots_event_codec", + "radroots_secrets", + "radroots_storage", + "radroots_transport", + "rustix", + "serde", + "serde_json", + "sha2", + "sqlx", + "subtle", + "tokio", + "zeroize", +] + +[[package]] +name = "radroots_sync" +version = "0.1.0-alpha" +dependencies = [ + "radroots_event", + "radroots_event_codec", + "radroots_protocol", + "radroots_signing", + "radroots_storage", + "radroots_trade", + "radroots_transport", + "sha2", +] + +[[package]] +name = "radroots_trade" +version = "0.1.0-alpha" +dependencies = [ + "hex", + "radroots_core", + "radroots_event", + "radroots_identity", + "serde", + "serde_json", + "sha2", +] + +[[package]] +name = "radroots_transport" +version = "0.1.0-alpha" +dependencies = [ + "radroots_event", + "radroots_identity", + "radroots_protocol", + "serde", + "sha2", +] + +[[package]] +name = "radroots_transport_nostr" +version = "0.1.0-alpha" +dependencies = [ + "async-utility", + "async-wsocket", + "futures", + "getrandom 0.4.2", + "nostr-sdk", + "radroots_event_codec", + "radroots_nostr", + "radroots_protocol", + "radroots_transport", + "serde_json", + "sha2", + "tokio", + "url", + "wasm-bindgen-futures", + "web-time", +] + +[[package]] +name = "radroots_transport_nostr_native" +version = "0.1.0-alpha" +dependencies = [ + "futures", + "radroots_transport", + "radroots_transport_nostr", + "rustls", + "tokio", + "tokio-rustls", + "tokio-tungstenite", + "url", + "webpki-roots 0.26.11", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" +dependencies = [ + "getrandom 0.4.2", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.11.0", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rust_decimal" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61f703d19852dbf87cbc513643fa81428361eb6940f1ac14fd58155d295a3eb0" +dependencies = [ + "arrayvec", + "num-traits", + "serde", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b74b56ffa8bb2830709a538c2cbcae9aa062db0d2a42563bfb09bdaae44020eb" + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags 2.11.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scrypt" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" +dependencies = [ + "password-hash", + "pbkdf2", + "salsa20", + "sha2", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +dependencies = [ + "rand 0.8.5", + "secp256k1-sys", + "serde", +] + +[[package]] +name = "secp256k1" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b50c5943d326858130af85e049f2661ba3c78b26589b8ab98e65e80ae44a1252" +dependencies = [ + "bitcoin_hashes 0.14.1", + "rand 0.8.5", + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +dependencies = [ + "serde_core", +] + +[[package]] +name = "sha1" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "sqlx" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "378620ccc25c62c89d8be1c819e76a88d59bdcc3304733330788948e619bfd71" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b44e85bf579a8eeb4ceaa77a3a523baf2bf0e9bac7e40f405d537b5d2d5ccb" +dependencies = [ + "base64", + "bytes", + "cfg-if", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.16.1", + "hashlink", + "indexmap", + "log", + "memchr", + "percent-encoding", + "serde", + "sha2", + "smallvec", + "thiserror 2.0.18", + "tokio", + "tokio-stream", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd2b84f2bc39a5705ef27ec785a11c934a41bbd4a24941e257927cddc26b60bf" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 2.0.117", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb8d96de5fdc85a5c4ec813432b523ec637e80ba98f046555f75f7908ddac7c3" +dependencies = [ + "cfg-if", + "dotenvy", + "either", + "heck", + "hex", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-sqlite", + "syn 2.0.117", + "tokio", + "url", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488e99c397a62007e4229aec669a179816339afc6d2620ca6fa420dbee2e982c" +dependencies = [ + "atoi", + "flume", + "form_urlencoded", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "thiserror 2.0.18", + "tracing", + "url", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a207d6d6a2b7fc470b80443726053f18a2481b7e1eee970597051596567987a3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tempfile" +version = "3.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +dependencies = [ + "backtrace", + "bytes", + "io-uring", + "libc", + "mio", + "pin-project-lite", + "slab", + "socket2", + "tokio-macros", + "windows-sys 0.59.0", +] + +[[package]] +name = "tokio-happy-eyeballs" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8564c32dfb6f4257f8bc6edfc178a34af97520e0b7b9815500c55eb3d092f29f" +dependencies = [ + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-socks" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7e2948f60dbe26b35f2c7fb74ac2854c1fddded0fe9d7548fcc674a246f7615" +dependencies = [ + "either", + "futures-util", + "thiserror 1.0.69", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25a406cddcc431a75d3d9afc6a7c0f7428d4891dd973e4d54c56b46127bf857" +dependencies = [ + "futures-util", + "log", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tungstenite", + "webpki-roots 0.26.11", +] + +[[package]] +name = "tokio-util" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "1.1.8+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tungstenite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8628dcc84e5a09eb3d8423d6cb682965dea9133204e8fb3efee74c2a0c259442" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.9.2", + "rustls", + "rustls-pki-types", + "sha1", + "thiserror 2.0.18", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-general-category" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b993bddc193ae5bd0d623b49ec06ac3e9312875fdae725a975c51db1cc1677f" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "uniffi" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76407f5f396a2c949a069eff4a9fca9ce462410eb872bffef4c2b7b89804a77a" +dependencies = [ + "anyhow", + "uniffi_core", + "uniffi_macros", + "uniffi_pipeline", +] + +[[package]] +name = "uniffi_core" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7530ae8efeaaa488622865966763fe0294832779fff80508c36d69c6a874a6a" +dependencies = [ + "anyhow", + "async-compat", + "bytes", + "once_cell", + "static_assertions", +] + +[[package]] +name = "uniffi_internal_macros" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4bad017164375d99450d70495014810d15a84ba9da6ed14b9628b1424223ba" +dependencies = [ + "anyhow", + "indexmap", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "uniffi_macros" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b855a58da153739ce6e863f6e296edc3716a093768c4d3d957f17f5e4317c60" +dependencies = [ + "camino", + "fs-err", + "once_cell", + "proc-macro2", + "quote", + "serde", + "syn 2.0.117", + "toml", + "uniffi_meta", +] + +[[package]] +name = "uniffi_meta" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af0c88664a9cb9559856f5a250283c9708923b303170e2e5c7db8f4ad65e9459" +dependencies = [ + "anyhow", + "siphasher", + "uniffi_internal_macros", + "uniffi_pipeline", +] + +[[package]] +name = "uniffi_pipeline" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d00f5c044b4a3dca0b1226c92ddaeea626f337470e22180dd182160c87a06b0b" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "tempfile", + "uniffi_internal_macros", +] + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "universal-time" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47a939edecc3c5a7b83c02e5f6b3c31d2bc69eabcc9a87ab12c6d37ee6dbc856" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna 1.1.0", + "percent-encoding", + "serde", + "serde_derive", +] + +[[package]] +name = "url-fork" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fa3323c39b8e786154d3000b70ae9af0e9bd746c9791456da0d4a1f68ad89d6" +dependencies = [ + "form_urlencoded", + "idna 0.5.0", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf3923a6f5c4c6382e0b653c4117f48d631ea17f38ed86e2a828e6f7412f5239" +dependencies = [ + "getrandom 0.4.2", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" +dependencies = [ + "cfg-if", + "futures-util", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 2.0.117", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags 2.11.0", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "web-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.6", +] + +[[package]] +name = "webpki-roots" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn 2.0.117", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags 2.11.0", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbb2a062be311f2ba113ce66f697a4dc589f85e78a4aea276200804cea0ed87" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e8bc7269b54418e7aeeef514aa68f8690b8c0489a06b0136e5f57c4c5ccab89" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" + +[[patch.unused]] +name = "radroots_geonames" +version = "0.1.0-alpha" + +[[patch.unused]] +name = "radroots_nostr_connect" +version = "0.1.0-alpha" diff --git a/crates/radroots_ffi/tests/native/Cargo.toml b/crates/radroots_ffi/tests/native/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "radroots_native_binding_fixture" +version = "0.0.0" +publish = false +edition = "2024" +rust-version = "1.99.0" +license = "MIT OR Apache-2.0" + +[workspace] + +# The producer is also a cdylib/staticlib and emits a fixed-name rlib. Keep +# this standalone consumer's artifact closure separate from main-workspace +# generator builds while leaving target-directory ownership with extbuild. +[profile.native_binding_fixture] +inherits = "dev" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +radroots_ffi = { path = "../.." } +radroots = { path = "../../../radroots", default-features = false, features = ["native"] } +radroots_domain = { path = "../../../domain", default-features = false, features = ["std"] } +radroots_nostr = { path = "../../../nostr", default-features = false, features = ["signing", "nip17"] } +radroots_secrets = { path = "../../../secrets", default-features = false, features = ["file"] } +radroots_signing = { path = "../../../signing", default-features = false, features = ["chat", "std"] } +radroots_storage = { path = "../../../storage", default-features = false, features = ["protected_outbox"] } +radroots_storage_sqlite = { path = "../../../storage_sqlite" } +radroots_transport = { path = "../../../transport", default-features = false, features = ["std"] } +radroots_transport_nostr = { path = "../../../transport_nostr", default-features = false } +futures = "=0.3.32" +nostr = { version = "=0.44.7", default-features = false, features = ["std", "nip44", "nip59"] } +serde_json = { version = "=1.0.149", features = ["raw_value"] } +tempfile = "=3.23.0" +thiserror = "1" +tokio = { version = "1", features = ["rt-multi-thread", "sync", "net", "time", "macros"] } +tokio-tungstenite = "=0.28.0" +uniffi = { version = "=0.32.2", default-features = false, features = ["tokio"] } diff --git a/crates/radroots_ffi/tests/native/README.md b/crates/radroots_ffi/tests/native/README.md @@ -0,0 +1,38 @@ +# Native binding qualification host + +This standalone test library composes the real shared client, protected native +outbox, file-secret provider and signer with an isolated loopback relay. It +reexports the production `radroots_ffi` component and exports test setup and +measurement controls in its own component. It contains no product commands, +validators, outbox or recovery implementation. + +Generated Swift and generic Kotlin callers must invoke the production objects. +Rust host setup, measured effects and language execution remain separate proof +scopes. Synthetic keys, test grants, pause controls and the deliberate panic +probe belong only to this fixture. They are not product API or custody, +hardware, app-migration, signing or release qualification. + +Build and test this independent manifest with the `native_binding_fixture` +Cargo profile, after the root producer/generator build. Keep every command +inside `cargo extbuild run --`. The named profile prevents fixed-name FFI +rlib collisions without overriding extbuild's target-directory routing. + +After building the fixture and `radroots_ffi_bindgen`, execute the actual +language lane from the Lib root: + +```sh +cargo extbuild run -- cargo build -p xtask --bin radroots_ffi_bindgen --locked +cargo extbuild run -- node crates/radroots_ffi/tests/native/qualify.mjs \ + --out /absolute/new/external/evidence-directory \ + --kotlinc /absolute/kotlin/bin/kotlinc \ + --jna /absolute/jna.jar \ + --java /absolute/java +``` + +The lane records actual tool versions, source and binary hashes, deterministic +generation, compiler output and real workflow results. Kotlin's coroutines +runtime is resolved from the specified Kotlin installation. This lane requires +native macOS with Swift6, Kotlin2.2 and Java21. Plain nonthrowing Swift panic +conversion is a deliberately isolated process-failure probe; Result-shaped +panics must be caught as unexpected errors. No panic probe belongs to product +API. Original failures remain in their original evidence directories. diff --git a/crates/radroots_ffi/tests/native/Smoke.kt b/crates/radroots_ffi/tests/native/Smoke.kt @@ -0,0 +1,177 @@ +import kotlinx.coroutines.* +import uniffi.radroots_ffi.* +import uniffi.radroots_ffi.Exception as RadrootsException +import uniffi.radroots_native_binding_fixture.* + +private fun request(host: Host, id: String, seconds: Long = 120) = CommandRequest( + id.repeat(32), (host.unixSeconds().toLong() + seconds).toString(), "Kotlin actual calls") + +private fun listing(host: Host, id: String): ListingInput { + val option = "02".repeat(32) + val json = """{"id":"${id.repeat(16)}","title":" Kotlin carrots 🥕 ","summary":"Quote required","description_markdown":"Exact native terms","published_at":"${host.unixSeconds()}","profile":{"profile":"radroots.listing","version":1,"state":"active","product":{"name":"Carrots","description":"Fresh carrots","producer":null,"origin_summary":null},"default_option":"$option","options":[{"id":"$option","label":"Bunch","unit":{"type":"package","label":"bunch","contents":{"type":"unspecified"}},"increment":"1","minimum":"1","price":{"type":"quote_required"},"supply":{"type":"available","amount":"10"},"lead_seconds":"0"}],"fulfillment":{"modes":["pickup"],"area":"Example","lead_seconds":"0"},"authority":null,"media":[]}}""" + return ListingInput.parse(json.toByteArray(Charsets.UTF_8)) +} + +private suspend fun close(host: Host, session: Session) { + val callbacks = host.measurements().closedCallbacks.toLong() + session.client.close() + check(session.client.state() == SessionState.CLOSED) + check(host.measurements().closedCallbacks.toLong() == callbacks + 1) + host.cleanup() + // Only after actual resource closure release the language's references. + session.workspace.destroy() + session.client.destroy() + host.destroy() +} + +private suspend fun publicFlow() { + val host = Host.open(true, false, false) + val first = host.session() + check(first.client.state() == SessionState.READY) + first.client.start(StartMode.ONLINE) + host.setAccepting(false) + val context = request(host, "31", 10) + val input = listing(host, "31") + val receipt = first.client.publishListing(first.workspace, context, input) + check(receipt.kind == OperationKind.LISTING && receipt.admission == Admission.CONFIRMED) + check(receipt.businessInstallation == BusinessInstallation.INSTALLED && receipt.issuance == Issuance.OBTAINED) + val value = (receipt.businessResult as Value.Listing).listing + check(value.title() == " Kotlin carrots 🥕 ") + check(receipt.messageId == null && receipt.artifacts.all { it.recipient == null }) + check(receipt.deliveryObservations.single().outcome == TargetObservation.REJECTED) + val before = host.measurements() + check(before.signingCalls == "1" && before.legacySigningCalls == "0" && before.relayReads == "0") + check(before.originalSignedEvents.single().contains(value.revision())) + val replay = first.client.publishListing(first.workspace, context, input) + check(replay.operationCheckpoint == receipt.operationCheckpoint) + check(host.measurements().originalSignedEvents == before.originalSignedEvents) + first.client.close() + val next = host.reopen() + next.client.start(StartMode.ONLINE) + val query = next.client.operation(next.workspace, receipt.operationId, receipt.commandDigest) + check(query?.operationCheckpoint == receipt.operationCheckpoint) + check(host.measurements().originalSignedEvents == before.originalSignedEvents) + while (host.unixSeconds().toLong() <= receipt.firstIssueNotAfter.toLong()) delay(100) + host.setAccepting(true) + val resumed = next.client.resume(next.workspace, receipt.operationId, receipt.commandDigest) + check(resumed.firstIssueNotAfter == receipt.firstIssueNotAfter) + check(resumed.deliveryAttempts.size == 2) + check(resumed.deliveryAttempts.map { it.targetOrdinals.toList() }.toSet() == setOf(listOf(1.toByte()), listOf(2.toByte()))) + check(resumed.deliveryAttempts[0].originalBytesDigest == resumed.deliveryAttempts[1].originalBytesDigest) + check(resumed.deliveryAttempts[0].publicationPolicyDigest == resumed.deliveryAttempts[1].publicationPolicyDigest) + check(resumed.deliveryObservations.any { it.outcome == TargetObservation.ACCEPTED }) + val after = host.measurements() + check(after.signingCalls == "1" && after.originalSignedEvents == List(2) { before.originalSignedEvents.single() }) + close(host, next) +} + +private suspend fun privateFlowAndErrors() { + val host = Host.open(false, false, false) + val session = host.session() + session.client.start(StartMode.ONLINE) + val peer = "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5" + val text = "\uFEFF Cafe\u0301 / Café Kotlin inquiry 🥕\nExact text\u0000 " + val input = InquiryInput("32".repeat(32), peer, null, text) + val receipt = session.client.inquire(session.workspace, request(host, "32"), input) + val message = (receipt.businessResult as Value.Chat).message + check(receipt.kind == OperationKind.CHAT && message.text().toByteArray().contentEquals(text.toByteArray()) && message.peer() == peer) + check(receipt.artifacts.size == 2 && receipt.artifacts.all { it.recipient != null }) + val before = host.measurements() + check(before.signingCalls == "2" && before.relayReads != "0") + try { + InquiryInput("32".repeat(32), peer.uppercase(), null, "must not enter error details") + error("uppercase key accepted") + } catch (e: RadrootsException.InvalidInput) { check(e.field == "peer") } + try { + ListingInput.parse("{}".toByteArray()) + error("invalid listing accepted") + } catch (e: RadrootsException.InvalidInput) { check(e.field == "listing_input") } + try { + ListingInput.parse("""{"profile":{"version":2}}""".toByteArray()) + error("unsupported profile accepted") + } catch (e: RadrootsException.CommandInput) { check(e.kind == InputFailure.UNSUPPORTED_PROFILE) } + try { + ListingInput.parse(ByteArray(65_537) { 32 }) + error("oversize input accepted") + } catch (e: RadrootsException.CommandInput) { check(e.kind == InputFailure.LIMIT_EXCEEDED) } + val foreign = Host.open(false, false, false) + val other = foreign.session() + other.client.start(StartMode.ONLINE) + val context = request(host, "33") + try { + session.client.inquire(other.workspace, context, input) + error("foreign scope accepted") + } catch (e: RadrootsException.Operation) { + check(e.admission == Admission.NOT_ADMITTED && e.operationId == context.operationId) + } + check(host.measurements().signingCalls == before.signingCalls) + check(foreign.measurements().signingCalls == "0") + session.workspace.close() + check(!session.workspace.uniffiIsDestroyed) + try { + session.client.inquire(session.workspace, request(host, "36"), input) + error("closed attachment accepted") + } catch (e: RadrootsException.Operation) { check(e.admission == Admission.NOT_ADMITTED) } + check(host.measurements().signingCalls == before.signingCalls) + close(foreign, other) + close(host, session) +} + +private suspend fun unknownFlow() { + val host = Host.open(true, true, false) + val session = host.session() + session.client.start(StartMode.ONLINE) + val receipt = session.client.publishListing(session.workspace, request(host, "34"), listing(host, "34")) + check(receipt.issuance == Issuance.UNKNOWN && receipt.businessResult == null) + session.client.close() + host.setUnknownSigning(false) + val next = host.reopen() + next.client.start(StartMode.ONLINE) + val resumed = next.client.resume(next.workspace, receipt.operationId, receipt.commandDigest) + check(resumed.issuance == Issuance.UNKNOWN && resumed.businessResult == null) + val measured = host.measurements() + check(measured.signingCalls == "1" && measured.originalSignedEvents.isEmpty()) + close(host, next) +} + +private suspend fun cancelledObservers() = coroutineScope { + val host = Host.open(true, false, true) + val session = host.session() + session.client.start(StartMode.ONLINE) + val context = request(host, "35") + val input = listing(host, "35") + val observer = async { session.client.publishListing(session.workspace, context, input) } + host.waitUntilSignerPaused() + observer.cancelAndJoin() + val closing = async { session.client.close() } + withTimeout(5_000) { + while (session.client.state() != SessionState.CLOSING) delay(5) + } + closing.cancelAndJoin() + host.releaseSigner() + session.client.close() + val next = host.reopen() + next.client.start(StartMode.ONLINE) + val recovered = next.client.resume(next.workspace, context.operationId, null) + check(recovered.issuance == Issuance.OBTAINED && recovered.businessInstallation == BusinessInstallation.INSTALLED) + check(host.measurements().signingCalls == "1") + close(host, next) +} + +fun main(args: Array<String>) = runBlocking { + if ("--plain-panic" in args) { + var caught = false + try { fixturePanicProbe() } catch (_: uniffi.radroots_native_binding_fixture.InternalException) { caught = true } + check(caught) + println("{\"language\":\"kotlin\",\"plain_panic_caught\":true}") + return@runBlocking + } + var caught = false + try { fixtureResultPanicProbe() } catch (_: uniffi.radroots_native_binding_fixture.InternalException) { caught = true } + check(caught) + publicFlow() + privateFlowAndErrors() + unknownFlow() + cancelledObservers() + println("{\"language\":\"kotlin\",\"state\":\"passed\",\"actual_workflows\":4,\"result_panic_caught\":true}") +} diff --git a/crates/radroots_ffi/tests/native/Smoke.swift b/crates/radroots_ffi/tests/native/Smoke.swift @@ -0,0 +1,196 @@ +import Foundation + +enum SmokeFailure: Swift.Error { + case failed(String) +} +func trace(_ message: String) { + FileHandle.standardOutput.write(Data((message + "\n").utf8)) +} +func check(_ value: Bool, _ message: String) throws { + if !value { throw SmokeFailure.failed(message) } +} +func request(_ host: Host, _ id: String) throws -> CommandRequest { + CommandRequest(operationId: String(repeating: id, count: 32), + firstIssueNotAfter: String(UInt64(try host.unixSeconds())! + 120), correlationId: "Swift actual calls") +} +func listing(_ host: Host, _ id: String) throws -> ListingInput { + let option = String(repeating: "02", count: 32) + let profile: [String: Any] = [ + "profile": "radroots.listing", "version": 1, "state": "active", + "product": ["name": "Carrots", "description": "Fresh carrots", "producer": NSNull(), "origin_summary": NSNull()], + "default_option": option, + "options": [["id": option, "label": "Bunch", "unit": ["type": "package", "label": "bunch", "contents": ["type": "unspecified"]], + "increment": "1", "minimum": "1", "price": ["type": "quote_required"], "supply": ["type": "available", "amount": "10"], "lead_seconds": "0"]], + "fulfillment": ["modes": ["pickup"], "area": "Example", "lead_seconds": "0"], "authority": NSNull(), "media": [] + ] + let input: [String: Any] = ["id": String(repeating: id, count: 16), "title": " Swift carrots 🥕 ", + "summary": "Quote required", "description_markdown": "Exact native terms", "published_at": try host.unixSeconds(), "profile": profile] + return try ListingInput.parse(input: JSONSerialization.data(withJSONObject: input)) +} +func close(_ host: Host, _ session: Session) async throws { + let callbacks = UInt64(try host.measurements().closedCallbacks)! + try await session.client.close() + try check(session.client.state() == .closed, "actual closed state") + try check(UInt64(try host.measurements().closedCallbacks)! == callbacks + 1, "actual provider closure") + try await host.cleanup() +} + +func publicFlow() async throws { + let host = try await Host.open(seller: true, unknownSigning: false, pauseAfterSigning: false) + let first = host.session() + try check(first.client.state() == .ready, "host does not auto-start") + _ = try await first.client.start(mode: .online) + host.setAccepting(accepting: false) + var context = try request(host, "11") + context.firstIssueNotAfter = String(UInt64(try host.unixSeconds())! + 10) + let input = try listing(host, "11") + let result = try await first.client.publishListing(workspace: first.workspace, request: context, input: input) + try check(result.kind == .listing && result.admission == .confirmed, "real public admission") + try check(result.businessInstallation == .installed && result.issuance == .obtained, "independent install/issuance") + guard case let .listing(value)? = result.businessResult else { throw SmokeFailure.failed("typed listing result") } + try check(value.title() == " Swift carrots 🥕 ", "exact Unicode/whitespace") + try check(result.messageId == nil && result.artifacts.allSatisfy { $0.recipient == nil }, "public optional identity") + try check(result.deliveryObservations.count == 1 && result.deliveryObservations[0].outcome == .rejected, "actual rejection") + let before = try host.measurements() + try check(before.signingCalls == "1" && before.legacySigningCalls == "0" && before.relayReads == "0", "actual public effects") + let event = try JSONSerialization.jsonObject(with: Data(before.originalSignedEvents[0].utf8)) as! [String: Any] + try check(event["id"] as? String == value.revision(), "actual wire revision") + let replay = try await first.client.publishListing(workspace: first.workspace, request: context, input: input) + try check(replay.operationCheckpoint == result.operationCheckpoint, "replay retains facts") + try check(try host.measurements().originalSignedEvents == before.originalSignedEvents, "replay has no network effect") + try await first.client.close() + let next = try await host.reopen() + _ = try await next.client.start(mode: .online) + let queried = try await next.client.operation(workspace: next.workspace, operationId: result.operationId, expectedDigest: result.commandDigest) + try check(queried?.operationCheckpoint == result.operationCheckpoint, "scoped reopened query") + host.setAccepting(accepting: true) + while UInt64(try host.unixSeconds())! <= UInt64(result.firstIssueNotAfter)! { + try await Task.sleep(nanoseconds: 100_000_000) + } + let resumed = try await next.client.resume(workspace: next.workspace, operationId: result.operationId, expectedDigest: result.commandDigest) + try check(resumed.deliveryAttempts.count == 2, "fresh retained retry count=\(resumed.deliveryAttempts.count), issuance=\(resumed.issuance), recovery=\(resumed.recovery), error=\(String(describing: resumed.error))") + try check(Set(resumed.deliveryAttempts.map { $0.targetOrdinals }) == Set([Data([1]), Data([2])]), "both original and fresh ordinals are retained independently of identity order") + try check(resumed.deliveryAttempts[0].originalBytesDigest == resumed.deliveryAttempts[1].originalBytesDigest, "original byte commitment") + try check(resumed.deliveryAttempts[0].publicationPolicyDigest == resumed.deliveryAttempts[1].publicationPolicyDigest, "original policy") + try check(resumed.deliveryObservations.contains { $0.outcome == .accepted }, "actual acceptance") + let after = try host.measurements() + try check(after.signingCalls == "1" && after.originalSignedEvents == [before.originalSignedEvents[0], before.originalSignedEvents[0]], "same actual bytes, no resign") + try await close(host, next) +} + +func privateFlowAndErrors() async throws { + let host = try await Host.open(seller: false, unknownSigning: false, pauseAfterSigning: false) + let session = host.session(); _ = try await session.client.start(mode: .online) + let peer = "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5" + let text = "\u{feff} Cafe\u{301} / Café Swift inquiry 🥕\nExact text\0 " + let input = try InquiryInput(threadId: String(repeating: "22", count: 32), peer: peer, source: nil, text: text) + let result = try await session.client.inquire(workspace: session.workspace, request: request(host, "12"), input: input) + guard case let .chat(value)? = result.businessResult else { throw SmokeFailure.failed("typed chat") } + try check(result.kind == .chat && value.peer() == peer && value.text().utf8.elementsEqual(text.utf8), "actual private UTF8 data without normalization") + try check(result.artifacts.count == 2 && result.artifacts.allSatisfy { $0.recipient != nil }, "original private subjects") + let before = try host.measurements(); try check(before.signingCalls == "2" && before.relayReads != "0", "private route/signing effects") + do { + _ = try InquiryInput(threadId: String(repeating: "22", count: 32), peer: peer.uppercased(), source: nil, text: "private input must not enter errors") + throw SmokeFailure.failed("uppercase key accepted") + } catch Error.InvalidInput(let field) { try check(field == "peer", "safe input cause") } + do { _ = try ListingInput.parse(input: Data("{}".utf8)); throw SmokeFailure.failed("invalid listing accepted") } + catch Error.InvalidInput(let field) { try check(field == "listing_input", "shared input parser") } + do { _ = try ListingInput.parse(input: Data("{\"profile\":{\"version\":2}}".utf8)); throw SmokeFailure.failed("unsupported profile accepted") } + catch Error.CommandInput(let field, let kind) { try check(field == "listing_input" && kind == .unsupportedProfile, "typed unsupported profile") } + do { _ = try ListingInput.parse(input: Data(repeating: 32, count: 65_537)); throw SmokeFailure.failed("oversize input accepted") } + catch Error.CommandInput(let field, let kind) { try check(field == "listing_input" && kind == .limitExceeded, "typed shared bound") } + let otherHost = try await Host.open(seller: false, unknownSigning: false, pauseAfterSigning: false) + let other = otherHost.session(); _ = try await other.client.start(mode: .online) + do { + _ = try await session.client.inquire(workspace: other.workspace, request: request(host, "13"), input: input) + throw SmokeFailure.failed("foreign scope accepted") + } catch Error.Operation(_, _, let operation, let admission) { + try check(operation == String(repeating: "13", count: 32) && admission == .notAdmitted, "retained safe error context") + } + try check(try host.measurements().signingCalls == before.signingCalls, "refusal has no signature") + try check(try otherHost.measurements().signingCalls == "0", "foreign host unused") + session.workspace.close() + do { + _ = try await session.client.inquire(workspace: session.workspace, request: request(host, "16"), input: input) + throw SmokeFailure.failed("closed attachment accepted") + } catch Error.Operation(_, _, _, let admission) { + try check(admission == .notAdmitted, "actual attachment close releases authority") + } + try check(try host.measurements().signingCalls == before.signingCalls, "closed scope has no signature") + try await close(otherHost, other); try await close(host, session) +} + +func unknownFlow() async throws { + let host = try await Host.open(seller: true, unknownSigning: true, pauseAfterSigning: false) + let session = host.session(); _ = try await session.client.start(mode: .online) + let result = try await session.client.publishListing(workspace: session.workspace, request: request(host, "14"), input: listing(host, "14")) + try check(result.issuance == .unknown && result.businessResult == nil, "unknown result remains explicit") + try await session.client.close(); host.setUnknownSigning(unknown: false) + let next = try await host.reopen(); _ = try await next.client.start(mode: .online) + let resumed = try await next.client.resume(workspace: next.workspace, operationId: result.operationId, expectedDigest: result.commandDigest) + try check(resumed.issuance == .unknown && resumed.businessResult == nil, "reopen cannot turn uncertainty into permission") + let measured = try host.measurements(); try check(measured.signingCalls == "1" && measured.originalSignedEvents.isEmpty, "no repeated invocation") + try await close(host, next) +} + +func cancelledObservers() async throws { + let host = try await Host.open(seller: true, unknownSigning: false, pauseAfterSigning: true) + let session = host.session(); _ = try await session.client.start(mode: .online) + let context = try request(host, "15"); let input = try listing(host, "15") + let observer = Task { try await session.client.publishListing(workspace: session.workspace, request: context, input: input) } + try await host.waitUntilSignerPaused() + for _ in 0..<2 { + let safe = await withTaskGroup(of: Bool.self) { group in + for index in 0..<16 { + group.addTask { + let query = Task { try await session.client.operation(workspace: session.workspace, operationId: context.operationId, expectedDigest: nil) } + if index % 2 == 0 { await Task.yield() } + query.cancel() + do { _ = try await query.value; return true } + catch is CancellationError { return true } + catch { return false } + } + } + var accepted = true + for await outcome in group { accepted = accepted && outcome } + return accepted + } + try check(safe, "cancel/completion race preserves safe future lifetime") + } + observer.cancel(); _ = await observer.result + let closing = Task { try await session.client.close() } + for _ in 0..<200 where session.client.state() != .closing { try await Task.sleep(nanoseconds: 5_000_000) } + try check(session.client.state() == .closing, "close owns pending produced signature") + closing.cancel(); _ = await closing.result; host.releaseSigner(); try await session.client.close() + let next = try await host.reopen(); _ = try await next.client.start(mode: .online) + let recovered = try await next.client.resume(workspace: next.workspace, operationId: context.operationId, expectedDigest: nil) + try check(recovered.issuance == .obtained && recovered.businessInstallation == .installed, "actual obtained result recovered") + try check(try host.measurements().signingCalls == "1", "observer loss never resigns") + try await close(host, next) +} + +@main enum NativeSmoke { + static func main() async throws { + if CommandLine.arguments.contains("--plain-panic") { _ = fixturePanicProbe(); throw SmokeFailure.failed("plain panic returned") } + var resultPanicCaught = false + do { _ = try fixtureResultPanicProbe() } catch { resultPanicCaught = true } + try check(resultPanicCaught, "actual Result panic boundary") + let host = try await Host.open(seller: false, unknownSigning: false, pauseAfterSigning: false) + let session = host.session() + let alreadyCancelled = Task { + do { try await Task.sleep(nanoseconds: 5_000_000_000) } catch {} + return try await session.client.start(mode: .online) + } + alreadyCancelled.cancel() + do { _ = try await alreadyCancelled.value; throw SmokeFailure.failed("already cancelled call started") } + catch is CancellationError {} + try check(session.client.state() == .ready, "already cancelled binding call has no host effect") + try await close(host, session) + trace("swift already-cancelled call passed") + try await publicFlow(); trace("swift public workflow passed") + try await privateFlowAndErrors(); trace("swift private workflow passed") + try await unknownFlow(); trace("swift unknown workflow passed") + try await cancelledObservers(); trace("swift cancellation workflow passed") + print("{\"language\":\"swift\",\"state\":\"passed\",\"actual_workflows\":4,\"result_panic_caught\":true}") + } +} diff --git a/crates/radroots_ffi/tests/native/qualify.mjs b/crates/radroots_ffi/tests/native/qualify.mjs @@ -0,0 +1,87 @@ +// Actual generated-language execution against the real shared native host. +import { execFileSync, spawnSync } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const fixture = dirname(fileURLToPath(import.meta.url)); +const root = resolve(fixture, '../../../..'); +const options = new Map(); +for (let index = 2; index < process.argv.length; index += 2) { + const key = process.argv[index], value = process.argv[index + 1]; + if (!['--out', '--kotlinc', '--jna', '--java'].includes(key) || !value || options.has(key)) throw new Error('invalid fixture arguments'); + options.set(key, resolve(value)); +} +if (options.size !== 4 || !process.env.CARGO_TARGET_DIR) throw new Error('requires extbuild and --out/--kotlinc/--jna/--java'); +if (process.platform !== 'darwin') throw new Error('this Swift/Kotlin lane requires native macOS'); +const out = options.get('--out'); +if (existsSync(out)) throw new Error('output directory must be new'); +mkdirSync(out, { recursive: true }); +const hash = path => createHash('sha256').update(readFileSync(path)).digest('hex'); +function files(directory, prefix = '') { + return readdirSync(directory, { withFileTypes: true }).flatMap(entry => { + const name = join(prefix, entry.name); + if (entry.isDirectory()) return files(join(directory, entry.name), name); + if (!entry.isFile()) throw new Error('unexpected non-file input'); + return [name]; + }).sort(); +} +const git = (...args) => execFileSync('git', args, { cwd: root, encoding: 'utf8' }); +const head = git('rev-parse', 'HEAD').trim(); +const dirty = [...git('diff', '--name-only', '-z', 'HEAD').split('\0'), ...git('ls-files', '--others', '--exclude-standard', '-z').split('\0')].filter(Boolean); +const sourceFiles = [...new Set(['Cargo.toml', 'Cargo.lock', ...dirty, ...files(join(root, 'crates/radroots_ffi')).map(name => `crates/radroots_ffi/${name}`)])].sort().filter(name => existsSync(join(root, name))); +const sources = Object.fromEntries(sourceFiles.map(name => [name, hash(join(root, name))])); +const target = process.env.CARGO_TARGET_DIR; +const library = join(target, 'native_binding_fixture/libradroots_native_binding_fixture.dylib'); +const generator = join(target, 'debug/radroots_ffi_bindgen'); +const report = { state: 'running', head, dirty_paths: dirty.sort(), started_at: new Date().toISOString(), scope: 'actual native macOS Swift/Kotlin shared-client fixture; no iOS/custody/factory or consumer-adoption qualification', sources, library: { path: library, sha256: hash(library) }, generator: { path: generator, sha256: hash(generator) }, commands: [] }; +function persist() { writeFileSync(join(out, 'report.json'), JSON.stringify(report, null, 2) + '\n'); } +function run(command, args, { expectedPanic = false } = {}) { + const started = performance.now(); + const result = spawnSync(command, args, { cwd: root, encoding: 'utf8', timeout: 240_000, maxBuffer: 16 * 1024 * 1024 }); + const log = join(out, `${report.commands.length}.log`); + writeFileSync(log, (result.stdout || '') + (result.stderr || '')); + const output = readFileSync(log, 'utf8'); + const passed = expectedPanic + ? !result.error && ['SIGILL', 'SIGTRAP', 'SIGABRT'].includes(result.signal) && output.includes('synthetic native binding panic probe') + : !result.error && result.status === 0; + report.commands.push({ command: [command, ...args], exit_code: result.status, signal: result.signal, error: result.error?.message, elapsed_seconds: (performance.now() - started) / 1000, log, sha256: hash(log), expected_plain_swift_panic: expectedPanic, passed }); + persist(); + if (!passed) throw new Error(`native fixture command failed: ${command}\n${output.slice(-6000)}`); + console.log(JSON.stringify({ command, state: 'passed', log })); +} +try { + run(generator, ['--version']); + run('/usr/bin/swiftc', ['--version']); + run(options.get('--kotlinc'), ['-version']); + run(options.get('--java'), ['-version']); + const swift = join(out, 'swift'), kotlin = join(out, 'kotlin'); + for (const [language, destination] of [['swift', swift], ['kotlin', kotlin]]) { + run(generator, ['generate', '--library', library, '--language', language, '--no-format', '--out-dir', destination]); + const repeat = destination + '_repeat'; + run(generator, ['generate', '--library', library, '--language', language, '--no-format', '--out-dir', repeat]); + const names = files(destination); + if (JSON.stringify(names) !== JSON.stringify(files(repeat)) || names.some(name => hash(join(destination, name)) !== hash(join(repeat, name)))) throw new Error('generation is not byte deterministic'); + report[language] = Object.fromEntries(names.map(name => [name, hash(join(destination, name))])); + } + const executable = join(out, 'swift_smoke'); + run('/usr/bin/swiftc', ['-swift-version', '6', '-warnings-as-errors', '-parse-as-library', '-I', swift, + ...['radroots_ffi', 'radroots_native_binding_fixture'].flatMap(name => ['-Xcc', `-fmodule-map-file=${join(swift, name + 'FFI.modulemap')}`]), + ...files(swift).filter(name => name.endsWith('.swift')).map(name => join(swift, name)), join(fixture, 'Smoke.swift'), library, '-o', executable]); + run(executable, []); + run('/bin/sh', ['-c', 'ulimit -c 0; exec "$@"', 'native-fixture-panic', executable, '--plain-panic'], { expectedPanic: true }); + const coroutine = resolve(options.get('--kotlinc'), '../../lib/kotlinx-coroutines-core-jvm.jar'); + report.runtime_jars = Object.fromEntries([options.get('--jna'), coroutine].map(path => [path, hash(path)])); + const classpath = [options.get('--jna'), coroutine].join(':'); + const jar = join(out, 'kotlin_smoke.jar'); + run(options.get('--kotlinc'), [...files(kotlin).filter(name => name.endsWith('.kt')).map(name => join(kotlin, name)), join(fixture, 'Smoke.kt'), '-Werror', '-classpath', classpath, '-include-runtime', '-d', jar]); + const java = ['-Duniffi.component.radroots_ffi.libraryOverride=' + library, '-Duniffi.component.radroots_native_binding_fixture.libraryOverride=' + library, '-cp', jar + ':' + classpath, 'SmokeKt']; + run(options.get('--java'), java); + run(options.get('--java'), [...java, '--plain-panic']); + const currentDirty = [...git('diff', '--name-only', '-z', 'HEAD').split('\0'), ...git('ls-files', '--others', '--exclude-standard', '-z').split('\0')].filter(Boolean).sort(); + if (git('rev-parse', 'HEAD').trim() !== head || JSON.stringify(currentDirty) !== JSON.stringify(report.dirty_paths) || sourceFiles.some(name => !existsSync(join(root, name)) || hash(join(root, name)) !== sources[name]) || hash(library) !== report.library.sha256 || hash(generator) !== report.generator.sha256) throw new Error('qualification inputs changed'); + report.state = 'passed'; +} catch (error) { + report.state = 'failed'; report.failure = error.message; throw error; +} finally { persist(); } diff --git a/crates/radroots_ffi/tests/native/src/lib.rs b/crates/radroots_ffi/tests/native/src/lib.rs @@ -0,0 +1,364 @@ +//! Synthetic native host for actual generated-language qualification. +#![forbid(unsafe_code)] +mod relay; +mod signer; + +use radroots::{Client, NativeConfig}; +use radroots_domain::{PublicKey, UnixSeconds}; +use radroots_ffi::{NativeClient, SessionState, Workspace}; +use radroots_secrets::{ + SecretId, SecretRef, + envelope::Nonce, + file::{FileOpenMode, FileProvider}, + id::{BackendKind, KeyVersion}, + provider::AccessPolicy, + wrapping::SecretMaterial, +}; +use radroots_signing::{ + provider::{ProviderError, SignerCallbacks, SignerHandle}, + signer::BoxFuture, +}; +use radroots_storage::{ + event::SourceGeneration, + workspace::{AttachmentInput, AttachmentProof, WorkspaceClock, WorkspaceError}, +}; +use radroots_storage_sqlite::{ + OpenMode, OpenOptions, Paths, + workspace::{LocalOutboxConfig, NativeWorkspace, WorkspaceCrypto}, +}; +use std::{ + path::PathBuf, + sync::{ + Arc, Mutex, + atomic::{AtomicU64, Ordering}, + }, + time::{Duration, SystemTime, UNIX_EPOCH}, +}; + +uniffi::setup_scaffolding!(); +radroots_ffi::uniffi_reexport_scaffolding!(); + +#[derive(Debug, thiserror::Error, uniffi::Error)] +pub enum FixtureError { + #[error("native fixture unavailable")] + Unavailable, + #[error("native fixture still owns an open client")] + Busy, +} +pub(crate) fn now() -> Result<u64, FixtureError> { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .map(|v| v.as_secs()) + .map_err(|_| FixtureError::Unavailable) +} +struct Clock; +impl WorkspaceClock for Clock { + fn now(&self) -> Result<UnixSeconds, WorkspaceError> { + UnixSeconds::new(now().map_err(|_| WorkspaceError::Unavailable)?) + .map_err(|_| WorkspaceError::Unavailable) + } +} +struct Callbacks { + closed: Arc<AtomicU64>, +} +impl SignerCallbacks for Callbacks { + fn quiesce(&self) -> BoxFuture<'_, Result<(), ProviderError>> { + Box::pin(async { Ok(()) }) + } + fn close(&self) -> BoxFuture<'_, Result<(), ProviderError>> { + self.closed.fetch_add(1, Ordering::SeqCst); + Box::pin(async { Ok(()) }) + } +} + +#[derive(Clone, uniffi::Record)] +pub struct Session { + pub client: Arc<NativeClient>, + pub workspace: Arc<Workspace>, +} +#[derive(Clone, uniffi::Record)] +pub struct Measurements { + pub signing_calls: String, + pub legacy_signing_calls: String, + pub relay_reads: String, + pub closed_callbacks: String, + pub original_signed_events: Vec<String>, +} + +/// Explicit test-host assembly choices; evaluation remains in shared Rust. +#[derive(Clone, Copy, uniffi::Enum)] +pub enum FixturePolicy { + All, + Any, + Quorum, + Required, +} + +/// Test resources and counters. The shared client owns every command effect. +#[derive(uniffi::Object)] +pub struct Host { + root: PathBuf, + provider: Arc<FileProvider>, + clock: Arc<Clock>, + selected: AttachmentInput, + proof: AttachmentProof, + signer: Arc<signer::MeasuredSigner>, + closed: Arc<AtomicU64>, + relay: relay::Relay, + initial: Session, + clients: Mutex<Vec<Arc<NativeClient>>>, + lifecycle: tokio::sync::Mutex<()>, +} +#[uniffi::export(async_runtime = "tokio")] +impl Host { + /// Explicit test setup, with real protected grant creation and no commands. + #[uniffi::constructor] + pub async fn open( + seller: bool, + unknown_signing: bool, + pause_after_signing: bool, + ) -> Result<Arc<Self>, FixtureError> { + Self::open_with_policy( + seller, + unknown_signing, + pause_after_signing, + FixturePolicy::All, + ) + .await + } + #[uniffi::constructor] + pub async fn open_with_policy( + seller: bool, + unknown_signing: bool, + pause_after_signing: bool, + policy: FixturePolicy, + ) -> Result<Arc<Self>, FixtureError> { + let directory = tempfile::Builder::new() + .prefix("radroots_native_binding_fixture_") + .tempdir() + .map_err(|_| FixtureError::Unavailable)?; + // Keep failed or observer-lost fixtures recoverable. Only explicit + // cleanup after confirmed client closure removes this owned namespace. + let root = directory + .keep() + .canonicalize() + .map_err(|_| FixtureError::Unavailable)?; + let provider = Arc::new( + FileProvider::open(root.join("vault"), FileOpenMode::CreateNew, material(0xa5)?) + .map_err(|_| FixtureError::Unavailable)?, + ); + provider + .provision(&reference()?, &material(0x41)?, Nonce::new([0x11; 24])) + .map_err(|_| FixtureError::Unavailable)?; + let clock = Arc::new(Clock); + let expiry = UnixSeconds::new(now()? + 600).map_err(|_| FixtureError::Unavailable)?; + let config = if seller { + LocalOutboxConfig::seller(key()?, key()?, "native-binding-fixture", expiry) + } else { + LocalOutboxConfig::new(key()?, key()?, "native-binding-fixture", expiry) + } + .map_err(|_| FixtureError::Unavailable)?; + let (store, selected, proof) = NativeWorkspace::initialize_local_outbox( + &root.join("outbox"), + config, + crypto(provider.clone())?, + clock.clone(), + ) + .await + .map_err(|_| FixtureError::Unavailable)?; + let relay = relay::Relay::new(policy).await?; + let signer = signer::MeasuredSigner::new(unknown_signing, pause_after_signing); + let closed = Arc::new(AtomicU64::new(0)); + let initial = open_client( + &root.join("cache0"), + store, + &selected, + &proof, + signer.clone(), + closed.clone(), + &relay, + ) + .await?; + Ok(Arc::new(Self { + root, + provider, + clock, + selected, + proof, + signer, + closed, + relay, + clients: Mutex::new(vec![initial.client.clone()]), + initial, + lifecycle: tokio::sync::Mutex::new(()), + })) + } + pub fn session(&self) -> Session { + self.initial.clone() + } + pub fn unix_seconds(&self) -> Result<String, FixtureError> { + now().map(|v| v.to_string()) + } + pub fn set_accepting(&self, accepting: bool) { + self.relay.accepting.store(accepting, Ordering::SeqCst); + } + pub fn set_unknown_signing(&self, unknown: bool) { + self.signer.unknown.store(unknown, Ordering::SeqCst); + } + pub fn release_signer(&self) { + self.signer.release(); + } + pub async fn wait_until_signer_paused(&self) -> Result<(), FixtureError> { + tokio::time::timeout(Duration::from_secs(5), async { + while !self.signer.paused.load(Ordering::SeqCst) { + tokio::time::sleep(Duration::from_millis(5)).await; + } + }) + .await + .map_err(|_| FixtureError::Unavailable) + } + /// Opens the same real namespace only after every previous client closed. + /// No start, query, signature or outbox continuation is performed here. + pub async fn reopen(&self) -> Result<Session, FixtureError> { + let _lifecycle = self.lifecycle.lock().await; + let index = { + let clients = self.clients.lock().map_err(|_| FixtureError::Unavailable)?; + if clients.len() >= 16 || clients.iter().any(|v| v.state() != SessionState::Closed) { + return Err(FixtureError::Busy); + } + clients.len() + }; + let store = NativeWorkspace::open_existing( + &self.root.join("outbox"), + self.selected.clone(), + crypto(self.provider.clone())?, + self.clock.clone(), + ) + .await + .map_err(|_| FixtureError::Unavailable)?; + let session = open_client( + &self.root.join(format!("cache{index}")), + store, + &self.selected, + &self.proof, + self.signer.clone(), + self.closed.clone(), + &self.relay, + ) + .await?; + self.clients + .lock() + .map_err(|_| FixtureError::Unavailable)? + .push(session.client.clone()); + Ok(session) + } + pub fn measurements(&self) -> Result<Measurements, FixtureError> { + Ok(Measurements { + signing_calls: self.signer.calls.load(Ordering::SeqCst).to_string(), + legacy_signing_calls: self.signer.legacy_calls.load(Ordering::SeqCst).to_string(), + relay_reads: self.relay.reads.load(Ordering::SeqCst).to_string(), + closed_callbacks: self.closed.load(Ordering::SeqCst).to_string(), + original_signed_events: self + .relay + .events + .lock() + .map_err(|_| FixtureError::Unavailable)? + .clone(), + }) + } + pub async fn cleanup(&self) -> Result<(), FixtureError> { + let _lifecycle = self.lifecycle.lock().await; + if self + .clients + .lock() + .map_err(|_| FixtureError::Unavailable)? + .iter() + .any(|v| v.state() != SessionState::Closed) + { + return Err(FixtureError::Busy); + } + self.relay.stop().await?; + std::fs::remove_dir_all(&self.root).map_err(|_| FixtureError::Unavailable) + } +} + +async fn open_client( + cache: &std::path::Path, + store: NativeWorkspace, + selected: &AttachmentInput, + proof: &AttachmentProof, + signer: Arc<signer::MeasuredSigner>, + closed: Arc<AtomicU64>, + relay: &relay::Relay, +) -> Result<Session, FixtureError> { + std::fs::create_dir(cache).map_err(|_| FixtureError::Unavailable)?; + let options = OpenOptions::new( + Paths::from_directory(cache).map_err(|_| FixtureError::Unavailable)?, + OpenMode::Create, + ) + .with_source_generation( + SourceGeneration::new([43; 32]).map_err(|_| FixtureError::Unavailable)?, + 1, + ) + .map_err(|_| FixtureError::Unavailable)?; + let config = NativeConfig::public_read(options) + .with_workspace(store) + .with_nostr(relay.config()?, relay.policy.clone()) + .map_err(|_| FixtureError::Unavailable)?; + let client = Client::open(config) + .await + .map_err(|_| FixtureError::Unavailable)?; + let scope = client + .attach( + selected.clone(), + proof + .with_secret(|v| AttachmentProof::from_protected_input(v)) + .map_err(|_| FixtureError::Unavailable)?, + ) + .await + .map_err(|_| FixtureError::Unavailable)?; + client + .attach_signer(SignerHandle::new(signer, Arc::new(Callbacks { closed }))) + .await + .map_err(|_| FixtureError::Unavailable)?; + Ok(Session { + client: NativeClient::from_native(client), + workspace: Workspace::from_session(scope), + }) +} +fn reference() -> Result<SecretRef, FixtureError> { + Ok(SecretRef::new( + SecretId::parse("workspace-key").map_err(|_| FixtureError::Unavailable)?, + BackendKind::File, + KeyVersion::new(1).map_err(|_| FixtureError::Unavailable)?, + )) +} +fn key() -> Result<PublicKey, FixtureError> { + PublicKey::from_hex("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798") + .map_err(|_| FixtureError::Unavailable) +} +fn material(byte: u8) -> Result<SecretMaterial, FixtureError> { + SecretMaterial::from_slice(&[byte; 32]).map_err(|_| FixtureError::Unavailable) +} +fn crypto(provider: Arc<FileProvider>) -> Result<WorkspaceCrypto, FixtureError> { + WorkspaceCrypto::new( + provider, + reference()?, + material(0x41)?, + AccessPolicy::standard(), + ) + .map_err(|_| FixtureError::Unavailable) +} + +/// This probe belongs only to this test library, never to product bindings. +#[uniffi::export] +pub fn fixture_panic_probe() -> String { + panic!("synthetic native binding panic probe") +} + +/// Exercises unexpected panic conversion on the same Result-shaped boundary +/// used by the production command methods. This is fixture-only code. +#[uniffi::export] +pub fn fixture_result_panic_probe() -> Result<String, FixtureError> { + panic!("synthetic native binding Result panic probe") +} diff --git a/crates/radroots_ffi/tests/native/src/relay.rs b/crates/radroots_ffi/tests/native/src/relay.rs @@ -0,0 +1,179 @@ +use crate::{FixtureError, FixturePolicy, now}; +use futures::{SinkExt, StreamExt}; +use nostr::JsonUtil; +use radroots_transport::{ + policy::{SatisfactionClass, SatisfactionPolicy, TargetPolicy}, + target::Target, +}; +use radroots_transport_nostr::{ + Config, RelayAccess, RelayEndpoint, RelayProfile, RelayProfileKind, RelayUrlPolicy, +}; +use serde_json::{Value, value::RawValue}; +use std::sync::{ + Arc, Mutex, + atomic::{AtomicBool, AtomicU64, Ordering}, +}; +use tokio::{ + net::TcpListener, + sync::oneshot, + task::{JoinHandle, JoinSet}, +}; +use tokio_tungstenite::{ + accept_async_with_config, + tungstenite::{Message, protocol::WebSocketConfig}, +}; + +pub(crate) struct Relay { + pub url: String, + pub policy: SatisfactionPolicy, + pub events: Arc<Mutex<Vec<String>>>, + pub reads: Arc<AtomicU64>, + pub accepting: Arc<AtomicBool>, + stop: Mutex<Option<oneshot::Sender<()>>>, + task: Mutex<Option<JoinHandle<()>>>, +} +impl Relay { + pub async fn new(selected: FixturePolicy) -> Result<Self, FixtureError> { + let listener = TcpListener::bind("127.0.0.1:0") + .await + .map_err(|_| FixtureError::Unavailable)?; + let url = format!( + "ws://{}", + listener + .local_addr() + .map_err(|_| FixtureError::Unavailable)? + ); + let sources = Arc::new([advertisement(1, &url)?, advertisement(2, &url)?]); + let policy = match selected { + FixturePolicy::All => TargetPolicy::all(), + FixturePolicy::Any => TargetPolicy::any(), + FixturePolicy::Quorum => { + TargetPolicy::quorum(1).map_err(|_| FixtureError::Unavailable)? + } + FixturePolicy::Required => TargetPolicy::required(vec![ + Target::nostr_relay(&url) + .map_err(|_| FixtureError::Unavailable)? + .fingerprint() + .clone(), + ]) + .map_err(|_| FixtureError::Unavailable)?, + }; + let policy = SatisfactionPolicy::new(SatisfactionClass::Accepted, policy); + let events = Arc::new(Mutex::new(Vec::new())); + let received = events.clone(); + let reads = Arc::new(AtomicU64::new(0)); + let requests = reads.clone(); + let accepting = Arc::new(AtomicBool::new(true)); + let accepted = accepting.clone(); + let (stop, mut stopped) = oneshot::channel(); + let task = tokio::spawn(async move { + let mut clients = JoinSet::new(); + loop { + tokio::select! { + _ = &mut stopped => break, + _ = clients.join_next(), if !clients.is_empty() => {}, + connection = listener.accept() => { + let Ok((tcp, _)) = connection else { break }; + if clients.len() >= 16 { continue; } + let sources = sources.clone(); let events = received.clone(); let reads = requests.clone(); let accepting = accepted.clone(); + clients.spawn(async move { + let config = WebSocketConfig::default().max_message_size(Some(65_600)).max_frame_size(Some(65_600)); + let Ok(mut socket) = accept_async_with_config(tcp, Some(config)).await else { return }; + while let Some(Ok(message)) = socket.next().await { + let Message::Text(raw) = message else { continue }; + let Ok(frame) = serde_json::from_str::<Vec<&RawValue>>(&raw) else { break }; + match frame.first().map(|v| v.get()) { + Some("\"REQ\"") if frame.len() >= 3 => { + reads.fetch_add(1, Ordering::SeqCst); + let Ok(filter) = serde_json::from_str::<Value>(frame[2].get()) else { break }; + let author = filter["authors"][0].as_str(); + for source in sources.iter() { + let event: Value = serde_json::from_str(source).expect("synthetic event"); + if event["pubkey"].as_str() == author && socket.send(Message::Text(format!("[\"EVENT\",{},{}]", frame[1].get(), source).into())).await.is_err() { return; } + } + if socket.send(Message::Text(format!("[\"EOSE\",{}]", frame[1].get()).into())).await.is_err() { return; } + } + Some("\"EVENT\"") if frame.len() == 2 => { + let original = frame[1].get(); + let Ok(event) = nostr::Event::from_json(original) else { break }; + if event.verify().is_err() { break; } + { + let mut retained = events.lock().expect("fixture events"); + let bytes: usize = retained.iter().map(String::len).sum(); + if bytes + original.len() > 4 * 1024 * 1024 { return; } + retained.push(original.to_owned()); + } + let accepted = accepting.load(Ordering::SeqCst); + let reason = if accepted { "" } else { "blocked: measured loopback rejection" }; + let ack = serde_json::json!(["OK", event.id.to_hex(), accepted, reason]); + if socket.send(Message::Text(ack.to_string().into())).await.is_err() { return; } + } + _ => {} + } + } + }); + } + } + } + clients.abort_all(); + while clients.join_next().await.is_some() {} + }); + Ok(Self { + url, + policy, + events, + reads, + accepting, + stop: Mutex::new(Some(stop)), + task: Mutex::new(Some(task)), + }) + } + pub fn config(&self) -> Result<Config, FixtureError> { + let endpoint = RelayEndpoint::new(&self.url, RelayUrlPolicy::Local, RelayAccess::ReadWrite) + .map_err(|_| FixtureError::Unavailable)?; + let profile = RelayProfile::explicit(RelayProfileKind::Simulator, [endpoint]) + .map_err(|_| FixtureError::Unavailable)?; + Config::from_profile(profile) + .with_timeouts(2000, 2000, 2000) + .map_err(|_| FixtureError::Unavailable) + } + pub async fn stop(&self) -> Result<(), FixtureError> { + if let Some(stop) = self + .stop + .lock() + .map_err(|_| FixtureError::Unavailable)? + .take() + { + let _ = stop.send(()); + } + let task = self + .task + .lock() + .map_err(|_| FixtureError::Unavailable)? + .take(); + if let Some(task) = task { + task.await.map_err(|_| FixtureError::Unavailable)?; + } + Ok(()) + } +} +fn advertisement(last: u8, url: &str) -> Result<String, FixtureError> { + let mut scalar = [0; 32]; + scalar[31] = last; + let keys = nostr::Keys::new( + nostr::SecretKey::from_slice(&scalar).map_err(|_| FixtureError::Unavailable)?, + ); + nostr::UnsignedEvent { + id: None, + pubkey: keys.public_key(), + created_at: nostr::Timestamp::from_secs(now()?.saturating_sub(1)), + kind: nostr::Kind::Custom(10050), + tags: nostr::Tags::from_list(vec![ + nostr::Tag::parse(["relay", url]).map_err(|_| FixtureError::Unavailable)?, + ]), + content: String::new(), + } + .sign_with_keys(&keys) + .map(|v| v.as_json()) + .map_err(|_| FixtureError::Unavailable) +} diff --git a/crates/radroots_ffi/tests/native/src/signer.rs b/crates/radroots_ffi/tests/native/src/signer.rs @@ -0,0 +1,101 @@ +use radroots_nostr::{ + key::parse_secret_key, + signing::{LocalSigner, OsNonceSource}, +}; +use radroots_signing::{ + Signer, + issuance::{SigningIntent, SigningOutcome}, + provider::{ + ParticipantProvider, PrivateCiphertext, PrivateText, ProviderCall, ProviderError, + ProviderState, + }, + signer::BoxFuture, +}; +use std::sync::{ + Arc, + atomic::{AtomicBool, AtomicU64, Ordering}, +}; +use tokio::sync::Notify; + +pub(crate) struct MeasuredSigner { + local: LocalSigner, + pub calls: AtomicU64, + pub legacy_calls: AtomicU64, + pub unknown: AtomicBool, + pub pause_next: AtomicBool, + pub paused: AtomicBool, + release: Notify, +} +impl MeasuredSigner { + pub fn new(unknown: bool, pause: bool) -> Arc<Self> { + Arc::new(Self { + local: LocalSigner::new( + parse_secret_key( + "0000000000000000000000000000000000000000000000000000000000000001", + ) + .expect("synthetic scalar"), + ) + .expect("synthetic signer") + .with_nonce_source(Arc::new(OsNonceSource)), + calls: AtomicU64::new(0), + legacy_calls: AtomicU64::new(0), + unknown: AtomicBool::new(unknown), + pause_next: AtomicBool::new(pause), + paused: AtomicBool::new(false), + release: Notify::new(), + }) + } + pub fn release(&self) { + self.release.notify_one(); + } +} +impl Signer for MeasuredSigner { + fn status( + &self, + ) -> BoxFuture<'_, Result<radroots_signing::SignerStatus, radroots_signing::Error>> { + self.local.status() + } + fn sign( + &self, + request: radroots_signing::SignRequest, + ) -> BoxFuture<'_, Result<radroots_signing::SignReceipt, radroots_signing::Error>> { + self.legacy_calls.fetch_add(1, Ordering::SeqCst); + self.local.sign(request) + } +} +impl ParticipantProvider for MeasuredSigner { + fn provider_state(&self) -> BoxFuture<'_, Result<ProviderState, ProviderError>> { + self.local.provider_state() + } + fn sign_exact(&self, intent: SigningIntent) -> BoxFuture<'_, SigningOutcome> { + Box::pin(async move { + self.calls.fetch_add(1, Ordering::SeqCst); + if self.unknown.load(Ordering::SeqCst) { + return SigningOutcome::unknown(intent.binding(), ProviderError::ProviderFailure); + } + let outcome = self.local.sign_exact(intent).await; + if self.pause_next.swap(false, Ordering::SeqCst) { + self.paused.store(true, Ordering::SeqCst); + self.release.notified().await; + self.paused.store(false, Ordering::SeqCst); + } + outcome + }) + } + fn encrypt_private( + &self, + call: ProviderCall, + recipient: radroots_domain::PublicKey, + plaintext: PrivateText, + ) -> BoxFuture<'_, Result<PrivateCiphertext, ProviderError>> { + self.local.encrypt_private(call, recipient, plaintext) + } + fn decrypt_private( + &self, + call: ProviderCall, + sender: radroots_domain::PublicKey, + ciphertext: PrivateCiphertext, + ) -> BoxFuture<'_, Result<PrivateText, ProviderError>> { + self.local.decrypt_private(call, sender, ciphertext) + } +} diff --git a/crates/radroots_ffi/tests/native/tests/flows.rs b/crates/radroots_ffi/tests/native/tests/flows.rs @@ -0,0 +1,452 @@ +//! Real host/kernel effects through the same production objects used by languages. +use nostr::JsonUtil; +use radroots_ffi::{ + Admission, BusinessInstallation, CommandRequest, InquiryInput, Issuance, ListingInput, + OperationKind, SessionState, StartMode, TargetObservation, Value, +}; +use radroots_native_binding_fixture::{Host, Session}; +use std::{sync::Arc, time::Duration}; + +fn request(host: &Host, id: u8) -> CommandRequest { + CommandRequest { + operation_id: format!("{id:02x}").repeat(32), + first_issue_not_after: (host.unix_seconds().unwrap().parse::<u64>().unwrap() + 120) + .to_string(), + correlation_id: Some("native binding workflow".into()), + } +} +fn listing(host: &Host, id: u8) -> Arc<ListingInput> { + let input = serde_json::json!({"id":format!("{id:02x}").repeat(16),"title":" Native carrots 🥕 ","summary":"Quote required","description_markdown":"Exact public terms","published_at":host.unix_seconds().unwrap(), + "profile":{"profile":"radroots.listing","version":1,"state":"active","product":{"name":"Carrots","description":"Fresh carrots","producer":null,"origin_summary":null},"default_option":"02".repeat(32), + "options":[{"id":"02".repeat(32),"label":"Bunch","unit":{"type":"package","label":"bunch","contents":{"type":"unspecified"}},"increment":"1","minimum":"1","price":{"type":"quote_required"},"supply":{"type":"available","amount":"10"},"lead_seconds":"0"}], + "fulfillment":{"modes":["pickup"],"area":"Example","lead_seconds":"0"},"authority":null,"media":[]}}); + ListingInput::parse(serde_json::to_vec(&input).unwrap()).unwrap() +} +async fn close(host: &Host, session: &Session) { + let callbacks = host + .measurements() + .unwrap() + .closed_callbacks + .parse::<u64>() + .unwrap(); + session.client.close().await.unwrap(); + assert_eq!(session.client.state(), SessionState::Closed); + assert_eq!( + host.measurements() + .unwrap() + .closed_callbacks + .parse::<u64>() + .unwrap(), + callbacks + 1 + ); + host.cleanup().await.unwrap(); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn public_projection_reopen_and_explicit_retry_keep_actual_original_signature_and_bytes() { + let host = Host::open(true, false, false).await.unwrap(); + let first = host.session(); + first.client.start(StartMode::Online).await.unwrap(); + host.set_accepting(false); + let input = listing(&host, 1); + let mut context = request(&host, 1); + context.first_issue_not_after = + (host.unix_seconds().unwrap().parse::<u64>().unwrap() + 10).to_string(); + let receipt = first + .client + .publish_listing(first.workspace.clone(), context.clone(), input.clone()) + .await + .unwrap(); + assert_eq!(receipt.kind, OperationKind::Listing); + assert_eq!(receipt.admission, Admission::Confirmed); + assert_eq!( + receipt.business_installation, + BusinessInstallation::Installed + ); + assert_eq!(receipt.issuance, Issuance::Obtained); + assert!(receipt.message_id.is_none()); + assert!(receipt.artifacts.iter().all(|v| v.recipient.is_none())); + assert_eq!(receipt.delivery_observations.len(), 1); + assert_eq!( + receipt.delivery_observations[0].outcome, + TargetObservation::Rejected + ); + let Value::Listing { listing } = receipt.business_result.as_ref().unwrap() else { + panic!("actual public family") + }; + assert_eq!(listing.title(), " Native carrots 🥕 "); + let original = host.measurements().unwrap(); + assert_eq!(original.signing_calls, "1"); + assert_eq!(original.legacy_signing_calls, "0"); + assert_eq!(original.relay_reads, "0"); + let event = nostr::Event::from_json(&original.original_signed_events[0]).unwrap(); + event.verify().unwrap(); + assert_eq!(event.id.to_hex(), listing.revision()); + assert_eq!(listing.id(), "01".repeat(16)); + assert_eq!(listing.author(), event.pubkey.to_hex()); + assert_eq!(listing.created_at(), event.created_at.as_secs().to_string()); + assert!(listing.published_at().parse::<u64>().unwrap() > 0); + assert_eq!(listing.summary(), "Quote required"); + assert_eq!(listing.description_markdown(), "Exact public terms"); + let terms: serde_json::Value = serde_json::from_slice(&listing.terms_json().unwrap()).unwrap(); + assert_eq!(terms["product"]["name"], "Carrots"); + let replay = first + .client + .publish_listing(first.workspace.clone(), context, input) + .await + .unwrap(); + assert_eq!(replay.operation_checkpoint, receipt.operation_checkpoint); + assert_eq!( + host.measurements().unwrap().original_signed_events, + original.original_signed_events + ); + first.client.close().await.unwrap(); + let reopened = host.reopen().await.unwrap(); + reopened.client.start(StartMode::Online).await.unwrap(); + let queried = reopened + .client + .operation( + reopened.workspace.clone(), + receipt.operation_id.clone(), + Some(receipt.command_digest.clone()), + ) + .await + .unwrap() + .unwrap(); + assert_eq!(queried.operation_checkpoint, receipt.operation_checkpoint); + assert_eq!( + host.measurements().unwrap().original_signed_events, + original.original_signed_events + ); + let expiry = receipt.first_issue_not_after.parse::<u64>().unwrap(); + let now = host.unix_seconds().unwrap().parse::<u64>().unwrap(); + if now <= expiry { + tokio::time::sleep(Duration::from_secs(expiry - now + 1)).await; + } + host.set_accepting(true); + let resumed = reopened + .client + .resume( + reopened.workspace.clone(), + receipt.operation_id, + Some(receipt.command_digest), + ) + .await + .unwrap(); + assert_eq!(resumed.first_issue_not_after, receipt.first_issue_not_after); + assert_eq!(resumed.delivery_attempts.len(), 2); + assert_eq!( + resumed.delivery_attempts[0].original_bytes_digest, + resumed.delivery_attempts[1].original_bytes_digest + ); + assert_eq!( + resumed.delivery_attempts[0].publication_policy_digest, + resumed.delivery_attempts[1].publication_policy_digest + ); + let mut ordinals: Vec<_> = resumed + .delivery_attempts + .iter() + .map(|attempt| attempt.target_ordinals.clone()) + .collect(); + ordinals.sort(); + assert_eq!(ordinals, [vec![1], vec![2]]); + assert!( + resumed + .delivery_observations + .iter() + .any(|v| v.outcome == TargetObservation::Accepted) + ); + let actual = host.measurements().unwrap(); + assert_eq!(actual.signing_calls, "1"); + assert_eq!( + actual.original_signed_events, + [ + original.original_signed_events[0].clone(), + original.original_signed_events[0].clone() + ] + ); + close(&host, &reopened).await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn private_value_and_foreign_scope_refusal_use_real_grants_and_no_additional_effects() { + let host = Host::open(false, false, false).await.unwrap(); + let session = host.session(); + session.client.start(StartMode::Online).await.unwrap(); + let mut scalar = [0; 32]; + scalar[31] = 2; + let peer = nostr::Keys::new(nostr::SecretKey::from_slice(&scalar).unwrap()) + .public_key() + .to_hex(); + let text = "\u{feff} Cafe\u{301} / Café Binding inquiry 🥕\nExact text\0 "; + let input = InquiryInput::new("22".repeat(32), peer.clone(), None, text.into()).unwrap(); + let receipt = session + .client + .inquire(session.workspace.clone(), request(&host, 2), input.clone()) + .await + .unwrap(); + assert_eq!(receipt.kind, OperationKind::Chat); + assert_eq!( + receipt.business_installation, + BusinessInstallation::Installed + ); + let Value::Chat { message } = receipt.business_result.unwrap() else { + panic!("actual private family") + }; + assert_eq!(message.peer(), peer); + assert_eq!(message.text(), text); + assert_eq!(Some(message.id()), receipt.message_id); + assert_eq!(message.thread_id(), "22".repeat(32)); + assert_eq!( + message.author(), + "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" + ); + assert!(message.created_at().parse::<u64>().unwrap() > 0); + assert!(matches!( + message.relation().unwrap(), + radroots_ffi::ChatRelation::Inquire { source: None } + )); + let queried = session + .client + .operation( + session.workspace.clone(), + receipt.operation_id.clone(), + Some(receipt.command_digest.clone()), + ) + .await + .unwrap() + .unwrap(); + assert!(matches!(queried.business_result, Some(Value::Chat { .. }))); + assert_eq!(receipt.artifacts.len(), 2); + assert!(receipt.artifacts.iter().all(|v| v.recipient.is_some())); + let before = host.measurements().unwrap(); + assert_eq!(before.signing_calls, "2"); + assert_ne!(before.relay_reads, "0"); + let foreign = Host::open(false, false, false).await.unwrap(); + let other = foreign.session(); + other.client.start(StartMode::Online).await.unwrap(); + let error = session + .client + .inquire(other.workspace.clone(), request(&host, 3), input) + .await + .err() + .expect("foreign scope must refuse"); + assert!(matches!( + error, + radroots_ffi::Error::Operation { + admission: Admission::NotAdmitted, + .. + } + )); + assert_eq!( + host.measurements().unwrap().signing_calls, + before.signing_calls + ); + assert_eq!( + host.measurements().unwrap().original_signed_events, + before.original_signed_events + ); + assert_eq!(foreign.measurements().unwrap().signing_calls, "0"); + close(&foreign, &other).await; + close(&host, &session).await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn unknown_provider_outcome_survives_reopen_without_reissuance() { + let host = Host::open(true, true, false).await.unwrap(); + let session = host.session(); + session.client.start(StartMode::Online).await.unwrap(); + let receipt = session + .client + .publish_listing( + session.workspace.clone(), + request(&host, 4), + listing(&host, 4), + ) + .await + .unwrap(); + assert_eq!(receipt.issuance, Issuance::Unknown); + assert!(receipt.business_result.is_none()); + session.client.close().await.unwrap(); + host.set_unknown_signing(false); + let reopened = host.reopen().await.unwrap(); + reopened.client.start(StartMode::Online).await.unwrap(); + let resumed = reopened + .client + .resume( + reopened.workspace.clone(), + receipt.operation_id, + Some(receipt.command_digest), + ) + .await + .unwrap(); + assert_eq!(resumed.issuance, Issuance::Unknown); + assert!(resumed.business_result.is_none()); + let measured = host.measurements().unwrap(); + assert_eq!(measured.signing_calls, "1"); + assert!(measured.original_signed_events.is_empty()); + close(&host, &reopened).await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn malformed_context_and_selectors_and_closed_attachment_have_no_signing_effects() { + let host = Host::open(true, false, false).await.unwrap(); + let session = host.session(); + assert_eq!( + session.client.start(StartMode::LocalOnly).await.unwrap(), + SessionState::Running + ); + let input = listing(&host, 7); + for (field, value) in [ + ("operation_id", "bad"), + ("first_issue_not_after", "not-time"), + ("correlation_id", "not\nallowed"), + ] { + let mut context = request(&host, 7); + match field { + "operation_id" => context.operation_id = value.into(), + "first_issue_not_after" => context.first_issue_not_after = value.into(), + _ => context.correlation_id = Some(value.into()), + } + let error = session + .client + .publish_listing(session.workspace.clone(), context, input.clone()) + .await + .err() + .expect("invalid context"); + assert!( + matches!(error, radroots_ffi::Error::InvalidInput { field: actual } if actual == field) + ); + } + for (id, digest, field) in [ + ("bad".into(), None, "operation_id"), + ("77".repeat(32), Some("bad".into()), "command_digest"), + ] { + let error = session + .client + .operation(session.workspace.clone(), id, digest) + .await + .err() + .expect("invalid selector"); + assert!( + matches!(error, radroots_ffi::Error::InvalidInput { field: actual } if actual == field) + ); + } + assert!( + session + .client + .operation(session.workspace.clone(), "77".repeat(32), None) + .await + .unwrap() + .is_none() + ); + session.workspace.close(); + assert!(matches!( + session + .client + .publish_listing(session.workspace.clone(), request(&host, 7), input) + .await, + Err(radroots_ffi::Error::Operation { + admission: Admission::NotAdmitted, + .. + }) + )); + let measured = host.measurements().unwrap(); + assert_eq!(measured.signing_calls, "0"); + assert_eq!(measured.relay_reads, "0"); + assert!(measured.original_signed_events.is_empty()); + close(&host, &session).await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn actual_public_deliveries_retain_each_configured_shared_satisfaction_policy() { + use radroots_native_binding_fixture::FixturePolicy; + for (index, policy) in [ + FixturePolicy::All, + FixturePolicy::Any, + FixturePolicy::Quorum, + FixturePolicy::Required, + ] + .into_iter() + .enumerate() + { + let host = Host::open_with_policy(true, false, false, policy) + .await + .unwrap(); + let session = host.session(); + session.client.start(StartMode::Online).await.unwrap(); + let receipt = session + .client + .publish_listing( + session.workspace.clone(), + request(&host, 10 + index as u8), + listing(&host, 10 + index as u8), + ) + .await + .unwrap(); + let attempt = &receipt.delivery_attempts[0]; + match (policy, &attempt.policy) { + (FixturePolicy::All, radroots_ffi::TargetPolicy::All) + | (FixturePolicy::Any, radroots_ffi::TargetPolicy::Any) => {} + (FixturePolicy::Quorum, radroots_ffi::TargetPolicy::Quorum { threshold }) => { + assert_eq!(*threshold, 1) + } + (FixturePolicy::Required, radroots_ffi::TargetPolicy::Required { fingerprints }) => { + assert_eq!(fingerprints, &attempt.selected_fingerprints) + } + _ => panic!("source-owned policy changed at projection"), + } + assert_eq!(host.measurements().unwrap().signing_calls, "1"); + assert!( + receipt + .delivery_observations + .iter() + .any(|value| value.outcome == TargetObservation::Accepted) + ); + close(&host, &session).await; + } +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn lost_observers_preserve_actual_obtained_signature_through_close_and_reopen() { + let host = Host::open(true, false, true).await.unwrap(); + let session = host.session(); + session.client.start(StartMode::Online).await.unwrap(); + let request = request(&host, 5); + let operation = request.operation_id.clone(); + let input = listing(&host, 5); + let client = session.client.clone(); + let workspace = session.workspace.clone(); + let observer = + tokio::spawn(async move { client.publish_listing(workspace, request, input).await }); + host.wait_until_signer_paused().await.unwrap(); + observer.abort(); + let _ = observer.await; + let client = session.client.clone(); + let closing = tokio::spawn(async move { client.close().await }); + tokio::time::timeout(Duration::from_secs(2), async { + while session.client.state() != SessionState::Closing { + tokio::task::yield_now().await; + } + }) + .await + .unwrap(); + closing.abort(); + let _ = closing.await; + host.release_signer(); + session.client.close().await.unwrap(); + let reopened = host.reopen().await.unwrap(); + reopened.client.start(StartMode::Online).await.unwrap(); + let receipt = reopened + .client + .resume(reopened.workspace.clone(), operation, None) + .await + .unwrap(); + assert_eq!(receipt.issuance, Issuance::Obtained); + assert_eq!( + receipt.business_installation, + BusinessInstallation::Installed + ); + assert_eq!(host.measurements().unwrap().signing_calls, "1"); + close(&host, &reopened).await; +} diff --git a/crates/sdk_ffi/Cargo.toml b/crates/sdk_ffi/Cargo.toml @@ -24,7 +24,7 @@ radroots_event = { workspace = true, features = ["std"] } radroots_event_codec = { workspace = true, features = ["json", "std"] } radroots_sdk = { workspace = true, features = ["memory"] } thiserror = { workspace = true } -uniffi = { workspace = true, features = ["cli"] } +uniffi = { workspace = true, features = ["cli", "cargo-metadata"] } [dev-dependencies] serde_json = { workspace = true } diff --git a/tools/xtask/Cargo.toml b/tools/xtask/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "xtask" +default-run = "xtask" version = "0.1.0-alpha" edition.workspace = true rust-version.workspace = true @@ -9,7 +10,13 @@ license.workspace = true publish = false authors = ["Tyson Lupul <tyson@radroots.org>"] +[[bin]] +name = "radroots_ffi_bindgen" +path = "src/bin/radroots_ffi_bindgen/main.rs" + [dependencies] +anyhow = { workspace = true } +camino = "1" clap = { workspace = true, features = ["derive"] } dto_bindgen_core = { workspace = true } dto_bindgen_backend_ts = { workspace = true } @@ -40,6 +47,7 @@ tar = { workspace = true } tempfile = { workspace = true } toml = { workspace = true } walkdir = { workspace = true } +uniffi_bindgen = "=0.32.2" [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] } diff --git a/tools/xtask/src/bin/radroots_ffi_bindgen/async.swift b/tools/xtask/src/bin/radroots_ffi_bindgen/async.swift @@ -0,0 +1,57 @@ +// radroots-swift-cancellation-v1. Only the observing Rust future is cancelled; +// admitted work and obtained material remain owned by the shared runtime. +// NSLock serializes cancel against release. The unchecked Sendable owner has +// no unsynchronized mutable state; its immutable C callback is Sendable. +fileprivate final class UniffiRustCancellation: @unchecked Sendable { + private let lock = NSLock() + private var handle: UInt64? + private let cancelFunction: @Sendable (UInt64) -> Void + init(_ handle: UInt64, _ cancelFunction: @escaping @Sendable (UInt64) -> Void) { + self.handle = handle + self.cancelFunction = cancelFunction + } + func cancel() { + lock.lock() + defer { lock.unlock() } + if let handle { cancelFunction(handle) } + } + func finish() { + lock.lock() + defer { lock.unlock() } + handle = nil + } +} + +fileprivate func uniffiRustCallAsync<F, T>( + rustFutureFunc: () -> UInt64, + pollFunc: (UInt64, @escaping UniffiRustFutureContinuationCallback, UInt64) -> (), + completeFunc: (UInt64, UnsafeMutablePointer<RustCallStatus>) -> F, + cancelFunc: @escaping @Sendable (UInt64) -> Void, + freeFunc: (UInt64) -> (), + liftFunc: (F) throws -> T, + errorHandler: ((RustBuffer) throws -> Swift.Error)? +) async throws -> T { + try Task.checkCancellation() + __RADROOTS_ENSURE_INIT__ + let handle = rustFutureFunc() + let cancellation = UniffiRustCancellation(handle, cancelFunc) + defer { + cancellation.finish() + freeFunc(handle) + } + return try await withTaskCancellationHandler { + var ready: Int8 + repeat { + ready = await withUnsafeContinuation { continuation in + let callbackHandle = uniffiContinuationHandleMap.insert(obj: continuation) + pollFunc(handle, { callbackHandle, status in + uniffiFutureContinuationCallback(handle: callbackHandle, pollResult: status) + }, callbackHandle) + } + } while ready != UNIFFI_RUST_FUTURE_POLL_READY + let result = try makeRustCall({ completeFunc(handle, $0) }, errorHandler: errorHandler) + return try liftFunc(result) + } onCancel: { + cancellation.cancel() + } +} diff --git a/tools/xtask/src/bin/radroots_ffi_bindgen/kotlin.rs b/tools/xtask/src/bin/radroots_ffi_bindgen/kotlin.rs @@ -0,0 +1,95 @@ +//! UniFFI0.32.2 close policy. The upstream automatic AutoCloseable helper +//! collides with a real exported close method (upstream issue2955). +//! Only remove the handle-destruction alias for objects whose extracted Rust +//! metadata declares close; keep the source lifecycle call and destroy intact. +use anyhow::{Result, ensure}; + +const SHIM: &str = " @Synchronized\n override fun close() {\n this.destroy()\n }\n"; + +pub(super) fn preserve_close(source: &str, methods: &[(String, bool)]) -> Result<String> { + let mut output = source.to_owned(); + for (name, asynchronous) in methods { + let header = format!("open class {name}: Disposable, AutoCloseable, {name}Interface"); + ensure!( + output.matches(&header).count() == 1, + "unexpected Kotlin object header for {name}" + ); + let start = output.find(&header).expect("counted header"); + let end = start + + output[start..] + .find(" internal inline fun <R> callWithHandle(") + .ok_or_else(|| anyhow::anyhow!("unexpected Kotlin handle layout for {name}"))?; + let prefix = &output[start..end]; + ensure!( + prefix.matches(SHIM).count() == 1, + "unexpected Kotlin close helper for {name}" + ); + let method = if *asynchronous { + "override suspend fun `close`()" + } else { + "override fun `close`()" + }; + // Scope the exported method to this object, rather than another class. + let tail_end = output[end..] + .find("\nopen class ") + .map_or(output.len(), |offset| end + offset); + ensure!( + output[end..tail_end].matches(method).count() == 1, + "missing source close for {name}" + ); + let replacement = prefix + .replace(&header, &header.replace(", AutoCloseable", "")) + .replacen(SHIM, "", 1); + output.replace_range(start..end, &replacement); + } + Ok(output) +} + +#[cfg(test)] +mod tests { + use super::*; + fn object(name: &str, asynchronous: bool) -> String { + format!( + "open class {name}: Disposable, AutoCloseable, {name}Interface\n{{\n override fun destroy() {{ actualFree() }}\n{SHIM}\n internal inline fun <R> callWithHandle(block: (Long) -> R): R {{ actualCall() }}\n override {}fun `close`() {{ actualSourceClose() }}\n}}\n", + if asynchronous { "suspend " } else { "" } + ) + } + #[test] + fn preserves_actual_sync_and_async_close_and_other_objects() { + let host = object("Host", false); + let source = format!( + "{}{}{}", + object("NativeClient", true), + object("Workspace", false), + host + ); + let actual = preserve_close( + &source, + &[("NativeClient".into(), true), ("Workspace".into(), false)], + ) + .unwrap(); + assert!(actual.ends_with(&host)); + assert_eq!(actual.matches("actualSourceClose()").count(), 3); + assert_eq!(actual.matches("actualFree()").count(), 3); + assert_eq!(actual.matches(SHIM).count(), 1); + assert!(!actual.contains("NativeClient: Disposable, AutoCloseable")); + assert!(!actual.contains("Workspace: Disposable, AutoCloseable")); + } + #[test] + fn rejects_drift_missing_source_and_reapplication() { + let metadata = [("NativeClient".into(), true)]; + let source = object("NativeClient", true); + assert!(preserve_close(&source.replace(SHIM, ""), &metadata).is_err()); + assert!( + preserve_close( + &source.replace("override suspend fun `close`", "fun other"), + &metadata + ) + .is_err() + ); + assert!(preserve_close(&source.replace("callWithHandle", "changed"), &metadata).is_err()); + assert!(preserve_close(&format!("{source}{source}"), &metadata).is_err()); + assert!(preserve_close(&preserve_close(&source, &metadata).unwrap(), &metadata).is_err()); + assert_eq!(preserve_close(&source, &[]).unwrap(), source); + } +} diff --git a/tools/xtask/src/bin/radroots_ffi_bindgen/main.rs b/tools/xtask/src/bin/radroots_ffi_bindgen/main.rs @@ -0,0 +1,125 @@ +//! Source-owned native generation; no hand-edited generated bindings. +use anyhow::{Context, Result, ensure}; +use camino::Utf8PathBuf; +use clap::{Parser, Subcommand, ValueEnum}; +use std::fs; +use uniffi_bindgen::bindings::{GenerateOptions, TargetLanguage}; + +mod kotlin; +mod swift; + +#[derive(Parser)] +#[command(version = "0.32.2+radroots-native-v1")] +struct Cli { + #[command(subcommand)] + command: Command, +} +#[derive(Subcommand)] +enum Command { + /// Generate from the actual multi-component native library. + Generate { + #[arg(long)] + library: bool, + source: Utf8PathBuf, + #[arg(long, value_enum)] + language: Language, + #[arg(long)] + out_dir: Utf8PathBuf, + /// Stable unformatted output is required by the source-owned policy. + #[arg(long)] + no_format: bool, + }, +} +#[derive(Clone, Copy, ValueEnum)] +enum Language { + Swift, + Kotlin, +} + +fn main() -> Result<()> { + let Command::Generate { + library: _, + source, + language, + out_dir, + no_format, + } = Cli::parse().command; + ensure!(no_format, "source-owned generation requires --no-format"); + ensure!(!out_dir.exists(), "output directory must be new"); + let staging = tempfile::tempdir().context("create generation staging")?; + let stage = Utf8PathBuf::from_path_buf(staging.path().to_owned()) + .map_err(|_| anyhow::anyhow!("non-UTF8 generation staging"))?; + uniffi_bindgen::bindings::generate(GenerateOptions { + languages: vec![match language { + Language::Swift => TargetLanguage::Swift, + Language::Kotlin => TargetLanguage::Kotlin, + }], + source: source.clone(), + out_dir: stage.clone(), + format: false, + ..Default::default() + })?; + { + let components = uniffi_bindgen::library_mode::find_cis( + &source, + &uniffi_bindgen::EmptyCrateConfigSupplier, + )?; + for ci in components { + if matches!(language, Language::Swift) { + if ci.has_async_fns() { + let path = stage.join(format!("{}.swift", ci.namespace())); + let header = + fs::read_to_string(stage.join(format!("{}FFI.h", ci.namespace())))?; + let generated = swift::cancellation(&fs::read_to_string(&path)?, &header)?; + fs::write(path, generated)?; + } + continue; + } + let methods: Vec<_> = ci + .object_definitions() + .iter() + .filter_map(|object| { + object + .methods() + .into_iter() + .find(|method| method.name() == "close") + .map(|method| (object.name().to_owned(), method.is_async())) + }) + .collect(); + if methods.is_empty() { + continue; + } + // This producer has no foreign renaming/package configuration. Fail + // closed if its source-owned canonical package layout ever changes. + let path = stage.join(format!("uniffi/{0}/{0}.kt", ci.namespace())); + let original = fs::read_to_string(&path).context("read Kotlin component")?; + let generated = kotlin::preserve_close(&original, &methods)?; + fs::write(path, generated)?; + } + } + copy_tree(&stage, &out_dir)?; + Ok(()) +} + +fn copy_tree(source: &camino::Utf8Path, output: &camino::Utf8Path) -> Result<()> { + fs::create_dir(output)?; + for entry in fs::read_dir(source)? { + let entry = entry?; + let destination = output.join( + entry + .file_name() + .to_str() + .context("non-UTF8 generated path")?, + ); + let kind = entry.file_type()?; + if kind.is_dir() { + let path = Utf8PathBuf::from_path_buf(entry.path()) + .map_err(|_| anyhow::anyhow!("non-UTF8 generated path"))?; + copy_tree(&path, &destination)?; + } else { + ensure!(kind.is_file(), "unexpected generated entry type"); + fs::copy(entry.path(), destination)?; + } + } + Ok(()) +} diff --git a/tools/xtask/src/bin/radroots_ffi_bindgen/swift.rs b/tools/xtask/src/bin/radroots_ffi_bindgen/swift.rs @@ -0,0 +1,82 @@ +//! Source-owned observer cancellation over UniFFI's thread-safe cancel ABI. +use anyhow::{Result, ensure}; +use sha2::{Digest, Sha256}; + +const START: &str = "fileprivate func uniffiRustCallAsync<F, T>("; +const END: &str = "// Callback handlers for an async calls."; +const UPSTREAM_SHA256: &str = "f05b2a0d1b6d335801874c67de4b25ad50d2995ccdf6650da0562a4b8d943518"; +const CANCELLED: &str = + " case CALL_CANCELLED:\n fatalError(\"Cancellation not supported yet\")"; + +pub(super) fn cancellation(source: &str, header: &str) -> Result<String> { + ensure!( + source.matches(START).count() == 1 && source.matches(END).count() == 1, + "unexpected Swift async helper layout" + ); + let start = source.find(START).expect("counted helper"); + let end = source.find(END).expect("counted boundary"); + ensure!(end > start, "invalid Swift helper boundaries"); + let original = &source[start..end]; + let initializers: Vec<_> = original + .lines() + .filter(|line| line.starts_with(" uniffiEnsure") && line.ends_with("Initialized()")) + .collect(); + ensure!(initializers.len() == 1, "unexpected Swift initializer"); + let normalized = original.replace(initializers[0], " {{ ensure_init_fn_name }}()"); + ensure!( + format!("{:x}", Sha256::digest(normalized.as_bytes())) == UPSTREAM_SHA256, + "upstream Swift async helper changed" + ); + ensure!( + source.matches(CANCELLED).count() == 1, + "unexpected Swift cancellation error branch" + ); + let helper = format!("{}\n", include_str!("async.swift")) + .replace(" __RADROOTS_ENSURE_INIT__", initializers[0]); + let mut output = format!("{}{}{}", &source[..start], helper, &source[end..]); + output = output.replacen( + CANCELLED, + " case CALL_CANCELLED:\n throw CancellationError()", + 1, + ); + let mut rewritten = String::with_capacity(output.len()); + let mut count = 0; + for line in output.split_inclusive('\n') { + if let Some(symbol) = line.strip_prefix(" freeFunc: ") { + let symbol = symbol + .strip_suffix(",\n") + .ok_or_else(|| anyhow::anyhow!("unexpected Swift free callback"))?; + ensure!( + symbol + .bytes() + .all(|byte| byte.is_ascii_alphanumeric() || byte == b'_') + && symbol.matches("_rust_future_free_").count() == 1, + "unexpected Swift callback symbol" + ); + let cancel = symbol.replacen("_rust_future_free_", "_rust_future_cancel_", 1); + ensure!( + header + .matches(&format!("void {cancel}(uint64_t handle")) + .count() + == 1, + "missing native cancel ABI" + ); + rewritten.push_str(&format!(" cancelFunc: {cancel},\n")); + count += 1; + } + rewritten.push_str(line); + } + ensure!(count > 0, "no Swift async calls found"); + Ok(rewritten) +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn refuses_unknown_layout_and_prepatched_input() { + assert!(cancellation("", "").is_err()); + assert!(cancellation(&format!("{START}\nchanged\n{END}"), "").is_err()); + assert!(cancellation(include_str!("async.swift"), "").is_err()); + } +} diff --git a/tools/xtask/src/catalog.rs b/tools/xtask/src/catalog.rs @@ -362,6 +362,8 @@ fn validate_catalog(catalog: &Catalog) -> Result<(), String> { "radroots" => "crates/radroots".to_owned(), // shared_sdk_refactor.v1.json fixes the browser artifact-root path. "radroots_browser" => "crates/radroots_browser".to_owned(), + // The same approved decision fixes the concrete native boundary. + "radroots_ffi" => "crates/radroots_ffi".to_owned(), "xtask" => "tools/xtask".to_owned(), name => format!( "crates/{}", diff --git a/tools/xtask/src/coverage.rs b/tools/xtask/src/coverage.rs @@ -294,6 +294,7 @@ struct CoverageProfileRaw { features: Option<Vec<String>>, test_threads: Option<u32>, test_packages: Option<Vec<String>>, + test_manifest: Option<String>, } #[derive(Debug, Clone)] @@ -302,6 +303,7 @@ struct CoverageProfile { features: Vec<String>, test_threads: Option<u32>, test_packages: Vec<String>, + test_manifest: Option<String>, } #[cfg_attr(not(test), allow(dead_code))] @@ -1186,6 +1188,7 @@ fn merge_coverage_profile( test_packages: overlay .test_packages .unwrap_or_else(|| base.test_packages.unwrap_or_default()), + test_manifest: overlay.test_manifest.or(base.test_manifest), } } @@ -1202,6 +1205,7 @@ fn read_coverage_profile( features: Vec::new(), test_threads: None, test_packages: Vec::new(), + test_manifest: None, }); } let parsed = parse_toml::<CoverageProfilesFile>(&path)?; @@ -1227,7 +1231,15 @@ fn read_coverage_profile( "coverage profile for {crate_name} must set test_threads > 0" )); } - let workspace_packages = if resolved.test_packages.is_empty() { + let fixture = coverage_fixture_manifest( + workspace_root, + crate_name, + resolved.test_manifest.as_deref(), + )?; + let workspace_packages = if let Some(manifest) = fixture { + let parsed: PackageManifest = parse_toml(&manifest)?; + BTreeSet::from([parsed.package.name]) + } else if resolved.test_packages.is_empty() { BTreeSet::new() } else { read_workspace_packages(workspace_root)? @@ -1261,6 +1273,45 @@ fn read_coverage_profile( Ok(resolved) } +fn coverage_fixture_manifest( + root: &Path, + crate_name: &str, + relative: Option<&str>, +) -> Result<Option<PathBuf>, String> { + let Some(relative) = relative else { + return Ok(None); + }; + let package = read_workspace_packages(root)? + .into_iter() + .find(|(name, _)| name == crate_name) + .ok_or_else(|| format!("coverage fixture target {crate_name} is not a workspace package"))? + .1; + let path = Path::new(relative); + if !path + .components() + .all(|component| matches!(component, std::path::Component::Normal(_))) + || path.file_name().is_none_or(|name| name != "Cargo.toml") + || !path.starts_with(package.join("tests")) + { + return Err( + "coverage fixture manifest must be below the target package tests directory".to_owned(), + ); + } + let canonical_root = root + .canonicalize() + .map_err(|error| format!("resolve coverage root: {error}"))?; + let manifest = root + .join(path) + .canonicalize() + .map_err(|error| format!("resolve coverage fixture: {error}"))?; + if manifest != canonical_root.join(path) || !manifest.is_file() { + return Err( + "coverage fixture manifest must be a regular non-symlink source path".to_owned(), + ); + } + Ok(Some(manifest)) +} + pub fn read_lcov(path: &Path) -> Result<LcovCoverage, String> { let raw = match fs::read_to_string(path) { Ok(raw) => raw, @@ -1740,6 +1791,15 @@ fn run_crate_with_runner_at_root( ) -> Result<(), String> { let crate_name = parse_string_arg(args, "crate")?; let profile = read_coverage_profile(workspace_root, &crate_name)?; + let fixture = coverage_fixture_manifest( + workspace_root, + &crate_name, + profile.test_manifest.as_deref(), + )?; + let test_root = fixture + .as_deref() + .and_then(Path::parent) + .unwrap_or(workspace_root); let out_dir = if let Some(raw) = parse_optional_string_arg(args, "out") { PathBuf::from(raw) } else { @@ -1774,6 +1834,9 @@ fn run_crate_with_runner_at_root( { let mut cmd = coverage_llvm_cov_command(); cmd.arg("-p").arg(&crate_name); + if fixture.is_some() { + cmd.arg("--dep-coverage").arg(&crate_name); + } for package in &profile.test_packages { cmd.arg("-p").arg(package); } @@ -1782,7 +1845,7 @@ fn run_crate_with_runner_at_root( .arg("--branch") .arg("--") .arg(format!("--test-threads={test_threads}")) - .current_dir(workspace_root); + .current_dir(test_root); cmd }, "cargo llvm-cov --no-report", @@ -4181,6 +4244,113 @@ features = ["rt"] } #[test] + fn standalone_fixture_coverage_uses_the_owned_manifest_and_preserves_target_filters() { + let root = temp_dir_path("native_fixture_profile"); + let fixture = root.join("crates/radroots_ffi/tests/native"); + write_file( + &root.join("Cargo.toml"), + "[workspace]\nmembers = [\"crates/radroots_ffi\"]\n", + ); + write_file( + &root.join("crates/radroots_ffi/Cargo.toml"), + "[package]\nname = \"radroots_ffi\"\n", + ); + write_file( + &fixture.join("Cargo.toml"), + "[package]\nname = \"radroots_native_binding_fixture\"\n[workspace]\n", + ); + write_file( + &root.join("contracts/coverage-profiles.toml"), + "[profiles.crates.radroots_ffi]\ntest_manifest = \"crates/radroots_ffi/tests/native/Cargo.toml\"\ntest_packages = [\"radroots_native_binding_fixture\"]\nfeatures = [\"radroots_ffi/bindgen\"]\n", + ); + let profile = read_coverage_profile(&root, "radroots_ffi").expect("owned fixture profile"); + assert_eq!(profile.test_packages, ["radroots_native_binding_fixture"]); + let out = root.join("evidence"); + let execution_root = fixture.canonicalize().expect("canonical fixture root"); + let mut commands = Vec::new(); + let mut runner = |command: Command, _: &str| { + let expected = if commands.len() == 1 { + execution_root.as_path() + } else { + root.as_path() + }; + assert_eq!(command.get_current_dir(), Some(expected)); + commands.push( + command + .get_args() + .map(|arg| arg.to_string_lossy().into_owned()) + .collect::<Vec<_>>(), + ); + Ok(()) + }; + run_crate_with_runner_at_root( + &[ + "--crate".into(), + "radroots_ffi".into(), + "--out".into(), + out.display().to_string(), + ], + &root, + &mut runner, + ) + .expect("fixture commands"); + assert_eq!(commands.len(), 5); + assert!( + commands[1] + .windows(2) + .any(|pair| pair == ["-p", "radroots_native_binding_fixture"]) + ); + assert!( + commands[1] + .windows(2) + .any(|pair| pair == ["--dep-coverage", "radroots_ffi"]) + ); + for command in commands.iter().skip(2) { + assert!( + command + .windows(2) + .any(|pair| pair == ["-p", "radroots_ffi"]) + ); + assert!(!command.iter().any(|arg| arg == "--dep-coverage")); + } + assert!(commands[2].iter().any(|arg| arg.contains("tests/"))); + for path in [ + "../Cargo.toml", + "/tmp/Cargo.toml", + "crates/other/tests/Cargo.toml", + "crates/radroots_ffi/tests/../Cargo.toml", + "crates/radroots_ffi/tests/missing/Cargo.toml", + ] { + assert!( + coverage_fixture_manifest(&root, "radroots_ffi", Some(path)).is_err(), + "{path}" + ); + } + assert!( + coverage_fixture_manifest( + &root, + "unknown", + Some("crates/radroots_ffi/tests/native/Cargo.toml") + ) + .is_err() + ); + #[cfg(unix)] + { + std::os::unix::fs::symlink(&fixture, root.join("crates/radroots_ffi/tests/linked")) + .expect("fixture symlink"); + assert!( + coverage_fixture_manifest( + &root, + "radroots_ffi", + Some("crates/radroots_ffi/tests/linked/Cargo.toml") + ) + .is_err() + ); + } + fs::remove_dir_all(root).expect("remove fixture profile"); + } + + #[test] fn coverage_profiles_accept_positive_test_threads() { let root = temp_dir_path("profile_positive_threads"); let coverage_dir = root.join("contracts"); @@ -4671,6 +4841,7 @@ test_threads = 0 features: vec!["std".to_string(), "serde".to_string()], test_threads: Some(2), test_packages: Vec::new(), + test_manifest: None, }; let mut command = Command::new("cargo"); apply_coverage_profile_flags(&mut command, &profile); diff --git a/tools/xtask/src/sdk_generation/bindings.rs b/tools/xtask/src/sdk_generation/bindings.rs @@ -12,7 +12,7 @@ use crate::{build_control::Mode, sdk_generation::fs::write_or_check}; const FFI_PACKAGE: &str = "radroots_sdk_ffi"; const FFI_VERSION: &str = "0.1.0-alpha"; -const BINDGEN_VERSION: &str = "0.29.5"; +const BINDGEN_VERSION: &str = "0.32.2"; #[derive(Debug, Deserialize, Eq, PartialEq, Serialize)] struct SourceLock {