adk-core 3.0.0

Core traits and types for Rust Agent Development Kit (ADK-Rust) agents, tools, sessions, and events
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
//! Conformance suites for the durable stores behind safe actions and the durable runtime.
//!
//! Every store backend — the in-memory ones here, the SQL, Redis, MongoDB, Neo4j, and
//! Firestore ones in `adk-session`, and any third-party one — proves its contract by
//! running the same suite:
//!
//! | Store | Harness | Test macro | Cases |
//! |-------|---------|------------|-------|
//! | [`SpendLedger`](crate::SpendLedger) | [`SpendLedgerHarness`](crate::conformance::SpendLedgerHarness) | [`spend_ledger_conformance_tests!`](crate::spend_ledger_conformance_tests) | [`spend_ledger`](crate::conformance::spend_ledger) |
//! | [`ActionLedger`](crate::ActionLedger) | [`ActionLedgerHarness`](crate::conformance::ActionLedgerHarness) | [`action_ledger_conformance_tests!`](crate::action_ledger_conformance_tests) | [`action_ledger`](crate::conformance::action_ledger) |
//! | [`ApprovalStore`](crate::ApprovalStore) | [`ApprovalStoreHarness`](crate::conformance::ApprovalStoreHarness) | [`approval_store_conformance_tests!`](crate::approval_store_conformance_tests) | [`approval_store`](crate::conformance::approval_store) |
//! | [`StoreApprovalService`](crate::StoreApprovalService) over an [`ApprovalStore`](crate::ApprovalStore) | [`ApprovalStoreHarness`](crate::conformance::ApprovalStoreHarness) | [`approval_service_conformance_tests!`](crate::approval_service_conformance_tests) | [`approval_service`](crate::conformance::approval_service) |
//! | [`LeaseStore`](crate::LeaseStore) | [`LeaseStoreHarness`](crate::conformance::LeaseStoreHarness) | [`lease_store_conformance_tests!`](crate::lease_store_conformance_tests) | [`lease_store`](crate::conformance::lease_store) |
//! | [`DurableRunStore`](crate::DurableRunStore) | [`RunStoreHarness`](crate::conformance::RunStoreHarness) | [`run_store_conformance_tests!`](crate::run_store_conformance_tests) | [`run_store`](crate::conformance::run_store) |
//! | [`ScheduleStore`](crate::ScheduleStore) | [`ScheduleStoreHarness`](crate::conformance::ScheduleStoreHarness) | [`schedule_store_conformance_tests!`](crate::schedule_store_conformance_tests) | [`schedule_store`](crate::conformance::schedule_store) |
//! | [`GovernanceStateStore`](crate::GovernanceStateStore) | [`GovernanceStateStoreHarness`](crate::conformance::GovernanceStateStoreHarness) | [`governance_state_store_conformance_tests!`](crate::governance_state_store_conformance_tests) | [`governance_state_store`](crate::conformance::governance_state_store) |
//! | [`QueueSource`](crate::QueueSource) | [`QueueSourceHarness`](crate::conformance::QueueSourceHarness) | [`queue_source_conformance_tests!`](crate::queue_source_conformance_tests) | [`queue_source`](crate::conformance::queue_source) |
//! | [`AuditLogStore`](crate::audit_log::AuditLogStore) | [`AuditLogStoreHarness`](crate::conformance::AuditLogStoreHarness) | [`audit_log_store_conformance_tests!`](crate::audit_log_store_conformance_tests) | [`audit_log_store`](crate::conformance::audit_log_store) |
//! | [`SubjectRegistry`](crate::subject::SubjectRegistry) | [`SubjectRegistryHarness`](crate::conformance::SubjectRegistryHarness) | [`subject_registry_conformance_tests!`](crate::subject_registry_conformance_tests) | [`subject_registry`](crate::conformance::subject_registry) |
//! | [`ConsentStore`](crate::subject::ConsentStore) | [`ConsentStoreHarness`](crate::conformance::ConsentStoreHarness) | [`consent_store_conformance_tests!`](crate::consent_store_conformance_tests) | [`consent_store`](crate::conformance::consent_store) |
//! | [`SubjectDataStore`](crate::subject::SubjectDataStore) adapters | [`SubjectDataStoreHarness`](crate::conformance::SubjectDataStoreHarness) | [`subject_data_store_conformance_tests!`](crate::subject_data_store_conformance_tests) | [`subject_data_store`](crate::conformance::subject_data_store) |
//!
//! The harnesses of time-dependent stores receive the [`Clock`](crate::Clock) to read,
//! and the suites drive it as a [`ManualClock`](crate::ManualClock), so lease expiry,
//! delays, and timers are checked without waiting.
//!
//! A harness opens the backend. Each call to `open` returns a new handle over the same
//! data, as a process restart or a second process would, so the suite can check that
//! records survive a restart and that two handles never overspend or double-execute.
//! Each case writes under fresh identifiers, so a harness may point every case at one
//! shared database.
//!
//! The macros expand to one `#[tokio::test]` per case on a multi-threaded runtime, so
//! the calling crate needs `tokio` with the `macros` and `rt-multi-thread` features.
//! Attributes written before `harness =` are applied to every generated test, which is
//! how a live-database suite is marked `#[ignore]`.
//!
//! Enable the `conformance` feature of `adk-core` in `[dev-dependencies]`.
//!
//! # Example
//!
//! ```rust,ignore
//! use std::sync::Arc;
//! use adk_core::conformance::{SpendLedgerHarness, SpendLedgerSetup};
//! use adk_core::{SpendLedger, async_trait};
//!
//! struct MyHarness { url: String }
//!
//! #[async_trait]
//! impl SpendLedgerHarness for MyHarness {
//!     async fn open(&self, setup: SpendLedgerSetup) -> Arc<dyn SpendLedger> {
//!         Arc::new(
//!             MyLedger::connect(&self.url).await.unwrap()
//!                 .with_limits(setup.limits)
//!                 .with_reservation_ttl(setup.reservation_ttl)
//!                 .with_clock(setup.clock),
//!         )
//!     }
//! }
//!
//! adk_core::spend_ledger_conformance_tests! {
//!     #[ignore = "requires a server at MY_URL"]
//!     harness = MyHarness { url: std::env::var("MY_URL").unwrap() },
//! }
//! ```

pub mod action_ledger;
pub mod approval_service;
pub mod approval_store;
pub mod audit_log_store;
pub mod consent_store;
pub mod governance_state_store;
pub mod lease_store;
pub mod queue_source;
pub mod run_store;
pub mod schedule_store;
pub mod spend_ledger;
pub mod subject_data_store;
pub mod subject_registry;

pub use action_ledger::ActionLedgerHarness;
pub use approval_store::ApprovalStoreHarness;
pub use audit_log_store::AuditLogStoreHarness;
pub use consent_store::ConsentStoreHarness;
pub use governance_state_store::GovernanceStateStoreHarness;
pub use lease_store::LeaseStoreHarness;
pub use queue_source::QueueSourceHarness;
pub use run_store::RunStoreHarness;
pub use schedule_store::ScheduleStoreHarness;
pub use spend_ledger::{SpendLedgerHarness, SpendLedgerSetup};
pub use subject_data_store::SubjectDataStoreHarness;
pub use subject_registry::SubjectRegistryHarness;

/// Returns an identifier no other case or run uses. It contains `:` and `/` so a
/// backend that builds keys or paths from identifiers is checked for escaping.
fn unique(prefix: &str) -> String {
    format!("conformance:{prefix}/{}", uuid::Uuid::new_v4())
}

/// Like [`unique`], with non-ASCII characters as well, so a backend that builds keys,
/// paths, or document ids from identifiers is checked for escaping beyond ASCII.
fn unique_unicode(prefix: &str) -> String {
    format!("conformance:{prefix}/ü-日本/{}", uuid::Uuid::new_v4())
}

/// A fixed whole-second instant, so stores that round timestamps read them back unchanged.
fn base_time() -> chrono::DateTime<chrono::Utc> {
    use chrono::TimeZone;
    chrono::Utc.with_ymd_and_hms(2026, 10, 15, 12, 0, 0).single().expect("valid instant")
}

/// Generates one test per [`spend_ledger`] case for a [`SpendLedgerHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! spend_ledger_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn spend_reserve_commit_release_accounting() {
            $crate::conformance::spend_ledger::reserve_commit_release_accounting(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn spend_settles_each_reservation_once() {
            $crate::conformance::spend_ledger::settles_each_reservation_once(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn spend_limits_apply_per_key() {
            $crate::conformance::spend_ledger::limits_apply_per_key(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn spend_periods_roll_over_at_utc_boundaries() {
            $crate::conformance::spend_ledger::periods_roll_over_at_utc_boundaries(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn spend_expired_reservations_stop_holding_budget() {
            $crate::conformance::spend_ledger::expired_reservations_stop_holding_budget(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn spend_concurrent_reservations_never_exceed_a_cap() {
            $crate::conformance::spend_ledger::concurrent_reservations_never_exceed_a_cap(
                &$harness,
            )
            .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn spend_reservations_survive_a_restart() {
            $crate::conformance::spend_ledger::reservations_survive_a_restart(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn spend_unbounded_holds_need_an_uncapped_key() {
            $crate::conformance::spend_ledger::unbounded_holds_need_an_uncapped_key(&$harness)
                .await;
        }
    };
}

/// Generates one test per [`action_ledger`] case for an [`ActionLedgerHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! action_ledger_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn action_begin_complete_round_trip() {
            $crate::conformance::action_ledger::begin_complete_round_trip(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn action_recorded_call_is_answered_without_executing() {
            $crate::conformance::action_ledger::recorded_call_is_answered_without_executing(
                &$harness,
            )
            .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn action_incomplete_call_is_outcome_unknown_after_restart() {
            $crate::conformance::action_ledger::incomplete_call_is_outcome_unknown_after_restart(
                &$harness,
            )
            .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn action_concurrent_begin_has_one_winner() {
            $crate::conformance::action_ledger::concurrent_begin_has_one_winner(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn action_outcomes_are_write_once() {
            $crate::conformance::action_ledger::outcomes_are_write_once(&$harness).await;
        }
    };
}

/// Generates one test per [`approval_store`] case for an [`ApprovalStoreHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! approval_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_pending_requests_are_kept_once_oldest_first() {
            $crate::conformance::approval_store::pending_requests_are_kept_once_oldest_first(
                &$harness,
            )
            .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_decision_is_consumed_once() {
            $crate::conformance::approval_store::decision_is_consumed_once(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_later_decision_replaces_earlier() {
            $crate::conformance::approval_store::later_decision_replaces_earlier(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_expired_decisions_are_discarded() {
            $crate::conformance::approval_store::expired_decisions_are_discarded(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_decisions_stay_in_their_scope() {
            $crate::conformance::approval_store::decisions_stay_in_their_scope(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_decisions_stay_with_their_agent_and_tool() {
            $crate::conformance::approval_store::decisions_stay_with_their_agent_and_tool(
                &$harness,
            )
            .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_concurrent_take_has_one_winner() {
            $crate::conformance::approval_store::concurrent_take_has_one_winner(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_records_survive_a_restart() {
            $crate::conformance::approval_store::records_survive_a_restart(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_decisions_carry_edits_and_messages() {
            $crate::conformance::approval_store::decisions_carry_edits_and_messages(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_requests_are_created_once() {
            $crate::conformance::approval_store::requests_are_created_once(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_concurrent_replace_has_one_winner() {
            $crate::conformance::approval_store::concurrent_replace_has_one_winner(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_requests_list_in_order_with_filters() {
            $crate::conformance::approval_store::requests_list_in_order_with_filters(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_requests_list_by_session() {
            $crate::conformance::approval_store::requests_list_by_session(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_delegations_round_trip() {
            $crate::conformance::approval_store::delegations_round_trip(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_requests_survive_a_restart() {
            $crate::conformance::approval_store::approval_requests_survive_a_restart(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_evidence_round_trips() {
            $crate::conformance::approval_store::evidence_round_trips(&$harness).await;
        }
    };
}

/// Generates one test per [`approval_service`] case for an [`ApprovalStoreHarness`]:
/// the [`StoreApprovalService`](crate::StoreApprovalService) over the harness's store.
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! approval_service_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_expiry_denies_the_call() {
            $crate::conformance::approval_service::expiry_denies_the_call(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_quorum_needs_distinct_approvers() {
            $crate::conformance::approval_service::quorum_needs_distinct_approvers(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_self_approval_is_refused() {
            $crate::conformance::approval_service::self_approval_is_refused(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_delegation_applies_only_in_its_window() {
            $crate::conformance::approval_service::delegation_applies_only_in_its_window(
                &$harness,
            )
            .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_concurrent_decide_has_one_winner() {
            $crate::conformance::approval_service::concurrent_decide_has_one_winner(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_edit_substitutes_arguments() {
            $crate::conformance::approval_service::edit_substitutes_arguments(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_escalation_fires_once() {
            $crate::conformance::approval_service::escalation_fires_once(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_inbox_lists_what_an_approver_may_decide() {
            $crate::conformance::approval_service::inbox_lists_what_an_approver_may_decide(
                &$harness,
            )
            .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_inbox_lists_one_session() {
            $crate::conformance::approval_service::inbox_lists_one_session(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_a_call_held_again_keeps_its_open_request() {
            $crate::conformance::approval_service::a_call_held_again_keeps_its_open_request(
                &$harness,
            )
            .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_cancel_and_reject_deny_the_call() {
            $crate::conformance::approval_service::cancel_and_reject_deny_the_call(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_requests_survive_a_restart() {
            $crate::conformance::approval_service::requests_survive_a_restart(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_slots_need_distinct_approvers() {
            $crate::conformance::approval_service::slots_need_distinct_approvers(&$harness)
                .await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn approval_service_directory_decides_groups() {
            $crate::conformance::approval_service::directory_decides_groups(&$harness).await;
        }
    };
}

/// Generates one test per [`lease_store`] case for a [`LeaseStoreHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! lease_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn lease_acquire_renew_release() {
            $crate::conformance::lease_store::acquire_renew_release(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn lease_concurrent_acquire_has_one_winner() {
            $crate::conformance::lease_store::concurrent_acquire_has_one_winner(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn lease_expiry_takeover_bumps_epoch() {
            $crate::conformance::lease_store::expiry_takeover_bumps_epoch(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn lease_stale_renew_and_release_are_refused() {
            $crate::conformance::lease_store::stale_renew_and_release_are_refused(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn lease_leases_survive_a_restart() {
            $crate::conformance::lease_store::leases_survive_a_restart(&$harness).await;
        }
    };
}

/// Generates one test per [`run_store`] case for a [`RunStoreHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! run_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_enqueue_claim_finish_round_trip() {
            $crate::conformance::run_store::enqueue_claim_finish_round_trip(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_idempotent_enqueue_under_concurrency() {
            $crate::conformance::run_store::idempotent_enqueue_under_concurrency(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_on_conflict_policies() {
            $crate::conformance::run_store::on_conflict_policies(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_concurrent_claims_have_one_winner() {
            $crate::conformance::run_store::concurrent_claims_have_one_winner(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_not_before_is_respected() {
            $crate::conformance::run_store::not_before_is_respected(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_expired_lease_recovery() {
            $crate::conformance::run_store::expired_lease_recovery(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_stale_epoch_writes_are_refused() {
            $crate::conformance::run_store::stale_epoch_writes_are_refused(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_retryable_failure_requeues_until_max_attempts() {
            $crate::conformance::run_store::retryable_failure_requeues_until_max_attempts(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_wait_and_wake() {
            $crate::conformance::run_store::wait_and_wake(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_parked_run_keeps_its_checkpoint() {
            $crate::conformance::run_store::parked_run_keeps_its_checkpoint(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_freeze_parked_runs_wake_only_when_woken() {
            $crate::conformance::run_store::freeze_parked_runs_wake_only_when_woken(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_cancel_is_visible_through_heartbeat() {
            $crate::conformance::run_store::cancel_is_visible_through_heartbeat(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_prune_removes_old_finished_runs() {
            $crate::conformance::run_store::prune_removes_old_finished_runs(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn run_runs_survive_a_restart() {
            $crate::conformance::run_store::runs_survive_a_restart(&$harness).await;
        }
    };
}

/// Generates one test per [`schedule_store`] case for a [`ScheduleStoreHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! schedule_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn schedule_upsert_is_idempotent() {
            $crate::conformance::schedule_store::upsert_is_idempotent(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn schedule_due_orders_by_fire_time() {
            $crate::conformance::schedule_store::due_orders_by_fire_time(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn schedule_advance_has_one_winner() {
            $crate::conformance::schedule_store::advance_has_one_winner(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn schedule_paused_schedules_are_not_due() {
            $crate::conformance::schedule_store::paused_schedules_are_not_due(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn schedule_schedules_survive_a_restart() {
            $crate::conformance::schedule_store::schedules_survive_a_restart(&$harness).await;
        }
    };
}

/// Generates one test per [`governance_state_store`] case for a [`GovernanceStateStoreHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! governance_state_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn governance_set_get_list_round_trip() {
            $crate::conformance::governance_state_store::set_get_list_round_trip(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn governance_concurrent_set_has_one_winner() {
            $crate::conformance::governance_state_store::concurrent_set_has_one_winner(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn governance_scopes_are_independent() {
            $crate::conformance::governance_state_store::scopes_are_independent(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn governance_states_survive_a_restart() {
            $crate::conformance::governance_state_store::states_survive_a_restart(&$harness).await;
        }
    };
}

/// Generates one test per [`audit_log_store`] case for an [`AuditLogStoreHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! audit_log_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_append_assigns_contiguous_sequences() {
            $crate::conformance::audit_log_store::append_assigns_contiguous_sequences(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_append_refuses_a_wrong_start() {
            $crate::conformance::audit_log_store::append_refuses_a_wrong_start(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_append_refuses_invalid_batches() {
            $crate::conformance::audit_log_store::append_refuses_invalid_batches(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_concurrent_appends_have_one_winner() {
            $crate::conformance::audit_log_store::concurrent_appends_have_one_winner(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_logs_are_independent() {
            $crate::conformance::audit_log_store::logs_are_independent(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_logs_sort_by_bytes() {
            $crate::conformance::audit_log_store::logs_sort_by_bytes(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_hash_at_returns_leaves_and_nodes() {
            $crate::conformance::audit_log_store::hash_at_returns_leaves_and_nodes(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_reads_past_the_end_fail() {
            $crate::conformance::audit_log_store::reads_past_the_end_fail(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_checkpoints_never_fork() {
            $crate::conformance::audit_log_store::checkpoints_never_fork(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_prune_keeps_hashes() {
            $crate::conformance::audit_log_store::prune_keeps_hashes(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_redaction_keeps_hashes() {
            $crate::conformance::audit_log_store::redaction_keeps_hashes(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn audit_log_logs_survive_a_restart() {
            $crate::conformance::audit_log_store::logs_survive_a_restart(&$harness).await;
        }
    };
}

/// Generates one test per [`queue_source`] case for a [`QueueSourceHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! queue_source_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn queue_pull_leases_and_ack_removes() {
            $crate::conformance::queue_source::pull_leases_and_ack_removes(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn queue_nack_redelivers_with_a_new_receipt() {
            $crate::conformance::queue_source::nack_redelivers_with_a_new_receipt(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn queue_lapsed_lease_redelivers() {
            $crate::conformance::queue_source::lapsed_lease_redelivers(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn queue_pull_respects_the_batch_size() {
            $crate::conformance::queue_source::pull_respects_the_batch_size(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn queue_duplicate_publishes_are_both_delivered() {
            $crate::conformance::queue_source::duplicate_publishes_are_both_delivered(&$harness)
                .await;
        }
    };
}

/// Generates one test per [`subject_registry`] case for a [`SubjectRegistryHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! subject_registry_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn registry_ensure_registers_once() {
            $crate::conformance::subject_registry::ensure_registers_once(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn registry_concurrent_ensure_has_one_pseudonym() {
            $crate::conformance::subject_registry::concurrent_ensure_has_one_pseudonym(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn registry_pseudonyms_resolve() {
            $crate::conformance::subject_registry::pseudonyms_resolve(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn registry_links_once_per_visitor() {
            $crate::conformance::subject_registry::links_once_per_visitor(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn registry_concurrent_links_have_one_winner() {
            $crate::conformance::subject_registry::concurrent_links_have_one_winner(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn registry_erasing_blocks_links() {
            $crate::conformance::subject_registry::erasing_blocks_links(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn registry_remove_forgets_the_subject() {
            $crate::conformance::subject_registry::remove_forgets_the_subject(&$harness).await;
        }
    };
}

/// Generates one test per [`consent_store`] case for a [`ConsentStoreHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! consent_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn consent_grant_get_round_trip() {
            $crate::conformance::consent_store::grant_get_round_trip(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn consent_records_are_per_subject() {
            $crate::conformance::consent_store::records_are_per_subject(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn consent_revocation_keeps_the_first_time() {
            $crate::conformance::consent_store::revocation_keeps_the_first_time(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn consent_revoke_purpose_revokes_live_records() {
            $crate::conformance::consent_store::revoke_purpose_revokes_live_records(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn consent_live_respects_expiry_and_revocation() {
            $crate::conformance::consent_store::live_respects_expiry_and_revocation(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn consent_erase_removes_one_subject() {
            $crate::conformance::consent_store::erase_removes_one_subject(&$harness).await;
        }
    };
}

/// Generates one test per [`subject_data_store`] case for a [`SubjectDataStoreHarness`].
///
/// See the [module documentation](crate::conformance) for an example.
#[macro_export]
macro_rules! subject_data_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn subject_data_export_returns_only_the_subject() {
            $crate::conformance::subject_data_store::export_returns_only_the_subject(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn subject_data_erase_removes_only_the_subject() {
            $crate::conformance::subject_data_store::erase_removes_only_the_subject(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn subject_data_erase_is_idempotent() {
            $crate::conformance::subject_data_store::erase_is_idempotent(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn subject_data_erase_covers_linked_ids() {
            $crate::conformance::subject_data_store::erase_covers_linked_ids(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn subject_data_erase_stays_in_its_applications() {
            $crate::conformance::subject_data_store::erase_stays_in_its_applications(&$harness).await;
        }
    };
}