alkblobs 0.2.1

Content-addressed blob storage: multi-hash put/get/verify store with pluggable backends, transport- and protocol-agnostic
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
//! The engine-side enum dispatch: the two tier engine enums (the
//! engine-representation design point's closed sets) and the
//! cursor/staging dispatch enums (the sub-enum design points) between
//! the facade and the backends. Everything here is crate-internal —
//! engine types never leak onto the public surface. The per-verb
//! dispatch bodies (the `Store` methods consuming these enums) live
//! with their paths in the sibling files.

use crate::backend::{Backend, ReadCursor, StagingCursor};
#[cfg(any(
    feature = "postgres",
    feature = "sqlite",
    all(feature = "mem", feature = "pg-lo")
))]
use crate::gc::EngineWindowState;
use crate::local::{LocalBackend, LocalCursor, LocalStaging};
#[cfg(feature = "mem")]
use crate::mem::{MemBackend, MemCursor};
#[cfg(feature = "pg-lo")]
use crate::pg_lo::{PgLoBackend, PgLoCursor, PgLoStaging};
#[cfg(feature = "postgres")]
use crate::postgres::{PostgresBackend, PostgresCursor};
#[cfg(feature = "sqlite")]
use crate::sqlite::{SqliteBackend, SqliteCursor};
use crate::Error;
#[cfg(feature = "postgres")]
use std::sync::Arc;

/// **The kv dispatches' empty-build arm** (a build whose feature set
/// enables no kv engine — local-only, pg-lo-only): every kv variant
/// is feature-gated, so [`KvEngine`]/[`KvCursor`] compile with zero
/// variants and every `&self` match needs one wildcard arm to remain
/// exhaustive (rustc treats references as inhabited even over a
/// variant-less enum). The arm is unreachable by construction — every
/// constructor is kv-engine-gated, so `Store` cannot exist in such a
/// build — and closes the dispatch with an error, never a panic (the
/// library code's no-panic convention).
#[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
pub(crate) fn no_kv_engine() -> Error {
    Error::Io(
        "no kv engine: this build enables no kv-tier engine feature, so Store cannot be \
         constructed and the kv dispatch is unreachable by construction"
            .to_owned(),
    )
}

/// The kv-tier engine set — the closed per-tier engine enum of the
/// engine-representation design point. Feature-gated variants slot in
/// as their engine waves land: sqlite (wave 3 — landed, the default),
/// postgres (wave 4 — landed, feature-gated default-off).
///
/// The variant payloads are structurally dissimilar by design — the
/// in-process engine holds one `Arc`, the SQL-backed engines hold
/// their connection postures inline — and every dispatch rides the
/// enum by reference (`&self` matches only), so the size difference
/// costs nothing.
#[allow(clippy::large_enum_variant)]
pub(crate) enum KvEngine {
    /// The contract-reference ephemeral engine (ADR-011 §2).
    #[cfg(feature = "mem")]
    Mem(MemBackend),
    /// The default build's kv engine — the first SQL-backed engine,
    /// the durable delete window's host (ADR-012 §5's one-window-host
    /// rule: the window is the kv engine's when the kv engine is
    /// SQL-backed).
    #[cfg(feature = "sqlite")]
    Sqlite(SqliteBackend),
    /// The second SQL-backed engine — the fleet host (ADR-012 §4) and
    /// a one-window-host alongside sqlite: its constructors run the
    /// GC schema's engine-neutral call (the postgres row's body
    /// creates `gc_pins` + `gc_window`) and its sweeps run the durable
    /// window form on it. Feature `postgres`, default-off. The payload
    /// is an `Arc` shared with the store core's detached pin-renewal
    /// tasks (fleet puts mint one per guard — the task outlives the
    /// `Store`, renewing its row through the engine handle it carries;
    /// `PostgresBackend` itself is not `Clone` — its lease checkout
    /// must not be), so the fleet constructor's one backend serves both
    /// the in-line dispatch and the detached duties.
    #[cfg(feature = "postgres")]
    Postgres(Arc<PostgresBackend>),
}

/// The large-tier engine set. `local` is ungated (dependency-free,
/// always present, ADR-013 §4); pg-lo landed behind feature `pg-lo`
/// (wave 5) — its slotting is exactly the enum-variant-plus-named-
/// constructor pattern the module doc pins.
#[cfg_attr(
    not(any(feature = "mem", feature = "sqlite", feature = "postgres")),
    allow(dead_code)
)]
pub(crate) enum LargeEngine {
    /// The sharded-filesystem engine (ADR-003/008).
    Local(LocalBackend),
    /// The pg-lo large-object engine (ADR-009): postgres Large
    /// Objects hold the bytes, the companion table is the addressing
    /// authority. Feature `pg-lo`, default-off (it does not imply
    /// feature `postgres`, ADR-013 §4).
    #[cfg(feature = "pg-lo")]
    PgLo(PgLoBackend),
}

/// **The large-arm shape over multiple large engines (named design
/// point): a `LargeCursor` sub-enum behind [`AnyCursor`]'s one large
/// arm — the recorded [`KvCursor`] sub-enum pattern's large-tier
/// twin, on the same bounded-memory framing as the kv side.** The
/// alternative — one `AnyCursor` variant per large engine — would
/// copy the large streaming arm into the tier dispatch per engine,
/// and the tier dispatch's variant count must stay bounded so
/// `Blob`-tier consumers (the verification posture's arm shapes in
/// `Store::get`) stay a two-arm tier dispatch while large engines
/// multiply inside this one. Recorded for the review gate and landed
/// with wave 5: pg-lo slotted one arm in here (exactly the shape the
/// design point named, no reshaping).
pub(crate) enum LargeCursor {
    /// The pread body over the committed file (ADR-003/008).
    Local(LocalCursor),
    /// The descriptorless window body over the companion row —
    /// `lo_get` windows (ADR-009).
    #[cfg(feature = "pg-lo")]
    PgLo(PgLoCursor),
}

impl ReadCursor for LargeCursor {
    fn len(&self) -> u64 {
        match self {
            Self::Local(cursor) => cursor.len(),
            #[cfg(feature = "pg-lo")]
            Self::PgLo(cursor) => cursor.len(),
        }
    }

    async fn read_at(&self, offset: u64, len: u64) -> Result<Vec<u8>, Error> {
        match self {
            Self::Local(cursor) => cursor.read_at(offset, len).await,
            #[cfg(feature = "pg-lo")]
            Self::PgLo(cursor) => cursor.read_at(offset, len).await,
        }
    }
}

/// **The kv-arm shape over multiple kv engines (named design point):
/// a `KvCursor` sub-enum behind [`AnyCursor`]'s one kv arm.** The
/// alternative — one `AnyCursor` variant per kv engine — would copy
/// the kv materializing arm (and its consumers: the verification-on-
/// get body, `Blob`'s drive) per engine without adding a behavior;
/// the sub-enum keeps [`AnyCursor`] a two-arm tier dispatch (kv /
/// large) while kv engines multiply inside this one. Recorded for the
/// review gate and landed with wave 4: postgres slotted one arm in
/// here (exactly the predicted shape, no reshaping).
pub(crate) enum KvCursor {
    /// The contract-reference ephemeral body (ADR-011 §2).
    #[cfg(feature = "mem")]
    Mem(MemCursor),
    /// The default build's materializing body: the row's value loaded
    /// once, reads in-memory slices (the sqlite engine's record).
    #[cfg(feature = "sqlite")]
    Sqlite(SqliteCursor),
    /// The postgres body — the same materializing shape, the value
    /// loaded once from the engine's pooled row (the postgres
    /// engine's record).
    #[cfg(feature = "postgres")]
    Postgres(PostgresCursor),
}

#[cfg_attr(
    not(any(feature = "mem", feature = "sqlite", feature = "postgres")),
    allow(unused_variables)
)]
impl ReadCursor for KvCursor {
    fn len(&self) -> u64 {
        match self {
            #[cfg(feature = "mem")]
            Self::Mem(cursor) => cursor.len(),
            #[cfg(feature = "postgres")]
            Self::Postgres(cursor) => cursor.len(),
            #[cfg(feature = "sqlite")]
            Self::Sqlite(cursor) => cursor.len(),
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => 0,
        }
    }

    async fn read_at(&self, offset: u64, len: u64) -> Result<Vec<u8>, Error> {
        match self {
            #[cfg(feature = "mem")]
            Self::Mem(cursor) => cursor.read_at(offset, len).await,
            #[cfg(feature = "postgres")]
            Self::Postgres(cursor) => cursor.read_at(offset, len).await,
            #[cfg(feature = "sqlite")]
            Self::Sqlite(cursor) => cursor.read_at(offset, len).await,
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => Err(no_kv_engine()),
        }
    }
}

/// The read path's cursor-dispatch enum (ADR-010 §1's "store core
/// programs the abstraction"): tier dispatch over the engine cursor
/// bodies — the kv tier's materializing body and the large tier's
/// streaming body — behind one crate-internal value that [`Blob`] holds
/// and drives. Crate-internal: engine cursors never appear on the
/// public surface; the facade's stream shape is this enum's uniform
/// [`ReadCursor`] view (`Blob`). The per-tier body families live
/// behind the sub-enums — [`KvCursor`] for the kv arm, [`LargeCursor`]
/// for the large arm (both the recorded design points).
#[cfg_attr(
    not(any(feature = "mem", feature = "sqlite", feature = "postgres")),
    allow(dead_code)
)]
pub(crate) enum AnyCursor {
    /// The kv body family: the whole value materialized in memory
    /// (bounded by tier policy).
    Kv(KvCursor),
    /// The large body family: streaming readers over the committed
    /// home, behind the large-tier sub-enum.
    Large(LargeCursor),
}

impl ReadCursor for AnyCursor {
    fn len(&self) -> u64 {
        match self {
            Self::Kv(cursor) => cursor.len(),
            Self::Large(cursor) => cursor.len(),
        }
    }

    async fn read_at(&self, offset: u64, len: u64) -> Result<Vec<u8>, Error> {
        match self {
            Self::Kv(cursor) => cursor.read_at(offset, len).await,
            Self::Large(cursor) => cursor.read_at(offset, len).await,
        }
    }
}

/// The write path's staging-cursor dispatch (ADR-010 §1: the store core
/// programs the abstraction): the large tier's stage bodies behind one
/// crate-internal value, the put seam's twin of [`AnyCursor`]. The kv
/// tier never stages on the facade path (the whole-value put is its
/// settled form); a kv-degenerate staged body variant arrives only if
/// the conformance suite demands the staged form through the facade.
/// Crate-internal — engine cursors never leak onto the public surface.
/// The stage bodies live behind [`LargeStaging`] (the sub-enum design
/// point's staging-side twin).
pub(crate) enum AnyStaging {
    /// The large body family: stage bodies behind the large-tier
    /// sub-enum.
    Large(LargeStaging),
}

impl ReadCursor for AnyStaging {
    fn len(&self) -> u64 {
        match self {
            Self::Large(cursor) => cursor.len(),
        }
    }

    async fn read_at(&self, offset: u64, len: u64) -> Result<Vec<u8>, Error> {
        match self {
            Self::Large(cursor) => cursor.read_at(offset, len).await,
        }
    }
}

/// The staged arm's sub-enum — the [`LargeCursor`]/staging-side twin
/// of the `KvCursor` pattern: the local stage-file body and pg-lo's
/// held-transaction body behind [`AnyStaging`]'s one large arm rather
/// than one `AnyStaging` variant per large engine (the same
/// bounded-variant argument; landed with wave 5). The variant payloads
/// are structurally dissimilar by design (the file-descriptor posture
/// vs the held pooled checkout + tx) and every dispatch rides the enum
/// by value-consumption or `&self`, so the size difference costs
/// nothing — the recorded `KvEngine` enum's allow posture.
#[allow(clippy::large_enum_variant)]
pub(crate) enum LargeStaging {
    /// The stage-file body under the stage-hygiene protocol,
    /// published by commit-rename (ADR-003/008).
    Local(LocalStaging),
    /// The held-transaction body: the stage lives in uncommitted LO
    /// pages, published by the companion-row insert + COMMIT
    /// (ADR-009).
    #[cfg(feature = "pg-lo")]
    PgLo(PgLoStaging),
}

impl ReadCursor for LargeStaging {
    fn len(&self) -> u64 {
        match self {
            Self::Local(cursor) => cursor.len(),
            #[cfg(feature = "pg-lo")]
            Self::PgLo(cursor) => cursor.len(),
        }
    }

    async fn read_at(&self, offset: u64, len: u64) -> Result<Vec<u8>, Error> {
        match self {
            Self::Local(cursor) => cursor.read_at(offset, len).await,
            #[cfg(feature = "pg-lo")]
            Self::PgLo(cursor) => cursor.read_at(offset, len).await,
        }
    }
}

impl StagingCursor for LargeStaging {
    async fn append(&mut self, chunk: &[u8]) -> Result<(), Error> {
        match self {
            Self::Local(cursor) => cursor.append(chunk).await,
            #[cfg(feature = "pg-lo")]
            Self::PgLo(cursor) => cursor.append(chunk).await,
        }
    }

    async fn commit(self, key: &[u8]) -> Result<(), Error> {
        match self {
            Self::Local(cursor) => cursor.commit(key).await,
            #[cfg(feature = "pg-lo")]
            Self::PgLo(cursor) => cursor.commit(key).await,
        }
    }

    async fn discard(self) {
        match self {
            Self::Local(cursor) => cursor.discard().await,
            #[cfg(feature = "pg-lo")]
            Self::PgLo(cursor) => cursor.discard().await,
        }
    }
}

impl StagingCursor for AnyStaging {
    async fn append(&mut self, chunk: &[u8]) -> Result<(), Error> {
        match self {
            Self::Large(cursor) => cursor.append(chunk).await,
        }
    }

    async fn commit(self, key: &[u8]) -> Result<(), Error> {
        match self {
            Self::Large(cursor) => cursor.commit(key).await,
        }
    }

    async fn discard(self) {
        match self {
            Self::Large(cursor) => cursor.discard().await,
        }
    }
}

#[cfg_attr(
    not(any(feature = "mem", feature = "sqlite", feature = "postgres")),
    allow(unused_variables)
)]
impl KvEngine {
    pub(crate) async fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Error> {
        match self {
            #[cfg(feature = "mem")]
            KvEngine::Mem(engine) => engine.put(key, value).await,
            #[cfg(feature = "postgres")]
            KvEngine::Postgres(engine) => engine.put(key, value).await,
            #[cfg(feature = "sqlite")]
            KvEngine::Sqlite(engine) => engine.put(key, value).await,
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => Err(no_kv_engine()),
        }
    }

    pub(crate) async fn get(&self, key: &[u8]) -> Result<Option<AnyCursor>, Error> {
        match self {
            #[cfg(feature = "mem")]
            KvEngine::Mem(engine) => Ok(engine
                .get(key)
                .await?
                .map(|c| AnyCursor::Kv(KvCursor::Mem(c)))),
            #[cfg(feature = "postgres")]
            KvEngine::Postgres(engine) => Ok(engine
                .get(key)
                .await?
                .map(|c| AnyCursor::Kv(KvCursor::Postgres(c)))),
            #[cfg(feature = "sqlite")]
            KvEngine::Sqlite(engine) => Ok(engine
                .get(key)
                .await?
                .map(|c| AnyCursor::Kv(KvCursor::Sqlite(c)))),
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => Err(no_kv_engine()),
        }
    }

    /// The GC schema's engine-neutral kv-host arm (ADR-010 §2's
    /// companion seam; ADR-012 §5's applicability table): a SQL-backed
    /// kv engine creates the tables its applicability row names —
    /// sqlite's body creates `gc_window` only, postgres's creates
    /// `gc_pins` + `gc_window` (the fleet host's both-tables row) — and
    /// an in-process kv engine is structurally nothing (the
    /// local/mem row of the table: those engines execute the window
    /// protocol inline, ADR-005, and carry no GC schema). The
    /// store-core construction call is
    /// [`ensure_gc_schema_at_construction`] — the one-window-host
    /// rule's dispatch, which consults this method on the SQL-backed
    /// kv arms and the large tier only when the kv engine is not
    /// SQL-backed.
    // consumer: `ensure_gc_schema_at_construction`'s SQL-backed kv
    // arms (features `sqlite`/`postgres`); a build whose kv set holds
    // only mem compiles the closed dispatch unread.
    #[allow(dead_code)]
    pub(crate) async fn ensure_gc_schema(&self) -> Result<(), Error> {
        match self {
            #[cfg(feature = "mem")]
            KvEngine::Mem(_) => Ok(()),
            #[cfg(feature = "postgres")]
            KvEngine::Postgres(engine) => engine.ensure_gc_schema().await,
            #[cfg(feature = "sqlite")]
            KvEngine::Sqlite(engine) => engine.ensure_gc_schema().await,
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => Err(no_kv_engine()),
        }
    }

    pub(crate) async fn has(&self, key: &[u8]) -> Result<bool, Error> {
        match self {
            #[cfg(feature = "mem")]
            KvEngine::Mem(engine) => engine.has(key).await,
            #[cfg(feature = "postgres")]
            KvEngine::Postgres(engine) => engine.has(key).await,
            #[cfg(feature = "sqlite")]
            KvEngine::Sqlite(engine) => engine.has(key).await,
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => Err(no_kv_engine()),
        }
    }

    pub(crate) async fn size(&self, key: &[u8]) -> Result<Option<u64>, Error> {
        match self {
            #[cfg(feature = "mem")]
            KvEngine::Mem(engine) => engine.size(key).await,
            #[cfg(feature = "postgres")]
            KvEngine::Postgres(engine) => engine.size(key).await,
            #[cfg(feature = "sqlite")]
            KvEngine::Sqlite(engine) => engine.size(key).await,
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => Err(no_kv_engine()),
        }
    }

    pub(crate) async fn delete(&self, key: &[u8]) -> Result<(), Error> {
        match self {
            #[cfg(feature = "mem")]
            KvEngine::Mem(engine) => engine.delete(key).await,
            #[cfg(feature = "postgres")]
            KvEngine::Postgres(engine) => engine.delete(key).await,
            #[cfg(feature = "sqlite")]
            KvEngine::Sqlite(engine) => engine.delete(key).await,
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => Err(no_kv_engine()),
        }
    }

    pub(crate) async fn list(&self) -> Result<Vec<Vec<u8>>, Error> {
        match self {
            #[cfg(feature = "mem")]
            KvEngine::Mem(engine) => engine.list().await,
            #[cfg(feature = "postgres")]
            KvEngine::Postgres(engine) => engine.list().await,
            #[cfg(feature = "sqlite")]
            KvEngine::Sqlite(engine) => engine.list().await,
            #[cfg(not(any(feature = "mem", feature = "sqlite", feature = "postgres")))]
            _ => Err(no_kv_engine()),
        }
    }
}

impl LargeEngine {
    /// The staged form's handout (ADR-010 §1): the put seam's large path
    /// streams into this cursor while hashing; the key resolves at the
    /// staging cursor's commit.
    pub(crate) async fn put_staged(&self) -> Result<AnyStaging, Error> {
        match self {
            LargeEngine::Local(engine) => Ok(engine
                .put_staged()
                .await
                .map(|c| AnyStaging::Large(LargeStaging::Local(c)))?),
            #[cfg(feature = "pg-lo")]
            LargeEngine::PgLo(engine) => Ok(engine
                .put_staged()
                .await
                .map(|c| AnyStaging::Large(LargeStaging::PgLo(c)))?),
        }
    }

    pub(crate) async fn get(&self, key: &[u8]) -> Result<Option<AnyCursor>, Error> {
        match self {
            LargeEngine::Local(engine) => Ok(engine
                .get(key)
                .await?
                .map(|c| AnyCursor::Large(LargeCursor::Local(c)))),
            #[cfg(feature = "pg-lo")]
            LargeEngine::PgLo(engine) => Ok(engine
                .get(key)
                .await?
                .map(|c| AnyCursor::Large(LargeCursor::PgLo(c)))),
        }
    }

    pub(crate) async fn has(&self, key: &[u8]) -> Result<bool, Error> {
        match self {
            LargeEngine::Local(engine) => engine.has(key).await,
            #[cfg(feature = "pg-lo")]
            LargeEngine::PgLo(engine) => engine.has(key).await,
        }
    }

    pub(crate) async fn size(&self, key: &[u8]) -> Result<Option<u64>, Error> {
        match self {
            LargeEngine::Local(engine) => engine.size(key).await,
            #[cfg(feature = "pg-lo")]
            LargeEngine::PgLo(engine) => engine.size(key).await,
        }
    }

    pub(crate) async fn delete(&self, key: &[u8]) -> Result<(), Error> {
        match self {
            LargeEngine::Local(engine) => engine.delete(key).await,
            #[cfg(feature = "pg-lo")]
            LargeEngine::PgLo(engine) => engine.delete(key).await,
        }
    }

    pub(crate) async fn list(&self) -> Result<Vec<Vec<u8>>, Error> {
        match self {
            LargeEngine::Local(engine) => engine.list().await,
            #[cfg(feature = "pg-lo")]
            LargeEngine::PgLo(engine) => engine.list().await,
        }
    }

    /// The large tier's arm of the one-window-host rule's construction
    /// call: the pg-lo host's `ensure_gc_schema` (creating `gc_window`
    /// in the pg-lo schema), consulted by
    /// [`ensure_gc_schema_at_construction`] only when the kv engine is
    /// not SQL-backed. No arm exists for `local` — it is
    /// seam-excluded by construction (ADR-010/012 §5).
    #[cfg(feature = "mem")]
    // consumer: the construction dispatch's large-host arm
    // (kv = mem + large = pg-lo); a pg-lo-less mem build compiles the
    // local arm only, structurally nothing.
    #[allow(dead_code)]
    pub(crate) async fn ensure_gc_schema(&self) -> Result<(), Error> {
        match self {
            #[cfg(feature = "pg-lo")]
            LargeEngine::PgLo(engine) => engine.ensure_gc_schema().await,
            LargeEngine::Local(_) => Ok(()),
        }
    }
}