commit 4c0718774d6dbaf8894a6b161cc69faa320ba8d5 parent 4323d26a431503ca918d009cfc7f85d50901efa2 Author: triesap <tyson@radroots.org> Date: Sun, 25 Oct 2026 18:51:58 +0000 storage: include local signed records in causal history - Authenticate local records through original signed evidence and ancestry. - Require independent inventory minima on history and request queries. - Refuse new installation before its original bound-plan time. - Verify native and Linux rollback, scope, deduplication and recovery. Diffstat:
23 files changed, 575 insertions(+), 40 deletions(-)
diff --git a/contracts/api_baselines/radroots_storage_sqlite.txt b/contracts/api_baselines/radroots_storage_sqlite.txt @@ -454,8 +454,8 @@ pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::stock_listing_ pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::stock_listing_source(&self, radroots_storage::workspace::WorkspaceBinding, radroots_storage::workspace::seller_stock::source::StockListingCheckpointRef, radroots_domain::listing::reference::ListingRevision, &radroots_storage::workspace::AttachmentProof) -> core::result::Result<core::option::Option<radroots_storage_sqlite::workspace::StockListingSnapshot>, radroots_storage::command::OperationError> impl radroots_storage_sqlite::workspace::NativeWorkspace pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::retain_stock_source(&self, radroots_storage::workspace::WorkspaceBinding, radroots_storage::workspace::seller_stock::source::StockSourceCheckpointRef, &radroots_storage_sqlite::workspace::StockSourceCapture, &radroots_storage::workspace::AttachmentProof) -> core::result::Result<radroots_storage_sqlite::workspace::StockSourceOutcome, radroots_storage::command::OperationError> -pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::stock_order_history(&self, radroots_storage::workspace::WorkspaceBinding, radroots_storage::workspace::seller_stock::source::StockSourceCheckpointRef, radroots_storage::workspace::seller_stock::source::StockListingCheckpointRef, radroots_domain::commerce::causal::CausalScope, &radroots_storage::workspace::AttachmentProof) -> core::result::Result<radroots_storage_sqlite::workspace::StockHistorySnapshot, radroots_storage::command::OperationError> -pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::stock_order_request(&self, radroots_storage::workspace::WorkspaceBinding, radroots_storage::workspace::seller_stock::source::StockSourceCheckpointRef, radroots_storage::workspace::seller_stock::source::StockListingCheckpointRef, radroots_domain::identifier::RecordId, &radroots_storage::workspace::AttachmentProof) -> core::result::Result<radroots_storage_sqlite::workspace::StockRequestSnapshot, radroots_storage::command::OperationError> +pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::stock_order_history(&self, radroots_storage::workspace::WorkspaceBinding, radroots_storage::inventory::InventoryCheckpointRef, radroots_storage::workspace::seller_stock::source::StockSourceCheckpointRef, radroots_storage::workspace::seller_stock::source::StockListingCheckpointRef, radroots_domain::commerce::causal::CausalScope, &radroots_storage::workspace::AttachmentProof) -> core::result::Result<radroots_storage_sqlite::workspace::StockHistorySnapshot, radroots_storage::command::OperationError> +pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::stock_order_request(&self, radroots_storage::workspace::WorkspaceBinding, radroots_storage::inventory::InventoryCheckpointRef, radroots_storage::workspace::seller_stock::source::StockSourceCheckpointRef, radroots_storage::workspace::seller_stock::source::StockListingCheckpointRef, radroots_domain::identifier::RecordId, &radroots_storage::workspace::AttachmentProof) -> core::result::Result<radroots_storage_sqlite::workspace::StockRequestSnapshot, radroots_storage::command::OperationError> pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::stock_source(&self, radroots_storage::workspace::WorkspaceBinding, radroots_storage::workspace::seller_stock::source::StockSourceCheckpointRef, radroots_domain::identifier::EnvelopeEventId, &radroots_storage::workspace::AttachmentProof) -> core::result::Result<core::option::Option<radroots_storage_sqlite::workspace::StockSourceSnapshot>, radroots_storage::command::OperationError> impl radroots_storage_sqlite::workspace::NativeWorkspace pub async fn radroots_storage_sqlite::workspace::NativeWorkspace::stock_operation_snapshot(&self, radroots_storage_sqlite::workspace::StockSnapshotRequest, &radroots_storage::workspace::AttachmentProof) -> core::result::Result<radroots_storage_sqlite::workspace::StockOperationSnapshot, radroots_storage::command::OperationError> @@ -612,6 +612,7 @@ pub struct radroots_storage_sqlite::workspace::StockHistorySnapshot impl radroots_storage_sqlite::workspace::StockHistorySnapshot pub const fn radroots_storage_sqlite::workspace::StockHistorySnapshot::analysis(&self) -> &radroots_domain::commerce::causal::CausalAnalysis pub fn radroots_storage_sqlite::workspace::StockHistorySnapshot::checkpoint(&self) -> core::option::Option<&radroots_domain::context::CheckpointRef> +pub const fn radroots_storage_sqlite::workspace::StockHistorySnapshot::inventory_checkpoint(&self) -> radroots_storage::inventory::InventoryCheckpointRef pub const fn radroots_storage_sqlite::workspace::StockHistorySnapshot::known_records(&self) -> usize pub const fn radroots_storage_sqlite::workspace::StockHistorySnapshot::listing_checkpoint(&self) -> radroots_storage::workspace::seller_stock::source::StockListingCheckpointRef pub const fn radroots_storage_sqlite::workspace::StockHistorySnapshot::observed_at(&self) -> radroots_domain::context::UnixSeconds @@ -686,6 +687,7 @@ pub struct radroots_storage_sqlite::workspace::StockRequestSnapshot impl radroots_storage_sqlite::workspace::StockRequestSnapshot pub const fn radroots_storage_sqlite::workspace::StockRequestSnapshot::checkpoint(&self) -> &radroots_domain::context::CheckpointRef pub const fn radroots_storage_sqlite::workspace::StockRequestSnapshot::expires_at(&self) -> radroots_domain::context::UnixSeconds +pub const fn radroots_storage_sqlite::workspace::StockRequestSnapshot::inventory_checkpoint(&self) -> radroots_storage::inventory::InventoryCheckpointRef pub const fn radroots_storage_sqlite::workspace::StockRequestSnapshot::listing_checkpoint(&self) -> radroots_storage::workspace::seller_stock::source::StockListingCheckpointRef pub const fn radroots_storage_sqlite::workspace::StockRequestSnapshot::observed_at(&self) -> radroots_domain::context::UnixSeconds pub const fn radroots_storage_sqlite::workspace::StockRequestSnapshot::quote(&self) -> core::option::Option<radroots_domain::identifier::RecordId> diff --git a/contracts/architecture/decisions/shared_sdk_refactor.v1.json b/contracts/architecture/decisions/shared_sdk_refactor.v1.json @@ -202,6 +202,10 @@ "source_profile_implies_actionability": false, "causal_history_current_administrator_required": true, "causal_history_complete_local_scope_required": true, + "causal_history_includes_actual_local_signed_records": true, + "causal_history_inventory_minimum_required": true, + "causal_history_logical_record_deduplication_required": true, + "causal_history_implies_installation": false, "causal_history_uninterpreted_policy": "conservative_authenticated_participant_pair_barrier", "causal_history_transaction_witnesses_required": true, "causal_history_implies_business_permission": false, @@ -251,6 +255,7 @@ "original_order_fence_immutable": true, "exact_original_hold_quantities_required": true, "current_exact_recovery_consent_required": true, + "fresh_time_not_before_original_bound_plan": true, "atomic_pool_agreement_and_work_required": true, "recipient_work_count": 2, "unknown_commit_fences_owner": true, diff --git a/crates/storage_sqlite/README.md b/crates/storage_sqlite/README.md @@ -395,6 +395,18 @@ The ordinary facade and complete commerce behavior remain in implementation. ## Initial native acceptance and signing-plan retention +`stock_order_history` and `stock_order_request` require independently retained +inventory, private-source and public-listing checkpoint minima. Their snapshots +return all three checkpoints. Local peer or self records enter causal coverage +only after original signed output is actually retained and independently +verified. They share the incoming-record graph and deduplicate by logical record +identity across recipients and encodings. An intent or unknown dispatch adds no +record. An actual local signature advances causal history before installation; +it does not itself install an agreement or prove delivery. Full protected +inventory ancestry and final transaction witnesses guard this local coverage, +including refusal of an acknowledged local-tail rollback when incoming-source +checkpoints have not changed. + `prepare_stock_acceptance` retains the exact authorized command, original request/quote/Terms and causal observation. Current issued consent is required. Complete automatic or explicit allocation, preparatory pool holds and the order @@ -452,3 +464,5 @@ uncertain commit fences the owner until drain/reopen. `stock_operation_snapshot` reports installation separately from signing and delivery facts. This initial primitive does not implement amendments, handovers, releases, deficits, browser stock or complete ordinary caller orchestration. +Fresh installation also refuses an observed time before its original bound +plan, before any write; recovery of an existing installation remains historical. diff --git a/crates/storage_sqlite/src/workspace/stock/inventory/acceptance.rs b/crates/storage_sqlite/src/workspace/stock/inventory/acceptance.rs @@ -421,7 +421,11 @@ pub(in crate::workspace) async fn admit( turn.connection, turn.selected, turn.crypto, - &access.authority, + source::history::InventoryRead { + binding: &access.current, + authority: &access.authority, + minimum: request.minimum, + }, command.input().request(), request.listings, access.current.observed_at(), diff --git a/crates/storage_sqlite/src/workspace/stock/inventory/acceptance/codec.rs b/crates/storage_sqlite/src/workspace/stock/inventory/acceptance/codec.rs @@ -84,6 +84,7 @@ impl Retained { } pub fn into_history(self) -> ledger::HistoryEntry { ledger::HistoryEntry { + local_record: None, installation: None, signing: None, header: self.frame.header, diff --git a/crates/storage_sqlite/src/workspace/stock/inventory/checkpoint.rs b/crates/storage_sqlite/src/workspace/stock/inventory/checkpoint.rs @@ -342,6 +342,27 @@ pub(in crate::workspace::stock) async fn authenticate_minimum( authority: &Authority, minimum: radroots_storage::inventory::InventoryCheckpointRef, ) -> Result<MinimumProof, OperationError> { + Box::pin(authenticate_minimum_with_local( + connection, input, crypto, binding, authority, minimum, None, + )) + .await +} +pub(in crate::workspace::stock) struct LocalSources<'a> { + pub scope: radroots_domain::causal::CausalScope, + pub records: &'a mut std::collections::BTreeMap< + radroots_domain::RecordId, + radroots_protocol::commerce::DecodedRecord, + >, +} +pub(in crate::workspace::stock) async fn authenticate_minimum_with_local( + connection: &mut SqliteConnection, + input: &AttachmentInput, + crypto: &WorkspaceCrypto, + binding: &WorkspaceBinding, + authority: &Authority, + minimum: radroots_storage::inventory::InventoryCheckpointRef, + mut local: Option<LocalSources<'_>>, +) -> Result<MinimumProof, OperationError> { let current = authority .inventory .ok_or(OperationError::UnsupportedOperation)?; @@ -351,7 +372,11 @@ pub(in crate::workspace::stock) async fn authenticate_minimum( if minimum.revision().get() > current.revision.get() { return Err(WorkspaceError::StaleCheckpoint.into()); } - let lower = minimum.revision().get().max(1); + let lower = if local.is_some() { + 1 + } else { + minimum.revision().get().max(1) + }; let upper = current.revision.get(); let multipart = matches!(authority.catalog, 7..=12); let mut hash = history_hash(multipart); @@ -364,7 +389,7 @@ pub(in crate::workspace::stock) async fn authenticate_minimum( .map_err(|_| OperationError::RecoveryRequired)?, ); if multipart { - let retained = Box::pin(super::super::ledger::history( + let mut retained = Box::pin(super::super::ledger::history( connection, input, crypto, binding, authority, operation, )) .await? @@ -377,6 +402,22 @@ pub(in crate::workspace::stock) async fn authenticate_minimum( return Err(WorkspaceError::StaleCheckpoint.into()); } retained.hash(&mut hash)?; + if let Some(local) = &mut local + && let Some(record) = retained.local_record.take() + && local.scope.contains(record.content()) + { + let id = record.record_id(); + if let Some(known) = local.records.get(&id) { + if known.content() != record.content() { + return Err(OperationError::RecoveryRequired); + } + } else { + local.records.insert(id, *record); + if local.records.len() > radroots_domain::causal::MAX_CAUSAL_RECORDS { + return Err(WorkspaceError::Capacity.into()); + } + } + } expected = retained.header.previous; continue; } @@ -395,7 +436,7 @@ pub(in crate::workspace::stock) async fn authenticate_minimum( hash_retained(&mut hash, revision, binding, operation, &retained)?; expected = retained.previous_head; } - if minimum.revision().get() == 0 && expected.is_some() { + if (minimum.revision().get() == 0 || local.is_some()) && expected.is_some() { return Err(WorkspaceError::StaleCheckpoint.into()); } Ok(MinimumProof { diff --git a/crates/storage_sqlite/src/workspace/stock/inventory/installation.rs b/crates/storage_sqlite/src/workspace/stock/inventory/installation.rs @@ -231,6 +231,9 @@ pub(in crate::workspace) async fn install( return Ok(StockInstallationOutcome::Installed(Box::new(old.receipt))); } let plan = auth.plan.as_ref().ok_or(OperationError::StaleState)?; + if auth.access.current.observed_at() < plan.bound.bound_at() { + return Err(WorkspaceError::Unavailable.into()); + } let recipients = *plan.bound.preparation().rumor().recipients(); let mut selections = Vec::with_capacity(2); let mut work = Vec::with_capacity(2); diff --git a/crates/storage_sqlite/src/workspace/stock/inventory/installation/codec.rs b/crates/storage_sqlite/src/workspace/stock/inventory/installation/codec.rs @@ -292,6 +292,7 @@ impl Retained { } pub(in crate::workspace::stock) fn into_history(self) -> ledger::HistoryEntry { ledger::HistoryEntry { + local_record: None, header: self.frame.header, protected: self.frame.protected, parts_witness: self.frame.parts_witness, diff --git a/crates/storage_sqlite/src/workspace/stock/issuance/claim/codec.rs b/crates/storage_sqlite/src/workspace/stock/issuance/claim/codec.rs @@ -142,6 +142,7 @@ impl Retained { } pub(in crate::workspace::stock) fn into_history(self) -> ledger::HistoryEntry { ledger::HistoryEntry { + local_record: None, installation: None, header: self.frame.header, protected: self.frame.protected, diff --git a/crates/storage_sqlite/src/workspace/stock/issuance/evidence/codec.rs b/crates/storage_sqlite/src/workspace/stock/issuance/evidence/codec.rs @@ -63,6 +63,7 @@ pub(in crate::workspace::stock) struct Retained { pub frame: ledger::Retained, pub value: StockCapturedEvidence, projection: Projection, + local_record: Box<radroots_protocol::commerce::DecodedRecord>, } pub(in crate::workspace::stock) async fn read_entry( connection: &mut SqliteConnection, @@ -135,6 +136,15 @@ pub(in crate::workspace::stock) async fn read_entry( return Err(OperationError::RecoveryRequired); } let digest = Sha256::digest(raw.as_bytes()).into(); + let rumor = original.report.bound_plan().preparation().rumor(); + let logical = + radroots_protocol::private_rumor::DecodedRumor::decode(rumor.protected_wire().as_bytes()) + .map_err(|_| OperationError::RecoveryRequired)?; + let local_record = radroots_protocol::commerce::decode(logical.protected_content().as_bytes()) + .map_err(|_| OperationError::RecoveryRequired)?; + if local_record.record_id() != rumor.record_id() || logical.event_id() != rumor.event_id() { + return Err(OperationError::RecoveryRequired); + } let projection = Projection { operation: original.report.bound_plan().plan().operation_id(), recipient: original.report.recipient(), @@ -160,6 +170,7 @@ pub(in crate::workspace::stock) async fn read_entry( frame, value, projection, + local_record: Box::new(local_record), }; retained.confirm(connection).await?; Ok(Some(retained)) @@ -208,6 +219,7 @@ impl Retained { mapping: None, movements: vec![], signing: Some(self.projection), + local_record: Some(self.local_record), } } } diff --git a/crates/storage_sqlite/src/workspace/stock/ledger.rs b/crates/storage_sqlite/src/workspace/stock/ledger.rs @@ -443,6 +443,8 @@ pub(super) struct HistoryEntry { pub movements: Vec<MovementWitness>, pub signing: Option<super::issuance::Projection>, pub installation: Option<super::inventory::installation::Projection>, + /// Derived only by the independently verified obtained-evidence decoder. + pub local_record: Option<Box<radroots_protocol::commerce::DecodedRecord>>, } pub(super) async fn history( connection: &mut SqliteConnection, @@ -479,6 +481,7 @@ pub(super) async fn history( _ => return Err(OperationError::RecoveryRequired), }; Ok(Some(HistoryEntry { + local_record: None, installation: None, signing: None, header, @@ -511,6 +514,7 @@ pub(super) async fn history( return Err(OperationError::RecoveryRequired); } Ok(Some(HistoryEntry { + local_record: None, installation: None, signing: None, header: retained.frame.header, @@ -631,6 +635,9 @@ impl HistoryEntry { } (_, None) => {} } + if (header.family == Family::SigningEvidence) != self.local_record.is_some() { + return Err(OperationError::RecoveryRequired); + } if self.movements.len() > 64 || self .movements diff --git a/crates/storage_sqlite/src/workspace/stock/public_source/acceptance_tests.rs b/crates/storage_sqlite/src/workspace/stock/public_source/acceptance_tests.rs @@ -65,10 +65,11 @@ async fn seed(r: &Rig, amount: &str) { physical(r, serde_json::json!({"type":"stock.map_option","context":context(r,82),"input":{"listing":line.source().coordinate(),"option_id":line.option_id(),"pool_id":pool(80),"expected_mapping_version":"0","per_sale_unit":{"amount":"1","unit":"each"}}})).await; } async fn inspect(r: &Rig) -> StockRequestSnapshot { - let (private, public) = minima(r).await; + let (private, public, _inventory) = minima(r).await; r.store .stock_order_request( r.binding.clone(), + _inventory, private, public, identity("request"), @@ -108,10 +109,11 @@ async fn inspect_named(r: &Rig, name: &str) -> StockRequestSnapshot { .unwrap() .parse() .unwrap(); - let (private, public) = minima(r).await; + let (private, public, _inventory) = minima(r).await; r.store .stock_order_request( r.binding.clone(), + _inventory, private, public, selected, @@ -144,7 +146,7 @@ async fn consent(r: &Rig, command: &CapturedOrderAcceptance) { )); } async fn request(r: &Rig, command: &CapturedOrderAcceptance) -> StockAcceptanceRequest { - let (private, public) = minima(r).await; + let (private, public, _inventory) = minima(r).await; StockAcceptanceRequest::capture( r.binding.clone(), inventory_minimum(r).await, @@ -350,7 +352,7 @@ async fn actual_commit_failure_returns_original_identity_and_requires_drain_befo let command = command(&r, 90, true).await; consent(&r, &command).await; let before = inventory_minimum(&r).await; - let (private, public) = minima(&r).await; + let (private, public, _inventory) = minima(&r).await; let mut raw = database(&r).await; sqlx::raw_sql("CREATE TABLE deferred_fault(value INTEGER REFERENCES stock_authority(singleton) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER fault AFTER INSERT ON stock_orders BEGIN INSERT INTO deferred_fault VALUES(2); END").execute(&mut raw).await.unwrap(); let StockAcceptanceOutcome::Unknown(attempt) = r @@ -681,7 +683,7 @@ async fn current_recovery_only_consent_recovers_original_after_deadlines_without .unwrap(), StockConsentOutcome::Committed(_) )); - let (private, public) = minima(&r).await; + let (private, public, _inventory) = minima(&r).await; let request = StockAcceptanceRequest::capture( binding, inventory_minimum(&r).await, diff --git a/crates/storage_sqlite/src/workspace/stock/public_source/history_tests.rs b/crates/storage_sqlite/src/workspace/stock/public_source/history_tests.rs @@ -74,7 +74,7 @@ async fn retain(r: &Rig, name: &str) { StockSourceProfile::Known }; assert_eq!(capture.profile(), expected, "{name}"); - let (minimum, _) = minima(r).await; + let (minimum, _, _) = minima(r).await; assert!(matches!( r.store .retain_stock_source(r.binding.clone(), minimum, &capture, r.enrollment.proof()) @@ -83,7 +83,13 @@ async fn retain(r: &Rig, name: &str) { StockSourceOutcome::Committed(_) )); } -async fn minima(r: &Rig) -> (StockSourceCheckpointRef, StockListingCheckpointRef) { +async fn minima( + r: &Rig, +) -> ( + StockSourceCheckpointRef, + StockListingCheckpointRef, + radroots_storage::inventory::InventoryCheckpointRef, +) { let current = r .store .stock_authority(r.enrollment.input().clone(), r.enrollment.proof()) @@ -92,13 +98,15 @@ async fn minima(r: &Rig) -> (StockSourceCheckpointRef, StockListingCheckpointRef ( current.source_checkpoint().unwrap(), current.listing_checkpoint().unwrap(), + current.inventory_checkpoint().unwrap(), ) } async fn history(r: &Rig) -> StockHistorySnapshot { - let (private, public) = minima(r).await; + let (private, public, inventory) = minima(r).await; r.store .stock_order_history( r.binding.clone(), + inventory, private, public, scope(), @@ -313,7 +321,14 @@ async fn physical_grants_and_forked_source_acknowledgments_cannot_read_private_h let current = minima(&r).await; assert_eq!( r.store - .stock_order_history(child_binding, current.0, current.1, scope(), child.proof()) + .stock_order_history( + child_binding, + current.2, + current.0, + current.1, + scope(), + child.proof() + ) .await .unwrap_err() .code(), @@ -323,6 +338,7 @@ async fn physical_grants_and_forked_source_acknowledgments_cannot_read_private_h r.store .stock_order_history( r.binding.clone(), + old.2, old.0, old.1, scope(), @@ -344,6 +360,7 @@ async fn physical_grants_and_forked_source_acknowledgments_cannot_read_private_h r.store .stock_order_history( r.binding.clone(), + current.2, fork, current.1, scope(), @@ -381,11 +398,12 @@ async fn causal_reads_recheck_real_canonical_rumor_and_listing_rows_after_succes let mut r = Rig::new().await; base(&r).await; let provider = reopen(&mut r).await; - let (private, public) = minima(&r).await; + let (private, public, inventory) = minima(&r).await; let mut raw = database(&r).await; provider.gate.arm(Direction::Unwrap, schema, 0); let mut future = Box::pin(r.store.stock_order_history( r.binding.clone(), + inventory, private, public, scope(), @@ -438,7 +456,7 @@ async fn causal_snapshot_reports_the_actual_final_checked_time_and_rejects_expir let mut r = Rig::new().await; base(&r).await; let provider = reopen(&mut r).await; - let (private, public) = minima(&r).await; + let (private, public, inventory) = minima(&r).await; provider.gate.arm( Direction::Unwrap, "radroots.seller_stock.public_source_part.v1", @@ -446,6 +464,7 @@ async fn causal_snapshot_reports_the_actual_final_checked_time_and_rejects_expir ); let mut future = Box::pin(r.store.stock_order_history( r.binding.clone(), + inventory, private, public, scope(), @@ -470,7 +489,7 @@ async fn observer_loss_does_not_abandon_admitted_history_work_or_release_the_own let mut r = Rig::new().await; base(&r).await; let provider = reopen(&mut r).await; - let (private, public) = minima(&r).await; + let (private, public, inventory) = minima(&r).await; provider.gate.arm( Direction::Unwrap, "radroots.seller_stock.public_source_part.v1", @@ -478,6 +497,7 @@ async fn observer_loss_does_not_abandon_admitted_history_work_or_release_the_own ); let mut future = Box::pin(r.store.stock_order_history( r.binding.clone(), + inventory, private, public, scope(), @@ -510,6 +530,6 @@ async fn observer_loss_does_not_abandon_admitted_history_work_or_release_the_own history(&r).await.analysis().readiness(), CausalReadiness::Complete ); - assert_eq!(minima(&r).await, (private, public)); + assert_eq!(minima(&r).await, (private, public, inventory)); r.store.close().await.unwrap(); } diff --git a/crates/storage_sqlite/src/workspace/stock/public_source/installation_tests.rs b/crates/storage_sqlite/src/workspace/stock/public_source/installation_tests.rs @@ -1,4 +1,6 @@ //! Real T2 transactions over original T0/T1 and authenticated peer evidence. +#[path = "local_history_tests.rs"] +mod local_history; use super::*; use crate::workspace::{ StockInstallationOutcome, StockInstallationReceipt, StockInstallationRequest, diff --git a/crates/storage_sqlite/src/workspace/stock/public_source/local_history_tests.rs b/crates/storage_sqlite/src/workspace/stock/public_source/local_history_tests.rs @@ -0,0 +1,286 @@ +//! Actual locally issued records must join the same retained causal graph. +use super::*; + +type CausalMinima = ( + StockSourceCheckpointRef, + StockListingCheckpointRef, + radroots_storage::inventory::InventoryCheckpointRef, +); +async fn query(r: &Rig, minimum: CausalMinima) -> Result<StockHistorySnapshot, OperationError> { + r.store + .stock_order_history( + r.binding.clone(), + minimum.2, + minimum.0, + minimum.1, + scope(), + r.enrollment.proof(), + ) + .await +} + +#[tokio::test] +async fn bound_or_claimed_intents_without_actual_output_never_become_causal_records() { + let r = Rig::new().await; + let receipt = ready(&r).await; + let before = history(&r).await; + let StockClaimOutcome::Fresh(permit) = claim(&r, &receipt, peer(&r, &receipt)).await.unwrap() + else { + panic!("fresh claim"); + }; + drop(permit); + let unknown = history(&r).await; + assert_eq!(unknown.known_records(), before.known_records()); + assert!(unknown.analysis().seller_head().is_none()); + assert!( + r.store + .stock_agreement_installation(request(&r, &receipt).await, r.enrollment.proof()) + .await + .unwrap() + .is_none() + ); + r.store.close().await.unwrap(); +} + +#[tokio::test] +async fn peer_self_and_distinct_valid_encodings_supply_one_logical_record_without_installing() { + let r = Rig::new().await; + let receipt = ready(&r).await; + let before = history(&r).await; + for recipient in receipt.rumor().recipients() { + let (report, raw) = obtained(&r, &receipt, *recipient).await; + for text in [raw.clone(), format!("\n{raw}\n")] { + let captured = + StockEvidenceCapture::verify(r.binding.clone(), &report, &text, None).unwrap(); + committed( + r.store + .capture_stock_signing_evidence(&captured, r.enrollment.proof()) + .await + .unwrap(), + ); + let view = history(&r).await; + assert_eq!(view.known_records(), before.known_records() + 1); + assert_eq!( + view.analysis().seller_head(), + Some(receipt.rumor().record_id()) + ); + assert_eq!(view.inventory_checkpoint(), inventory_minimum(&r).await); + } + } + assert!( + r.store + .stock_agreement_installation(request(&r, &receipt).await, r.enrollment.proof()) + .await + .unwrap() + .is_none() + ); + assert_pool(&r, 80, 9, 1, 2).await; + let minimum = minima(&r).await; + assert!( + r.store + .stock_order_request( + r.binding.clone(), + minimum.2, + minimum.0, + minimum.1, + identity("request"), + r.enrollment.proof() + ) + .await + .is_err(), + "an issued seller decision cannot be presented as a fresh initial request" + ); + r.store.close().await.unwrap(); +} + +#[tokio::test] +async fn local_signed_records_from_another_order_do_not_advance_the_selected_order() { + let r = Rig::new().await; + let receipt = ready(&r).await; + let own = scope(); + let other = radroots_domain::causal::CausalScope::new( + own.thread_id(), + radroots_domain::OrderId::from_bytes([0xa7; 32]), + own.buyer(), + own.seller(), + ) + .unwrap(); + let minimum = minima(&r).await; + let before = r + .store + .stock_order_history( + r.binding.clone(), + minimum.2, + minimum.0, + minimum.1, + other, + r.enrollment.proof(), + ) + .await + .unwrap(); + retain(&r, &receipt, peer(&r, &receipt)).await; + let minimum = minima(&r).await; + let after = r + .store + .stock_order_history( + r.binding.clone(), + minimum.2, + minimum.0, + minimum.1, + other, + r.enrollment.proof(), + ) + .await + .unwrap(); + assert_eq!(after.known_records(), before.known_records()); + assert!(after.analysis().seller_head().is_none()); + r.store.close().await.unwrap(); +} + +#[tokio::test] +async fn inventory_minimum_rejects_restored_local_tail_with_unchanged_incoming_checkpoints() { + let mut r = Rig::new().await; + let receipt = ready(&r).await; + let before = minima(&r).await; + r.store.close().await.unwrap(); + let backup = r.fixture.root().join("before-local-output.sqlite"); + std::fs::copy(r.path.join("stock_execution_v1.sqlite"), &backup).unwrap(); + r.store = NativeWorkspace::open_seller_stock( + &r.path, + r.enrollment.input().clone(), + r.fixture.crypto(), + r.clock.clone(), + ) + .await + .unwrap(); + retain(&r, &receipt, peer(&r, &receipt)).await; + let acknowledged = minima(&r).await; + assert_eq!((before.0, before.1), (acknowledged.0, acknowledged.1)); + assert_ne!(before.2, acknowledged.2); + assert_eq!( + query(&r, acknowledged) + .await + .unwrap() + .analysis() + .seller_head(), + Some(receipt.rumor().record_id()) + ); + r.store.close().await.unwrap(); + std::fs::copy(&backup, r.path.join("stock_execution_v1.sqlite")).unwrap(); + r.store = NativeWorkspace::open_seller_stock( + &r.path, + r.enrollment.input().clone(), + r.fixture.crypto(), + r.clock.clone(), + ) + .await + .unwrap(); + assert_eq!( + query(&r, acknowledged).await.unwrap_err().code(), + "stale_checkpoint" + ); + r.store.close().await.unwrap(); +} + +#[tokio::test] +async fn local_history_rechecks_signed_indexes_root_and_grant_after_provider_io_and_drains_loss() { + for statement in [ + None, + Some("UPDATE stock_signing_evidence SET evidence_digest=randomblob(32)"), + Some("UPDATE stock_grants SET protected=randomblob(length(protected))"), + Some("UPDATE stock_authority SET protected=randomblob(length(protected))"), + ] { + let mut r = Rig::new().await; + let receipt = ready(&r).await; + retain(&r, &receipt, peer(&r, &receipt)).await; + let minimum = minima(&r).await; + let provider = reopen(&mut r).await; + let mut raw = database(&r).await; + provider.gate.arm( + Direction::Unwrap, + "radroots.seller_stock.operation_part.v1", + 0, + ); + let mut pending = Box::pin(query(&r, minimum)); + assert!(futures::poll!(pending.as_mut()).is_pending()); + provider.gate.entered(); + if let Some(statement) = statement { + sqlx::raw_sql(statement).execute(&mut raw).await.unwrap(); + provider.gate.release(); + assert!(pending.await.is_err(), "{statement}"); + } else { + drop(pending); + provider.gate.release(); + reopen_plain(&mut r).await; + assert_eq!( + query(&r, minimum).await.unwrap().analysis().seller_head(), + Some(receipt.rumor().record_id()) + ); + assert_eq!(minima(&r).await, minimum); + } + raw.close().await.unwrap(); + r.store.close().await.unwrap(); + } +} + +#[tokio::test] +async fn initial_installation_refuses_clock_before_its_original_bound_record() { + let r = Rig::new().await; + r.clock.0.store(155, Ordering::SeqCst); + let receipt = ready(&r).await; + retain(&r, &receipt, peer(&r, &receipt)).await; + let before = inventory_minimum(&r).await; + r.clock.0.store(152, Ordering::SeqCst); + assert_eq!( + install(&r, &receipt).await.unwrap_err().code(), + "workspace_unavailable", + "fresh installation must not write a timestamp its retained decoder will reject" + ); + assert_eq!(inventory_minimum(&r).await, before); + r.clock.0.store(155, Ordering::SeqCst); + let first = installed(install(&r, &receipt).await.unwrap()); + assert_eq!( + r.store + .stock_agreement_installation(request(&r, &receipt).await, r.enrollment.proof()) + .await + .unwrap() + .unwrap() + .attempt(), + first.attempt() + ); + r.store.close().await.unwrap(); +} + +#[tokio::test] +async fn actual_local_peer_commitment_advances_causal_history_once_before_and_after_installation() { + let mut r = Rig::new().await; + let receipt = ready(&r).await; + let before = history(&r).await; + assert!(before.analysis().seller_head().is_none()); + retain(&r, &receipt, peer(&r, &receipt)).await; + let obtained = history(&r).await; + assert_eq!( + obtained.known_records(), + before.known_records() + 1, + "actual retained local signing evidence must participate in complete local causal coverage" + ); + assert_eq!( + obtained.analysis().seller_head(), + Some(receipt.rumor().record_id()) + ); + installed(install(&r, &receipt).await.unwrap()); + let committed = history(&r).await; + assert_eq!(committed.known_records(), obtained.known_records()); + assert_eq!( + committed.analysis().seller_head(), + obtained.analysis().seller_head() + ); + reopen_plain(&mut r).await; + let reopened = history(&r).await; + assert_eq!(reopened.known_records(), obtained.known_records()); + assert_eq!( + reopened.analysis().seller_head(), + obtained.analysis().seller_head() + ); + r.store.close().await.unwrap(); +} diff --git a/crates/storage_sqlite/src/workspace/stock/public_source/request_tests.rs b/crates/storage_sqlite/src/workspace/stock/public_source/request_tests.rs @@ -14,10 +14,11 @@ fn selected(name: &str) -> RecordId { .unwrap() } async fn inspect(r: &Rig, name: &str) -> Result<StockRequestSnapshot, OperationError> { - let (private, public) = minima(r).await; + let (private, public, inventory) = minima(r).await; r.store .stock_order_request( r.binding.clone(), + inventory, private, public, selected(name), @@ -199,7 +200,7 @@ async fn request_deadline_and_current_access_are_rechecked_after_all_actual_prov let mut r = Rig::new().await; base(&r).await; let provider = reopen(&mut r).await; - let (private, public) = minima(&r).await; + let (private, public, inventory) = minima(&r).await; provider.gate.arm( Direction::Unwrap, "radroots.seller_stock.public_source_part.v1", @@ -207,6 +208,7 @@ async fn request_deadline_and_current_access_are_rechecked_after_all_actual_prov ); let mut future = Box::pin(r.store.stock_order_request( r.binding.clone(), + inventory, private, public, identity("request"), @@ -231,7 +233,7 @@ async fn protected_current_head_changes_after_opening_refuse_even_a_valid_quote_ let mut r = Rig::new().await; base(&r).await; let provider = reopen(&mut r).await; - let (private, public) = minima(&r).await; + let (private, public, inventory) = minima(&r).await; let mut raw = database(&r).await; provider.gate.arm( Direction::Unwrap, @@ -240,6 +242,7 @@ async fn protected_current_head_changes_after_opening_refuse_even_a_valid_quote_ ); let mut future = Box::pin(r.store.stock_order_request( r.binding.clone(), + inventory, private, public, identity("request"), diff --git a/crates/storage_sqlite/src/workspace/stock/signing_plan/codec.rs b/crates/storage_sqlite/src/workspace/stock/signing_plan/codec.rs @@ -191,6 +191,7 @@ impl Retained { } pub(in crate::workspace::stock) fn into_history(self) -> ledger::HistoryEntry { ledger::HistoryEntry { + local_record: None, installation: None, signing: None, header: self.frame.header, diff --git a/crates/storage_sqlite/src/workspace/stock/source.rs b/crates/storage_sqlite/src/workspace/stock/source.rs @@ -259,6 +259,7 @@ impl NativeWorkspace { pub async fn stock_order_request( &self, binding: WorkspaceBinding, + inventory_minimum: radroots_storage::inventory::InventoryCheckpointRef, minimum: StockSourceCheckpointRef, listing_minimum: radroots_storage::workspace::seller_stock::StockListingCheckpointRef, request: RecordId, @@ -266,7 +267,14 @@ impl NativeWorkspace { ) -> Result<StockRequestSnapshot, OperationError> { let proof = proof.with_secret(|bytes| AttachmentProof::from_protected_input(bytes))?; self.worker - .stock_order_request(binding, minimum, listing_minimum, request, proof) + .stock_order_request( + binding, + inventory_minimum, + minimum, + listing_minimum, + request, + proof, + ) .await } /// Reads complete retained local causal coverage for one bilateral scope. @@ -278,6 +286,7 @@ impl NativeWorkspace { pub async fn stock_order_history( &self, binding: WorkspaceBinding, + inventory_minimum: radroots_storage::inventory::InventoryCheckpointRef, minimum: StockSourceCheckpointRef, listing_minimum: radroots_storage::workspace::seller_stock::StockListingCheckpointRef, scope: radroots_domain::causal::CausalScope, @@ -285,7 +294,14 @@ impl NativeWorkspace { ) -> Result<StockHistorySnapshot, OperationError> { let proof = proof.with_secret(|bytes| AttachmentProof::from_protected_input(bytes))?; self.worker - .stock_order_history(binding, minimum, listing_minimum, scope, proof) + .stock_order_history( + binding, + inventory_minimum, + minimum, + listing_minimum, + scope, + proof, + ) .await } /// Retains original authenticated evidence on the selected owner worker. diff --git a/crates/storage_sqlite/src/workspace/stock/source/history.rs b/crates/storage_sqlite/src/workspace/stock/source/history.rs @@ -19,9 +19,16 @@ pub struct StockHistorySnapshot { pub(super) listings: StockListingCheckpointRef, pub(super) observed_at: UnixSeconds, pub(super) records: usize, + pub(super) inventory: radroots_storage::inventory::InventoryCheckpointRef, pub(super) checkpoint: Option<radroots_domain::CheckpointRef>, } impl StockHistorySnapshot { + /// Independently acknowledged inventory history containing local issued records. + pub const fn inventory_checkpoint( + &self, + ) -> radroots_storage::inventory::InventoryCheckpointRef { + self.inventory + } /// Borrows complete local causal coverage data. This is not an installed /// order, pending-decision fence or permission to accept the request. pub fn checkpoint(&self) -> Option<&radroots_domain::CheckpointRef> { @@ -58,8 +65,17 @@ impl std::fmt::Debug for StockHistorySnapshot { f.write_str("StockHistorySnapshot(<private coverage>)") } } +/// Current verified access plus caller checkpoint data; not fresh authority. +pub(in crate::workspace::stock) struct InventoryRead<'a> { + pub binding: &'a WorkspaceBinding, + pub authority: &'a Authority, + pub minimum: radroots_storage::inventory::InventoryCheckpointRef, +} pub(in crate::workspace::stock) struct Prepared { pub records: BTreeMap<RecordId, DecodedRecord>, + pub inventory: radroots_storage::inventory::InventoryCheckpointRef, + inventory_proof: super::super::inventory::checkpoint::MinimumProof, + inventory_state: super::super::InventoryCheckpoint, pub analysis: CausalAnalysis, pub checkpoint: Option<radroots_domain::CheckpointRef>, pub external: Vec<SourceId>, @@ -194,10 +210,14 @@ pub(in crate::workspace::stock) async fn prepare( connection: &mut SqliteConnection, input: &AttachmentInput, crypto: &WorkspaceCrypto, - authority: &Authority, + inventory_read: InventoryRead<'_>, scope: CausalScope, listing_minimum: StockListingCheckpointRef, ) -> Result<Prepared, OperationError> { + let authority = inventory_read.authority; + if inventory_read.minimum.authorization() != authority.authorization { + return Err(WorkspaceError::StaleCheckpoint.into()); + } if scope.seller() != input.participant() { return Err(OperationError::Unauthorized); } @@ -242,6 +262,35 @@ pub(in crate::workspace::stock) async fn prepare( } } } + let inventory_state = authority + .inventory + .ok_or(OperationError::UnsupportedOperation)?; + super::super::inventory::check_head(connection, inventory_state).await?; + let inventory_proof = Box::pin( + super::super::inventory::checkpoint::authenticate_minimum_with_local( + connection, + input, + crypto, + inventory_read.binding, + authority, + inventory_read.minimum, + Some(super::super::inventory::checkpoint::LocalSources { + scope, + records: &mut records, + }), + ), + ) + .await?; + let inventory = radroots_storage::inventory::InventoryCheckpointRef::from_host_metadata( + input.authority(), + inventory_state.revision, + inventory_state.head, + )? + .with_authorization( + authority + .authorization + .ok_or(OperationError::RecoveryRequired)?, + ); let mut wanted: BTreeSet<_> = records .values() .flat_map(|record| record.content().header().parents().iter().copied()) @@ -314,6 +363,9 @@ pub(in crate::workspace::stock) async fn prepare( })?; let (analysis, checkpoint) = coverage.into_parts(); Ok(Prepared { + inventory, + inventory_state, + inventory_proof, records, analysis, checkpoint, @@ -332,6 +384,8 @@ impl Prepared { connection: &mut SqliteConnection, ) -> Result<(), OperationError> { self.ancestry.confirm(connection).await?; + super::super::inventory::check_head(connection, self.inventory_state).await?; + self.inventory_proof.confirm(connection).await?; let mut known = known_hash(); let mut unknown = unknown_hash(); for revision in 1..=self.revision { diff --git a/crates/storage_sqlite/src/workspace/stock/source/request.rs b/crates/storage_sqlite/src/workspace/stock/source/request.rs @@ -21,8 +21,15 @@ pub struct StockRequestSnapshot { pub(super) sources: StockSourceCheckpointRef, pub(super) listings: StockListingCheckpointRef, pub(super) observed_at: UnixSeconds, + pub(super) inventory: radroots_storage::inventory::InventoryCheckpointRef, } impl StockRequestSnapshot { + /// Inventory progress included in the complete local causal read. + pub const fn inventory_checkpoint( + &self, + ) -> radroots_storage::inventory::InventoryCheckpointRef { + self.inventory + } /// Exact selected scope derived from original authenticated request content. pub const fn scope(&self) -> CausalScope { self.scope @@ -130,11 +137,12 @@ pub(in crate::workspace::stock) async fn prepare( connection: &mut SqliteConnection, input: &AttachmentInput, crypto: &WorkspaceCrypto, - authority: &Authority, + inventory_read: history::InventoryRead<'_>, request: RecordId, listing_minimum: StockListingCheckpointRef, observed_at: UnixSeconds, ) -> Result<Prepared, OperationError> { + let authority = inventory_read.authority; let raw = record::canonical(connection, input, crypto, request).await?; let observed = raw .as_ref() @@ -163,8 +171,15 @@ pub(in crate::workspace::stock) async fn prepare( header.seller(), ) .map_err(|_| OperationError::InvalidEvidence)?; - let history = - history::prepare(connection, input, crypto, authority, scope, listing_minimum).await?; + let history = Box::pin(history::prepare( + connection, + input, + crypto, + inventory_read, + scope, + listing_minimum, + )) + .await?; let nodes: Vec<_> = history .records .iter() diff --git a/crates/storage_sqlite/src/workspace/stock/source/transaction.rs b/crates/storage_sqlite/src/workspace/stock/source/transaction.rs @@ -107,6 +107,7 @@ impl Access { pub(in crate::workspace) async fn history( turn: &mut Turn<'_>, binding: WorkspaceBinding, + inventory_minimum: radroots_storage::inventory::InventoryCheckpointRef, minimum: StockSourceCheckpointRef, listing_minimum: radroots_storage::workspace::seller_stock::StockListingCheckpointRef, scope: radroots_domain::causal::CausalScope, @@ -116,14 +117,18 @@ pub(in crate::workspace) async fn history( if !matches!(access.authority.catalog, 8..=12) { return Err(OperationError::UnsupportedOperation); } - let prepared = super::history::prepare( + let prepared = Box::pin(super::history::prepare( turn.connection, turn.selected, turn.crypto, - &access.authority, + super::history::InventoryRead { + binding: &access.current, + authority: &access.authority, + minimum: inventory_minimum, + }, scope, listing_minimum, - ) + )) .await?; let mut tx = turn .connection @@ -154,6 +159,7 @@ pub(in crate::workspace) async fn history( .public_sources .ok_or(OperationError::RecoveryRequired)?; Ok(StockHistorySnapshot { + inventory: prepared.inventory, scope,records:prepared.records.len(),analysis:prepared.analysis,checkpoint:prepared.checkpoint,observed_at, sources:StockSourceCheckpointRef::from_host_metadata(turn.selected.authority(),private.revision,private.head)?.with_optional_authorization(access.authority.authorization), listings:radroots_storage::workspace::seller_stock::StockListingCheckpointRef::from_host_metadata(turn.selected.authority(),public.revision,public.head)?.with_optional_authorization(access.authority.authorization), @@ -162,6 +168,7 @@ pub(in crate::workspace) async fn history( pub(in crate::workspace) async fn inspect_request( turn: &mut Turn<'_>, binding: WorkspaceBinding, + inventory_minimum: radroots_storage::inventory::InventoryCheckpointRef, minimum: StockSourceCheckpointRef, listing_minimum: radroots_storage::workspace::seller_stock::StockListingCheckpointRef, selected: RecordId, @@ -171,15 +178,19 @@ pub(in crate::workspace) async fn inspect_request( if !matches!(access.authority.catalog, 8..=12) { return Err(OperationError::UnsupportedOperation); } - let prepared = super::request::prepare( + let prepared = Box::pin(super::request::prepare( turn.connection, turn.selected, turn.crypto, - &access.authority, + super::history::InventoryRead { + binding: &access.current, + authority: &access.authority, + minimum: inventory_minimum, + }, selected, listing_minimum, access.current.observed_at(), - ) + )) .await; let mut tx = turn .connection @@ -218,6 +229,7 @@ pub(in crate::workspace) async fn inspect_request( .public_sources .ok_or(OperationError::RecoveryRequired)?; Ok(StockRequestSnapshot { + inventory: prepared.history.inventory, scope:prepared.scope,request:prepared.request,terms:Box::new(prepared.terms()?.clone()),digest:prepared.digest, expires:prepared.expires,quote:prepared.quote,checkpoint:prepared.history.checkpoint.clone().ok_or(OperationError::RecoveryRequired)?,observed_at, sources:StockSourceCheckpointRef::from_host_metadata(turn.selected.authority(),private.revision,private.head)?.with_optional_authorization(access.authority.authorization), diff --git a/crates/storage_sqlite/src/workspace/worker.rs b/crates/storage_sqlite/src/workspace/worker.rs @@ -100,6 +100,7 @@ enum Job { ), StockOrderRequest( Box<WorkspaceBinding>, + radroots_storage::inventory::InventoryCheckpointRef, radroots_storage::workspace::seller_stock::StockSourceCheckpointRef, radroots_storage::workspace::seller_stock::StockListingCheckpointRef, radroots_domain::RecordId, @@ -108,6 +109,7 @@ enum Job { ), StockOrderHistory( Box<WorkspaceBinding>, + radroots_storage::inventory::InventoryCheckpointRef, radroots_storage::workspace::seller_stock::StockSourceCheckpointRef, radroots_storage::workspace::seller_stock::StockListingCheckpointRef, radroots_domain::causal::CausalScope, @@ -327,10 +329,10 @@ impl Job { Self::PrepareStockAcceptance(_, _, reply) => { let _ = reply.send(Err(OperationError::RecoveryRequired)); } - Self::StockOrderRequest(_, _, _, _, _, reply) => { + Self::StockOrderRequest(_, _, _, _, _, _, reply) => { let _ = reply.send(Err(OperationError::RecoveryRequired)); } - Self::StockOrderHistory(_, _, _, _, _, reply) => { + Self::StockOrderHistory(_, _, _, _, _, _, reply) => { let _ = reply.send(Err(OperationError::RecoveryRequired)); } Self::RetainStockListing(_, _, _, _, reply) => { @@ -1033,6 +1035,7 @@ impl Handle { } Job::StockOrderRequest( binding, + inventory_minimum, minimum, listings, selected, @@ -1040,7 +1043,7 @@ impl Handle { reply, ) => { let result = if kind == Kind::SellerStock { - stock::source::inspect_request( + Box::pin(stock::source::inspect_request( &mut stock::inventory::Turn { connection, namespace: &namespace, @@ -1050,11 +1053,12 @@ impl Handle { uncertain: &mut uncertain, }, *binding, + inventory_minimum, minimum, listings, selected, proof, - ) + )) .await } else { Err(OperationError::UnsupportedOperation) @@ -1063,6 +1067,7 @@ impl Handle { } Job::StockOrderHistory( binding, + inventory_minimum, minimum, listings, scope, @@ -1070,7 +1075,7 @@ impl Handle { reply, ) => { let result = if kind == Kind::SellerStock { - stock::source::query_history( + Box::pin(stock::source::query_history( &mut stock::inventory::Turn { connection, namespace: &namespace, @@ -1080,11 +1085,12 @@ impl Handle { uncertain: &mut uncertain, }, *binding, + inventory_minimum, minimum, listings, scope, proof, - ) + )) .await } else { Err(OperationError::UnsupportedOperation) @@ -1775,6 +1781,7 @@ impl Handle { pub(super) async fn stock_order_request( &self, binding: WorkspaceBinding, + inventory_minimum: radroots_storage::inventory::InventoryCheckpointRef, minimum: radroots_storage::workspace::seller_stock::StockSourceCheckpointRef, listings: radroots_storage::workspace::seller_stock::StockListingCheckpointRef, selected: radroots_domain::RecordId, @@ -1783,6 +1790,7 @@ impl Handle { let (reply, result) = oneshot::channel(); self.send(Job::StockOrderRequest( Box::new(binding), + inventory_minimum, minimum, listings, selected, @@ -1794,6 +1802,7 @@ impl Handle { pub(super) async fn stock_order_history( &self, binding: WorkspaceBinding, + inventory_minimum: radroots_storage::inventory::InventoryCheckpointRef, minimum: radroots_storage::workspace::seller_stock::StockSourceCheckpointRef, listings: radroots_storage::workspace::seller_stock::StockListingCheckpointRef, scope: radroots_domain::causal::CausalScope, @@ -1802,6 +1811,7 @@ impl Handle { let (reply, result) = oneshot::channel(); self.send(Job::StockOrderHistory( Box::new(binding), + inventory_minimum, minimum, listings, scope, diff --git a/tools/xtask/src/architecture/decision_package.rs b/tools/xtask/src/architecture/decision_package.rs @@ -111,6 +111,10 @@ struct NativeSellerStockAuthority { source_profile_implies_actionability: bool, causal_history_current_administrator_required: bool, causal_history_complete_local_scope_required: bool, + causal_history_includes_actual_local_signed_records: bool, + causal_history_inventory_minimum_required: bool, + causal_history_logical_record_deduplication_required: bool, + causal_history_implies_installation: bool, causal_history_uninterpreted_policy: String, causal_history_transaction_witnesses_required: bool, causal_history_implies_business_permission: bool, @@ -220,6 +224,7 @@ struct InitialAgreementInstallation { original_order_fence_immutable: bool, exact_original_hold_quantities_required: bool, current_exact_recovery_consent_required: bool, + fresh_time_not_before_original_bound_plan: bool, atomic_pool_agreement_and_work_required: bool, recipient_work_count: u32, unknown_commit_fences_owner: bool, @@ -566,6 +571,9 @@ fn validate_bytes(raw: &[u8]) -> Result<(), String> { .current_exact_recovery_consent_required && stock .initial_agreement_installation + .fresh_time_not_before_original_bound_plan + && stock + .initial_agreement_installation .atomic_pool_agreement_and_work_required && stock.initial_agreement_installation.recipient_work_count == 2 && stock @@ -596,6 +604,10 @@ fn validate_bytes(raw: &[u8]) -> Result<(), String> { && !stock.source_profile_implies_actionability && stock.causal_history_current_administrator_required && stock.causal_history_complete_local_scope_required + && stock.causal_history_includes_actual_local_signed_records + && stock.causal_history_inventory_minimum_required + && stock.causal_history_logical_record_deduplication_required + && !stock.causal_history_implies_installation && stock.causal_history_uninterpreted_policy == "conservative_authenticated_participant_pair_barrier" && stock.causal_history_transaction_witnesses_required @@ -1234,6 +1246,7 @@ mod tests { ("original_order_fence_immutable", json!(false)), ("exact_original_hold_quantities_required", json!(false)), ("current_exact_recovery_consent_required", json!(false)), + ("fresh_time_not_before_original_bound_plan", json!(false)), ("atomic_pool_agreement_and_work_required", json!(false)), ("recipient_work_count", json!(3)), ("unknown_commit_fences_owner", json!(false)), @@ -1403,6 +1416,16 @@ mod tests { ), ("causal_history_complete_local_scope_required", json!(false)), ( + "causal_history_includes_actual_local_signed_records", + json!(false), + ), + ("causal_history_inventory_minimum_required", json!(false)), + ( + "causal_history_logical_record_deduplication_required", + json!(false), + ), + ("causal_history_implies_installation", json!(true)), + ( "causal_history_uninterpreted_policy", json!("ignore_unknown_scope"), ),