adk-kernel 3.0.0

Agent kernel for ADK-Rust: a resident supervisor with a process model, wake sources, an event bus and a control plane over durable runs
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
//! Conformance cases for [`DeviceStore`] backends (spec 3.3 §10 K2, §11 S-I7).
//!
//! | Case | Contract |
//! |------|----------|
//! | [`code_round_trip_and_take_once`] | A code reads back exactly as put, once: a second take finds nothing |
//! | [`take_returns_expired_codes`] | A take returns a code past its expiry; the caller decides |
//! | [`prune_removes_expired_codes`] | `prune_codes` removes the codes expired at or before the instant, and only those |
//! | [`clear_removes_every_code`] | `clear_codes` removes every waiting code |
//! | [`device_round_trip`] | A device reads back exactly as put: every field, every scope |
//! | [`put_device_replaces`] | A second put of one device replaces it, as a revocation does |
//! | [`list_devices_orders_by_pairing_then_id`] | `list_devices` orders by pairing time, then id |
//! | [`unknown_ids`] | An unknown device and an unknown code are `None` |
//! | [`records_survive_a_restart`] | Devices and codes read back through a new handle (durable backends only) |
//! | [`concurrent_takes_take_once`] | Eight concurrent takes of one code from two handles take it once |
//! | [`concurrent_writers`] | Concurrent puts from two handles over distinct devices and codes lose none |
//! | [`claim_attempts_are_counted_once_and_shared`] | Concurrent claim counts from two handles each get a distinct count, a reset starts again at one, and the count survives a restart |
//! | [`attachments_round_trip_per_kind`] | An attachment reads back exactly as put, listed under its holder and kind only, in key order |
//! | [`put_attachment_replaces`] | A second put of one holder, kind and key replaces it |
//! | [`put_attachment_if_absent_writes_once`] | Eight concurrent puts-if-absent of one attachment from two handles write it once |
//! | [`remove_attachment_removes_one`] | Removing one attachment says whether it was there and leaves the rest |
//! | [`remove_attachments_removes_the_holders`] | Removing a holder's attachments removes every kind of it and nothing of another holder |
//! | [`attachments_survive_a_restart`] | Attachments read back through a new handle (durable backends only) |
//!
//! Every case writes under fresh ids and hashes, so a harness may point every case at one
//! shared database, except [`clear_removes_every_code`], which removes every code, and
//! [`claim_attempts_are_counted_once_and_shared`], which uses the one count of claims: give
//! each a database of its own, as the harnesses of this crate give every case.

use std::sync::Arc;
use std::time::Duration;

use async_trait::async_trait;
use chrono::{DateTime, TimeZone, Utc};

use crate::pairing::{
    AttachmentHolder, DeviceAttachment, DeviceKind, DeviceRecord, DeviceScope, DeviceStore,
    PairingCode,
};

/// Opens a [`DeviceStore`] backend for the conformance suite.
///
/// # Example
///
/// ```rust
/// use std::sync::Arc;
/// use adk_kernel::conformance::DeviceStoreHarness;
/// use adk_kernel::pairing::{DeviceStore, InMemoryDeviceStore};
///
/// struct InMemory;
///
/// #[async_trait::async_trait]
/// impl DeviceStoreHarness for InMemory {
///     async fn open(&self) -> Arc<dyn DeviceStore> {
///         Arc::new(InMemoryDeviceStore::new())
///     }
///
///     fn is_durable(&self) -> bool {
///         false
///     }
/// }
/// ```
#[async_trait]
pub trait DeviceStoreHarness: Send + Sync {
    /// Opens a store. For a durable backend every call returns a new handle over the same
    /// stored data. Panics when the backend cannot be opened.
    async fn open(&self) -> Arc<dyn DeviceStore>;

    /// Whether data written through one handle is visible through the next.
    fn is_durable(&self) -> bool {
        true
    }
}

/// Two handles over one store: two opens of a durable backend, one store twice otherwise.
async fn two(harness: &dyn DeviceStoreHarness) -> [Arc<dyn DeviceStore>; 2] {
    if harness.is_durable() {
        [harness.open().await, harness.open().await]
    } else {
        let store = harness.open().await;
        [store.clone(), store]
    }
}

/// A fresh hex id, as the pairing service makes them.
fn fresh() -> String {
    uuid::Uuid::new_v4().simple().to_string()
}

/// An instant with microseconds, so a backend that rounds timestamps is caught.
fn instant(seconds: i64) -> DateTime<Utc> {
    Utc.timestamp_opt(1_800_000_000 + seconds, 123_456_000).single().expect("valid instant")
}

fn code(owner: &str, expires: i64) -> PairingCode {
    let mut code = PairingCode::new(
        fresh(),
        owner,
        Duration::from_secs(90 * 86_400),
        instant(0),
        instant(expires),
    );
    code.groups = vec!["operator".into(), "on-call/日本".into()];
    code.scopes = vec![DeviceScope::Decide, DeviceScope::Stop];
    code.name = Some("Ana's phone \u{1F4F1}".into());
    code.kind = Some(DeviceKind::Tray);
    code
}

fn device(created: i64) -> DeviceRecord {
    DeviceRecord::new(
        fresh(),
        "Ana's \"phone\" 日本",
        "user/ü",
        fresh(),
        instant(created),
        instant(created + 86_400),
    )
    .with_scopes([DeviceScope::Read, DeviceScope::Decide])
    .with_groups(["operator"])
    .with_kind(DeviceKind::Phone)
}

/// An attachment of `holder` with a record that has nested JSON and text outside ASCII.
fn attachment(holder: &AttachmentHolder, kind: &str, key: &str, at: i64) -> DeviceAttachment {
    DeviceAttachment::new(
        holder.clone(),
        kind,
        key,
        serde_json::json!({ "endpoint": format!("https://web.push.apple.com/{key}"), "keys": { "auth": "日本" }, "at": at }),
        instant(at),
    )
}

/// An attachment reads back exactly as put, listed under its holder and kind only, in key
/// order.
pub async fn attachments_round_trip_per_kind(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let phone = AttachmentHolder::Device(fresh());
    let person = AttachmentHolder::User(format!("user/ü {}", fresh()));
    let push = attachment(&phone, "push", "subscription", 1);
    let b = attachment(&phone, "wake", "b:1", 2);
    let a = attachment(&phone, "wake", "a:1", 3);
    let theirs = attachment(&person, "push", "subscription", 4);
    for row in [&push, &b, &a, &theirs] {
        store.put_attachment(row.clone()).await.expect("put");
    }
    assert_eq!(store.attachments(&phone, "push").await.expect("list"), vec![push]);
    assert_eq!(store.attachments(&phone, "wake").await.expect("list"), vec![a, b]);
    assert_eq!(store.attachments(&person, "push").await.expect("list"), vec![theirs]);
    assert_eq!(store.attachments(&phone, "passkey").await.expect("list"), vec![]);
}

/// A second put of one holder, kind and key replaces it.
pub async fn put_attachment_replaces(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let phone = AttachmentHolder::Device(fresh());
    store.put_attachment(attachment(&phone, "passkey", "only", 1)).await.expect("put");
    let replaced = attachment(&phone, "passkey", "only", 2);
    store.put_attachment(replaced.clone()).await.expect("put again");
    assert_eq!(store.attachments(&phone, "passkey").await.expect("list"), vec![replaced]);
}

/// Eight concurrent puts-if-absent of one attachment from two handles write it once.
pub async fn put_attachment_if_absent_writes_once(harness: &dyn DeviceStoreHarness) {
    let [first, second] = two(harness).await;
    let phone = AttachmentHolder::Device(fresh());
    let tasks: Vec<_> = (0..8)
        .map(|index| {
            let store = if index % 2 == 0 { first.clone() } else { second.clone() };
            let row = attachment(&phone, "wake", "apr-1:3", index);
            tokio::spawn(async move { store.put_attachment_if_absent(row).await.expect("put") })
        })
        .collect();
    let mut wrote = 0;
    for task in tasks {
        if task.await.expect("join") {
            wrote += 1;
        }
    }
    assert_eq!(wrote, 1, "one of eight puts wrote");
    assert_eq!(first.attachments(&phone, "wake").await.expect("list").len(), 1);
    assert!(
        !second
            .put_attachment_if_absent(attachment(&phone, "wake", "apr-1:3", 9))
            .await
            .expect("put")
    );
}

/// Removing one attachment says whether it was there and leaves the rest.
pub async fn remove_attachment_removes_one(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let phone = AttachmentHolder::Device(fresh());
    let kept = attachment(&phone, "push", "kept", 1);
    store.put_attachment(attachment(&phone, "push", "gone", 0)).await.expect("put");
    store.put_attachment(kept.clone()).await.expect("put");
    assert!(store.remove_attachment(&phone, "push", "gone").await.expect("remove"));
    assert!(!store.remove_attachment(&phone, "push", "gone").await.expect("remove again"));
    assert_eq!(store.attachments(&phone, "push").await.expect("list"), vec![kept]);
}

/// Removing a holder's attachments removes every kind of it and nothing of another holder.
pub async fn remove_attachments_removes_the_holders(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let phone = AttachmentHolder::Device(fresh());
    let other = AttachmentHolder::Device(fresh());
    for (kind, key) in [("push", "subscription"), ("passkey", "only"), ("wake", "a:1")] {
        store.put_attachment(attachment(&phone, kind, key, 1)).await.expect("put");
    }
    let theirs = attachment(&other, "push", "subscription", 1);
    store.put_attachment(theirs.clone()).await.expect("put");
    assert_eq!(store.remove_attachments(&phone).await.expect("remove"), 3);
    for kind in ["push", "passkey", "wake"] {
        assert_eq!(store.attachments(&phone, kind).await.expect("list"), vec![], "{kind}");
    }
    assert_eq!(store.attachments(&other, "push").await.expect("list"), vec![theirs]);
    assert_eq!(store.remove_attachments(&phone).await.expect("remove again"), 0);
}

/// Attachments read back through a new handle (durable backends only).
pub async fn attachments_survive_a_restart(harness: &dyn DeviceStoreHarness) {
    if !harness.is_durable() {
        return;
    }
    let phone = AttachmentHolder::Device(fresh());
    let row = attachment(&phone, "passkey", "only", 5);
    harness.open().await.put_attachment(row.clone()).await.expect("put");
    let reopened = harness.open().await;
    assert_eq!(reopened.attachments(&phone, "passkey").await.expect("list"), vec![row]);
}

/// A code reads back exactly as put, once.
pub async fn code_round_trip_and_take_once(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let code = code("ana", 600);
    store.put_code(code.clone()).await.expect("put");
    assert_eq!(store.take_code(&code.code_hash).await.expect("take"), Some(code.clone()));
    assert_eq!(store.take_code(&code.code_hash).await.expect("take again"), None);
}

/// A take returns a code past its expiry.
pub async fn take_returns_expired_codes(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let code = code("ana", -600);
    store.put_code(code.clone()).await.expect("put");
    assert_eq!(store.take_code(&code.code_hash).await.expect("take"), Some(code));
}

/// `prune_codes` removes the codes expired at or before the instant, and only those.
pub async fn prune_removes_expired_codes(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    // Far in the past, so codes other cases left in a shared database are pruned too and
    // the count stays exact only for this case's codes below the cut.
    let expired = code("ana", -1_000_000_000);
    let edge = code("ana", -999_999_000);
    let live = code("ana", 1_000_000_000);
    for code in [&expired, &edge, &live] {
        store.put_code(code.clone()).await.expect("put");
    }
    let removed = store.prune_codes(edge.expires_at).await.expect("prune");
    assert!(removed >= 2, "removed {removed}");
    assert_eq!(store.take_code(&expired.code_hash).await.expect("take"), None);
    assert_eq!(store.take_code(&edge.code_hash).await.expect("take"), None);
    assert_eq!(store.take_code(&live.code_hash).await.expect("take"), Some(live));
}

/// `clear_codes` removes every waiting code.
pub async fn clear_removes_every_code(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let codes = [code("ana", 600), code("bo", 600)];
    for code in &codes {
        store.put_code(code.clone()).await.expect("put");
    }
    assert!(store.clear_codes().await.expect("clear") >= 2);
    for code in &codes {
        assert_eq!(store.take_code(&code.code_hash).await.expect("take"), None);
    }
}

/// A device reads back exactly as put.
pub async fn device_round_trip(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    for scopes in [DeviceScope::ALL.to_vec(), vec![DeviceScope::Read], vec![DeviceScope::Stop]] {
        let mut device = device(0).with_scopes(scopes);
        device.revoked_at = Some(instant(30));
        store.put_device(device.clone()).await.expect("put");
        assert_eq!(store.get_device(&device.id).await.expect("get"), Some(device));
    }
}

/// A second put of one device replaces it.
pub async fn put_device_replaces(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let mut device = device(0);
    store.put_device(device.clone()).await.expect("put");
    device.revoked_at = Some(instant(60));
    store.put_device(device.clone()).await.expect("put again");
    assert_eq!(store.get_device(&device.id).await.expect("get"), Some(device.clone()));
    let listed = store.list_devices().await.expect("list");
    assert_eq!(listed.iter().filter(|listed| listed.id == device.id).count(), 1);
}

/// `list_devices` orders by pairing time, then id.
pub async fn list_devices_orders_by_pairing_then_id(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    let mut late = device(200);
    let early = device(100);
    let mut tied = device(200);
    // Two devices paired at one instant order by id.
    if tied.id < late.id {
        std::mem::swap(&mut tied.id, &mut late.id);
    }
    for device in [&late, &tied, &early] {
        store.put_device(device.clone()).await.expect("put");
    }
    let ours = [&early.id, &late.id, &tied.id];
    let listed: Vec<String> = store
        .list_devices()
        .await
        .expect("list")
        .into_iter()
        .filter(|device| ours.contains(&&device.id))
        .map(|device| device.id)
        .collect();
    assert_eq!(listed, [early.id.clone(), late.id.clone(), tied.id.clone()]);
}

/// An unknown device and an unknown code are `None`.
pub async fn unknown_ids(harness: &dyn DeviceStoreHarness) {
    let store = harness.open().await;
    assert_eq!(store.get_device(&fresh()).await.expect("get"), None);
    assert_eq!(store.take_code(&fresh()).await.expect("take"), None);
}

/// Devices and codes read back through a new handle.
pub async fn records_survive_a_restart(harness: &dyn DeviceStoreHarness) {
    if !harness.is_durable() {
        return;
    }
    let device = device(0);
    let code = code("ana", 600);
    {
        let store = harness.open().await;
        store.put_device(device.clone()).await.expect("put");
        store.put_code(code.clone()).await.expect("put");
    }
    let store = harness.open().await;
    assert_eq!(store.get_device(&device.id).await.expect("get"), Some(device));
    assert_eq!(store.take_code(&code.code_hash).await.expect("take"), Some(code));
}

/// Eight concurrent takes of one code from two handles take it once.
pub async fn concurrent_takes_take_once(harness: &dyn DeviceStoreHarness) {
    let stores = two(harness).await;
    let code = code("ana", 600);
    stores[0].put_code(code.clone()).await.expect("put");
    let mut takes = Vec::new();
    for index in 0..8 {
        let store = stores[index % 2].clone();
        let hash = code.code_hash.clone();
        takes.push(tokio::spawn(async move { store.take_code(&hash).await.expect("take") }));
    }
    let mut taken = 0;
    for take in takes {
        if take.await.expect("take completes").is_some() {
            taken += 1;
        }
    }
    assert_eq!(taken, 1);
}

/// Concurrent puts from two handles over distinct devices and codes lose none.
pub async fn concurrent_writers(harness: &dyn DeviceStoreHarness) {
    let stores = two(harness).await;
    let mut writes = Vec::new();
    let mut devices = Vec::new();
    let mut codes = Vec::new();
    for index in 0..16 {
        let store = stores[index % 2].clone();
        let device = device(i64::try_from(index).expect("small"));
        let code = code("ana", 600);
        devices.push(device.clone());
        codes.push(code.clone());
        writes.push(tokio::spawn(async move {
            store.put_device(device).await.expect("put device");
            store.put_code(code).await.expect("put code");
        }));
    }
    for write in writes {
        write.await.expect("write completes");
    }
    let store = &stores[1];
    for device in devices {
        assert_eq!(store.get_device(&device.id).await.expect("get").as_ref(), Some(&device));
    }
    for code in codes {
        assert_eq!(store.take_code(&code.code_hash).await.expect("take"), Some(code));
    }
}

/// Concurrent claim counts from two handles each get a distinct count, a reset starts the
/// count again at one, and a durable count survives a restart, so replicas share the
/// count of wrong codes.
pub async fn claim_attempts_are_counted_once_and_shared(harness: &dyn DeviceStoreHarness) {
    let stores = two(harness).await;
    stores[0].reset_claim_attempts().await.expect("reset");
    let mut counts = Vec::new();
    for index in 0..16 {
        let store = stores[index % 2].clone();
        counts.push(tokio::spawn(async move { store.count_claim_attempt().await.expect("count") }));
    }
    let mut seen = Vec::new();
    for count in counts {
        seen.push(count.await.expect("count completes"));
    }
    seen.sort_unstable();
    assert_eq!(seen, (1..=16).collect::<Vec<u64>>(), "every count is distinct");
    stores[1].reset_claim_attempts().await.expect("reset");
    assert_eq!(stores[0].count_claim_attempt().await.expect("count"), 1);
    if harness.is_durable() {
        let reopened = harness.open().await;
        assert_eq!(reopened.count_claim_attempt().await.expect("count"), 2);
    }
}

/// Generates one test per [`device_store`](self) case for a `DeviceStoreHarness` (spec 3.3 §10 K2).
///
/// Used as [`process_store_conformance_tests!`](crate::process_store_conformance_tests) is;
/// see the [module documentation](crate::conformance).
#[macro_export]
macro_rules! device_store_conformance_tests {
    ($(#[$attr:meta])* harness = $harness:expr $(,)?) => {
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_code_round_trip_and_take_once() {
            $crate::conformance::device_store::code_round_trip_and_take_once(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_take_returns_expired_codes() {
            $crate::conformance::device_store::take_returns_expired_codes(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_prune_removes_expired_codes() {
            $crate::conformance::device_store::prune_removes_expired_codes(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_clear_removes_every_code() {
            $crate::conformance::device_store::clear_removes_every_code(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_device_round_trip() {
            $crate::conformance::device_store::device_round_trip(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_put_device_replaces() {
            $crate::conformance::device_store::put_device_replaces(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_list_devices_orders_by_pairing_then_id() {
            $crate::conformance::device_store::list_devices_orders_by_pairing_then_id(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_unknown_ids() {
            $crate::conformance::device_store::unknown_ids(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_records_survive_a_restart() {
            $crate::conformance::device_store::records_survive_a_restart(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_concurrent_takes_take_once() {
            $crate::conformance::device_store::concurrent_takes_take_once(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_concurrent_writers() {
            $crate::conformance::device_store::concurrent_writers(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_claim_attempts_are_counted_once_and_shared() {
            $crate::conformance::device_store::claim_attempts_are_counted_once_and_shared(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_attachments_round_trip_per_kind() {
            $crate::conformance::device_store::attachments_round_trip_per_kind(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_put_attachment_replaces() {
            $crate::conformance::device_store::put_attachment_replaces(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_put_attachment_if_absent_writes_once() {
            $crate::conformance::device_store::put_attachment_if_absent_writes_once(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_remove_attachment_removes_one() {
            $crate::conformance::device_store::remove_attachment_removes_one(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_remove_attachments_removes_the_holders() {
            $crate::conformance::device_store::remove_attachments_removes_the_holders(&$harness).await;
        }
        $(#[$attr])*
        #[::tokio::test(flavor = "multi_thread", worker_threads = 4)]
        async fn device_store_attachments_survive_a_restart() {
            $crate::conformance::device_store::attachments_survive_a_restart(&$harness).await;
        }
    };
}