orders.rs (6347B)
1 //! Ordinary captured order acceptance and original recovery through Core. 2 use crate::{Client, CommandContext, Result, WorkspaceSession}; 3 use radroots_domain::{CommandDigest, OperationId}; 4 pub use radroots_execution::session::commerce::{ 5 AcceptanceRecipient, AcceptanceRewrapStatus, AcceptanceStatus, AcceptanceUnissuedReceipt, 6 InstalledAcceptance, 7 }; 8 pub use radroots_protocol::command::{AcceptOrderInput, InstallTermsInput}; 9 use radroots_storage::{ 10 inventory::InventoryCheckpointRef, 11 workspace::seller_stock::{StockListingCheckpointRef, StockSourceCheckpointRef}, 12 }; 13 14 /// Borrowed order workflows for one explicitly selected client-owned scope. 15 pub struct Orders<'a> { 16 client: &'a Client, 17 scope: WorkspaceSession, 18 } 19 impl<'a> Orders<'a> { 20 pub(crate) const fn new(client: &'a Client, scope: WorkspaceSession) -> Self { 21 Self { client, scope } 22 } 23 /// Owns captured acceptance through native T0/T1/S/T2 and original delivery. 24 /// Inspect independent signing, installation and relay observations. An 25 /// installed peer can reach delivery even if later self signing fails. 26 /// Available command IO controls progress; pending preparation is not acceptance. 27 pub async fn accept( 28 &self, 29 context: CommandContext, 30 minimum: InventoryCheckpointRef, 31 sources: StockSourceCheckpointRef, 32 listings: StockListingCheckpointRef, 33 input: AcceptOrderInput, 34 ) -> crate::ExecutionResult<AcceptanceStatus> { 35 self.client 36 .session 37 .accept_stock_order( 38 self.client.inventory()?, 39 self.client.acceptance_store()?, 40 &self.scope, 41 context, 42 minimum, 43 sources, 44 listings, 45 input, 46 ) 47 .await 48 } 49 /// Owns mutually authorized complete replacement installation through the 50 /// same executor as acceptance. Positive holds precede issuance; old 51 /// obligations remain pending and negative deltas release only at T2. 52 pub async fn install_terms( 53 &self, 54 context: CommandContext, 55 minimum: InventoryCheckpointRef, 56 sources: StockSourceCheckpointRef, 57 listings: StockListingCheckpointRef, 58 input: InstallTermsInput, 59 ) -> crate::ExecutionResult<AcceptanceStatus> { 60 self.client 61 .session 62 .install_stock_terms( 63 self.client.inventory()?, 64 self.client.acceptance_store()?, 65 &self.scope, 66 context, 67 minimum, 68 sources, 69 listings, 70 input, 71 ) 72 .await 73 } 74 /// Explicitly resumes captured original work. Existing non-replayable 75 /// claims never sign again; qualified replay uses the original host permit. 76 pub async fn resume_acceptance( 77 &self, 78 minimum: InventoryCheckpointRef, 79 operation: OperationId, 80 digest: CommandDigest, 81 ) -> crate::ExecutionResult<AcceptanceStatus> { 82 self.client 83 .session 84 .resume_stock_acceptance( 85 self.client.inventory()?, 86 self.client.acceptance_store()?, 87 &self.scope, 88 minimum, 89 operation, 90 digest, 91 ) 92 .await 93 } 94 /// Reads coherent original acceptance, independent signing and installation 95 /// facts without issuing, replaying or publishing any artifact. 96 pub async fn acceptance_status( 97 &self, 98 minimum: InventoryCheckpointRef, 99 operation: OperationId, 100 digest: CommandDigest, 101 ) -> Result<AcceptanceStatus> { 102 self.client 103 .session 104 .stock_acceptance_status( 105 self.client.acceptance_store()?, 106 &self.scope, 107 minimum, 108 operation, 109 digest, 110 ) 111 .await 112 } 113 /// Creates one explicitly requested additional carrier for the same original 114 /// commitment. Existing/unknown admissions never generate another key. 115 pub async fn rewrap_acceptance( 116 &self, 117 minimum: InventoryCheckpointRef, 118 operation: OperationId, 119 digest: CommandDigest, 120 recipient: radroots_domain::PublicKey, 121 rewrap_id: OperationId, 122 ) -> crate::ExecutionResult<AcceptanceRewrapStatus> { 123 self.client 124 .session 125 .rewrap_stock_acceptance( 126 self.client.inventory()?, 127 self.client.acceptance_store()?, 128 &self.scope, 129 minimum, 130 operation, 131 digest, 132 recipient, 133 rewrap_id, 134 ) 135 .await 136 } 137 /// Explicitly retries only a known captured carrier within its original 138 /// policy and cumulative invocation budget. Unknown bytes never regenerate. 139 pub async fn resume_acceptance_rewrap( 140 &self, 141 minimum: InventoryCheckpointRef, 142 operation: OperationId, 143 digest: CommandDigest, 144 recipient: radroots_domain::PublicKey, 145 rewrap_id: OperationId, 146 ) -> crate::ExecutionResult<AcceptanceRewrapStatus> { 147 self.client 148 .session 149 .resume_stock_rewrap( 150 self.client.inventory()?, 151 self.client.acceptance_store()?, 152 &self.scope, 153 minimum, 154 operation, 155 digest, 156 recipient, 157 rewrap_id, 158 ) 159 .await 160 } 161 /// Reads retained carrier facts without wrapping, signing or dispatch. 162 pub async fn acceptance_rewrap_status( 163 &self, 164 minimum: InventoryCheckpointRef, 165 operation: OperationId, 166 digest: CommandDigest, 167 recipient: radroots_domain::PublicKey, 168 rewrap_id: OperationId, 169 ) -> Result<AcceptanceRewrapStatus> { 170 self.client 171 .session 172 .stock_acceptance_rewrap_status( 173 self.client.inventory()?, 174 &self.scope, 175 minimum, 176 operation, 177 digest, 178 recipient, 179 rewrap_id, 180 ) 181 .await 182 } 183 }