commit f26d0997638a33dc51caf3976dedf5675cdc4832 parent 352d020cd11aa4a1a5d02c9eca7a8ff7b23bd48b Author: triesap <tyson@radroots.org> Date: Sat, 17 Oct 2026 14:02:22 +0000 ports: Support thread-local browser host implementations - Preserve native thread guarantees while using local futures and Rc in WASM. - Align signing, storage, transport, subscription and clock ownership bounds. - Regenerate public APIs and pin the independent host fixture dependencies. - Verify native callers, retained tests, WASM composition and source policy. Diffstat:
36 files changed, 1484 insertions(+), 105 deletions(-)
diff --git a/contracts/api_baselines/radroots_signing.txt b/contracts/api_baselines/radroots_signing.txt @@ -48,7 +48,7 @@ pub const fn radroots_signing::authorization::ManagedSigningPolicy::permits(self pub struct radroots_signing::authorization::CurrentRegistryAuthority impl radroots_signing::authorization::CurrentAuthoringAuthority for radroots_signing::authorization::CurrentRegistryAuthority pub fn radroots_signing::authorization::CurrentRegistryAuthority::evaluate(&self, &radroots_event_codec::authoring::AuthoredEventPlan) -> radroots_signing::authorization::CurrentAuthoringDecision -pub trait radroots_signing::authorization::CurrentAuthoringAuthority: core::marker::Send + core::marker::Sync +pub trait radroots_signing::authorization::CurrentAuthoringAuthority: radroots_signing::host::HostBound pub fn radroots_signing::authorization::CurrentAuthoringAuthority::evaluate(&self, &radroots_event_codec::authoring::AuthoredEventPlan) -> radroots_signing::authorization::CurrentAuthoringDecision impl radroots_signing::authorization::CurrentAuthoringAuthority for radroots_signing::authorization::CurrentRegistryAuthority pub fn radroots_signing::authorization::CurrentRegistryAuthority::evaluate(&self, &radroots_event_codec::authoring::AuthoredEventPlan) -> radroots_signing::authorization::CurrentAuthoringDecision @@ -114,6 +114,10 @@ pub fn radroots_signing::error::Error::fmt(&self, &mut core::fmt::Formatter<'_>) impl core::fmt::Display for radroots_signing::error::Error pub fn radroots_signing::error::Error::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub const radroots_signing::error::CATALOG: &[radroots_signing::error::Descriptor] +pub mod radroots_signing::host +pub trait radroots_signing::host::HostBound: core::marker::Send + core::marker::Sync +impl<T: core::marker::Send + core::marker::Sync + ?core::marker::Sized> radroots_signing::host::HostBound for T +pub type radroots_signing::host::Shared<T> = alloc::sync::Arc<T> pub mod radroots_signing::identity pub struct radroots_signing::identity::AuthoredArtifactId(_) impl radroots_signing::identity::AuthoredArtifactId @@ -225,18 +229,18 @@ pub fn radroots_signing::request::SignRequest::report_progress(&self, &radroots_ pub const fn radroots_signing::request::SignRequest::signer_request_id(&self) -> radroots_signing::identity::SignerRequestId pub fn radroots_signing::request::SignRequest::tags(&self) -> &[alloc::vec::Vec<alloc::string::String>] pub fn radroots_signing::request::SignRequest::with_cancellation_signal(self, radroots_signing::request::CancellationSignal) -> Self -pub fn radroots_signing::request::SignRequest::with_progress_observer(self, alloc::sync::Arc<dyn radroots_signing::request::ProgressObserver>) -> Self +pub fn radroots_signing::request::SignRequest::with_progress_observer(self, radroots_signing::host::Shared<dyn radroots_signing::request::ProgressObserver>) -> Self impl core::fmt::Debug for radroots_signing::request::SignRequest pub fn radroots_signing::request::SignRequest::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result -pub trait radroots_signing::request::ProgressObserver: core::marker::Send + core::marker::Sync +pub trait radroots_signing::request::ProgressObserver: radroots_signing::host::HostBound pub fn radroots_signing::request::ProgressObserver::on_progress(&self, &radroots_signing::status::SignProgress) pub mod radroots_signing::signer -pub trait radroots_signing::signer::Signer: core::marker::Send + core::marker::Sync +pub trait radroots_signing::signer::Signer: radroots_signing::host::HostBound pub fn radroots_signing::signer::Signer::sign(&self, radroots_signing::request::SignRequest) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::receipt::SignReceipt, radroots_signing::error::Error>> pub fn radroots_signing::signer::Signer::sign_authored_evidence(&self, radroots_signing::request::SignRequest) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::receipt::AuthoredSignEvidence, radroots_signing::error::Error>> pub fn radroots_signing::signer::Signer::status(&self) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::status::SignerStatus, radroots_signing::error::Error>> pub type radroots_signing::signer::BoxFuture<'a, T> = core::pin::Pin<alloc::boxed::Box<(dyn core::future::future::Future<Output = T> + core::marker::Send + 'a)>> -pub type radroots_signing::signer::DynSigner = alloc::sync::Arc<dyn radroots_signing::signer::Signer> +pub type radroots_signing::signer::DynSigner = radroots_signing::host::Shared<dyn radroots_signing::signer::Signer> pub mod radroots_signing::status #[non_exhaustive] pub enum radroots_signing::status::SignProgressStage pub radroots_signing::status::SignProgressStage::AwaitingAuthentication @@ -370,7 +374,7 @@ pub fn radroots_signing::request::SignRequest::report_progress(&self, &radroots_ pub const fn radroots_signing::request::SignRequest::signer_request_id(&self) -> radroots_signing::identity::SignerRequestId pub fn radroots_signing::request::SignRequest::tags(&self) -> &[alloc::vec::Vec<alloc::string::String>] pub fn radroots_signing::request::SignRequest::with_cancellation_signal(self, radroots_signing::request::CancellationSignal) -> Self -pub fn radroots_signing::request::SignRequest::with_progress_observer(self, alloc::sync::Arc<dyn radroots_signing::request::ProgressObserver>) -> Self +pub fn radroots_signing::request::SignRequest::with_progress_observer(self, radroots_signing::host::Shared<dyn radroots_signing::request::ProgressObserver>) -> Self impl core::fmt::Debug for radroots_signing::request::SignRequest pub fn radroots_signing::request::SignRequest::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub struct radroots_signing::SignerRequestId(_) @@ -399,11 +403,11 @@ pub fn radroots_signing::identity::SigningOperationId::new([u8; 16]) -> core::re pub fn radroots_signing::identity::SigningOperationId::to_hex(self) -> alloc::string::String impl core::fmt::Debug for radroots_signing::identity::SigningOperationId pub fn radroots_signing::identity::SigningOperationId::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result -pub trait radroots_signing::CurrentAuthoringAuthority: core::marker::Send + core::marker::Sync +pub trait radroots_signing::CurrentAuthoringAuthority: radroots_signing::host::HostBound pub fn radroots_signing::CurrentAuthoringAuthority::evaluate(&self, &radroots_event_codec::authoring::AuthoredEventPlan) -> radroots_signing::authorization::CurrentAuthoringDecision impl radroots_signing::authorization::CurrentAuthoringAuthority for radroots_signing::authorization::CurrentRegistryAuthority pub fn radroots_signing::authorization::CurrentRegistryAuthority::evaluate(&self, &radroots_event_codec::authoring::AuthoredEventPlan) -> radroots_signing::authorization::CurrentAuthoringDecision -pub trait radroots_signing::Signer: core::marker::Send + core::marker::Sync +pub trait radroots_signing::Signer: radroots_signing::host::HostBound pub fn radroots_signing::Signer::sign(&self, radroots_signing::request::SignRequest) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::receipt::SignReceipt, radroots_signing::error::Error>> pub fn radroots_signing::Signer::sign_authored_evidence(&self, radroots_signing::request::SignRequest) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::receipt::AuthoredSignEvidence, radroots_signing::error::Error>> pub fn radroots_signing::Signer::status(&self) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::status::SignerStatus, radroots_signing::error::Error>> diff --git a/contracts/api_baselines/radroots_storage.txt b/contracts/api_baselines/radroots_storage.txt @@ -44,7 +44,7 @@ impl radroots_storage::atomic::CommitIngested pub const fn radroots_storage::atomic::CommitIngested::admission(&self) -> &radroots_storage::event::EventAdmission pub const fn radroots_storage::atomic::CommitIngested::new(radroots_storage::event::EventAdmission, core::option::Option<radroots_storage::projection::ProjectionCheckpoint>) -> Self pub const fn radroots_storage::atomic::CommitIngested::projection(&self) -> core::option::Option<&radroots_storage::projection::ProjectionCheckpoint> -pub trait radroots_storage::atomic::AtomicStorage: core::marker::Send + core::marker::Sync +pub trait radroots_storage::atomic::AtomicStorage: radroots_transport::host::HostBound pub fn radroots_storage::atomic::AtomicStorage::commit(&self, radroots_storage::atomic::AtomicCommit) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::atomic::AtomicCommitReceipt, radroots_storage::Error>> pub fn radroots_storage::atomic::AtomicStorage::receipt(&self, radroots_storage::atomic::AtomicCommitId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::atomic::AtomicCommitReceipt>, radroots_storage::Error>> impl radroots_storage::atomic::AtomicStorage for radroots_storage::memory::MemoryStorage @@ -321,7 +321,7 @@ pub const fn radroots_storage::authored_atomic::WorkFence::generation(&self) -> pub const fn radroots_storage::authored_atomic::WorkFence::new([u8; 16], core::num::nonzero::NonZeroU64, core::num::nonzero::NonZeroU64) -> core::result::Result<Self, radroots_storage::Error> pub const fn radroots_storage::authored_atomic::WorkFence::row_revision(&self) -> core::num::nonzero::NonZeroU64 pub const fn radroots_storage::authored_atomic::WorkFence::token(&self) -> &[u8; 16] -pub trait radroots_storage::authored_atomic::AuthoredAtomicStorage: core::marker::Send + core::marker::Sync +pub trait radroots_storage::authored_atomic::AuthoredAtomicStorage: radroots_transport::host::HostBound pub fn radroots_storage::authored_atomic::AuthoredAtomicStorage::authored_artifact(&self, radroots_storage::authored::AuthoredArtifactId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::authored::AuthoredArtifact>, radroots_storage::Error>> pub fn radroots_storage::authored_atomic::AuthoredAtomicStorage::authored_delivery_history(&self, radroots_storage::authored_delivery::AuthoredDeliveryPlanId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::authored_delivery::AuthoredDeliveryHistory>, radroots_storage::Error>> pub fn radroots_storage::authored_atomic::AuthoredAtomicStorage::authored_delivery_plan(&self, radroots_storage::authored_delivery::AuthoredDeliveryPlanId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::authored_delivery::AuthoredDeliveryPlan>, radroots_storage::Error>> @@ -490,7 +490,7 @@ pub const fn radroots_storage::authored_draft::DraftAppendReceipt::new(radroots_ pub const radroots_storage::authored_draft::AUTHORED_DRAFT_PAYLOAD_MAX_BYTES: usize pub const radroots_storage::authored_draft::AUTHORED_DRAFT_QUERY_LIMIT_MAX: u16 pub const radroots_storage::authored_draft::AUTHORED_DRAFT_SCHEMA_MAX_BYTES: usize -pub trait radroots_storage::authored_draft::AuthoredDraftStore: core::marker::Send + core::marker::Sync +pub trait radroots_storage::authored_draft::AuthoredDraftStore: radroots_transport::host::HostBound pub fn radroots_storage::authored_draft::AuthoredDraftStore::append_authored_draft(&self, radroots_storage::authored_draft::AuthoredDraft, core::option::Option<radroots_storage::authored_draft::AuthoredDraftRevision>) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::authored_draft::DraftAppendReceipt, radroots_storage::Error>> pub fn radroots_storage::authored_draft::AuthoredDraftStore::append_authored_draft_pair(&self, radroots_storage::authored_draft_pair::AuthoredDraftPair) -> radroots_transport::source::BoxFuture<'_, core::result::Result<[radroots_storage::authored_draft::DraftAppendReceipt; 2], radroots_storage::Error>> pub fn radroots_storage::authored_draft::AuthoredDraftStore::authored_draft_head(&self, radroots_storage::authored_draft::AuthoredDraftId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::authored_draft::AuthoredDraft>, radroots_storage::Error>> @@ -728,7 +728,7 @@ impl<'de> serde_core::de::Deserialize<'de> for radroots_storage::backup::Restore pub fn radroots_storage::backup::RestorePlan::deserialize<D>(D) -> core::result::Result<Self, <D as serde_core::de::Deserializer>::Error> where D: serde_core::de::Deserializer<'de> pub const radroots_storage::backup::BACKUP_MEMBER_MAX: usize pub const radroots_storage::backup::BACKUP_MEMBER_PATH_MAX_BYTES: usize -pub trait radroots_storage::backup::StorageReliability: core::marker::Send + core::marker::Sync +pub trait radroots_storage::backup::StorageReliability: radroots_transport::host::HostBound pub fn radroots_storage::backup::StorageReliability::begin_backup(&self, radroots_storage::backup::BackupPlan) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::backup::BackupOperation, radroots_storage::Error>> pub fn radroots_storage::backup::StorageReliability::begin_restore(&self, radroots_storage::backup::RestorePlan) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::backup::RestoreOperation, radroots_storage::Error>> pub fn radroots_storage::backup::StorageReliability::capture_backup(&self, radroots_storage::backup::BackupPlan) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::backup::BackupManifest, radroots_storage::backup::BackupCapabilityError>> @@ -872,7 +872,7 @@ pub fn radroots_storage::event::VisibilitySnapshot::suppressed_event_ids(&self) pub fn radroots_storage::event::VisibilitySnapshot::visible_event_ids(&self) -> &[radroots_event::id::EventId] pub const radroots_storage::event::EVENT_QUERY_ID_MAX: usize pub const radroots_storage::event::EVENT_QUERY_LIMIT_MAX: u16 -pub trait radroots_storage::event::EventStore: core::marker::Send + core::marker::Sync +pub trait radroots_storage::event::EventStore: radroots_transport::host::HostBound pub fn radroots_storage::event::EventStore::admit(&self, radroots_storage::event::EventAdmission) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::event::AdmissionReceipt, radroots_storage::Error>> pub fn radroots_storage::event::EventStore::maintain_visibility(&self, radroots_storage::event::VisibilityIndexBounds) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::event::VisibilityIndexProgress, radroots_storage::Error>> pub fn radroots_storage::event::EventStore::query_provenance(&self, radroots_event::id::EventId, radroots_storage::event::EventQueryBounds) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::event::EventPage<radroots_storage::event::StoredEventProvenance>, radroots_storage::Error>> @@ -997,7 +997,7 @@ pub const fn radroots_storage::journal::RecoveryRecord::reason(&self) -> radroot pub const fn radroots_storage::journal::RecoveryRecord::retry_not_before_unix_ms(&self) -> core::option::Option<u64> pub const radroots_storage::journal::IDEMPOTENCY_KEY_MAX_BYTES: usize pub const radroots_storage::journal::RECOVERABLE_QUERY_LIMIT_MAX: u16 -pub trait radroots_storage::journal::Journal: core::marker::Send + core::marker::Sync +pub trait radroots_storage::journal::Journal: radroots_transport::host::HostBound pub fn radroots_storage::journal::Journal::by_idempotency_key(&self, radroots_protocol::runtime::v1::OperationId, radroots_storage::journal::IdempotencyKey) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::journal::OperationRecord>, radroots_storage::Error>> pub fn radroots_storage::journal::Journal::operation(&self, radroots_storage::journal::OperationInstanceId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::journal::OperationRecord>, radroots_storage::Error>> pub fn radroots_storage::journal::Journal::prepare(&self, radroots_storage::journal::PrepareOperation) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::journal::PrepareReceipt, radroots_storage::Error>> @@ -1257,7 +1257,7 @@ pub const fn radroots_storage::outbox::TargetDeliveryEvidence::target(&self) -> pub const fn radroots_storage::outbox::TargetDeliveryEvidence::was_attempted(&self) -> bool pub const radroots_storage::outbox::LEASE_OWNER_MAX_BYTES: usize pub const radroots_storage::outbox::OUTBOX_CLAIM_LIMIT_MAX: u16 -pub trait radroots_storage::outbox::Outbox: core::marker::Send + core::marker::Sync +pub trait radroots_storage::outbox::Outbox: radroots_transport::host::HostBound pub fn radroots_storage::outbox::Outbox::claim(&self, radroots_storage::outbox::ClaimOutboxItems) -> radroots_transport::source::BoxFuture<'_, core::result::Result<alloc::vec::Vec<radroots_storage::outbox::ClaimedOutboxItem>, radroots_storage::Error>> pub fn radroots_storage::outbox::Outbox::enqueue(&self, radroots_storage::outbox::EnqueueOutboxItem) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::outbox::EnqueueReceipt, radroots_storage::Error>> pub fn radroots_storage::outbox::Outbox::item(&self, radroots_storage::outbox::OutboxItemId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::outbox::OutboxRecord>, radroots_storage::Error>> @@ -1442,7 +1442,7 @@ pub const radroots_storage::private_artifact::PRIVATE_ARTIFACT_ENVELOPE_PURPOSE_ pub const radroots_storage::private_artifact::PRIVATE_ARTIFACT_ENVELOPE_SUBJECT_TYPE: &str pub const radroots_storage::private_artifact::SECRET_PROVIDER_MAX_BYTES: usize pub const radroots_storage::private_artifact::SECRET_REFERENCE_MAX_BYTES: usize -pub trait radroots_storage::private_artifact::PrivateArtifactStore: core::marker::Send + core::marker::Sync +pub trait radroots_storage::private_artifact::PrivateArtifactStore: radroots_transport::host::HostBound pub fn radroots_storage::private_artifact::PrivateArtifactStore::expired(&self, u64, u16) -> radroots_transport::source::BoxFuture<'_, core::result::Result<alloc::vec::Vec<radroots_storage::private_artifact::PrivateArtifactMetadata>, radroots_storage::Error>> pub fn radroots_storage::private_artifact::PrivateArtifactStore::mark_expired(&self, radroots_storage::private_artifact::PrivateArtifactId, radroots_storage::private_artifact::PrivateArtifactRevision, u64) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::private_artifact::PrivateArtifactMetadata, radroots_storage::Error>> pub fn radroots_storage::private_artifact::PrivateArtifactStore::metadata(&self, radroots_storage::private_artifact::PrivateArtifactId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::private_artifact::PrivateArtifactMetadata>, radroots_storage::Error>> @@ -1705,7 +1705,7 @@ pub const radroots_storage::projection::EVENT_INDEX_SHARD_ID_MAX_BYTES: usize pub const radroots_storage::projection::PROJECTION_DOCUMENT_KEY_MAX_BYTES: usize pub const radroots_storage::projection::PROJECTION_DOCUMENT_VALUE_MAX_BYTES: usize pub const radroots_storage::projection::PROJECTION_ID_MAX_BYTES: usize -pub trait radroots_storage::projection::ProjectionStore: core::marker::Send + core::marker::Sync +pub trait radroots_storage::projection::ProjectionStore: radroots_transport::host::HostBound pub fn radroots_storage::projection::ProjectionStore::checkpoint(&self, radroots_storage::projection::ProjectionCheckpoint) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::projection::ProjectionStatus, radroots_storage::Error>> pub fn radroots_storage::projection::ProjectionStore::collect_obsolete_projection_snapshots(&self, radroots_storage::projection::cache::ProjectionCacheScope) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::projection::cache::ProjectionCacheCollection, radroots_storage::Error>> pub fn radroots_storage::projection::ProjectionStore::collect_projection_cache(&self, radroots_storage::projection::cache::ProjectionCacheScope) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::projection::cache::ProjectionCacheCollection, radroots_storage::Error>> @@ -1816,7 +1816,7 @@ pub const fn radroots_storage::status::StorageStatus::open_mode(self) -> radroot pub const fn radroots_storage::status::StorageStatus::shutdown(self) -> radroots_storage::status::ShutdownState pub const fn radroots_storage::status::StorageStatus::wal_enabled(self) -> bool pub const fn radroots_storage::status::StorageStatus::writer_policy(self) -> radroots_storage::status::WriterPolicy -pub trait radroots_storage::status::StorageStatusProvider: core::marker::Send + core::marker::Sync +pub trait radroots_storage::status::StorageStatusProvider: radroots_transport::host::HostBound pub fn radroots_storage::status::StorageStatusProvider::storage_status(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::status::StorageStatus, radroots_storage::Error>> impl radroots_storage::status::StorageStatusProvider for radroots_storage::memory::MemoryStorage pub fn radroots_storage::memory::MemoryStorage::storage_status(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::status::StorageStatus, radroots_storage::Error>> @@ -1966,7 +1966,7 @@ pub const fn radroots_storage::status::StorageStatus::open_mode(self) -> radroot pub const fn radroots_storage::status::StorageStatus::shutdown(self) -> radroots_storage::status::ShutdownState pub const fn radroots_storage::status::StorageStatus::wal_enabled(self) -> bool pub const fn radroots_storage::status::StorageStatus::writer_policy(self) -> radroots_storage::status::WriterPolicy -pub trait radroots_storage::BackupSource: core::marker::Send + core::marker::Sync +pub trait radroots_storage::BackupSource: radroots_transport::host::HostBound pub fn radroots_storage::BackupSource::begin_backup(&self, radroots_storage::backup::BackupPlan) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::backup::BackupOperation, radroots_storage::Error>> pub fn radroots_storage::BackupSource::begin_restore(&self, radroots_storage::backup::RestorePlan) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::backup::RestoreOperation, radroots_storage::Error>> pub fn radroots_storage::BackupSource::capture_backup(&self, radroots_storage::backup::BackupPlan) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::backup::BackupManifest, radroots_storage::backup::BackupCapabilityError>> @@ -1994,7 +1994,7 @@ pub fn radroots_storage::memory::MemoryStorage::status(&self) -> radroots_transp pub fn radroots_storage::memory::MemoryStorage::transition_backup(&self, radroots_storage::backup::BackupId, radroots_storage::backup::ReliabilityRevision, radroots_storage::backup::BackupTransition, u64) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::backup::BackupOperation, radroots_storage::Error>> pub fn radroots_storage::memory::MemoryStorage::transition_restore(&self, radroots_storage::backup::BackupId, radroots_storage::backup::ReliabilityRevision, radroots_storage::backup::RestoreTransition, u64) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::backup::RestoreOperation, radroots_storage::Error>> pub fn radroots_storage::memory::MemoryStorage::verify_backup(&self, radroots_storage::backup::BackupPlan, radroots_storage::backup::BackupManifest) -> radroots_transport::source::BoxFuture<'_, core::result::Result<(), radroots_storage::backup::BackupCapabilityError>> -pub trait radroots_storage::EventStore: core::marker::Send + core::marker::Sync +pub trait radroots_storage::EventStore: radroots_transport::host::HostBound pub fn radroots_storage::EventStore::admit(&self, radroots_storage::event::EventAdmission) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::event::AdmissionReceipt, radroots_storage::Error>> pub fn radroots_storage::EventStore::maintain_visibility(&self, radroots_storage::event::VisibilityIndexBounds) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::event::VisibilityIndexProgress, radroots_storage::Error>> pub fn radroots_storage::EventStore::query_provenance(&self, radroots_event::id::EventId, radroots_storage::event::EventQueryBounds) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::event::EventPage<radroots_storage::event::StoredEventProvenance>, radroots_storage::Error>> @@ -2016,7 +2016,7 @@ pub fn radroots_storage::memory::MemoryStorage::query_visible_at(&self, radroots pub fn radroots_storage::memory::MemoryStorage::rebuild_visibility(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::event::VisibilitySnapshot, radroots_storage::Error>> pub fn radroots_storage::memory::MemoryStorage::source_token(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::event::EventSourceToken, radroots_storage::Error>> pub fn radroots_storage::memory::MemoryStorage::status(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::status::EventStoreStatus, radroots_storage::Error>> -pub trait radroots_storage::Journal: core::marker::Send + core::marker::Sync +pub trait radroots_storage::Journal: radroots_transport::host::HostBound pub fn radroots_storage::Journal::by_idempotency_key(&self, radroots_protocol::runtime::v1::OperationId, radroots_storage::journal::IdempotencyKey) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::journal::OperationRecord>, radroots_storage::Error>> pub fn radroots_storage::Journal::operation(&self, radroots_storage::journal::OperationInstanceId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::journal::OperationRecord>, radroots_storage::Error>> pub fn radroots_storage::Journal::prepare(&self, radroots_storage::journal::PrepareOperation) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::journal::PrepareReceipt, radroots_storage::Error>> @@ -2028,7 +2028,7 @@ pub fn radroots_storage::memory::MemoryStorage::operation(&self, radroots_storag pub fn radroots_storage::memory::MemoryStorage::prepare(&self, radroots_storage::journal::PrepareOperation) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::journal::PrepareReceipt, radroots_storage::Error>> pub fn radroots_storage::memory::MemoryStorage::recoverable(&self, u16) -> radroots_transport::source::BoxFuture<'_, core::result::Result<alloc::vec::Vec<radroots_storage::journal::OperationRecord>, radroots_storage::Error>> pub fn radroots_storage::memory::MemoryStorage::transition(&self, radroots_storage::journal::JournalTransition) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::journal::OperationRecord, radroots_storage::Error>> -pub trait radroots_storage::Outbox: core::marker::Send + core::marker::Sync +pub trait radroots_storage::Outbox: radroots_transport::host::HostBound pub fn radroots_storage::Outbox::claim(&self, radroots_storage::outbox::ClaimOutboxItems) -> radroots_transport::source::BoxFuture<'_, core::result::Result<alloc::vec::Vec<radroots_storage::outbox::ClaimedOutboxItem>, radroots_storage::Error>> pub fn radroots_storage::Outbox::enqueue(&self, radroots_storage::outbox::EnqueueOutboxItem) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::outbox::EnqueueReceipt, radroots_storage::Error>> pub fn radroots_storage::Outbox::item(&self, radroots_storage::outbox::OutboxItemId) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::outbox::OutboxRecord>, radroots_storage::Error>> @@ -2042,7 +2042,7 @@ pub fn radroots_storage::memory::MemoryStorage::item(&self, radroots_storage::ou pub fn radroots_storage::memory::MemoryStorage::record_attempt(&self, radroots_storage::outbox::DeliveryAttemptEvidence) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::outbox::OutboxRecord, radroots_storage::Error>> pub fn radroots_storage::memory::MemoryStorage::release(&self, radroots_storage::outbox::OutboxItemId, radroots_storage::outbox::LeaseId, radroots_storage::outbox::OutboxRevision, u64, core::option::Option<u64>) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::outbox::OutboxRecord, radroots_storage::Error>> pub fn radroots_storage::memory::MemoryStorage::status(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::outbox::OutboxStatus, radroots_storage::Error>> -pub trait radroots_storage::ProjectionStore: core::marker::Send + core::marker::Sync +pub trait radroots_storage::ProjectionStore: radroots_transport::host::HostBound pub fn radroots_storage::ProjectionStore::checkpoint(&self, radroots_storage::projection::ProjectionCheckpoint) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::projection::ProjectionStatus, radroots_storage::Error>> pub fn radroots_storage::ProjectionStore::collect_obsolete_projection_snapshots(&self, radroots_storage::projection::cache::ProjectionCacheScope) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::projection::cache::ProjectionCacheCollection, radroots_storage::Error>> pub fn radroots_storage::ProjectionStore::collect_projection_cache(&self, radroots_storage::projection::cache::ProjectionCacheScope) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::projection::cache::ProjectionCacheCollection, radroots_storage::Error>> diff --git a/contracts/api_baselines/radroots_sync.txt b/contracts/api_baselines/radroots_sync.txt @@ -90,18 +90,18 @@ pub fn radroots_sync::policy::DeadlinePolicy::deserialize<D>(D) -> core::result: pub struct radroots_sync::policy::EngineBuilder impl radroots_sync::policy::EngineBuilder pub fn radroots_sync::policy::EngineBuilder::build(self) -> core::result::Result<radroots_sync::Engine, radroots_sync::policy::Error> -pub fn radroots_sync::policy::EngineBuilder::signer(self, alloc::sync::Arc<dyn radroots_signing::signer::Signer>) -> Self -pub fn radroots_sync::policy::EngineBuilder::sink(self, alloc::sync::Arc<dyn radroots_transport::sink::EventSink>) -> Self -pub fn radroots_sync::policy::EngineBuilder::source(self, alloc::sync::Arc<dyn radroots_transport::source::EventSource>) -> Self +pub fn radroots_sync::policy::EngineBuilder::signer(self, radroots_transport::host::Shared<dyn radroots_signing::signer::Signer>) -> Self +pub fn radroots_sync::policy::EngineBuilder::sink(self, radroots_transport::host::Shared<dyn radroots_transport::sink::EventSink>) -> Self +pub fn radroots_sync::policy::EngineBuilder::source(self, radroots_transport::host::Shared<dyn radroots_transport::source::EventSource>) -> Self pub struct radroots_sync::policy::SyncId(_) impl radroots_sync::policy::SyncId pub const fn radroots_sync::policy::SyncId::as_bytes(&self) -> &[u8; 16] pub const fn radroots_sync::policy::SyncId::new([u8; 16]) -> core::result::Result<Self, radroots_sync::policy::Error> impl<'de> serde_core::de::Deserialize<'de> for radroots_sync::policy::SyncId pub fn radroots_sync::policy::SyncId::deserialize<D>(D) -> core::result::Result<Self, <D as serde_core::de::Deserializer>::Error> where D: serde_core::de::Deserializer<'de> -pub trait radroots_sync::policy::Clock: core::marker::Send + core::marker::Sync +pub trait radroots_sync::policy::Clock: radroots_transport::host::HostBound pub fn radroots_sync::policy::Clock::now_unix_ms(&self) -> core::result::Result<u64, radroots_sync::policy::Error> -pub trait radroots_sync::policy::IdSource: core::marker::Send + core::marker::Sync +pub trait radroots_sync::policy::IdSource: radroots_transport::host::HostBound pub fn radroots_sync::policy::IdSource::next_id(&self, radroots_sync::policy::OperationKind) -> core::result::Result<radroots_sync::policy::SyncId, radroots_sync::policy::Error> pub trait radroots_sync::policy::SyncStorage: radroots_storage::event::EventStore + radroots_storage::journal::Journal + radroots_storage::outbox::Outbox + radroots_storage::projection::ProjectionStore + radroots_storage::atomic::AtomicStorage + radroots_storage::authored_atomic::AuthoredAtomicStorage + radroots_storage::status::StorageStatusProvider impl<T> radroots_sync::policy::SyncStorage for T where T: radroots_storage::event::EventStore + radroots_storage::journal::Journal + radroots_storage::outbox::Outbox + radroots_storage::projection::ProjectionStore + radroots_storage::atomic::AtomicStorage + radroots_storage::authored_atomic::AuthoredAtomicStorage + radroots_storage::status::StorageStatusProvider @@ -129,6 +129,8 @@ pub const fn radroots_sync::projection::RefreshRequest::generation(&self) -> rad pub const fn radroots_sync::projection::RefreshRequest::max_batches(&self) -> u16 pub fn radroots_sync::projection::RefreshRequest::new(radroots_storage::projection::ProjectionId, radroots_storage::projection::ProjectionGeneration, u16, u16) -> core::result::Result<Self, radroots_sync::policy::Error> pub const fn radroots_sync::projection::RefreshRequest::projection_id(&self) -> &radroots_storage::projection::ProjectionId +impl<'de> serde_core::de::Deserialize<'de> for radroots_sync::projection::RefreshRequest +pub fn radroots_sync::projection::RefreshRequest::deserialize<D>(D) -> core::result::Result<Self, <D as serde_core::de::Deserializer>::Error> where D: serde_core::de::Deserializer<'de> pub const radroots_sync::projection::PROJECTION_RAW_SOURCE_MAX_EVENTS: u64 pub const radroots_sync::projection::PROJECTION_REFRESH_MAX_BATCHES: u16 pub trait radroots_sync::projection::Reducer: core::marker::Send + core::marker::Sync @@ -296,7 +298,7 @@ pub async fn radroots_sync::Engine::prepare_push(&self, radroots_sync::push::Pus pub async fn radroots_sync::Engine::push_status(&self, radroots_sync::policy::SyncId) -> core::result::Result<core::option::Option<radroots_sync::push::PushStatus>, radroots_sync::policy::Error> pub async fn radroots_sync::Engine::sign_prepared(&self, radroots_sync::push::PushRequest) -> core::result::Result<radroots_sync::push::SigningRunReceipt, radroots_sync::policy::Error> impl radroots_sync::Engine -pub fn radroots_sync::Engine::builder(alloc::sync::Arc<dyn radroots_sync::policy::SyncStorage>, alloc::sync::Arc<dyn radroots_sync::policy::Clock>, alloc::sync::Arc<dyn radroots_sync::policy::IdSource>, radroots_sync::policy::DeadlinePolicy) -> radroots_sync::policy::EngineBuilder +pub fn radroots_sync::Engine::builder(radroots_transport::host::Shared<dyn radroots_sync::policy::SyncStorage>, radroots_transport::host::Shared<dyn radroots_sync::policy::Clock>, radroots_transport::host::Shared<dyn radroots_sync::policy::IdSource>, radroots_sync::policy::DeadlinePolicy) -> radroots_sync::policy::EngineBuilder pub fn radroots_sync::Engine::clock(&self) -> &dyn radroots_sync::policy::Clock pub const fn radroots_sync::Engine::deadlines(&self) -> radroots_sync::policy::DeadlinePolicy pub fn radroots_sync::Engine::ids(&self) -> &dyn radroots_sync::policy::IdSource diff --git a/contracts/api_baselines/radroots_transport.txt b/contracts/api_baselines/radroots_transport.txt @@ -166,6 +166,12 @@ pub radroots_transport::error::Error::UnexpectedSubscriptionEvent pub radroots_transport::error::Error::UnsupportedOperation impl core::fmt::Display for radroots_transport::error::Error pub fn radroots_transport::error::Error::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub mod radroots_transport::host +pub trait radroots_transport::host::HostBound: core::marker::Send + core::marker::Sync +impl<T: core::marker::Send + core::marker::Sync + ?core::marker::Sized> radroots_transport::host::HostBound for T +pub trait radroots_transport::host::MoveBound: core::marker::Send +impl<T: core::marker::Send + ?core::marker::Sized> radroots_transport::host::MoveBound for T +pub type radroots_transport::host::Shared<T> = alloc::sync::Arc<T> pub mod radroots_transport::outcome pub enum radroots_transport::outcome::DeliveryOutcomeKind pub radroots_transport::outcome::DeliveryOutcomeKind::Accepted @@ -308,7 +314,7 @@ pub fn radroots_transport::SinkStatus::message(&self) -> &str pub fn radroots_transport::SinkStatus::new(radroots_transport::TransportId, bool, radroots_transport::capability::Maturity, radroots_transport::capability::Availability, radroots_transport::capability::SinkCapabilities, impl core::convert::Into<alloc::string::String>) -> Self pub const fn radroots_transport::SinkStatus::transport_id(&self) -> radroots_transport::TransportId pub const radroots_transport::sink::DELIVERY_REQUEST_ID_MAX_BYTES: usize -pub trait radroots_transport::sink::EventSink: core::marker::Send + core::marker::Sync +pub trait radroots_transport::sink::EventSink: radroots_transport::host::HostBound pub fn radroots_transport::sink::EventSink::deliver(&self, radroots_transport::sink::DeliveryRequest) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::sink::DeliveryReceipt, radroots_transport::sink::SinkFailure>> pub fn radroots_transport::sink::EventSink::deliver_selected(&self, radroots_transport::sink::DeliveryRequest, radroots_transport::target::TargetSet) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::sink::DeliveryReceipt, radroots_transport::sink::SinkFailure>> pub fn radroots_transport::sink::EventSink::status(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::SinkStatus, radroots_transport::error::Error>> @@ -481,12 +487,12 @@ pub const radroots_transport::source::FETCH_SELECTOR_MAX_TAG_VALUES: usize pub const radroots_transport::source::FETCH_SELECTOR_TAG_VALUE_MAX_BYTES: usize pub const radroots_transport::source::SUBSCRIPTION_MAX_EVENTS: u16 pub const radroots_transport::source::SUBSCRIPTION_REQUEST_ID_MAX_BYTES: usize -pub trait radroots_transport::source::EventSource: core::marker::Send + core::marker::Sync +pub trait radroots_transport::source::EventSource: radroots_transport::host::HostBound pub fn radroots_transport::source::EventSource::fetch(&self, radroots_transport::source::FetchRequest) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::source::FetchPage, radroots_transport::error::Error>> pub fn radroots_transport::source::EventSource::status(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::SourceStatus, radroots_transport::error::Error>> -pub trait radroots_transport::source::EventSubscriber: core::marker::Send + core::marker::Sync +pub trait radroots_transport::source::EventSubscriber: radroots_transport::host::HostBound pub fn radroots_transport::source::EventSubscriber::subscribe(&self, radroots_transport::source::SubscriptionRequest) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::source::BoxSubscription, radroots_transport::error::Error>> -pub trait radroots_transport::source::EventSubscription: core::marker::Send +pub trait radroots_transport::source::EventSubscription: radroots_transport::host::MoveBound pub fn radroots_transport::source::EventSubscription::cancel(&mut self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::source::SubscriptionEnd, radroots_transport::error::Error>> pub fn radroots_transport::source::EventSubscription::next(&mut self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::source::SubscriptionNext, radroots_transport::error::Error>> pub fn radroots_transport::source::EventSubscription::request(&self) -> &radroots_transport::source::SubscriptionRequest @@ -843,16 +849,16 @@ impl<'de> serde_core::de::Deserialize<'de> for radroots_transport::TransportId pub fn radroots_transport::TransportId::deserialize<D>(D) -> core::result::Result<Self, <D as serde_core::de::Deserializer>::Error> where D: serde_core::de::Deserializer<'de> pub const radroots_transport::TARGET_SET_MAX_ITEMS: usize pub const radroots_transport::TRANSPORT_ID_MAX_BYTES: usize -pub trait radroots_transport::EventSink: core::marker::Send + core::marker::Sync +pub trait radroots_transport::EventSink: radroots_transport::host::HostBound pub fn radroots_transport::EventSink::deliver(&self, radroots_transport::sink::DeliveryRequest) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::sink::DeliveryReceipt, radroots_transport::sink::SinkFailure>> pub fn radroots_transport::EventSink::deliver_selected(&self, radroots_transport::sink::DeliveryRequest, radroots_transport::target::TargetSet) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::sink::DeliveryReceipt, radroots_transport::sink::SinkFailure>> pub fn radroots_transport::EventSink::status(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::SinkStatus, radroots_transport::error::Error>> -pub trait radroots_transport::EventSource: core::marker::Send + core::marker::Sync +pub trait radroots_transport::EventSource: radroots_transport::host::HostBound pub fn radroots_transport::EventSource::fetch(&self, radroots_transport::source::FetchRequest) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::source::FetchPage, radroots_transport::error::Error>> pub fn radroots_transport::EventSource::status(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::SourceStatus, radroots_transport::error::Error>> -pub trait radroots_transport::EventSubscriber: core::marker::Send + core::marker::Sync +pub trait radroots_transport::EventSubscriber: radroots_transport::host::HostBound pub fn radroots_transport::EventSubscriber::subscribe(&self, radroots_transport::source::SubscriptionRequest) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::source::BoxSubscription, radroots_transport::error::Error>> -pub trait radroots_transport::EventSubscription: core::marker::Send +pub trait radroots_transport::EventSubscription: radroots_transport::host::MoveBound pub fn radroots_transport::EventSubscription::cancel(&mut self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::source::SubscriptionEnd, radroots_transport::error::Error>> pub fn radroots_transport::EventSubscription::next(&mut self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_transport::source::SubscriptionNext, radroots_transport::error::Error>> pub fn radroots_transport::EventSubscription::request(&self) -> &radroots_transport::source::SubscriptionRequest diff --git a/contracts/execution/host_ports.v1.json b/contracts/execution/host_ports.v1.json @@ -0,0 +1,12 @@ +{ + "schema": "radroots.execution.host_ports.v1", + "scope": ["signer", "authoring_authority", "progress_observer", "event_source", "event_sink", "event_subscriber", "event_subscription", "all_storage_spis", "sync_clock", "sync_id_source", "sync_composition"], + "native": {"hosts": "Send + Sync", "subscriptions": "Send", "futures": "Send", "shared_handles": "Arc"}, + "wasm32": {"hosts": "local", "subscriptions": "local", "futures": "local", "shared_handles": "Rc"}, + "pure_cancellation_signal": "An Arc<AtomicBool> remains a portable value without local host state", + "unsafe_send_bridge": false, + "runtime_created": false, + "native_proof": "All port trait objects, sync engine and future aliases retain their thread guarantees", + "wasm_proof": "Compile representative Rc<Cell> signer/progress/authority, source/sink/subscription, event-store/status and clock/id implementations and local futures through a separate consumer manifest", + "qualification_limit": "Compilation is not concrete IndexedDB/network/signing/replay qualification or a packed complete browser SDK consumer" +} diff --git a/crates/signing/README.md b/crates/signing/README.md @@ -88,9 +88,11 @@ The complete externally implementable SPI example is ## Host SPI contract -`Signer` is intentionally externally implementable, object-safe, `Send`, and -`Sync`. Its methods return boxed `Future + Send` values so the SPI does not -select an async runtime or require an async-trait macro. +`Signer` is externally implementable and object-safe. Native hosts retain +`Send + Sync` and boxed `Future + Send`; WASM hosts and futures may remain local. +`host::Shared` selects native `Arc` or browser `Rc` for signer and progress +callback ownership. These target bounds let the host choose its executor; +the SPI does not select an async runtime or require an async-trait macro. - `status` is observational and must not create a signing request or another durable side effect. diff --git a/crates/signing/src/authorization.rs b/crates/signing/src/authorization.rs @@ -18,7 +18,7 @@ pub enum CurrentAuthoringDecision { } /// Host or registry authority for current signing policy. -pub trait CurrentAuthoringAuthority: Send + Sync { +pub trait CurrentAuthoringAuthority: crate::host::HostBound { fn evaluate(&self, plan: &AuthoredEventPlan) -> CurrentAuthoringDecision; } diff --git a/crates/signing/src/host.rs b/crates/signing/src/host.rs @@ -0,0 +1,25 @@ +//! Target-aware ownership of signer and progress callback state. + +/// Native signer hosts are thread safe; browser hosts may retain local state. +#[cfg(not(target_arch = "wasm32"))] +pub trait HostBound: Send + Sync {} +#[cfg(not(target_arch = "wasm32"))] +impl<T: Send + Sync + ?Sized> HostBound for T {} +/// Native signer hosts are thread safe; browser hosts may retain local state. +#[cfg(target_arch = "wasm32")] +pub trait HostBound {} +#[cfg(target_arch = "wasm32")] +impl<T: ?Sized> HostBound for T {} + +/// Shared signer/callback ownership on its qualified host. +#[cfg(all(not(target_arch = "wasm32"), not(feature = "std")))] +pub type Shared<T> = alloc::sync::Arc<T>; +/// Shared signer/callback ownership on its qualified host. +#[cfg(all(not(target_arch = "wasm32"), feature = "std"))] +pub type Shared<T> = std::sync::Arc<T>; +/// Shared signer/callback ownership on its qualified host. +#[cfg(all(target_arch = "wasm32", not(feature = "std")))] +pub type Shared<T> = alloc::rc::Rc<T>; +/// Shared signer/callback ownership on its qualified host. +#[cfg(all(target_arch = "wasm32", feature = "std"))] +pub type Shared<T> = std::rc::Rc<T>; diff --git a/crates/signing/src/lib.rs b/crates/signing/src/lib.rs @@ -9,6 +9,7 @@ pub mod actor; pub mod authorization; pub mod capability; pub mod error; +pub mod host; pub mod identity; pub mod receipt; pub mod recovery; diff --git a/crates/signing/src/request.rs b/crates/signing/src/request.rs @@ -139,7 +139,7 @@ impl<'de> serde::Deserialize<'de> for SignPolicy { } /// Runtime-local observer for signing progress. -pub trait ProgressObserver: Send + Sync { +pub trait ProgressObserver: crate::host::HostBound { fn on_progress(&self, progress: &SignProgress); } @@ -239,7 +239,7 @@ pub struct SignRequest { authorization: Option<CurrentAuthoringDecision>, policy: SignPolicy, cancellation_signal: CancellationSignal, - progress_observer: Option<Arc<dyn ProgressObserver>>, + progress_observer: Option<crate::host::Shared<dyn ProgressObserver>>, } impl SignRequest { @@ -318,7 +318,10 @@ impl SignRequest { } #[must_use] - pub fn with_progress_observer(mut self, observer: Arc<dyn ProgressObserver>) -> Self { + pub fn with_progress_observer( + mut self, + observer: crate::host::Shared<dyn ProgressObserver>, + ) -> Self { self.progress_observer = Some(observer); self } diff --git a/crates/signing/src/signer.rs b/crates/signing/src/signer.rs @@ -3,16 +3,23 @@ use core::{future::Future, pin::Pin}; #[cfg(not(feature = "std"))] -use alloc::{boxed::Box, sync::Arc}; +use alloc::boxed::Box; #[cfg(feature = "std")] -use std::{boxed::Box, sync::Arc}; +use std::boxed::Box; use crate::{ - AuthoredSignEvidence, Error, SignReceipt, SignRequest, SignerStatus, error::Kind, + AuthoredSignEvidence, Error, SignReceipt, SignRequest, SignerStatus, + error::Kind, + host::{HostBound, Shared}, receipt::verify_identity, }; +/// A native Send future or a browser-local signer future. +#[cfg(not(target_arch = "wasm32"))] pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>; +/// A native Send future or a browser-local signer future. +#[cfg(target_arch = "wasm32")] +pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>; /// Protocol-neutral, caller-driven signing service-provider interface. /// @@ -20,7 +27,7 @@ pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>; /// a future after that point does not imply rollback. Replay behavior is /// advertised through signer status and every successful result must use a /// verified receipt or authored-evidence constructor. -pub trait Signer: Send + Sync { +pub trait Signer: HostBound { fn status(&self) -> BoxFuture<'_, Result<SignerStatus, Error>>; /// Signs one already-authorized exact plan. @@ -69,7 +76,7 @@ pub trait Signer: Send + Sync { } /// Shared signer handle used by composing hosts without selecting a runtime. -pub type DynSigner = Arc<dyn Signer>; +pub type DynSigner = Shared<dyn Signer>; #[cfg(test)] mod tests { @@ -87,6 +94,7 @@ mod tests { } } + #[cfg(not(target_arch = "wasm32"))] #[test] fn signer_remains_dyn_send_and_sync() { fn assert_dyn(_: &dyn Signer) {} diff --git a/crates/signing/tests/package_boundary.rs b/crates/signing/tests/package_boundary.rs @@ -74,6 +74,7 @@ fn crate_root_declares_the_approved_module_skeleton() { "authorization", "capability", "error", + "host", "identity", "recovery", "request", @@ -94,6 +95,7 @@ fn crate_root_declares_the_approved_module_skeleton() { "authorization", "capability", "error", + "host", "identity", "receipt", "recovery", @@ -191,6 +193,7 @@ fn every_public_module_has_crate_level_documentation() { "authorization", "capability", "error", + "host", "identity", "recovery", "request", @@ -249,10 +252,15 @@ fn production_sources_publish_only_the_approved_traits_and_no_host_stack() { assert_eq!( public_traits, - ["CurrentAuthoringAuthority", "ProgressObserver", "Signer"] - .into_iter() - .map(str::to_owned) - .collect() + [ + "CurrentAuthoringAuthority", + "HostBound", + "ProgressObserver", + "Signer" + ] + .into_iter() + .map(str::to_owned) + .collect() ); } diff --git a/crates/storage/README.md b/crates/storage/README.md @@ -70,9 +70,11 @@ The crate root exposes the ordinary aggregate [`Storage`] capability plus modules so ordinary consumers do not accidentally depend on workflow or protected-record internals. -All SPIs are externally implementable, dyn-compatible `Send + Sync` traits. -Their methods return boxed `Future + Send` values, allowing the host to choose -the async executor. Implementations must not install an executor, spawn hidden +All SPIs are externally implementable and dyn-compatible. Native traits retain +`Send + Sync` and boxed `Future + Send`; browser traits and futures may stay +local. Every SPI uses the same target-aware transport host bounds and future +alias, allowing the host to choose the async executor. Implementations must not +install an executor, spawn hidden workers, read a clock, generate identities, or perform implicit retries. `BackupSource::settle_backup_writes` waits for earlier owner writes, including diff --git a/crates/storage/src/atomic.rs b/crates/storage/src/atomic.rs @@ -224,7 +224,7 @@ impl AtomicCommitReceipt { } /// Backend-neutral all-or-nothing workflow commit SPI. -pub trait AtomicStorage: Send + Sync { +pub trait AtomicStorage: radroots_transport::host::HostBound { /// Commits every mutation in the workflow or none of them. Exact replay /// returns the original outcome; identity reuse with another digest or kind /// is [`Error::AtomicCommitConflict`]. diff --git a/crates/storage/src/authored_atomic.rs b/crates/storage/src/authored_atomic.rs @@ -786,7 +786,7 @@ impl AuthoredAtomicOutcome { } } -pub trait AuthoredAtomicStorage: Send + Sync { +pub trait AuthoredAtomicStorage: radroots_transport::host::HostBound { /// Read exact issued-claim provenance; unsupported backends fail closed. fn authored_delivery_history( &self, diff --git a/crates/storage/src/authored_draft.rs b/crates/storage/src/authored_draft.rs @@ -461,7 +461,7 @@ impl DraftAppendReceipt { } } -pub trait AuthoredDraftStore: Send + Sync { +pub trait AuthoredDraftStore: radroots_transport::host::HostBound { /// Atomically appends two opaque revisions or replays both exact snapshots. /// /// Unsupported backends fail closed; sequential single-row calls are not an diff --git a/crates/storage/src/backup.rs b/crates/storage/src/backup.rs @@ -689,7 +689,7 @@ pub enum RestoreTransition { /// Backend-neutral reliability operations. Implementations own staging and /// atomic filesystem replacement; callers receive only typed state. -pub trait StorageReliability: Send + Sync { +pub trait StorageReliability: radroots_transport::host::HostBound { /// Settles writes already admitted by this owner, including work whose /// caller was cancelled. The host must exclude new writes before calling /// this and retain that exclusion through related inventory and capture. diff --git a/crates/storage/src/event.rs b/crates/storage/src/event.rs @@ -625,11 +625,11 @@ impl StoredEventProvenance { /// Backend-neutral canonical event storage SPI. /// -/// Implementations are dyn-compatible and return `Send` futures. They may not +/// Implementations are dyn-compatible and return native `Send` or browser-local futures. They may not /// expose backend transactions, handles, SQL, or filesystem paths. Admission is /// idempotent for an identical event and provenance observation; a stage may /// advance but never regress. Query cursors are bound to one source generation. -pub trait EventStore: Send + Sync { +pub trait EventStore: radroots_transport::host::HostBound { /// Prepares one bounded, transactionally resumable canonical index chunk. /// /// Completion refers to canonical metadata at the returned source token, diff --git a/crates/storage/src/journal.rs b/crates/storage/src/journal.rs @@ -673,7 +673,7 @@ impl JournalTransition { } /// Backend-neutral durable operation journal SPI. -pub trait Journal: Send + Sync { +pub trait Journal: radroots_transport::host::HostBound { /// Creates a record or replays the exact existing operation. A reused key /// with a different operation kind, instance, or digest is a conflict. fn prepare(&self, operation: PrepareOperation) -> BoxFuture<'_, Result<PrepareReceipt, Error>>; diff --git a/crates/storage/src/outbox.rs b/crates/storage/src/outbox.rs @@ -806,7 +806,7 @@ impl OutboxStatus { } /// Backend-neutral durable delivery-plan SPI. -pub trait Outbox: Send + Sync { +pub trait Outbox: radroots_transport::host::HostBound { fn enqueue(&self, item: EnqueueOutboxItem) -> BoxFuture<'_, Result<EnqueueReceipt, Error>>; fn item(&self, item_id: OutboxItemId) -> BoxFuture<'_, Result<Option<OutboxRecord>, Error>>; fn claim( diff --git a/crates/storage/src/private_artifact.rs b/crates/storage/src/private_artifact.rs @@ -823,7 +823,7 @@ impl PrivateArtifactStatus { } /// Backend-neutral metadata-only private-artifact SPI. -pub trait PrivateArtifactStore: Send + Sync { +pub trait PrivateArtifactStore: radroots_transport::host::HostBound { fn put_metadata( &self, metadata: PrivateArtifactMetadata, diff --git a/crates/storage/src/projection.rs b/crates/storage/src/projection.rs @@ -1028,7 +1028,7 @@ impl ProjectionStatus { } /// Backend-neutral projection coordination SPI. -pub trait ProjectionStore: Send + Sync { +pub trait ProjectionStore: radroots_transport::host::HostBound { /// Registers one exact derived-cache identity under an immutable store budget. /// Configured identities cannot create new legacy whole-view snapshots. fn configure_projection_cache( diff --git a/crates/storage/src/status.rs b/crates/storage/src/status.rs @@ -5,7 +5,7 @@ use radroots_transport::BoxFuture; use crate::{Error, event::SourceGeneration}; /// Passive backend-level status capability independent of backup workflows. -pub trait StorageStatusProvider: Send + Sync { +pub trait StorageStatusProvider: radroots_transport::host::HostBound { fn storage_status(&self) -> BoxFuture<'_, Result<StorageStatus, Error>>; } diff --git a/crates/sync/README.md b/crates/sync/README.md @@ -6,6 +6,13 @@ The package owns the shared ingest, pull, projection, push, policy, and status boundaries. It does not create an executor, spawn workers, install timers, own process lifecycle, store UI state, or branch on concrete transport adapters. +Host composition uses target-aware shared ownership for storage, signer, +transport, clock and identity sources. Native handles retain `Arc` and +`Send + Sync`; WASM handles use `Rc` and permit local futures and callbacks. +This is a composition contract, not qualification of a browser store/network +adapter. The isolated browser-host fixture compiles local interfaces without +pulling native SQLite test dependencies into the browser target. + `StorageSpaceInsufficient` preserves the storage owner's typed capacity failure. It does not establish rollback or absence of signer or remote effects. Retain the original requests, signed bytes and unresolved receipts, then reconcile diff --git a/crates/sync/src/engine.rs b/crates/sync/src/engine.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use radroots_transport::host::Shared; use radroots_signing::Signer; use radroots_transport::{EventSink, EventSource}; @@ -8,21 +8,21 @@ use crate::policy::{Clock, DeadlinePolicy, EngineBuilder, IdSource, SyncStorage} /// Injected, executor-neutral synchronization composition boundary. #[derive(Clone)] pub struct Engine { - pub(crate) storage: Arc<dyn SyncStorage>, - pub(crate) source: Option<Arc<dyn EventSource>>, - pub(crate) sink: Option<Arc<dyn EventSink>>, - pub(crate) signer: Option<Arc<dyn Signer>>, - pub(crate) clock: Arc<dyn Clock>, - pub(crate) ids: Arc<dyn IdSource>, + pub(crate) storage: Shared<dyn SyncStorage>, + pub(crate) source: Option<Shared<dyn EventSource>>, + pub(crate) sink: Option<Shared<dyn EventSink>>, + pub(crate) signer: Option<Shared<dyn Signer>>, + pub(crate) clock: Shared<dyn Clock>, + pub(crate) ids: Shared<dyn IdSource>, pub(crate) deadlines: DeadlinePolicy, } impl Engine { /// Starts an explicit capability builder around required host policies. pub fn builder( - storage: Arc<dyn SyncStorage>, - clock: Arc<dyn Clock>, - ids: Arc<dyn IdSource>, + storage: Shared<dyn SyncStorage>, + clock: Shared<dyn Clock>, + ids: Shared<dyn IdSource>, deadlines: DeadlinePolicy, ) -> EngineBuilder { EngineBuilder::new(storage, clock, ids, deadlines) diff --git a/crates/sync/src/policy.rs b/crates/sync/src/policy.rs @@ -1,6 +1,6 @@ //! Explicit clocks, identifiers, deadlines, and retry decisions. -use std::sync::Arc; +use radroots_transport::host::Shared; use radroots_signing::Signer; use radroots_storage::{ @@ -72,12 +72,12 @@ impl SyncId { } /// Host clock used instead of reading ambient time inside orchestration. -pub trait Clock: Send + Sync { +pub trait Clock: radroots_transport::host::HostBound { fn now_unix_ms(&self) -> Result<u64, Error>; } /// Host identity source used instead of ambient randomness or global counters. -pub trait IdSource: Send + Sync { +pub trait IdSource: radroots_transport::host::HostBound { fn next_id(&self, operation: OperationKind) -> Result<SyncId, Error>; } @@ -141,20 +141,20 @@ const fn valid_timeout(value: u64) -> bool { /// Builder for an [`Engine`] with explicit optional transport capabilities. pub struct EngineBuilder { - storage: Arc<dyn SyncStorage>, - source: Option<Arc<dyn EventSource>>, - sink: Option<Arc<dyn EventSink>>, - signer: Option<Arc<dyn Signer>>, - clock: Arc<dyn Clock>, - ids: Arc<dyn IdSource>, + storage: Shared<dyn SyncStorage>, + source: Option<Shared<dyn EventSource>>, + sink: Option<Shared<dyn EventSink>>, + signer: Option<Shared<dyn Signer>>, + clock: Shared<dyn Clock>, + ids: Shared<dyn IdSource>, deadlines: DeadlinePolicy, } impl EngineBuilder { pub(crate) fn new( - storage: Arc<dyn SyncStorage>, - clock: Arc<dyn Clock>, - ids: Arc<dyn IdSource>, + storage: Shared<dyn SyncStorage>, + clock: Shared<dyn Clock>, + ids: Shared<dyn IdSource>, deadlines: DeadlinePolicy, ) -> Self { Self { @@ -169,19 +169,19 @@ impl EngineBuilder { } #[must_use] - pub fn source(mut self, source: Arc<dyn EventSource>) -> Self { + pub fn source(mut self, source: Shared<dyn EventSource>) -> Self { self.source = Some(source); self } #[must_use] - pub fn sink(mut self, sink: Arc<dyn EventSink>) -> Self { + pub fn sink(mut self, sink: Shared<dyn EventSink>) -> Self { self.sink = Some(sink); self } #[must_use] - pub fn signer(mut self, signer: Arc<dyn Signer>) -> Self { + pub fn signer(mut self, signer: Shared<dyn Signer>) -> Self { self.signer = Some(signer); self } diff --git a/crates/sync/tests/fixtures/browser_host/Cargo.lock b/crates/sync/tests/fixtures/browser_host/Cargo.lock @@ -0,0 +1,1016 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "arrayvec" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[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 = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "cc" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[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 = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "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", + "typenum", +] + +[[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", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + +[[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 = "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.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +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 = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "icu_collections" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" + +[[package]] +name = "icu_properties" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" + +[[package]] +name = "icu_provider" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[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 = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "elliptic-curve", +] + +[[package]] +name = "libc" +version = "0.2.190" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[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 = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radroots_blossom" +version = "0.1.0-alpha" +dependencies = [ + "mediatype", + "sha2", + "unicode-general-category", + "url", +] + +[[package]] +name = "radroots_browser_host_fixture" +version = "0.0.0" +dependencies = [ + "futures", + "radroots_event", + "radroots_event_codec", + "radroots_signing", + "radroots_storage", + "radroots_sync", + "radroots_transport", +] + +[[package]] +name = "radroots_core" +version = "0.1.0-alpha" +dependencies = [ + "rust_decimal", + "serde", +] + +[[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", + "serde", + "serde_json", + "sha2", +] + +[[package]] +name = "radroots_identity" +version = "0.1.0-alpha" +dependencies = [ + "k256", + "serde", + "thiserror", +] + +[[package]] +name = "radroots_protocol" +version = "0.1.0-alpha" +dependencies = [ + "serde", +] + +[[package]] +name = "radroots_signing" +version = "0.1.0-alpha" +dependencies = [ + "hex", + "radroots_event", + "radroots_event_codec", + "radroots_identity", + "radroots_protocol", + "sha2", +] + +[[package]] +name = "radroots_storage" +version = "0.1.0-alpha" +dependencies = [ + "radroots_event", + "radroots_event_codec", + "radroots_protocol", + "radroots_trade", + "radroots_transport", + "sha2", +] + +[[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 = [ + "radroots_core", + "radroots_event", + "radroots_identity", +] + +[[package]] +name = "radroots_transport" +version = "0.1.0-alpha" +dependencies = [ + "radroots_event", + "radroots_identity", + "radroots_protocol", + "sha2", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "rust_decimal" +version = "1.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7653272e75dcac41dc199fbea6f5797633994fafd339943c06c9af16bf29cd3a" +dependencies = [ + "arrayvec", + "num-traits", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[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 = [ + "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 = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[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 = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[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.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "serde", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[patch.unused]] +name = "radroots_geonames" +version = "0.1.0-alpha" + +[[patch.unused]] +name = "radroots_nostr" +version = "0.1.0-alpha" + +[[patch.unused]] +name = "radroots_nostr_connect" +version = "0.1.0-alpha" + +[[patch.unused]] +name = "radroots_secrets" +version = "0.1.0-alpha" + +[[patch.unused]] +name = "radroots_storage_sqlite" +version = "0.1.0-alpha" + +[[patch.unused]] +name = "radroots_transport_nostr" +version = "0.1.0-alpha" diff --git a/crates/sync/tests/fixtures/browser_host/Cargo.toml b/crates/sync/tests/fixtures/browser_host/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "radroots_browser_host_fixture" +version = "0.0.0" +edition = "2024" +rust-version = "1.99.0" +publish = false +license = "MIT OR Apache-2.0" + +[workspace] + +[dependencies] +radroots_sync = { path = "../../..", version = "=0.1.0-alpha", default-features = false } +radroots_signing = { path = "../../../../signing", version = "=0.1.0-alpha", default-features = false } +radroots_storage = { path = "../../../../storage", version = "=0.1.0-alpha", default-features = false } +radroots_transport = { path = "../../../../transport", version = "=0.1.0-alpha", default-features = false } +radroots_event = { path = "../../../../event", version = "=0.1.0-alpha", default-features = false } +radroots_event_codec = { path = "../../../../event_codec", version = "=0.1.0-alpha", default-features = false } +futures = "=0.3.32" diff --git a/crates/sync/tests/fixtures/browser_host/src/lib.rs b/crates/sync/tests/fixtures/browser_host/src/lib.rs @@ -0,0 +1,5 @@ +//! Compile-only host boundary fixture; not the full browser SDK qualification. + +#[cfg(test)] +#[path = "../../../host_bounds.rs"] +mod host_bounds; diff --git a/crates/sync/tests/host_bounds.rs b/crates/sync/tests/host_bounds.rs @@ -0,0 +1,221 @@ +//! Compile the complete port thread bounds, with representative local adapters. +//! These unavailable adapters prove host composition, not durable execution. + +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn every_native_port_retains_its_thread_guarantees() { + use radroots_storage as store; + fn send_sync<T: Send + Sync + ?Sized>() {} + fn send<T: Send + ?Sized>() {} + send_sync::<dyn radroots_signing::Signer>(); + send_sync::<dyn radroots_signing::CurrentAuthoringAuthority>(); + send_sync::<dyn radroots_signing::request::ProgressObserver>(); + send_sync::<dyn radroots_transport::EventSource>(); + send_sync::<dyn radroots_transport::EventSink>(); + send_sync::<dyn radroots_transport::EventSubscriber>(); + send::<dyn radroots_transport::EventSubscription>(); + send_sync::<dyn store::EventStore>(); + send_sync::<dyn store::Journal>(); + send_sync::<dyn store::Outbox>(); + send_sync::<dyn store::ProjectionStore>(); + send_sync::<dyn store::private_artifact::PrivateArtifactStore>(); + send_sync::<dyn store::backup::StorageReliability>(); + send_sync::<dyn store::authored_draft::AuthoredDraftStore>(); + send_sync::<dyn store::atomic::AtomicStorage>(); + send_sync::<dyn store::authored_atomic::AuthoredAtomicStorage>(); + send_sync::<dyn store::status::StorageStatusProvider>(); + send_sync::<dyn radroots_sync::policy::Clock>(); + send_sync::<dyn radroots_sync::policy::IdSource>(); + send_sync::<radroots_sync::Engine>(); + send::<radroots_signing::signer::BoxFuture<'static, ()>>(); + send::<radroots_transport::BoxFuture<'static, ()>>(); +} + +#[cfg(target_arch = "wasm32")] +mod browser { + use radroots_signing::{self as signing, host::Shared as SignerHandle}; + use radroots_storage::{self as store, event::*}; + use radroots_sync::policy::{Clock, IdSource, OperationKind, SyncId}; + use radroots_transport::{ + self as transport, BoxFuture, EventSink, EventSource, EventSubscriber, + }; + use std::{cell::Cell, rc::Rc}; + + struct Local(Rc<Cell<usize>>); + + impl Local { + fn failed<T: 'static, E: 'static>(&self, error: E) -> BoxFuture<'_, Result<T, E>> { + Box::pin(async move { + self.0.set(self.0.get() + 1); + Err(error) + }) + } + } + + impl signing::Signer for Local { + fn status( + &self, + ) -> signing::signer::BoxFuture<'_, Result<signing::SignerStatus, signing::Error>> { + self.failed(signing::Error::new(signing::error::Kind::SignerUnavailable)) + } + fn sign( + &self, + _: signing::SignRequest, + ) -> signing::signer::BoxFuture<'_, Result<signing::SignReceipt, signing::Error>> { + self.failed(signing::Error::new(signing::error::Kind::SignerUnavailable)) + } + } + impl signing::request::ProgressObserver for Local { + fn on_progress(&self, _: &signing::status::SignProgress) { + self.0.set(self.0.get() + 1); + } + } + impl signing::CurrentAuthoringAuthority for Local { + fn evaluate( + &self, + _: &radroots_event_codec::authoring::AuthoredEventPlan, + ) -> signing::CurrentAuthoringDecision { + signing::CurrentAuthoringDecision::Blocked { + code: "unavailable", + } + } + } + impl EventSource for Local { + fn status(&self) -> BoxFuture<'_, Result<transport::SourceStatus, transport::Error>> { + self.failed(transport::Error::TransportUnavailable) + } + fn fetch( + &self, + _: transport::FetchRequest, + ) -> BoxFuture<'_, Result<transport::FetchPage, transport::Error>> { + self.failed(transport::Error::TransportUnavailable) + } + } + impl EventSink for Local { + fn status(&self) -> BoxFuture<'_, Result<transport::SinkStatus, transport::Error>> { + self.failed(transport::Error::TransportUnavailable) + } + fn deliver( + &self, + request: transport::DeliveryRequest, + ) -> BoxFuture<'_, Result<transport::DeliveryReceipt, transport::SinkFailure>> { + self.failed(transport::SinkFailure::transport_unavailable(&request)) + } + } + impl EventSubscriber for Local { + fn subscribe( + &self, + _: transport::SubscriptionRequest, + ) -> BoxFuture<'_, Result<transport::BoxSubscription, transport::Error>> { + self.failed(transport::Error::SubscriptionUnavailable) + } + } + struct Subscription { + local: Local, + request: transport::SubscriptionRequest, + } + impl transport::EventSubscription for Subscription { + fn request(&self) -> &transport::SubscriptionRequest { + &self.request + } + fn next(&mut self) -> BoxFuture<'_, Result<transport::SubscriptionNext, transport::Error>> { + self.local.failed(transport::Error::TransportUnavailable) + } + fn cancel( + &mut self, + ) -> BoxFuture<'_, Result<transport::SubscriptionEnd, transport::Error>> { + self.local.failed(transport::Error::TransportUnavailable) + } + } + impl Clock for Local { + fn now_unix_ms(&self) -> Result<u64, radroots_sync::Error> { + self.0.set(self.0.get() + 1); + Err(radroots_sync::Error::ClockUnavailable) + } + } + impl IdSource for Local { + fn next_id(&self, _: OperationKind) -> Result<SyncId, radroots_sync::Error> { + self.0.set(self.0.get() + 1); + Err(radroots_sync::Error::InvalidSyncId) + } + } + impl store::EventStore for Local { + fn status(&self) -> BoxFuture<'_, Result<store::status::EventStoreStatus, store::Error>> { + self.failed(store::Error::BackendUnavailable) + } + fn admit( + &self, + _: EventAdmission, + ) -> BoxFuture<'_, Result<AdmissionReceipt, store::Error>> { + self.failed(store::Error::BackendUnavailable) + } + fn query_raw( + &self, + _: EventQuery, + ) -> BoxFuture<'_, Result<EventPage<StoredRawEvent>, store::Error>> { + self.failed(store::Error::BackendUnavailable) + } + fn query_verified( + &self, + _: EventQuery, + ) -> BoxFuture<'_, Result<EventPage<StoredVerifiedEvent>, store::Error>> { + self.failed(store::Error::BackendUnavailable) + } + fn query_visible( + &self, + _: EventQuery, + ) -> BoxFuture<'_, Result<EventPage<StoredVisibleEvent>, store::Error>> { + self.failed(store::Error::BackendUnavailable) + } + fn rebuild_visibility(&self) -> BoxFuture<'_, Result<VisibilitySnapshot, store::Error>> { + self.failed(store::Error::BackendUnavailable) + } + fn query_provenance( + &self, + _: radroots_event::EventId, + _: EventQueryBounds, + ) -> BoxFuture<'_, Result<EventPage<StoredEventProvenance>, store::Error>> { + self.failed(store::Error::BackendUnavailable) + } + } + impl store::status::StorageStatusProvider for Local { + fn storage_status( + &self, + ) -> BoxFuture<'_, Result<store::status::StorageStatus, store::Error>> { + self.failed(store::Error::BackendUnavailable) + } + } + + #[test] + fn browser_ports_accept_real_local_callback_and_future_state() { + let state = Rc::new(Cell::new(0)); + let signer: signing::signer::DynSigner = SignerHandle::new(Local(state.clone())); + let source: transport::host::Shared<dyn EventSource> = Rc::new(Local(state.clone())); + let sink: transport::host::Shared<dyn EventSink> = Rc::new(Local(state.clone())); + let subscriber: transport::host::Shared<dyn EventSubscriber> = + Rc::new(Local(state.clone())); + let store: Rc<dyn store::EventStore> = Rc::new(Local(state.clone())); + let observer: SignerHandle<dyn signing::request::ProgressObserver> = + Rc::new(Local(state.clone())); + let authority: Rc<dyn signing::CurrentAuthoringAuthority> = Rc::new(Local(state.clone())); + let clock: transport::host::Shared<dyn Clock> = Rc::new(Local(state.clone())); + let ids: transport::host::Shared<dyn IdSource> = Rc::new(Local(state.clone())); + drop((sink, subscriber, observer, authority, clock, ids)); + futures::executor::block_on(async { + assert!(signer.status().await.is_err()); + assert!(source.status().await.is_err()); + assert!(store.status().await.is_err()); + }); + assert_eq!(state.get(), 3); + fn owned_subscription( + request: transport::SubscriptionRequest, + state: Rc<Cell<usize>>, + ) -> transport::BoxSubscription { + Box::new(Subscription { + local: Local(state), + request, + }) + } + let _constructor = owned_subscription; + } +} diff --git a/crates/transport/README.md b/crates/transport/README.md @@ -59,9 +59,11 @@ The complete externally implementable SPI example is ## Host SPI contract `EventSource`, `EventSubscriber`, and `EventSink` are independent, externally -implementable, dyn-compatible `Send + Sync` traits. An adapter may implement -any subset. Their methods return boxed `Future + Send` values so this package -does not select an async runtime or require an async-trait macro. +implementable, dyn-compatible traits. Native hosts remain `Send + Sync`, with +movable subscriptions and boxed `Future + Send`. Browser hosts, subscriptions +and futures may remain local. `host::Shared` selects native `Arc` or browser +`Rc`. An adapter may implement any subset. This package does not select an +async runtime or require an async-trait macro. - `status` is observational and must not begin fetch or delivery work. - `fetch` returns one bounded page plus per-target outcomes and explicit diff --git a/crates/transport/src/host.rs b/crates/transport/src/host.rs @@ -0,0 +1,30 @@ +//! Target-aware host bounds and shared handles for transport composition. + +/// Native host implementations are thread safe; browser hosts may be local. +#[cfg(not(target_arch = "wasm32"))] +pub trait HostBound: Send + Sync {} +#[cfg(not(target_arch = "wasm32"))] +impl<T: Send + Sync + ?Sized> HostBound for T {} +/// Native host implementations are thread safe; browser hosts may be local. +#[cfg(target_arch = "wasm32")] +pub trait HostBound {} +#[cfg(target_arch = "wasm32")] +impl<T: ?Sized> HostBound for T {} + +/// Native subscription ownership may move between threads. +#[cfg(not(target_arch = "wasm32"))] +pub trait MoveBound: Send {} +#[cfg(not(target_arch = "wasm32"))] +impl<T: Send + ?Sized> MoveBound for T {} +/// Browser subscription ownership remains local to its host. +#[cfg(target_arch = "wasm32")] +pub trait MoveBound {} +#[cfg(target_arch = "wasm32")] +impl<T: ?Sized> MoveBound for T {} + +/// Shared host ownership. Browser handles never require an unsafe Send bridge. +#[cfg(not(target_arch = "wasm32"))] +pub type Shared<T> = alloc::sync::Arc<T>; +/// Shared host ownership. Browser handles never require an unsafe Send bridge. +#[cfg(target_arch = "wasm32")] +pub type Shared<T> = alloc::rc::Rc<T>; diff --git a/crates/transport/src/lib.rs b/crates/transport/src/lib.rs @@ -8,6 +8,7 @@ extern crate alloc; pub mod capability; pub mod endpoint; pub mod error; +pub mod host; mod id; pub mod outcome; pub mod policy; diff --git a/crates/transport/src/sink.rs b/crates/transport/src/sink.rs @@ -460,7 +460,7 @@ impl SinkFailure { /// Host SPI for outbound event delivery. /// /// This trait supports external implementations and is dyn-compatible. Its -/// futures are `Send`; implementations must not borrow request data after a +/// futures are native `Send` or browser-local; implementations must not borrow request data after a /// future completes. `status` observes sink state and does not initiate /// delivery. `deliver` performs only the attempts authorized by its request, /// returns partial success per target, and owns no hidden retry loop. @@ -470,7 +470,7 @@ impl SinkFailure { /// operation behind. Once publication may have occurred, cancellation cannot /// claim rollback; a later observation may report the remote outcome. An /// explicit request deadline bounds work independently of future cancellation. -pub trait EventSink: Send + Sync { +pub trait EventSink: crate::host::HostBound { /// Returns the sink's current runtime status. fn status(&self) -> BoxFuture<'_, Result<SinkStatus, Error>>; diff --git a/crates/transport/src/source.rs b/crates/transport/src/source.rs @@ -49,7 +49,11 @@ pub const SUBSCRIPTION_REQUEST_ID_MAX_BYTES: usize = 256; pub const SUBSCRIPTION_MAX_EVENTS: u16 = 1_000; /// Heap-backed future returned by transport SPIs. +#[cfg(not(target_arch = "wasm32"))] pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>; +/// Heap-backed future local to a browser main thread or worker. +#[cfg(target_arch = "wasm32")] +pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>; /// Validated caller identity for one fetch operation. #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -970,7 +974,7 @@ fn target_position(target_set: &TargetSet, fingerprint: &TargetFingerprint) -> O /// Host SPI for inbound event retrieval. /// /// This trait supports external implementations and is dyn-compatible. Its -/// futures are `Send`; implementations must not borrow request data after a +/// futures are native `Send` or browser-local; implementations must not borrow request data after a /// future completes. `status` observes source state and does not initiate a /// fetch. `fetch` performs at most the work bounded by its request and owns no /// hidden retry loop. @@ -980,7 +984,7 @@ fn target_position(target_set: &TargetSet, fingerprint: &TargetFingerprint) -> O /// operation behind. Once publication may have occurred, cancellation cannot /// claim rollback; a later observation may report the remote outcome. The /// explicit request deadline bounds work independently of future cancellation. -pub trait EventSource: Send + Sync { +pub trait EventSource: crate::host::HostBound { /// Returns the source's current runtime status. fn status(&self) -> BoxFuture<'_, Result<SourceStatus, Error>>; @@ -995,7 +999,7 @@ pub trait EventSource: Send + Sync { /// returned, every later `next` or `cancel` call must return the exact same /// terminal result. Dropping a pending future requests cancellation but does /// not claim that an already-observed remote event was rolled back. -pub trait EventSubscription: Send { +pub trait EventSubscription: crate::host::MoveBound { /// Returns the exact request governing this operation. fn request(&self) -> &SubscriptionRequest; @@ -1013,7 +1017,7 @@ pub type BoxSubscription = Box<dyn EventSubscription>; /// /// This is separate from [`EventSource`] so existing bounded-fetch producers /// remain source-compatible until they explicitly adopt live delivery. -pub trait EventSubscriber: Send + Sync { +pub trait EventSubscriber: crate::host::HostBound { /// Begins one exact bounded live-subscription request. fn subscribe( &self, diff --git a/crates/transport/tests/package_boundary.rs b/crates/transport/tests/package_boundary.rs @@ -61,6 +61,7 @@ fn crate_root_declares_the_approved_public_module_skeleton() { "capability", "endpoint", "error", + "host", "outcome", "policy", "sink", @@ -160,6 +161,7 @@ fn every_public_module_has_crate_level_documentation() { "capability", "endpoint", "error", + "host", "outcome", "policy", "sink", @@ -178,7 +180,7 @@ fn every_public_module_has_crate_level_documentation() { #[test] fn source_subscription_and_sink_are_independent_dyn_compatible_host_spis() { for required in [ - "pub trait EventSource: Send + Sync", + "pub trait EventSource: crate::host::HostBound", "fn status(&self)", "fn fetch(", "Dropping a returned future requests cancellation.", @@ -192,8 +194,8 @@ fn source_subscription_and_sink_are_independent_dyn_compatible_host_spis() { assert!(!SOURCE.contains("fn deliver(")); for required in [ - "pub trait EventSubscriber: Send + Sync", - "pub trait EventSubscription: Send", + "pub trait EventSubscriber: crate::host::HostBound", + "pub trait EventSubscription: crate::host::MoveBound", "fn subscribe(", "fn next(&mut self)", "fn cancel(&mut self)", @@ -207,7 +209,7 @@ fn source_subscription_and_sink_are_independent_dyn_compatible_host_spis() { } for required in [ - "pub trait EventSink: Send + Sync", + "pub trait EventSink: crate::host::HostBound", "fn status(&self)", "fn deliver(", "Dropping a returned future requests cancellation.",