lib

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

commit 24fc6509b1a1217b8acd619d37fc6bdd9677705e
parent b231e5fba2c38d78af0432d6fdde787f5bea52f3
Author: triesap <tyson@radroots.org>
Date:   Mon, 19 Oct 2026 23:45:39 +0000

storage_indexeddb: Reconcile original captures under the retained writer

- Implement the shared operation journal with actual browser ports
- Preserve original grant authorization across existing-only connection recovery
- Bind uncertainty clearance to the original obtained capture identity
- Exercise retained leases, failed reopen, cancellation and restart behavior

Diffstat:
Mcontracts/api_baselines/radroots_storage_indexeddb.wasm32_workspace.txt | 16++++++++++++++++
Mcontracts/architecture/decisions/browser_workspace.v2.json | 32+++++++++++++++++++++++++++++---
Mcrates/storage_indexeddb/README.md | 30+++++++++++++++++++++++++-----
Mcrates/storage_indexeddb/src/workspace/address.rs | 4++--
Mcrates/storage_indexeddb/src/workspace/delivery/observation_operations.rs | 15++++++++++-----
Mcrates/storage_indexeddb/src/workspace/delivery/operations.rs | 4++--
Mcrates/storage_indexeddb/src/workspace/installation.rs | 4++--
Mcrates/storage_indexeddb/src/workspace/issuance.rs | 19++++++++++++-------
Mcrates/storage_indexeddb/src/workspace/journal.rs | 6+++---
Mcrates/storage_indexeddb/src/workspace/mod.rs | 57++++++++++++++++++++++++++++++++++++++++++++-------------
Mcrates/storage_indexeddb/src/workspace/plans.rs | 4++--
Acrates/storage_indexeddb/src/workspace/ports.rs | 169+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/storage_indexeddb/src/workspace/recovery.rs | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/storage_indexeddb/tests/browser/journal.mjs | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/storage_indexeddb/tests/browser/run.mjs | 6++++--
Mcrates/storage_indexeddb/tests/browser/src/workspace.rs | 17+++++++++++------
Mcrates/storage_indexeddb/tests/browser/src/workspace/delivery.rs | 12++++++------
Mcrates/storage_indexeddb/tests/browser/src/workspace/installation.rs | 10+++++-----
Mcrates/storage_indexeddb/tests/browser/src/workspace/issuance.rs | 55+++++++++++++++++++++++++++++++++++++++++++------------
Mcrates/storage_indexeddb/tests/browser/src/workspace/observations.rs | 12++++++------
Mcrates/storage_indexeddb/tests/browser/src/workspace/plans.rs | 10+++++-----
21 files changed, 611 insertions(+), 86 deletions(-)

diff --git a/contracts/api_baselines/radroots_storage_indexeddb.wasm32_workspace.txt b/contracts/api_baselines/radroots_storage_indexeddb.wasm32_workspace.txt @@ -30,6 +30,22 @@ pub async fn radroots_storage_indexeddb::workspace::BrowserWorkspace::install_tr pub async fn radroots_storage_indexeddb::workspace::BrowserWorkspace::operation_snapshot(&self, radroots_storage::workspace::WorkspaceBinding, radroots_domain::identifier::OperationId, core::option::Option<radroots_domain::identifier::CommandDigest>, radroots_storage::workspace::AttachmentProof) -> core::result::Result<core::option::Option<radroots_storage::command::snapshot::OperationSnapshot>, radroots_storage::command::OperationError> impl core::fmt::Debug for radroots_storage_indexeddb::workspace::BrowserWorkspace pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +impl radroots_storage::command::OperationJournal for radroots_storage_indexeddb::workspace::BrowserWorkspace +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::admit_command_and_hold(&self, radroots_storage::command::AdmissionRequest, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::command::AdmissionOutcome, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::bind_signing_intents(&self, radroots_storage::workspace::WorkspaceBinding, radroots_protocol::chat::plan::ChatSigningPlan, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::command::PlanBindingOutcome, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::capture_evidence<'a>(&'a self, radroots_storage::workspace::AttachmentInput, &'a radroots_storage::workspace::AttachmentProof, &'a radroots_storage::command::issuance::SealEvidence) -> radroots_transport::source::BoxFuture<'a, core::result::Result<radroots_storage::command::issuance::EvidenceCaptureOutcome, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::claim_attempt(&self, radroots_storage::command::issuance::ClaimAttemptRequest, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::command::issuance::ClaimAttemptOutcome, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::delivery_attempt(&self, radroots_storage::workspace::WorkspaceBinding, radroots_domain::identifier::OperationId, radroots_domain::identifier::CommandDigest, radroots_identity::key::PublicKey, radroots_transport::sink::DeliveryRequestId, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::command::delivery::DeliveryAttempt>, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::delivery_observations(&self, radroots_storage::workspace::WorkspaceBinding, radroots_domain::identifier::OperationId, radroots_domain::identifier::CommandDigest, radroots_identity::key::PublicKey, radroots_transport::sink::DeliveryRequestId, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<alloc::vec::Vec<radroots_storage::command::observation::DeliveryObservation>, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::install_transition_and_outbox(&self, radroots_storage::command::installation::InstallationRequest, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::command::installation::InstallationOutcome, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::obtained_evidence(&self, radroots_storage::command::issuance::ClaimAttemptRequest, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::command::issuance::CapturedSeal>, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::operation(&self, radroots_storage::workspace::WorkspaceBinding, radroots_domain::identifier::OperationId, core::option::Option<radroots_domain::identifier::CommandDigest>, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::command::PreparedOperation>, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::operation_snapshot(&self, radroots_storage::workspace::WorkspaceBinding, radroots_domain::identifier::OperationId, core::option::Option<radroots_domain::identifier::CommandDigest>, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::command::snapshot::OperationSnapshot>, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::prepare_delivery_attempt<'a>(&'a self, radroots_storage::command::delivery::DeliveryAttemptRequest, radroots_storage::workspace::AttachmentProof, core::option::Option<&'a radroots_storage::command::delivery::EnvelopeCandidate>) -> radroots_transport::source::BoxFuture<'a, core::result::Result<radroots_storage::command::delivery::DeliveryAttemptOutcome, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::reconcile_unknown<'a>(&'a self, radroots_storage::workspace::AttachmentInput, &'a radroots_storage::workspace::AttachmentProof, &'a radroots_storage::command::issuance::SealEvidence) -> radroots_transport::source::BoxFuture<'a, core::result::Result<radroots_storage::command::issuance::EvidenceCaptureOutcome, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::record_delivery_observation(&self, radroots_storage::workspace::WorkspaceBinding, radroots_storage::workspace::AttachmentProof, radroots_storage::command::observation::DeliveryObservation) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::command::observation::DeliveryObservationOutcome, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::signing_attempt(&self, radroots_storage::command::issuance::ClaimAttemptRequest, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::command::issuance::SigningAttempt>, radroots_storage::command::OperationError>> +pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::signing_plan(&self, radroots_storage::workspace::WorkspaceBinding, radroots_domain::identifier::OperationId, radroots_domain::identifier::CommandDigest, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<core::option::Option<radroots_storage::command::BoundSigningPlan>, radroots_storage::command::OperationError>> impl radroots_storage::workspace::WorkspaceStore for radroots_storage_indexeddb::workspace::BrowserWorkspace pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::authenticate(&self, radroots_storage::workspace::AttachmentInput, radroots_storage::workspace::AttachmentProof) -> radroots_transport::source::BoxFuture<'_, core::result::Result<radroots_storage::workspace::WorkspaceBinding, radroots_storage::workspace::WorkspaceError>> pub fn radroots_storage_indexeddb::workspace::BrowserWorkspace::close_workspace(&self) -> radroots_transport::source::BoxFuture<'_, core::result::Result<(), radroots_storage::workspace::WorkspaceError>> diff --git a/contracts/architecture/decisions/browser_workspace.v2.json b/contracts/architecture/decisions/browser_workspace.v2.json @@ -1,7 +1,7 @@ { "schema_version": 1, "contract_id": "radroots.storage.browser_workspace.v2", - "state": "implemented_verified_delivery_observation_component", + "state": "implemented_verified_operation_journal_component", "owner": "radroots_storage_indexeddb", "feature": "workspace", "target": "wasm32-unknown-unknown", @@ -12,7 +12,6 @@ "scope": "fresh_unrelated_buyer_outbox", "stock_authority": false, "participant_key_is_workspace_proof": false, - "full_operation_journal_or_client_claim": false, "storage": { "namespace_domain": "radroots.browser.local_outbox.namespace.v2", "grant_key_domain": "radroots.browser.local_outbox.grant.v1", @@ -202,7 +201,10 @@ "prepare_delivery_attempt", "delivery_attempt", "record_delivery_observation", - "delivery_observations" + "delivery_observations", + "reconcile_unknown", + "admit_command_and_hold", + "bind_signing_intents" ], "delivery_frame": { "phase": "D_attempt", @@ -245,5 +247,29 @@ "retained_or_unknown_authorizes_dispatch": false, "capture_only_owner_allows_fresh_authentication_or_commands": false, "actual_remote_acceptance_or_full_client_claim": false + }, + "full_operation_journal_implemented_and_verified": true, + "full_browser_client_or_transport_execution_qualified": false, + "general_storage_spi_implemented": false, + "shared_operation_journal": "radroots_storage::command::OperationJournal", + "retained_capture_recovery": { + "ordinary_admission_while_uncertain": "denied", + "writer_held_through_connection_close_and_reopen": true, + "open_mode": "same_existing_namespace_and_schema_only", + "original_proof_authenticated_before_connection_disposal": true, + "cached_original_grant_after_confirmed_close": true, + "cached_grant_clear_bytes_max": 16384, + "raw_proof_retained_in_handle": false, + "current_grant_and_actual_original_claim_or_attempt_revalidated": true, + "old_witness_replayed_after_reopen": false, + "refcell_borrow_held_across_await": false, + "confirmation_clears_only_matching_original_capture_identity": true, + "unrelated_capture_clears_uncertainty": false, + "general_or_multiple_unrelated_uncertainty": "explicit_close_and_reopen_required", + "fresh_grant_clock_or_dispatch_authority_acquired": false, + "namespace_initialization_migration_or_damaged_state_repair": false, + "failed_recovery_keeps_uncertainty_and_writer": true, + "accepted_recovery_survives_lost_observer": true, + "final_close_drains_recovery_before_writer_release": true } } diff --git a/crates/storage_indexeddb/README.md b/crates/storage_indexeddb/README.md @@ -16,8 +16,9 @@ adds `workspace::BrowserWorkspace`: an authenticated protected local buyer outbox using the shared storage enrollment/grant rules and an explicitly selected nonvolatile provider. It creates only a fresh unrelated outbox; opening existing data requires its retained selection and protected proof. -It supplies no participant custody, complete operation journal/storage SPI or -stock authority. +It implements the shared `OperationJournal` for this protected local buyer +outbox. Participant custody, general storage SPI and stock authority remain +separate. The workspace also executes immutable buyer operation admission and lookup. It retains the original command, transaction identity and first-issue window; @@ -102,8 +103,26 @@ per operation. Reports decode while the original attempt frame is available, without retaining every raw outer body. The complete prefix and original grant are compared in the actual retention transaction. Uncertain completion returns the original observation and stops admission. `delivery_observations` and coherent -snapshots require current access and do not dispatch. A complete journal/client -and browser transport execution remain separate phases. +snapshots require current access and do not dispatch. Browser transport and the +ordinary client remain separate phases. + +All shared journal ports delegate to this actual owner. Uncertainty stops +ordinary admission while retaining the original namespace and writer lease. +Already obtained original seals and target observations may reconcile under +the retained proof. Recovery authenticates the actual grant before connection +disposal, confirms closure, opens only the same existing namespace/schema and +rechecks the current grant and actual original claim or attempt. Cached original +grant authorization survives a failed reopen without retaining raw proof in the +handle. Fresh connection-bound witnesses are acquired after reopening; no old +witness or `RefCell` borrow crosses the asynchronous replacement boundary. + +Only confirmation matching the original uncertain capture identity clears +admission. Confirming an unrelated older fact does not resolve another pending +operation. General or multiple unrelated uncertainty requires explicit closure +and reopening. Recovery grants no fresh command, grant, clock, signing, network +or redispatch permission and never initializes, migrates or repairs a namespace. +Accepted recovery stays owned through lost observation; final close drains it +before releasing the writer. An owner-bound read snapshot witnesses at most 16,384 ordered opaque keys, lengths and SHA-256 digests, using a conservative 2 MiB scan reservation. Every @@ -151,7 +170,8 @@ directory, that output directory, `chromium`, `firefox`, or `webkit`, and the preserved v1 fixture package directory for actual cross-version refusal checks. The optional final argument selects `delivery`, `delivery_limits`, `delivery_corruption`, `delivery_faults`, `observations`, `observation_faults`, -or `observation_corruption`; omission runs the existing base +`observation_corruption`, `journal`, `journal_observations`, or `journal_reopen`; +omission runs the existing base regressions. Additional profiles preserve that base's bounded deadline. Synthetic normalized observation inputs prove concrete storage and linkage behavior; they do not establish remote relay execution or acceptance. diff --git a/crates/storage_indexeddb/src/workspace/address.rs b/crates/storage_indexeddb/src/workspace/address.rs @@ -117,7 +117,7 @@ impl State { operation: OperationId, ) -> Result<ReadSnapshot, OperationError> { let view = self - .db + .database() .read_snapshot(prefix(operation)) .await .map_err(super::journal::storage_error)?; @@ -135,7 +135,7 @@ impl State { return Ok(None); } let value = self - .db + .database() .get(key) .await .map_err(super::journal::storage_error)?; diff --git a/crates/storage_indexeddb/src/workspace/delivery/observation_operations.rs b/crates/storage_indexeddb/src/workspace/delivery/observation_operations.rs @@ -20,12 +20,14 @@ impl BrowserWorkspace { proof: AttachmentProof, supplied: DeliveryObservation, ) -> Result<DeliveryObservationOutcome, OperationError> { + let capture_identity = crate::workspace::recovery::CaptureIdentity::observation(&supplied); + let owned_identity = capture_identity.clone(); let fallback = supplied.clone(); - let work = self.state.admit()?; + let work = self.state.admit_capture()?; let state = self.state.clone(); let result = owned(work, async move { let input = binding.input().clone(); - let (grant, protected) = state.capture_grant(&input, &proof).await?; + let (grant, protected) = state.capture_retained(&input, &proof).await?; let actual_work = supplied.work(); let evidence = actual_work.evidence(); let operation = evidence.operation_id(); @@ -98,9 +100,12 @@ impl BrowserWorkspace { }) .await { - Ok(()) => Ok(DeliveryObservationOutcome::Committed(retained)), + Ok(()) => { + state.capture_confirmed(&owned_identity); + Ok(DeliveryObservationOutcome::Committed(retained)) + } Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - state.stop(); + state.mark_capture_unknown(owned_identity); Ok(DeliveryObservationOutcome::Unknown(retained)) } Err(error) => Err(error), @@ -109,7 +114,7 @@ impl BrowserWorkspace { .await; match result { Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - self.state.stop(); + self.state.mark_capture_unknown(capture_identity); Ok(DeliveryObservationOutcome::Unknown(fallback)) } other => other, diff --git a/crates/storage_indexeddb/src/workspace/delivery/operations.rs b/crates/storage_indexeddb/src/workspace/delivery/operations.rs @@ -267,7 +267,7 @@ impl BrowserWorkspace { DeliveryAttemptOutcome::Retained(Box::new(report)) }), Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - state.stop(); + state.mark_unknown(); Ok(unknown(anchor, identity)) } Err(error) => Err(error), @@ -276,7 +276,7 @@ impl BrowserWorkspace { .await; match result { Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - self.state.stop(); + self.state.mark_unknown(); Ok(unknown(fallback, request_id)) } other => other, diff --git a/crates/storage_indexeddb/src/workspace/installation.rs b/crates/storage_indexeddb/src/workspace/installation.rs @@ -276,7 +276,7 @@ impl BrowserWorkspace { { Ok(()) => Ok(InstallationOutcome::Committed(Box::new(installed))), Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - state.stop(); + state.mark_unknown(); Ok(InstallationOutcome::Unknown(anchor)) } Err(error) => Err(error), @@ -285,7 +285,7 @@ impl BrowserWorkspace { .await; match result { Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - self.state.stop(); + self.state.mark_unknown(); Ok(InstallationOutcome::Unknown(fallback)) } other => other, diff --git a/crates/storage_indexeddb/src/workspace/issuance.rs b/crates/storage_indexeddb/src/workspace/issuance.rs @@ -334,7 +334,7 @@ impl BrowserWorkspace { ClaimAttemptOutcome::Retained(attempt) }), Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - state.stop(); + state.mark_unknown(); Ok(ClaimAttemptOutcome::Unknown(anchor)) } Err(error) => Err(error), @@ -343,7 +343,7 @@ impl BrowserWorkspace { .await; match result { Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - self.state.stop(); + self.state.mark_unknown(); Ok(ClaimAttemptOutcome::Unknown(fallback)) } other => other, @@ -412,18 +412,20 @@ impl BrowserWorkspace { proof: &AttachmentProof, supplied: &SealEvidence, ) -> Result<EvidenceCaptureOutcome, OperationError> { + let capture_identity = super::recovery::CaptureIdentity::seal(supplied); + let owned_identity = capture_identity.clone(); let fallback = CommitAttempt::new( supplied.workspace_id(), supplied.operation_id(), supplied.command_digest(), None, ); - let work = self.state.admit()?; + let work = self.state.admit_capture()?; let state = self.state.clone(); let proof = proof.with_secret(|raw| AttachmentProof::from_protected_input(raw))?; let supplied = supplied.retained_copy(); let result = owned(work, async move { - let (grant, protected) = state.capture_grant(&input, &proof).await?; + let (grant, protected) = state.capture_retained(&input, &proof).await?; if supplied.workspace_id() != state.selected.workspace_id() { return Err(OperationError::InvalidEvidence); } @@ -490,9 +492,12 @@ impl BrowserWorkspace { }) .await { - Ok(()) => Ok(EvidenceCaptureOutcome::Committed(receipt)), + Ok(()) => { + state.capture_confirmed(&owned_identity); + Ok(EvidenceCaptureOutcome::Committed(receipt)) + } Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - state.stop(); + state.mark_capture_unknown(owned_identity); Ok(EvidenceCaptureOutcome::Unknown(anchor)) } Err(error) => Err(error), @@ -501,7 +506,7 @@ impl BrowserWorkspace { .await; match result { Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - self.state.stop(); + self.state.mark_capture_unknown(capture_identity); Ok(EvidenceCaptureOutcome::Unknown(fallback)) } other => other, diff --git a/crates/storage_indexeddb/src/workspace/journal.rs b/crates/storage_indexeddb/src/workspace/journal.rs @@ -309,7 +309,7 @@ impl State { let failure = Rc::new(Cell::new(None)); let refused = failure.clone(); let result = self - .db + .database() .compare_exchange_snapshot_checked(batch, view, move || { if let Err(error) = check() { refused.set(Some(error)); @@ -411,7 +411,7 @@ impl BrowserWorkspace { { Ok(()) => Ok(AdmissionOutcome::Committed(prepared)), Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - state.stop(); + state.mark_unknown(); Ok(AdmissionOutcome::Unknown(attempt)) } Err(error) => Err(error), @@ -420,7 +420,7 @@ impl BrowserWorkspace { .await; match result { Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - self.state.stop(); + self.state.mark_unknown(); Ok(AdmissionOutcome::Unknown(fallback)) } other => other, diff --git a/crates/storage_indexeddb/src/workspace/mod.rs b/crates/storage_indexeddb/src/workspace/mod.rs @@ -9,6 +9,8 @@ mod issuance; mod journal; mod lease; mod plans; +mod ports; +mod recovery; mod retained; use super::{Batch, Database, Error, Mutation, Namespace, OpenMode, RecordKey}; @@ -141,7 +143,7 @@ enum AccessMode { } struct State { // Database drops before the lease if an unobserved owner is discarded. - db: Database, + db: RefCell<Database>, provider: Rc<dyn SecretProvider>, reference: SecretRef, selected: AttachmentInput, @@ -150,12 +152,28 @@ struct State { lease: RefCell<Option<lease::Lease>>, serial: Mutex<()>, jobs: Cell<usize>, + uncertain: Cell<bool>, + capture_scope: RefCell<Option<recovery::CaptureIdentity>>, + recovery: RefCell<Option<recovery::Authorization>>, closing: Cell<bool>, closed: Cell<Option<Result<(), WorkspaceError>>>, drain: RefCell<Option<Waker>>, waiters: RefCell<Vec<Weak<Signal>>>, } impl State { + fn database(&self) -> Database { + self.db.borrow().clone() + } + fn mark_unknown(&self) { + self.uncertain.set(true); + } + fn mark_capture_unknown(&self, identity: recovery::CaptureIdentity) { + if !self.uncertain.replace(true) { + *self.capture_scope.borrow_mut() = Some(identity); + } else if self.capture_scope.borrow().as_ref() != Some(&identity) { + self.capture_scope.borrow_mut().take(); + } + } fn active(&self) -> Result<Rc<Cell<bool>>, WorkspaceError> { let active = self .lease @@ -169,7 +187,13 @@ impl State { Ok(active) } fn admit(self: &Rc<Self>) -> Result<Work, WorkspaceError> { - if self.closing.get() { + self.admit_mode(false) + } + fn admit_capture(self: &Rc<Self>) -> Result<Work, WorkspaceError> { + self.admit_mode(true) + } + fn admit_mode(self: &Rc<Self>, capture: bool) -> Result<Work, WorkspaceError> { + if self.closing.get() || (self.uncertain.get() && !capture) { return Err(WorkspaceError::Closed); } if self.active().is_err() { @@ -180,7 +204,7 @@ impl State { return Err(WorkspaceError::Capacity); } self.jobs.set(self.jobs.get() + 1); - Ok(Work(self.clone())) + Ok(Work(self.clone(), self.uncertain.get())) } fn stop(self: &Rc<Self>) { if self.closing.replace(true) { @@ -197,7 +221,7 @@ impl State { } }) .await; - let database = state.db.close().await.map_err(stored); + let database = state.database().close().await.map_err(stored); let lease = state.lease.borrow_mut().take(); let released = match lease { Some(lease) => lease.release().await, @@ -239,7 +263,7 @@ impl State { return Err(WorkspaceError::Unauthorized); } let protected = self - .db + .database() .get(grant_key()) .await .map_err(stored)? @@ -258,7 +282,7 @@ impl State { Ok((record, protected)) } } -struct Work(Rc<State>); +struct Work(Rc<State>, bool); impl Drop for Work { fn drop(&mut self) { self.0.jobs.set(self.0.jobs.get() - 1); @@ -293,18 +317,22 @@ async fn owned<T: 'static, E: JobError + 'static>( let (send, observe) = oneshot::channel(); spawn_local(async move { let state = work.0.clone(); + let recovery = work.1; let _work = work; let _serial = state.serial.lock().await; let result = future.await; - if matches!( - result.as_ref().err().and_then(JobError::workspace_failure), + let failure = result.as_ref().err().and_then(JobError::workspace_failure); + if failure == Some(WorkspaceError::CommitUnknown) { + state.mark_unknown(); + } else if matches!( + failure, Some( WorkspaceError::Closed | WorkspaceError::Unavailable | WorkspaceError::RecoveryRequired - | WorkspaceError::CommitUnknown ) - ) { + ) && (!recovery || state.active().is_err()) + { state.stop(); } let _ = send.send(result); @@ -377,7 +405,7 @@ impl BrowserWorkspace { ]) .map_err(stored)?; commit_current( - &owner.state.db, + &owner.state.database(), batch, owner.state.clock.clone(), binding.observed_at(), @@ -496,7 +524,7 @@ impl BrowserWorkspace { ) -> Self { Self { state: Rc::new(State { - db, + db: RefCell::new(db), provider, reference, selected, @@ -505,6 +533,9 @@ impl BrowserWorkspace { lease: RefCell::new(Some(lease)), serial: Mutex::new(()), jobs: Cell::new(0), + uncertain: Cell::new(false), + capture_scope: RefCell::new(None), + recovery: RefCell::new(None), closing: Cell::new(false), closed: Cell::new(None), drain: RefCell::new(None), @@ -538,7 +569,7 @@ impl BrowserWorkspace { ]) .map_err(stored)?; commit_current( - &state.db, + &state.database(), batch, state.clock.clone(), current.observed_at(), diff --git a/crates/storage_indexeddb/src/workspace/plans.rs b/crates/storage_indexeddb/src/workspace/plans.rs @@ -274,7 +274,7 @@ impl BrowserWorkspace { manifest.bind(prepared, plan)?, )), Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - state.stop(); + state.mark_unknown(); Ok(PlanBindingOutcome::Unknown(attempt)) } Err(error) => Err(error), @@ -283,7 +283,7 @@ impl BrowserWorkspace { .await; match result { Err(OperationError::Workspace(WorkspaceError::CommitUnknown)) => { - self.state.stop(); + self.state.mark_unknown(); Ok(PlanBindingOutcome::Unknown(fallback)) } other => other, diff --git a/crates/storage_indexeddb/src/workspace/ports.rs b/crates/storage_indexeddb/src/workspace/ports.rs @@ -0,0 +1,169 @@ +//! Shared journal dispatch uses the actual browser owner, never another engine. +use super::BrowserWorkspace; +use radroots_domain::{CommandDigest, OperationId, PublicKey}; +use radroots_storage::{ + command::{ + AdmissionOutcome, AdmissionRequest, BoundSigningPlan, CapturedSeal, ChatSigningPlan, + ClaimAttemptOutcome, ClaimAttemptRequest, DeliveryAttempt, DeliveryAttemptOutcome, + DeliveryAttemptRequest, DeliveryObservation, DeliveryObservationOutcome, EnvelopeCandidate, + EvidenceCaptureOutcome, InstallationOutcome, InstallationRequest, OperationError, + OperationJournal, OperationSnapshot, PlanBindingOutcome, PreparedOperation, SealEvidence, + SigningAttempt, + }, + workspace::{AttachmentInput, AttachmentProof, WorkspaceBinding}, +}; +use radroots_transport::{BoxFuture, sink::DeliveryRequestId}; + +impl OperationJournal for BrowserWorkspace { + fn reconcile_unknown<'a>( + &'a self, + input: AttachmentInput, + proof: &'a AttachmentProof, + evidence: &'a SealEvidence, + ) -> BoxFuture<'a, Result<EvidenceCaptureOutcome, OperationError>> { + Box::pin(BrowserWorkspace::capture_evidence( + self, input, proof, evidence, + )) + } + fn record_delivery_observation( + &self, + binding: WorkspaceBinding, + proof: AttachmentProof, + observation: DeliveryObservation, + ) -> BoxFuture<'_, Result<DeliveryObservationOutcome, OperationError>> { + Box::pin(BrowserWorkspace::record_delivery_observation( + self, + binding, + proof, + observation, + )) + } + fn delivery_observations( + &self, + binding: WorkspaceBinding, + operation: OperationId, + digest: CommandDigest, + recipient: PublicKey, + request: DeliveryRequestId, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<Vec<DeliveryObservation>, OperationError>> { + Box::pin(BrowserWorkspace::delivery_observations( + self, binding, operation, digest, recipient, request, proof, + )) + } + fn prepare_delivery_attempt<'a>( + &'a self, + request: DeliveryAttemptRequest, + proof: AttachmentProof, + candidate: Option<&'a EnvelopeCandidate>, + ) -> BoxFuture<'a, Result<DeliveryAttemptOutcome, OperationError>> { + Box::pin(BrowserWorkspace::prepare_delivery_attempt( + self, request, proof, candidate, + )) + } + fn delivery_attempt( + &self, + binding: WorkspaceBinding, + operation: OperationId, + digest: CommandDigest, + recipient: PublicKey, + request: DeliveryRequestId, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<Option<DeliveryAttempt>, OperationError>> { + Box::pin(BrowserWorkspace::delivery_attempt( + self, binding, operation, digest, recipient, request, proof, + )) + } + fn install_transition_and_outbox( + &self, + request: InstallationRequest, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<InstallationOutcome, OperationError>> { + Box::pin(BrowserWorkspace::install_transition_and_outbox( + self, request, proof, + )) + } + fn operation_snapshot( + &self, + binding: WorkspaceBinding, + operation: OperationId, + digest: Option<CommandDigest>, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<Option<OperationSnapshot>, OperationError>> { + Box::pin(BrowserWorkspace::operation_snapshot( + self, binding, operation, digest, proof, + )) + } + fn claim_attempt( + &self, + request: ClaimAttemptRequest, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<ClaimAttemptOutcome, OperationError>> { + Box::pin(BrowserWorkspace::claim_attempt(self, request, proof)) + } + fn signing_attempt( + &self, + request: ClaimAttemptRequest, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<Option<SigningAttempt>, OperationError>> { + Box::pin(BrowserWorkspace::signing_attempt(self, request, proof)) + } + fn capture_evidence<'a>( + &'a self, + input: AttachmentInput, + proof: &'a AttachmentProof, + evidence: &'a SealEvidence, + ) -> BoxFuture<'a, Result<EvidenceCaptureOutcome, OperationError>> { + Box::pin(BrowserWorkspace::capture_evidence( + self, input, proof, evidence, + )) + } + fn obtained_evidence( + &self, + request: ClaimAttemptRequest, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<Option<CapturedSeal>, OperationError>> { + Box::pin(BrowserWorkspace::obtained_evidence(self, request, proof)) + } + fn bind_signing_intents( + &self, + binding: WorkspaceBinding, + plan: ChatSigningPlan, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<PlanBindingOutcome, OperationError>> { + Box::pin(BrowserWorkspace::bind_signing_intents( + self, binding, plan, proof, + )) + } + fn signing_plan( + &self, + binding: WorkspaceBinding, + operation: OperationId, + digest: CommandDigest, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<Option<BoundSigningPlan>, OperationError>> { + Box::pin(BrowserWorkspace::signing_plan( + self, binding, operation, digest, proof, + )) + } + fn admit_command_and_hold( + &self, + request: AdmissionRequest, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<AdmissionOutcome, OperationError>> { + Box::pin(BrowserWorkspace::admit_command_and_hold( + self, request, proof, + )) + } + fn operation( + &self, + binding: WorkspaceBinding, + operation: OperationId, + digest: Option<CommandDigest>, + proof: AttachmentProof, + ) -> BoxFuture<'_, Result<Option<PreparedOperation>, OperationError>> { + Box::pin(BrowserWorkspace::operation( + self, binding, operation, digest, proof, + )) + } +} diff --git a/crates/storage_indexeddb/src/workspace/recovery.rs b/crates/storage_indexeddb/src/workspace/recovery.rs @@ -0,0 +1,124 @@ +//! Same-owner connection recovery confers only original obtained-fact retention. +use super::{Database, OpenMode, State, WorkspaceError, namespace, stored}; +use radroots_domain::OperationId; +use radroots_storage::command::{ + DeliveryObservation, DeliveryObservationKind, PublicationWork, SealEvidence, +}; +use radroots_storage::workspace::{ + AttachmentInput, AttachmentProof, local_outbox::LocalOutboxGrant, +}; +use radroots_transport::{sink::DeliveryRequestId, target::TargetFingerprint}; + +#[derive(Clone, Eq, PartialEq)] +pub(super) enum CaptureIdentity { + Seal { + operation: OperationId, + digest: [u8; 32], + }, + Observation { + work: Box<PublicationWork>, + request: DeliveryRequestId, + target: TargetFingerprint, + kind: DeliveryObservationKind, + }, +} +impl CaptureIdentity { + pub fn seal(value: &SealEvidence) -> Self { + Self::Seal { + operation: value.operation_id(), + digest: *value.digest(), + } + } + pub fn observation(value: &DeliveryObservation) -> Self { + Self::Observation { + work: Box::new(value.work()), + request: value.request_id().clone(), + target: value.target_receipt().target().fingerprint().clone(), + kind: value.kind(), + } + } +} + +pub(super) struct Authorization { + grant: LocalOutboxGrant, + close_confirmed: bool, +} +impl State { + pub(super) fn capture_confirmed(&self, identity: &CaptureIdentity) { + let matches = self.capture_scope.borrow().as_ref() == Some(identity); + if matches { + self.uncertain.set(false); + self.capture_scope.borrow_mut().take(); + self.recovery.borrow_mut().take(); + } + } + pub(super) async fn capture_retained( + &self, + input: &AttachmentInput, + proof: &AttachmentProof, + ) -> Result<(LocalOutboxGrant, Vec<u8>), WorkspaceError> { + self.active()?; + if input != &self.selected { + return Err(WorkspaceError::Unauthorized); + } + if self.uncertain.get() { + self.reopen_retained(input, proof).await?; + } + self.capture_grant(input, proof).await + } + async fn reopen_retained( + &self, + input: &AttachmentInput, + proof: &AttachmentProof, + ) -> Result<(), WorkspaceError> { + // A live connection must authenticate its actual grant before disposal. + // After confirmed closure, cached original authorization survives a + // failed existing-only reopen. No raw proof is retained in this cache. + if self + .recovery + .borrow() + .as_ref() + .is_none_or(|value| !value.close_confirmed) + { + let (grant, _) = self.capture_grant(input, proof).await?; + *self.recovery.borrow_mut() = Some(Authorization { + grant, + close_confirmed: false, + }); + } + { + let cached = self.recovery.borrow(); + cached + .as_ref() + .ok_or(WorkspaceError::RecoveryRequired)? + .grant + .authenticate_retained_capture(input, proof)?; + } + let closed = self + .recovery + .borrow() + .as_ref() + .ok_or(WorkspaceError::RecoveryRequired)? + .close_confirmed; + if !closed { + self.database().close().await.map_err(stored)?; + self.recovery + .borrow_mut() + .as_mut() + .ok_or(WorkspaceError::RecoveryRequired)? + .close_confirmed = true; + } + self.active()?; + let replacement = Database::open(namespace(&self.selected)?, OpenMode::Existing) + .await + .map_err(stored)?; + self.active()?; + *self.db.borrow_mut() = replacement; + self.recovery + .borrow_mut() + .as_mut() + .ok_or(WorkspaceError::RecoveryRequired)? + .close_confirmed = false; + Ok(()) + } +} diff --git a/crates/storage_indexeddb/tests/browser/journal.mjs b/crates/storage_indexeddb/tests/browser/journal.mjs @@ -0,0 +1,91 @@ +import assert from 'node:assert/strict'; + +export async function runJournal(page,profile) { + const result=await page.evaluate(async profile=>{ + const {default:init,WorkspaceFixture}=await import('./fixture.js');await init(); + const tests=[],passed=name=>{tests.push(name);console.log('PASS '+name);}; + const same=(a,b)=>{if(JSON.stringify(a)!==JSON.stringify(b))throw Error('assertion mismatch: '+JSON.stringify(a)+' / '+JSON.stringify(b));}; + const rejects=async(fn,code)=>{try{await fn();}catch(error){if(String(error)!==code)throw Error('expected '+code+', received '+String(error));return;}throw Error('expected refusal: '+code);}; + const kb=key=>Array.from(new Uint8Array(key)); + const receipt=(owner,n)=>({n,fingerprint:Array.from(owner.fingerprint()),selection:Array.from(owner.selection()),proof:Array.from(owner.proof()),namespace:owner.data_namespace()}); + const open=(r,capture=false)=>(capture?WorkspaceFixture.open_capture:WorkspaceFixture.open)(r.n,new Uint8Array(r.fingerprint),new Uint8Array(r.selection),new Uint8Array(r.proof)); + const rawOpen=r=>new Promise((resolve,reject)=>{const req=indexedDB.open(r.namespace,1);req.onupgradeneeded=()=>req.transaction.abort();req.onsuccess=()=>resolve(req.result);req.onerror=reject;}); + const rows=async r=>{const db=await rawOpen(r);try{return await new Promise((resolve,reject)=>{const tx=db.transaction('records','readonly'),store=tx.objectStore('records');let keys,values;store.getAllKeys().onsuccess=e=>keys=e.target.result;store.getAll().onsuccess=e=>values=e.target.result;tx.oncomplete=()=>resolve({keys,values});tx.onabort=reject;});}finally{db.close();}}; + const sameRows=(a,b)=>{same(a.keys.map(kb),b.keys.map(kb));same(a.values.map(kb),b.values.map(kb));}; + const plan=async(owner,n)=>{await owner.admit(n,false);await owner.bind_plan(n,await owner.new_delivery_plan(n));return owner.obtain(n,0,false);}; + const setup=async n=>{const owner=await WorkspaceFixture.create(n+1),seal=await plan(owner,n);return{owner,seal,receipt:receipt(owner,n+1)};}; + const nativePut=IDBObjectStore.prototype.put,nativeAdd=IDBObjectStore.prototype.add,nativeAbort=IDBTransaction.prototype.abort,nativeClose=IDBDatabase.prototype.close,nativeOpen=IDBFactory.prototype.open; + const reset=()=>{IDBObjectStore.prototype.put=nativePut;IDBTransaction.prototype.abort=nativeAbort;IDBDatabase.prototype.close=nativeClose;IDBFactory.prototype.open=nativeOpen;}; + const inject=(namespace,key,redirect)=>{ + IDBObjectStore.prototype.put=function(bytes,at){if(this.transaction.db.name===namespace&&JSON.stringify(kb(at))===JSON.stringify(kb(key))){const req=nativeAdd.call(this,bytes,redirect??at);req.addEventListener('error',event=>event.preventDefault());return req;}return nativePut.call(this,bytes,at);}; + IDBTransaction.prototype.abort=function(){if(this.db.name===namespace)return;return nativeAbort.call(this);}; + }; + const unknownSeal=async s=>{const prefix=new Uint8Array(await crypto.subtle.digest('SHA-256',new Uint8Array([...new TextEncoder().encode('radroots.browser.local_outbox.operation.prefix.v2\0'),...new Uint8Array(32).fill(s.receipt.n-1)]))).slice(0,16),all=await rows(s.receipt),at=all.keys.find(k=>kb(k)[16]===1&&kb(k)[20]===1&&kb(k).slice(0,16).every((byte,index)=>byte===prefix[index]));if(!at)throw Error('missing original operation fault target');try{inject(s.receipt.namespace,at);return Array.from(await s.owner.capture_unknown(s.seal));}finally{reset();}}; + const setupDelivery=async n=>{const s=await setup(n);await s.owner.capture(s.seal);await s.owner.install(n);s.envelope=await s.owner.envelope(n,0,0);await s.owner.store_envelope(n,1,3,0,s.envelope);return s;}; + const faultTarget=async s=>(await rows(s.receipt)).keys.find(k=>kb(k)[16]===1&&kb(k)[20]===1); + const unknownObservation=async(s,value)=>{const at=await faultTarget(s);try{return JSON.parse(await s.owner.retain_observation_unknown(value,()=>inject(s.receipt.namespace,at)));}finally{reset();}}; + try { + if(profile==='journal') { + const n=200,s=await setup(n),anchor=await unknownSeal(s);await rejects(()=>s.owner.authenticate(),'closed');const stable=await rows(s.receipt);let closes=0,opens=0; + try{IDBDatabase.prototype.close=function(){if(this.name===s.receipt.namespace)closes++;return nativeClose.call(this);};IDBFactory.prototype.open=function(...args){if(args[0]===s.receipt.namespace)opens++;return nativeOpen.apply(this,args);};await rejects(()=>s.owner.reconcile(s.seal,true),'unauthorized');same(closes,0);same(opens,0);}finally{reset();} + sameRows(await rows(s.receipt),stable);await rejects(()=>open(s.receipt,true),'writer_active'); + passed('actual uncertain shared journal refuses ordinary admission and wrong-proof recovery without disposing its original connection or writer'); + let contender,opened=false,original; + try{IDBFactory.prototype.open=function(...args){if(args[0]===s.receipt.namespace&&!opened){opened=true;contender=open(s.receipt,true).then(()=> 'unexpected_writer',error=>String(error));}return nativeOpen.apply(this,args);};original=Array.from(await s.owner.reconcile(s.seal,false));same(original.slice(0,32),anchor.slice(64,96));same(Array.from(await s.owner.captured_original(s.seal)),original);same(opened,true);same(await contender,'writer_active');same(await s.owner.authenticate(),1);}finally{reset();} + sameRows(await rows(s.receipt),stable);await s.owner.close(); + passed('actual shared-trait reconciliation closes and reopens under the same retained writer and confirms the original capture transaction and bytes'); + const otherN=202,other=await setup(otherN),older=await plan(other.owner,otherN+2);await other.owner.capture(older);await unknownSeal(other);await other.owner.reconcile(older,false);await rejects(()=>other.owner.authenticate(),'closed');await other.owner.reconcile(other.seal,false);same(await other.owner.authenticate(),1);await other.owner.close(); + passed('confirming an unrelated older seal cannot clear the original uncertain capture identity'); + const lateN=206,late=await setup(lateN);await late.owner.revoke();late.owner.set_time(0);const lateAnchor=await unknownSeal(late),confirmed=Array.from(await late.owner.reconcile(late.seal,false));same(confirmed.slice(0,32),lateAnchor.slice(64,96));await late.owner.close(); + passed('actual original-proof reconciliation retains revoked and unavailable-clock obtained material without fresh authority'); + const cancelN=208,cancel=await setup(cancelN);await unknownSeal(cancel);cancel.owner.abandon_reconcile(cancel.seal);cancel.seal.free();cancel.owner.abandon_close();await cancel.owner.close();const reopened=await open(cancel.receipt);if((await reopened.captured(cancelN,0)).length===0)throw Error('cancelled recovery discarded original obtained bytes');await reopened.close(); + passed('accepted same-owner recovery survives lost observation and original disposal while final close drains before releasing the writer'); + return{tests,receipt:s.receipt,operation:n,golden:original}; + } + if(profile==='journal_observations') { + const n=210,s=await setupDelivery(n),original=await s.owner.observation(n,0,1,0,1,0),later=await s.owner.observation(n,0,1,0,1,1000100),other=await s.owner.observation(n,0,1,0,3,1000200),expected=JSON.parse(original.original());same((await unknownObservation(s,original)).report,expected);await rejects(()=>s.owner.authenticate(),'closed');await rejects(()=>s.owner.retain_observation(original,true),'unauthorized'); + same(JSON.parse(await s.owner.retain_observation(other,false)).kind,'committed');await rejects(()=>s.owner.authenticate(),'closed');same(JSON.parse(await s.owner.retain_observation(later,false)).report,expected);same(await s.owner.authenticate(),1);const actual=JSON.parse(await s.owner.query_observations(n,0,1));same(actual.length,2);same(actual.find(value=>value.class===1),expected);await s.owner.close(); + passed('actual same-owner target recovery preserves first details and unknown time while another outcome class cannot clear the original uncertainty'); + const missingN=212,missing=await setupDelivery(missingN),value=await missing.owner.observation(missingN,0,1,0,5,0),before=await rows(missing.receipt),old=await faultTarget(missing),target=new Uint8Array(before.keys.find(k=>kb(k)[16]===7&&kb(k)[20]===0));target[16]=8;target[21]=0;target[22]=5;let result; + try{result=JSON.parse(await missing.owner.retain_observation_unknown(value,()=>inject(missing.receipt.namespace,target,old)));}finally{reset();}same(result.kind,'unknown');same((await rows(missing.receipt)).keys.filter(k=>kb(k)[16]===8).length,0);same(JSON.parse(await missing.owner.retain_observation(value,false)).report,JSON.parse(value.original()));same(await missing.owner.authenticate(),1);same(JSON.parse(await missing.owner.query_observations(missingN,0,1)),[result.report]);await missing.owner.close(); + passed('actual same-owner reconciliation recaptures the exact obtained observation after unexpected completion omitted its row'); + const lateN=214,late=await setupDelivery(lateN),lateValue=await late.owner.observation(lateN,0,1,0,4,0);await late.owner.revoke();late.owner.set_time(0);await unknownObservation(late,lateValue);same(JSON.parse(await late.owner.retain_observation(lateValue,false)).report,JSON.parse(lateValue.original()));await late.owner.close(); + passed('actual same-owner target recovery uses retained proof despite revocation and an unavailable clock'); + const generalN=216,general=await setupDelivery(generalN),oldValue=await general.owner.observation(generalN,0,1,0,1,0),unchanged=await faultTarget(general); + try{result=JSON.parse(await general.owner.store_envelope_unknown(generalN,2,1,general.envelope,()=>inject(general.receipt.namespace,unchanged)));}finally{reset();}same(result.kind,'unknown');same(JSON.parse(await general.owner.retain_observation(oldValue,false)).kind,'committed');await rejects(()=>general.owner.authenticate(),'closed');await general.owner.close();let reopened=await open(general.receipt);same(JSON.parse(await reopened.query_observations(generalN,0,1)),[JSON.parse(oldValue.original())]);await reopened.close(); + passed('retaining an older obtained fact cannot clear general delivery uncertainty or authorize fresh work'); + const multipleN=218,multiple=await setupDelivery(multipleN),a=await multiple.owner.observation(multipleN,0,1,0,1,0),b=await multiple.owner.observation(multipleN,0,1,1,2,0);same((await unknownObservation(multiple,a)).kind,'unknown');same((await unknownObservation(multiple,b)).kind,'unknown');await multiple.owner.retain_observation(a,false);await rejects(()=>multiple.owner.authenticate(),'closed');await multiple.owner.retain_observation(b,false);await rejects(()=>multiple.owner.authenticate(),'closed');await multiple.owner.close();reopened=await open(multiple.receipt);same(JSON.parse(await reopened.query_observations(multipleN,0,1)).length,2);await reopened.close(); + passed('multiple unrelated uncertain target captures require explicit reopening even when each original fact is subsequently confirmed'); + return{tests}; + } + if(profile==='journal_reopen') { + const n=180,s=await setup(n),anchor=await unknownSeal(s),stable=await rows(s.receipt);let upgraded=false; + try{IDBFactory.prototype.open=function(...args){if(args[0]===s.receipt.namespace&&!upgraded){upgraded=true;const upgrade=nativeOpen.call(this,args[0],2);upgrade.onupgradeneeded=()=>upgrade.result.createObjectStore('foreign_fixture');upgrade.onsuccess=()=>upgrade.result.close();}return nativeOpen.apply(this,args);};await rejects(()=>s.owner.reconcile(s.seal,false),'recovery_required');}finally{reset();} + same(upgraded,true); + const actual=await new Promise((resolve,reject)=>{const request=indexedDB.open(s.receipt.namespace);request.onerror=reject;request.onsuccess=async()=>{const db=request.result;try{const state=await new Promise((resolve,reject)=>{const tx=db.transaction('records','readonly'),store=tx.objectStore('records');let keys,values;store.getAllKeys().onsuccess=e=>keys=e.target.result;store.getAll().onsuccess=e=>values=e.target.result;tx.oncomplete=()=>resolve({keys,values});tx.onabort=reject;});resolve({version:db.version,stores:Array.from(db.objectStoreNames),...state});}catch(error){reject(error);}finally{db.close();}};});same(actual.version,2);same(actual.stores,['foreign_fixture','records']);sameRows(actual,stable);await rejects(()=>open(s.receipt,true),'writer_active');let opened=0; + try{IDBFactory.prototype.open=function(...args){if(args[0]===s.receipt.namespace)opened++;return nativeOpen.apply(this,args);};await rejects(()=>s.owner.reconcile(s.seal,true),'unauthorized');same(opened,0);}finally{reset();} + passed('actual incompatible existing schema refuses recovery without repair, preserves protected rows and retains writer and original-proof authorization'); + // This restores only an isolated test database after verifying refusal. + // The SDK never creates, repairs, downgrades or restores the namespace. + await new Promise((resolve,reject)=>{const request=indexedDB.deleteDatabase(s.receipt.namespace);request.onsuccess=resolve;request.onerror=reject;request.onblocked=()=>reject(Error('fixture namespace deletion blocked'));}); + await new Promise((resolve,reject)=>{const request=indexedDB.open(s.receipt.namespace,1);request.onupgradeneeded=()=>request.result.createObjectStore('records');request.onerror=reject;request.onsuccess=()=>{const db=request.result,tx=db.transaction('records','readwrite'),store=tx.objectStore('records');stable.keys.forEach((key,i)=>store.put(stable.values[i],key));tx.oncomplete=()=>{db.close();resolve();};tx.onabort=()=>{db.close();reject(Error('fixture original restoration aborted'));};};}); + const restored=Array.from(await s.owner.reconcile(s.seal,false));same(restored.slice(0,32),anchor.slice(64,96));same(await s.owner.authenticate(),1);sameRows(await rows(s.receipt),stable);await s.owner.close(); + passed('cached original grant authorization permits same-owner retry after failed reopen only when the isolated original schema and bytes are restored'); + const damagedN=182,damaged=await setup(damagedN);await unknownSeal(damaged);const intact=await rows(damaged.receipt),claim=intact.keys.find(k=>kb(k)[16]===3);let db=await rawOpen(damaged.receipt);await new Promise((resolve,reject)=>{const tx=db.transaction('records','readwrite');tx.objectStore('records').delete(claim);tx.oncomplete=resolve;tx.onabort=reject;});db.close();const broken=await rows(damaged.receipt);await rejects(()=>damaged.owner.reconcile(damaged.seal,false),'recovery_required');sameRows(await rows(damaged.receipt),broken);await rejects(()=>damaged.owner.authenticate(),'closed');await rejects(()=>open(damaged.receipt,true),'writer_active'); + passed('actual missing original claim cannot become capture authority or replacement during same-owner recovery'); + db=await rawOpen(damaged.receipt);await new Promise((resolve,reject)=>{const tx=db.transaction('records','readwrite'),store=tx.objectStore('records');intact.keys.forEach((key,i)=>store.put(intact.values[i],key));tx.oncomplete=resolve;tx.onabort=reject;});db.close();await damaged.owner.reconcile(damaged.seal,false);same(await damaged.owner.authenticate(),1);sameRows(await rows(damaged.receipt),intact);await damaged.owner.close(); + passed('failed original-claim validation retains uncertainty and writer until the actual original capture can be confirmed'); + return{tests}; + } + throw Error('journal profile is not implemented yet'); + } finally {reset();} + },profile); + if(result.receipt) { + const message={kind:'recovered_query',...result.receipt,operation:result.operation}; + const worker=await page.evaluate(message=>new Promise((resolve,reject)=>{const worker=new Worker('./worker.js',{type:'module'});worker.onmessage=e=>{if(e.data.ready){worker.postMessage(message);return;}worker.terminate();resolve(e.data);};worker.onerror=error=>{worker.terminate();reject(Error(error.message));};}),message); + assert.deepEqual(worker,{captured:result.golden});result.tests.push('actual worker termination and fresh WASM preserve the exact reconciled original capture'); + await page.reload();const captured=await page.evaluate(async r=>{const{default:init,WorkspaceFixture}=await import('./fixture.js');await init();const owner=await WorkspaceFixture.open(r.receipt.n,new Uint8Array(r.receipt.fingerprint),new Uint8Array(r.receipt.selection),new Uint8Array(r.receipt.proof));const captured=Array.from(await owner.captured(r.operation,0));await owner.close();return captured;},result); + assert.deepEqual(captured,result.golden);result.tests.push('actual page and WASM restart preserve original reconciled transaction, representation digest and unknown observation time');delete result.receipt;delete result.golden; + } + assert(result.tests.length>0);return result; +} diff --git a/crates/storage_indexeddb/tests/browser/run.mjs b/crates/storage_indexeddb/tests/browser/run.mjs @@ -5,6 +5,7 @@ import { readFile } from 'node:fs/promises'; import { resolve, sep } from 'node:path'; import { runDelivery } from './delivery.mjs'; import { runObservations } from './observations.mjs'; +import { runJournal } from './journal.mjs'; // Caller supplies its installed Playwright package and an external generated // WASM directory. No dependency installation or generated bytes live here. @@ -12,7 +13,7 @@ const [moduleRoot, packageDir, engine = 'chromium', legacyPackageDir, profile = assert(moduleRoot && packageDir && legacyPackageDir, 'usage: node run.mjs PLAYWRIGHT_PACKAGE WASM_DIRECTORY ENGINE V1_WASM_DIRECTORY'); const playwright = createRequire(resolve(moduleRoot, 'package.json'))('playwright'); assert(['chromium','firefox','webkit'].includes(engine)); -assert(['base','delivery','delivery_limits','delivery_faults','delivery_corruption','observations','observation_faults','observation_corruption'].includes(profile)); +assert(['base','delivery','delivery_limits','delivery_faults','delivery_corruption','observations','observation_faults','observation_corruption','journal','journal_observations','journal_reopen'].includes(profile)); const root = resolve(packageDir); const legacyRoot = resolve(legacyPackageDir); const server = createServer(async (req,res) => { @@ -37,6 +38,7 @@ const server = createServer(async (req,res) => { if(event.data?.kind==='installation_query'){const m=event.data;const owner=await WorkspaceFixture.open(m.n,new Uint8Array(m.fingerprint),new Uint8Array(m.selection),new Uint8Array(m.proof));const state=JSON.parse(await owner.snapshot(200));await owner.close();self.postMessage({state});return;} if(event.data?.kind==='delivery_query'){const m=event.data;const owner=await WorkspaceFixture.open(m.n,new Uint8Array(m.fingerprint),new Uint8Array(m.selection),new Uint8Array(m.proof));const report=JSON.parse(await owner.query_envelope(m.operation,m.index,m.id));await owner.close();self.postMessage({report});return;} if(event.data?.kind==='observation_query'){const m=event.data;const owner=await WorkspaceFixture.open(m.n,new Uint8Array(m.fingerprint),new Uint8Array(m.selection),new Uint8Array(m.proof));const reports=JSON.parse(await owner.query_observations(m.operation,m.index,m.id));await owner.close();self.postMessage({reports});return;} + if(event.data?.kind==='recovered_query'){const m=event.data;const owner=await WorkspaceFixture.open(m.n,new Uint8Array(m.fingerprint),new Uint8Array(m.selection),new Uint8Array(m.proof));const captured=Array.from(await owner.captured(m.operation,0));await owner.close();self.postMessage({captured});return;} if(event.data?.kind==='persistent_create'){const provider=await Persistent.create(90);const fingerprint=provider.fingerprint();const encoded=await provider.protect(new Uint8Array([90,91,92]));await provider.close();self.postMessage({fingerprint:Array.from(fingerprint),encoded:Array.from(encoded)});return;} if(event.data?.kind==='persistent_open'){const provider=await Persistent.open(90,new Uint8Array(event.data.fingerprint));const plain=await provider.reveal(new Uint8Array(event.data.encoded));await provider.close();self.postMessage({plain:Array.from(plain)});return;} await protected_round_trip(79);const db=await Fixture.open(77,true);await db.write(1,undefined,new Uint8Array([77]));await db.close();const again=await Fixture.open(77,false);const value=await again.read(1);await again.close();self.postMessage({value:Array.from(value)});}catch(error){self.postMessage({error:String(error)});}}; @@ -716,7 +718,7 @@ try { const issuanceRestart=await page.evaluate(async r=>{const {default:init,WorkspaceFixture}=await import('./fixture.js');await init();const owner=await WorkspaceFixture.open(r.n,new Uint8Array(r.fingerprint),new Uint8Array(r.selection),new Uint8Array(r.proof));const claim=Array.from(await owner.attempt(190,0)),seal=Array.from(await owner.captured(190,0));await owner.close();return {claim,seal};},result.issuance);assert.deepEqual(issuanceRestart,{claim:result.issuance.originalClaim,seal:result.issuance.originalSeal});result.tests.push('original claim and captured signature survive actual page and WASM restart');delete result.issuance; console.log(JSON.stringify({engine,version:browser.version(),...result})); } else { - const result=await(profile.startsWith('observation')?runObservations(page,profile):runDelivery(page,profile)); + const result=await(profile.startsWith('journal')?runJournal(page,profile):profile.startsWith('observation')?runObservations(page,profile):runDelivery(page,profile)); console.log(JSON.stringify({engine,version:browser.version(),profile,...result})); } } finally { diff --git a/crates/storage_indexeddb/tests/browser/src/workspace.rs b/crates/storage_indexeddb/tests/browser/src/workspace.rs @@ -81,6 +81,11 @@ pub struct WorkspaceFixture { proof: AttachmentProof, clock: Rc<Clock>, } +impl WorkspaceFixture { + fn journal(&self) -> &dyn radroots_storage::command::OperationJournal { + &self.owner + } +} #[wasm_bindgen] impl WorkspaceFixture { pub async fn admit_read_unknown( @@ -92,7 +97,7 @@ impl WorkspaceFixture { let digest = request.command().digest(); hook.call0(&JsValue::NULL)?; match self - .owner + .journal() .admit_command_and_hold(request, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -113,7 +118,7 @@ impl WorkspaceFixture { let request = self.request(n, false).await?; let digest = request.command().digest(); match self - .owner + .journal() .admit_command_and_hold(request, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -133,7 +138,7 @@ impl WorkspaceFixture { pub async fn admit(&self, n: u8, changed: bool) -> Result<Vec<u8>, JsValue> { let request = self.request(n, changed).await?; match self - .owner + .journal() .admit_command_and_hold(request, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -149,7 +154,7 @@ impl WorkspaceFixture { .await .map_err(fail)?; let result = self - .owner + .journal() .operation( binding, OperationId::from_bytes([n; 32]), @@ -163,7 +168,7 @@ impl WorkspaceFixture { pub async fn admit_expiring(&self, n: u8) -> Result<(), JsValue> { let request = self.request(n, false).await?; self.clock.after.set(Some(1500)); - self.owner + self.journal() .admit_command_and_hold(request, copied(&self.proof)) .await .map(|_| ()) @@ -172,7 +177,7 @@ impl WorkspaceFixture { pub async fn abandon_admission(&self, n: u8) -> Result<(), JsValue> { let request = self.request(n, false).await?; if self - .owner + .journal() .admit_command_and_hold(request, copied(&self.proof)) .now_or_never() .is_some() diff --git a/crates/storage_indexeddb/tests/browser/src/workspace/delivery.rs b/crates/storage_indexeddb/tests/browser/src/workspace/delivery.rs @@ -135,7 +135,7 @@ impl WorkspaceFixture { pub async fn envelope(&self, n: u8, index: u8, mode: u8) -> Result<ObtainedEnvelope, JsValue> { let request = self.request(n, false).await?; let snapshot = self - .owner + .journal() .operation_snapshot( request.binding().clone(), OperationId::from_bytes([n; 32]), @@ -160,7 +160,7 @@ impl WorkspaceFixture { .copied() .ok_or(JsValue::from_str("missing_work"))?; let retained = self - .owner + .journal() .obtained_evidence( ClaimAttemptRequest::new( request.binding().clone(), @@ -228,7 +228,7 @@ impl WorkspaceFixture { 3 => Some(1800), _ => None, }); - self.owner + self.journal() .prepare_delivery_attempt( request, copied(&self.proof), @@ -252,7 +252,7 @@ impl WorkspaceFixture { ) -> Result<String, JsValue> { let request = self.delivery_request(n, id, selection, 0, envelope).await?; hook.call0(&JsValue::NULL)?; - self.owner + self.journal() .prepare_delivery_attempt(request, copied(&self.proof), Some(&envelope.candidate)) .await .map(|value| outcome(value).to_string()) @@ -267,7 +267,7 @@ impl WorkspaceFixture { ) -> Result<(), JsValue> { let request = self.delivery_request(n, id, selection, 0, envelope).await?; if self - .owner + .journal() .prepare_delivery_attempt(request, copied(&self.proof), Some(&envelope.candidate)) .now_or_never() .is_some() @@ -284,7 +284,7 @@ impl WorkspaceFixture { let recipient: PublicKey = *recipients .get(index as usize) .ok_or(JsValue::from_str("invalid_recipient"))?; - self.owner + self.journal() .delivery_attempt( request.binding().clone(), OperationId::from_bytes([n; 32]), diff --git a/crates/storage_indexeddb/tests/browser/src/workspace/installation.rs b/crates/storage_indexeddb/tests/browser/src/workspace/installation.rs @@ -26,7 +26,7 @@ impl WorkspaceFixture { async fn installation_request(&self, n: u8) -> Result<InstallationRequest, JsValue> { let request = self.request(n, false).await?; let bound = self - .owner + .journal() .signing_plan( request.binding().clone(), request.command().context().operation_id(), @@ -47,7 +47,7 @@ impl WorkspaceFixture { let request = self.installation_request(n).await?; self.clock.after.set(after); match self - .owner + .journal() .install_transition_and_outbox(request, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -74,7 +74,7 @@ impl WorkspaceFixture { let digest = request.command_digest(); hook.call0(&JsValue::NULL)?; match self - .owner + .journal() .install_transition_and_outbox(request, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -93,7 +93,7 @@ impl WorkspaceFixture { pub async fn abandon_install(&self, n: u8) -> Result<(), JsValue> { let request = self.installation_request(n).await?; if self - .owner + .journal() .install_transition_and_outbox(request, copied(&self.proof)) .now_or_never() .is_some() @@ -104,7 +104,7 @@ impl WorkspaceFixture { } pub async fn snapshot(&self, n: u8) -> Result<String, JsValue> { let request = self.request(n, false).await?; - self.owner + self.journal() .operation_snapshot( request.binding().clone(), request.command().context().operation_id(), diff --git a/crates/storage_indexeddb/tests/browser/src/workspace/issuance.rs b/crates/storage_indexeddb/tests/browser/src/workspace/issuance.rs @@ -91,7 +91,7 @@ impl WorkspaceFixture { async fn claim_request(&self, n: u8, index: u8) -> Result<ClaimAttemptRequest, JsValue> { let request = self.request(n, false).await?; let bound = self - .owner + .journal() .signing_plan( request.binding().clone(), request.command().context().operation_id(), @@ -130,7 +130,7 @@ impl WorkspaceFixture { *bound.plan().digest(), original.attempt.seal().recipient(), ); - self.owner + self.journal() .obtained_evidence(request, copied(&self.proof)) .await .map(|value| value.map(|v| receipt(v.receipt())).unwrap_or_default()) @@ -139,7 +139,7 @@ impl WorkspaceFixture { pub async fn claim(&self, n: u8, index: u8) -> Result<Vec<u8>, JsValue> { let request = self.claim_request(n, index).await?; match self - .owner + .journal() .claim_attempt(request, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -168,7 +168,7 @@ impl WorkspaceFixture { let digest = request.command_digest(); hook.call0(&JsValue::NULL)?; match self - .owner + .journal() .claim_attempt(request, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -186,7 +186,7 @@ impl WorkspaceFixture { } pub async fn attempt(&self, n: u8, index: u8) -> Result<Vec<u8>, JsValue> { let request = self.claim_request(n, index).await?; - self.owner + self.journal() .signing_attempt(request, copied(&self.proof)) .await .map(|value| value.as_ref().map(summary).unwrap_or_default()) @@ -200,7 +200,7 @@ impl WorkspaceFixture { ) -> Result<ObtainedSeal, JsValue> { let request = self.claim_request(n, index).await?; let attempt = match self - .owner + .journal() .claim_attempt(request, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -226,7 +226,7 @@ impl WorkspaceFixture { pub async fn capture_alternate(&self, original: &ObtainedSeal) -> Result<(), JsValue> { let alternate = signed_output(&original.attempt, None)?; assert_ne!(alternate.raw_json(), original.value.raw_json()); - self.owner + self.journal() .capture_evidence(self.input.clone(), &self.proof, &alternate) .await .map(|_| ()) @@ -240,7 +240,7 @@ impl WorkspaceFixture { ) .unwrap(); match self - .owner + .journal() .capture_evidence(self.input.clone(), &self.proof, &evidence) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -251,7 +251,7 @@ impl WorkspaceFixture { } pub async fn capture(&self, original: &ObtainedSeal) -> Result<Vec<u8>, JsValue> { match self - .owner + .journal() .capture_evidence(self.input.clone(), &self.proof, &original.value) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -260,9 +260,40 @@ impl WorkspaceFixture { EvidenceCaptureOutcome::Unknown(_) => Err(JsValue::from_str("commit_unknown")), } } + pub async fn reconcile( + &self, + original: &ObtainedSeal, + wrong_proof: bool, + ) -> Result<Vec<u8>, JsValue> { + let proof = if wrong_proof { + radroots_storage::workspace::AttachmentProof::from_protected_input(&[0x31; 32]).unwrap() + } else { + copied(&self.proof) + }; + match self + .journal() + .reconcile_unknown(self.input.clone(), &proof, &original.value) + .await + .map_err(|e| JsValue::from_str(e.code()))? + { + EvidenceCaptureOutcome::Committed(value) => Ok(receipt(value)), + EvidenceCaptureOutcome::Unknown(_) => Err(JsValue::from_str("commit_unknown")), + } + } + pub fn abandon_reconcile(&self, original: &ObtainedSeal) -> Result<(), JsValue> { + if self + .journal() + .reconcile_unknown(self.input.clone(), &self.proof, &original.value) + .now_or_never() + .is_some() + { + return Err(JsValue::from_str("unexpected_immediate_recovery")); + } + Ok(()) + } pub async fn capture_unknown(&self, original: &ObtainedSeal) -> Result<Vec<u8>, JsValue> { match self - .owner + .journal() .capture_evidence(self.input.clone(), &self.proof, &original.value) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -280,7 +311,7 @@ impl WorkspaceFixture { } pub async fn captured(&self, n: u8, index: u8) -> Result<Vec<u8>, JsValue> { let request = self.claim_request(n, index).await?; - self.owner + self.journal() .obtained_evidence(request, copied(&self.proof)) .await .map(|value| { @@ -292,7 +323,7 @@ impl WorkspaceFixture { } pub fn abandon_capture(&self, original: &ObtainedSeal) -> Result<(), JsValue> { if self - .owner + .journal() .capture_evidence(self.input.clone(), &self.proof, &original.value) .now_or_never() .is_some() diff --git a/crates/storage_indexeddb/tests/browser/src/workspace/observations.rs b/crates/storage_indexeddb/tests/browser/src/workspace/observations.rs @@ -57,7 +57,7 @@ impl WorkspaceFixture { recipients.sort_unstable(); recipients.dedup(); let attempt = self - .owner + .journal() .delivery_attempt( request.binding().clone(), OperationId::from_bytes([n; 32]), @@ -107,7 +107,7 @@ impl WorkspaceFixture { } else { copied(&self.proof) }; - self.owner + self.journal() .record_delivery_observation(original.binding.clone(), proof, original.value.clone()) .await .map(result) @@ -119,7 +119,7 @@ impl WorkspaceFixture { hook: js_sys::Function, ) -> Result<String, JsValue> { hook.call0(&JsValue::NULL)?; - self.owner + self.journal() .record_delivery_observation( original.binding.clone(), copied(&self.proof), @@ -131,7 +131,7 @@ impl WorkspaceFixture { } pub fn abandon_observation(&self, original: &ObtainedObservation) -> Result<(), JsValue> { if self - .owner + .journal() .record_delivery_observation( original.binding.clone(), copied(&self.proof), @@ -149,7 +149,7 @@ impl WorkspaceFixture { let mut recipients = vec![self.input.participant(), request.command().peer()]; recipients.sort_unstable(); recipients.dedup(); - self.owner + self.journal() .delivery_observations( request.binding().clone(), OperationId::from_bytes([n; 32]), @@ -168,7 +168,7 @@ impl WorkspaceFixture { original: &ObtainedObservation, ) -> Result<String, JsValue> { let evidence = original.value.work().evidence(); - self.owner + self.journal() .delivery_observations( original.binding.clone(), evidence.operation_id(), diff --git a/crates/storage_indexeddb/tests/browser/src/workspace/plans.rs b/crates/storage_indexeddb/tests/browser/src/workspace/plans.rs @@ -174,7 +174,7 @@ impl WorkspaceFixture { let plan = ChatSigningPlan::parse(request.command(), &wire).unwrap(); hook.call0(&JsValue::NULL)?; match self - .owner + .journal() .bind_signing_intents(request.binding().clone(), plan, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))? @@ -204,7 +204,7 @@ impl WorkspaceFixture { .await .map_err(super::fail)?; let result = self - .owner + .journal() .bind_signing_intents(foreign, plan, copied(&self.proof)) .await; sibling.close().await?; @@ -226,7 +226,7 @@ impl WorkspaceFixture { let request = self.request(n, false).await?; let plan = ChatSigningPlan::parse(request.command(), &wire).unwrap(); if self - .owner + .journal() .bind_signing_intents(request.binding().clone(), plan, copied(&self.proof)) .now_or_never() .is_some() @@ -237,7 +237,7 @@ impl WorkspaceFixture { } pub async fn plan_query(&self, n: u8) -> Result<Vec<u8>, JsValue> { let request = self.request(n, false).await?; - self.owner + self.journal() .signing_plan( request.binding().clone(), request.command().context().operation_id(), @@ -264,7 +264,7 @@ impl WorkspaceFixture { self.clock.after.set(Some(2000)); } let outcome = self - .owner + .journal() .bind_signing_intents(request.binding().clone(), plan, copied(&self.proof)) .await .map_err(|e| JsValue::from_str(e.code()))?;