aion_store/store.rs
1//! Event-store traits and single-writer capability.
2
3use aion_core::{
4 Event, RunId, TimerId, WorkflowFilter, WorkflowId, WorkflowStatus, WorkflowSummary,
5};
6use async_trait::async_trait;
7use chrono::{DateTime, Utc};
8
9use crate::{OutboxRow, StoreError, TimerEntry, TimerRetirement};
10
11mod write_capability {
12 /// Capability required to append workflow events.
13 ///
14 /// This token enforces Aion's single-writer durability invariant at the type level: only the
15 /// recorder append path may hold write authority for a workflow. `SequenceConflict` remains the
16 /// runtime defense-in-depth signal for any internal misuse or future bypass that attempts to
17 /// append with a stale head.
18 #[derive(Clone, Copy, Debug)]
19 pub struct WriteToken {
20 _private: (),
21 }
22
23 impl WriteToken {
24 /// Constructs a write token for Aion's recorder path.
25 #[must_use]
26 pub fn recorder() -> Self {
27 Self { _private: () }
28 }
29 }
30
31 pub(crate) fn conformance() -> WriteToken {
32 WriteToken { _private: () }
33 }
34}
35
36pub use write_capability::WriteToken;
37
38/// Summary of one concrete run in a workflow's continuation chain.
39#[derive(Clone, Debug, PartialEq, Eq)]
40pub struct RunSummary {
41 /// Concrete run identifier for this chain entry.
42 pub run_id: RunId,
43 /// Parent run that continued as this run, or `None` for the first run.
44 pub parent_run_id: Option<RunId>,
45 /// Status projected from this run's slice of lifecycle events.
46 pub status: WorkflowStatus,
47 /// Timestamp of this run's `WorkflowStarted` event.
48 pub started_at: DateTime<Utc>,
49 /// Workflow sequence of this run's `WorkflowStarted` event — the boundary
50 /// at which this generation opens.
51 ///
52 /// SEQUENCE, NOT TIMESTAMP, IS THE AXIS THAT LOCATES AN EVENT'S GENERATION.
53 /// A reader holding an event at sequence `n` answers "which run is this?" by
54 /// taking the last boundary at or before `n`; `started_at` is a recorded
55 /// value and cannot order events against it. Without this field the only way
56 /// to answer that question is to scan history for `WorkflowStarted` — which
57 /// is exactly what the ops console did, over whatever window it happened to
58 /// have loaded, so on any workflow longer than one window it reported
59 /// "run unknown" for every attempt it showed.
60 pub started_seq: u64,
61 /// Timestamp of this run's terminal lifecycle event, when closed.
62 pub closed_at: Option<DateTime<Utc>>,
63}
64
65/// Read and durable-timer contract for Aion event stores.
66#[async_trait]
67pub trait ReadableEventStore: Send + Sync + 'static {
68 /// Reads the complete event history for `workflow_id` in ascending sequence order.
69 ///
70 /// A workflow with no recorded events is observed as an empty history. This includes unknown
71 /// workflow identifiers: because the first append with `expected_seq == 0` creates a workflow
72 /// implicitly, "unknown workflow" and "empty history" are the same observable state for reads.
73 /// This method must not return [`StoreError::NotFound`] for absent workflows.
74 async fn read_history(&self, workflow_id: &WorkflowId) -> Result<Vec<Event>, StoreError>;
75
76 /// Reads the event history for `workflow_id` restricted to events with sequence number
77 /// greater than or equal to `from_seq`, in ascending sequence order.
78 ///
79 /// This is the range-read primitive behind O(delta) WS resume: callers replaying from a
80 /// cursor must not pay for the full history. Semantics:
81 ///
82 /// - `from_seq <= 1` is equivalent to [`Self::read_history`]: sequence numbers start at 1,
83 /// so every recorded event satisfies the bound.
84 /// - `from_seq` beyond the current head returns an empty vector, never an error. Whether a
85 /// beyond-head cursor is *valid* is protocol judgment, not store judgment: the WS resume
86 /// protocol rejects `resume_from_seq > head + 1` as an invalid cursor
87 /// (`ResumeCursorAheadOfHistory`), but it makes that call by comparing the cursor against
88 /// the head it observes — the store only answers which events exist at or after the
89 /// requested sequence.
90 /// - Unknown workflows behave exactly like [`Self::read_history`] for unknown workflows:
91 /// empty history, never [`StoreError::NotFound`], because "unknown workflow" and "empty
92 /// history" are the same observable state for reads.
93 ///
94 /// There is deliberately no default implementation: a read-all-then-filter fallback would
95 /// silently reintroduce O(history) behavior. Every backend must implement this as a real
96 /// range read (for SQL backends, an indexed `seq >= ?` range scan).
97 async fn read_history_from(
98 &self,
99 workflow_id: &WorkflowId,
100 from_seq: u64,
101 ) -> Result<Vec<Event>, StoreError>;
102
103 /// Reads the concrete run chain for `workflow_id` in continuation order.
104 async fn read_run_chain(&self, workflow_id: &WorkflowId)
105 -> Result<Vec<RunSummary>, StoreError>;
106
107 /// Lists every workflow identifier that has at least one event in history.
108 ///
109 /// Unlike [`Self::list_active`], this includes terminal workflows and exists to let projection
110 /// repair jobs reconcile derived indexes against the authoritative event history.
111 async fn list_workflow_ids(&self) -> Result<Vec<WorkflowId>, StoreError>;
112
113 /// Lists workflow identifiers whose projected status is exactly
114 /// [`WorkflowStatus::Running`](aion_core::WorkflowStatus::Running).
115 async fn list_active(&self) -> Result<Vec<WorkflowId>, StoreError>;
116
117 /// Lists workflow identifiers whose projected status is exactly
118 /// [`WorkflowStatus::Paused`](aion_core::WorkflowStatus::Paused).
119 ///
120 /// Mirrors [`Self::list_active`] with a `== Paused` exact-equality filter: it
121 /// is the durable source the dispatch-hold set is rebuilt from at startup and
122 /// at shard adoption, so a run paused before a `kill -9` keeps its outbox rows
123 /// held after restart. A paused run is excluded from [`Self::list_active`]
124 /// (which filters `== Running`), so nothing else would repopulate the hold.
125 async fn list_paused(&self) -> Result<Vec<WorkflowId>, StoreError>;
126
127 /// Returns workflow summaries matching `filter`.
128 async fn query(&self, filter: &WorkflowFilter) -> Result<Vec<WorkflowSummary>, StoreError>;
129
130 /// Persists a durable timer for `workflow_id` that is due at `fire_at`.
131 ///
132 /// Timer scheduling remains on the public store surface because timers are not workflow-history
133 /// appends and are used by the timer subsystem after the recorder has written `TimerStarted`.
134 ///
135 /// `armed_seq` is the workflow-history sequence of the arming's
136 /// `TimerStarted` event and becomes part of the row's identity
137 /// ([`TimerEntry::armed_seq`]): together with `fire_at` it is what a
138 /// [`Self::retire_timer`] compare matches, so a re-arm to the IDENTICAL
139 /// instant still writes a distinguishable row. An engine-internal arming
140 /// that records no `TimerStarted` (the schedule coordinator) passes `0` —
141 /// history sequences start at 1, so `0` is unambiguous, and such rows are
142 /// keyed per trigger and never alias a workflow arming.
143 async fn schedule_timer(
144 &self,
145 workflow_id: &WorkflowId,
146 timer_id: &TimerId,
147 fire_at: DateTime<Utc>,
148 armed_seq: u64,
149 ) -> Result<(), StoreError>;
150
151 /// Returns durable timers whose `fire_at` is less than or equal to `as_of`.
152 async fn expired_timers(&self, as_of: DateTime<Utc>) -> Result<Vec<TimerEntry>, StoreError>;
153
154 /// Removes the durable timer row for `(workflow_id, timer_id)` — but only
155 /// while the row still carries exactly the `(fire_at, armed_seq)`
156 /// identity of the arming being retired.
157 ///
158 /// Called by the timer subsystem once the row's consuming fact is durably
159 /// recorded — the fire path after `TimerFired` lands (or is refused by a
160 /// terminal run), the cancel path after `TimerCancelled` lands, and the
161 /// boot sweep's reconciliation of rows whose consumption predates this
162 /// method. Without retirement every timer a workflow ever armed leaves a
163 /// permanent row, [`Self::expired_timers`] returns the workflow's whole
164 /// consumed past on every call, and the startup sweep walks it — the
165 /// 2026-08-24 estate outage's 90-minute boot.
166 ///
167 /// The `(fire_at, armed_seq)` condition is what makes retirement safe
168 /// against re-arms: a named timer re-armed after its fire OVERWRITES the
169 /// same row with the replacement arming's values
170 /// ([`Self::schedule_timer`]), and a retirement decided against the
171 /// consumed arming must never delete the replacement's row — that row is
172 /// the re-armed timer's only durable claim to a recovery fire. The
173 /// `armed_seq` half is load-bearing for a re-arm to the IDENTICAL
174 /// instant: `fire_at` alone cannot tell those two armings apart, and the
175 /// replacement's `TimerStarted` always carries a strictly higher
176 /// sequence. A caller always knows the arming it is retiring (the sweep
177 /// row it walked, or the `TimerStarted` it read), so the condition costs
178 /// nothing; a mismatch means "already re-armed, nothing left to retire"
179 /// and is the [`TimerRetirement::Superseded`] SUCCESS, not an error.
180 ///
181 /// The condition must hold under CONCURRENT re-arming, not merely against
182 /// a stale caller decision: a `schedule_timer` racing this call must
183 /// either land before the compare (mismatch, `Superseded`) or after the
184 /// delete (its row survives) — never inside it. A backend without an
185 /// atomic conditional delete must serialize this method against
186 /// [`Self::schedule_timer`] itself.
187 ///
188 /// Idempotent: retiring an absent (never scheduled, or already retired)
189 /// row succeeds as [`TimerRetirement::Retired`] — the boot sweep and a
190 /// racing live fire may both retire the same row, and the second act must
191 /// be a no-op, not an error. Replay never calls this: replay is read-only
192 /// on the timer keyspace.
193 ///
194 /// A distributed backend must ride retirement on the same stamped,
195 /// replicated write path as [`Self::schedule_timer`], routed onto the
196 /// workflow's shard — an adopted shard must not resurrect retired rows.
197 async fn retire_timer(
198 &self,
199 workflow_id: &WorkflowId,
200 timer_id: &TimerId,
201 fire_at: DateTime<Utc>,
202 armed_seq: u64,
203 ) -> Result<TimerRetirement, StoreError>;
204
205 /// Restrict every per-workflow enumeration (active workflows, timers, outbox
206 /// rows) to the named set of distribution shards this node owns, or restore
207 /// the own-all-shards default when `shards` is `None`.
208 ///
209 /// This is the engine-lifecycle hook behind a multi-shard deployment: the
210 /// boot path tells the store which shards this node serves so recovery and
211 /// enumeration see only that node's slice of the cluster's state. The
212 /// default implementation is a deliberate no-op — the single-shard in-memory
213 /// backend owns everything unconditionally, so a `None` or any shard set
214 /// leaves its behaviour byte-identical. The sharded haematite backend
215 /// overrides this to scope its enumeration. Decorators that wrap another
216 /// store must forward this call to their inner store.
217 fn set_owned_shards(&self, shards: Option<&[usize]>) {
218 let _ = shards;
219 }
220
221 /// Acquire-and-serve ownership of each named distribution shard BEFORE the
222 /// boot path recovers or enumerates over them, so the node is the fenced
223 /// owner and its replicated state is union-merged locally first.
224 ///
225 /// This is the SS-2 election hook the engine boot path calls right after
226 /// [`Self::set_owned_shards`] and BEFORE startup recovery: a distributed
227 /// backend wins the per-shard election and becomes the live owner, so the
228 /// subsequent recovery reads see the full committed history for its shards.
229 ///
230 /// The default implementation is a deliberate no-op returning `Ok(())` —
231 /// non-distributed backends (the in-memory store and single-node haematite)
232 /// own everything unconditionally and elect nothing, so boot stays
233 /// byte-identical. Only a DISTRIBUTED sharded backend
234 /// overrides this to run the election. Decorators that wrap another store
235 /// must forward this call to their inner store.
236 ///
237 /// # Errors
238 ///
239 /// Returns [`StoreError::Backend`] when a distributed backend cannot win the
240 /// election or become the live owner of one of `shards`; the node must not
241 /// serve those shards in that case (fail-closed).
242 fn acquire_owned_shards(&self, shards: &[usize]) -> Result<(), StoreError> {
243 let _ = shards;
244 Ok(())
245 }
246
247 /// Acquire-and-serve ownership of a SINGLE distribution `shard` — the
248 /// per-shard primitive [`Self::acquire_owned_shards`] is a loop over, exposed
249 /// so the failover path can drive a per-shard abort seam: a clean election
250 /// loss on one shard ([`StoreError::NotOwner`]) drops only that shard rather
251 /// than failing the whole adoption batch (ADR-021 clean-partial).
252 ///
253 /// The default implementation is a deliberate no-op returning `Ok(())` —
254 /// single-shard / non-distributed backends own everything unconditionally and
255 /// elect nothing. Only a DISTRIBUTED sharded backend (haematite) overrides it.
256 /// Decorators that wrap another store must forward this call.
257 ///
258 /// # Errors
259 ///
260 /// Returns [`StoreError::NotOwner`] when a strictly higher ballot deposed this
261 /// candidate (a clean, droppable election loss), and [`StoreError::Backend`]
262 /// for a quorum-unavailable election or any transport fault (retryable).
263 fn acquire_owned_shard(&self, shard: usize) -> Result<(), StoreError> {
264 let _ = shard;
265 Ok(())
266 }
267
268 /// Whether this node currently holds LIVE serve-authority for `shard` — it won
269 /// the per-shard election THIS process lifetime and has not been deposed
270 /// in-process.
271 ///
272 /// This is the residual-window re-assertion the failover path uses to exclude
273 /// a survivor that lost its epoch between winning acquire+publish and widening
274 /// its enumeration scope (ADR-021 clean-partial). It is a POINT-IN-TIME
275 /// ADVISORY, not a durable lock — the authoritative gate remains the per-write
276 /// CAS fence.
277 ///
278 /// The default implementation returns `true` — single-shard / non-distributed
279 /// backends own everything unconditionally, so the failover path's
280 /// re-assertion is a no-op there and behaviour stays byte-identical. Only a
281 /// DISTRIBUTED sharded backend (haematite) overrides it. Decorators that wrap
282 /// another store must forward this call.
283 fn is_current_owner(&self, shard: usize) -> bool {
284 let _ = shard;
285 true
286 }
287
288 /// Add `shards` to this node's owned-enumeration scope, UNIONING them with
289 /// the shards it already owns rather than replacing the set.
290 ///
291 /// This is the SS-5 failover hook: when a live node absorbs a dead peer's
292 /// shards it must KEEP serving its own shards while ALSO enumerating the
293 /// adopted ones. [`Self::set_owned_shards`] replaces the scope (the boot
294 /// path's one-shot assignment); this widens it in place. The boot path uses
295 /// `set_owned_shards`; the failover path uses this.
296 ///
297 /// The default implementation is a deliberate no-op — single-shard backends
298 /// own everything unconditionally, so widening their scope is meaningless and
299 /// leaves their behaviour byte-identical. Only a sharded backend (haematite)
300 /// overrides this. Decorators that wrap another store must forward this call.
301 ///
302 /// When the store currently owns ALL shards (the `None` / single-node
303 /// default), it already enumerates `shards`, so a sharded backend leaves the
304 /// own-all scope untouched.
305 fn extend_owned_shards(&self, shards: &[usize]) {
306 let _ = shards;
307 }
308
309 /// Publish THIS node as the current owner of `shard` in the cluster's
310 /// shard-owner directory, so other nodes' request-routing edges resolve
311 /// `shard` to this node (SS-3).
312 ///
313 /// This is the failover-publish hook the engine calls from `adopt_shards`
314 /// right after it has won `shard`'s election: it records, durably and
315 /// cluster-visibly, that this node has adopted `shard`, so a request reaching
316 /// a DIFFERENT survivor routes to this adopter rather than mis-resolving to
317 /// the dead declared owner (gap #2).
318 ///
319 /// The default implementation is a deliberate no-op returning `Ok(())` —
320 /// single-shard / non-distributed backends own everything unconditionally and
321 /// have no peers to coordinate, so boot and adoption stay byte-identical. Only
322 /// a DISTRIBUTED sharded backend overrides this. Decorators that wrap another
323 /// store must forward this call.
324 ///
325 /// # Errors
326 ///
327 /// Returns [`StoreError::NotOwner`] when a distributed backend's fenced
328 /// directory write is out-voted (this node is not actually the owner), and
329 /// [`StoreError::Backend`] for any other replication/transport failure.
330 fn publish_shard_owner(&self, shard: usize) -> Result<(), StoreError> {
331 let _ = shard;
332 Ok(())
333 }
334}
335
336/// Write authority for appending workflow-history events.
337///
338/// `append` requires a [`WriteToken`], so having an `Arc<dyn EventStore>` or
339/// `Arc<dyn ReadableEventStore>` is not sufficient to write events.
340#[async_trait]
341pub trait WritableEventStore: Send + Sync + 'static {
342 /// Atomically appends `events` to `workflow_id` when the stored history head equals
343 /// `expected_seq`.
344 ///
345 /// Implementations must apply every event in `events` or none of them. If the current stored
346 /// head for `workflow_id` differs from `expected_seq`, this method must return
347 /// [`StoreError::SequenceConflict`] and leave history unchanged. A first append with
348 /// `expected_seq == 0` creates the workflow history implicitly.
349 async fn append(
350 &self,
351 token: WriteToken,
352 workflow_id: &WorkflowId,
353 events: &[Event],
354 expected_seq: u64,
355 ) -> Result<(), StoreError>;
356
357 /// Atomically appends `events` and the durable-outbox `outbox_rows` for `workflow_id` in a
358 /// single transaction, under the same expected-head sequence guard as [`Self::append`].
359 ///
360 /// This is the durable fan-out write: the `ActivityScheduled`/`ActivityStarted` scheduling
361 /// events and their matching outbox rows commit together or not at all. Atomicity is
362 /// load-bearing — a committed fan-out batch always carries both, or neither — so the out-of-band
363 /// dispatcher can never observe an outbox row whose scheduling events were rolled back, and a
364 /// re-issued append cannot leave events without their dispatch rows.
365 ///
366 /// # Default implementation (safe for outbox-unaware backends)
367 ///
368 /// The default delegates to [`Self::append`] when `outbox_rows` is empty (byte-for-byte
369 /// equivalent to an event-only append), and otherwise returns [`StoreError::Backend`] **rather
370 /// than silently dropping the outbox rows**. Dropping them would be the dangerous failure mode:
371 /// the events would commit, the workflow would believe its fan-out is durably staged, and the
372 /// rows would never be dispatched. A hard error forces a backend to opt in to durable-outbox
373 /// support by overriding this method (as the haematite store does) before any caller can route a
374 /// fan-out batch through it.
375 ///
376 /// # Errors
377 ///
378 /// Returns [`StoreError::SequenceConflict`] when the stored head differs from `expected_seq`,
379 /// [`StoreError::Serialization`] when an event or outbox payload cannot be serialized, and
380 /// [`StoreError::Backend`] for backend boundary failures or when an outbox-unaware backend is
381 /// asked to persist a non-empty `outbox_rows` slice.
382 async fn append_with_outbox(
383 &self,
384 token: WriteToken,
385 workflow_id: &WorkflowId,
386 events: &[Event],
387 expected_seq: u64,
388 outbox_rows: &[OutboxRow],
389 ) -> Result<(), StoreError> {
390 if outbox_rows.is_empty() {
391 return self.append(token, workflow_id, events, expected_seq).await;
392 }
393 Err(StoreError::Backend(String::from(
394 "this event store does not support durable-outbox appends; \
395 refusing to drop outbox rows (override WritableEventStore::append_with_outbox)",
396 )))
397 }
398
399 /// Returns the outbox rows for `rows`' `dispatch_key`s to `Pending`, re-staging them for the
400 /// out-of-band dispatcher.
401 ///
402 /// This is the crash-recovery re-arm: on first arrival after a restart, an activity whose
403 /// `ActivityScheduled` is recorded but which has no terminal event lost its in-flight dispatch
404 /// when the previous engine process died. Under the durable-outbox model the recovering workflow
405 /// re-stages the dispatch by flipping its outbox row back to claimable `Pending` (an UPSERT — a
406 /// brand-new `dispatch_key` with no prior row is inserted as `Pending`) instead of driving an
407 /// in-process completion task. Redelivery is safe: the completion dedup
408 /// (`record_fan_out_completion`) ignores a terminal for an already-resolved ordinal, so re-arm is
409 /// at-least-once.
410 ///
411 /// The dispatch retry budget is preserved across re-arm: a backend must NOT reset an existing
412 /// row's `attempt` to zero, so a workflow that reliably crashes the server still eventually
413 /// dead-letters rather than re-dispatching forever.
414 ///
415 /// # Default implementation (safe for outbox-unaware backends)
416 ///
417 /// An empty `rows` slice is `Ok(())`. A non-empty slice returns [`StoreError::Backend`] **rather
418 /// than silently no-op'ing the re-arm**: a store without durable-outbox support cannot re-stage a
419 /// dispatch, and silently dropping the request would strand the recovered activity. A hard error
420 /// forces a backend to opt in (as the haematite store does) before any caller can route a re-arm
421 /// through it.
422 ///
423 /// # Errors
424 ///
425 /// Returns [`StoreError::Serialization`] when an outbox payload cannot be serialized, and
426 /// [`StoreError::Backend`] for backend boundary failures or when an outbox-unaware backend is
427 /// asked to re-arm a non-empty `rows` slice.
428 async fn rearm_outbox_pending(&self, rows: &[OutboxRow]) -> Result<(), StoreError> {
429 if rows.is_empty() {
430 return Ok(());
431 }
432 Err(StoreError::Backend(String::from(
433 "this event store does not support durable-outbox re-arm; \
434 refusing to drop a non-empty re-arm (override WritableEventStore::rearm_outbox_pending)",
435 )))
436 }
437
438 /// Idempotently settles one outbox row to cancelled when this writer is backed by an outbox.
439 ///
440 /// Outbox-aware backends override this and delegate to [`crate::OutboxStore`]. The default is a
441 /// no-op so non-outbox test stores and legacy backends can still record `ActivityCancelled`
442 /// history without requiring an outbox table.
443 ///
444 /// # Errors
445 ///
446 /// Outbox-aware overrides return [`StoreError::Backend`] for backend boundary failures.
447 async fn settle_outbox_row_cancelled(&self, dispatch_key: &str) -> Result<(), StoreError> {
448 let _ = dispatch_key;
449 Ok(())
450 }
451
452 /// Idempotently settles EVERY live ([`crate::OutboxStatus::Pending`] or
453 /// [`crate::OutboxStatus::Claimed`]) outbox row of `workflow_id` to
454 /// [`crate::OutboxStatus::Cancelled`], returning the settled `dispatch_key`s (#253).
455 ///
456 /// This is the workflow-terminal settle the Recorder runs after durably recording a workflow
457 /// terminal (`WorkflowCompleted`/`WorkflowFailed`/`WorkflowCancelled`): a terminal workflow's
458 /// staged dispatches must never be redelivered, so its live rows are retired to the terminal
459 /// `Cancelled` disposition that re-arm and claim contractually never touch. Rows already in
460 /// `Done`/`Failed`/`Cancelled` are left untouched, so the settle is idempotent. Reopen still
461 /// supersedes it: [`Self::rearm_outbox_pending`] forcibly returns any existing row — including a
462 /// `Cancelled` one — to `Pending`, so a reopened workflow's re-dispatches deliver again.
463 ///
464 /// The default is a no-op returning no settled keys, mirroring
465 /// [`Self::settle_outbox_row_cancelled`], so non-outbox test stores and legacy backends record
466 /// workflow terminals without requiring an outbox table. Outbox-aware backends override it and
467 /// share the implementation with [`crate::OutboxStore::cancel_outbox_rows_for_workflow`].
468 ///
469 /// # Errors
470 ///
471 /// Outbox-aware overrides return [`StoreError::Backend`] for backend boundary failures and
472 /// [`StoreError::Serialization`] when a stored row cannot be decoded.
473 async fn settle_workflow_outbox_rows_cancelled(
474 &self,
475 workflow_id: &WorkflowId,
476 ) -> Result<Vec<String>, StoreError> {
477 let _ = workflow_id;
478 Ok(Vec::new())
479 }
480}
481
482/// Convenience trait for concrete stores that support reads/timers, recorder
483/// writes, and deployed-package persistence.
484///
485/// [`crate::PackageStore`] is part of the contract, not an optional add-on:
486/// runtime-deployed packages share the durability promise of event history
487/// (a recovered run is pinned to a recorded package version, and a backend
488/// that dropped the archive would strand it).
489pub trait EventStore: ReadableEventStore + WritableEventStore + crate::PackageStore {}
490
491impl<T> EventStore for T where
492 T: ReadableEventStore + WritableEventStore + crate::PackageStore + ?Sized
493{
494}
495
496pub(crate) fn conformance_write_token() -> WriteToken {
497 write_capability::conformance()
498}
499
500#[cfg(test)]
501mod tests {
502 use std::sync::Arc;
503
504 use super::{EventStore, ReadableEventStore, WritableEventStore};
505
506 #[test]
507 fn event_store_traits_are_object_safe() {
508 let _: Option<Arc<dyn ReadableEventStore>> = None;
509 let _: Option<Arc<dyn WritableEventStore>> = None;
510 let _: Option<Arc<dyn EventStore>> = None;
511 }
512}