ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
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
//! The STORAGE SEAM of the id vocabulary — [`IdColumn`], which answers *how does an id wrapping me
//! reach a column?* once per member, per dialect.
//!
//! # What it closes, and why it is a TRAIT rather than a word at a declaration
//!
//! `#[derive(ingraph::Id)]` writes an address's whole register from one word, and three of those
//! rows are storage: what a `CREATE TABLE` DECLARES the column as, how a value BINDS into it, and
//! how it READS BACK. Until this seam every one of them crossed through the canonical TEXT — the
//! road both live registers hand-wrote before the device existed — and by 2026-08-29 that had
//! stopped being the only road: the uuid knife filled [`uuid::Uuid`]'s value-column rows with a
//! NATIVE form per backend (PostgreSQL `uuid`, MySQL `binary(16)`, SQLite `BLOB`, BSON subtype 4),
//! so a wrapper over one was spending 36 characters on sixteen bytes and sorting by ASCII digits
//! where the value's own order was right there.
//!
//! Moving the rows onto the INNER unconditionally was measured and refused, and the measurement is
//! ingraph #452's: twelve members of the sealed key vocabulary had no column rows at all, so an
//! unconditional switch would have turned each of them from *stored as text* into *not storable* —
//! through a VACUOUS impl rather than a named refusal. A silently narrower door is worse than a wide
//! one that stores a uuid as text.
//!
//! An ATTRIBUTE at the declaration was the other candidate, and it is refused BY THE DEVICE'S OWN
//! DOCUMENTED LAW rather than by taste. **A macro sees TOKENS**: `type MyId = uuid::Uuid` reaches
//! `#[derive(ingraph::Id)]` as the word `MyId`, and no front-end pass can tell what it names. So a
//! per-inner choice made in the macro would be a guess about a spelling; made in an attribute it
//! would be a type-level fact RESTATED per declaration, against the zero-ceremony ruling the door
//! was opened under, with an unnamed `E0277` for the declarations that get it wrong. Per-inner
//! dispatch belongs in the type system, which is this trait.
//!
//! An optional override word MAY come later as sugar OVER this seam. It is not here.
//!
//! # TOTAL over the sealed vocabulary, which is what makes the failure mode unrepresentable
//!
//! Every member of [`for_each_id_member!`](super::for_each_id_member) has a row below, and the
//! audit at the bottom of this file is the compiler checking that sentence: a member admitted to
//! [`Id`](super::Id) tomorrow with no row here fails HERE, naming that member, rather than at
//! whatever declaration first wraps it. There are no vacuous rows and no member that stores in one
//! dialect and not another. Every row but one is written `impl<Db>`, and the audit demands each at
//! `Db = ()`, which is no database at all, so a row written for one dialect alone would not resolve
//! there — `u64` is the ONE exception, and the audit answers it by a NAMED arm rather than by
//! widening what `Db = ()` proves for everyone else; see the MySQL ruling below and
//! [`audit_row!`]'s own `u64` case.
//!
//! # THREE ROADS, and three of the twelve members #452 measured ride the newest one — ONE of them
//! split by dialect
//!
//! | road | [`Stored`](IdColumn::Stored) | who takes it |
//! |---|---|---|
//! | TEXT | `String` | every member left with a canonical rendering: `i8`…`i64`, `u8`…`u32`, the `NonZero*` family, the six `core::net` addresses, `SmolStr`, `bson::Uuid`, `bson::oid::ObjectId` |
//! | ITS OWN COLUMN | `Self` | the members that ARE a column: `String`, [`Utf8Bytes`](smol_bytes::Utf8Bytes) — and [`uuid::Uuid`], the first that MOVED |
//! | BIG-ENDIAN BLOB | [`BeU64`](crate::BeU64) / [`BeI128`](crate::BeI128) / [`BeU128`](crate::BeU128) | `i128`, `u128` on every dialect; `u64` on SQLite and PostgreSQL — the 2026-08-30 ruling, below |
//!
//! `u64` alone rides a FOURTH cell no other member needs: on MySQL its road is ITS OWN COLUMN
//! (`Self`, native `BIGINT UNSIGNED`) rather than the blob the row above states — the SAME ruling's
//! own MySQL fast-follow, a few paragraphs down.
//!
//! **The uuid change is exactly one row wide and it is real**: a `#[derive(ingraph::Id)]`
//! wrapper over a [`uuid::Uuid`] declares, binds and reads back the NATIVE sixteen bytes where it
//! used to spend the canonical 36-character text. Nothing in this workspace is published, so there
//! is no migration ceremony — a declarer re-emits its schema on the next sync.
//!
//! ## The 2026-08-30 ruling: `u64`, `i128` and `u128` move too, and the reason is ORDER
//!
//! A decimal rendering sorts LEXICOGRAPHICALLY: `"10"` precedes `"9"` in a TEXT column, while
//! [`CursorValue`](crate::CursorValue)'s big-endian bytes — and the type's own `Ord` — put them the
//! other way round. That disagreement was named and left standing when this file landed
//! (2026-08-29): moving the wide integers was a SECOND stored-form change, and that ruling named
//! only the uuid one. **This is the second ruling**, and it makes the three-way equality
//! [`uuid::Uuid`]'s move restored one member earlier — Rust `Ord` == stored order == cursor bytes —
//! uniform across the WHOLE sealed vocabulary rather than everywhere but three members.
//!
//! `i128`/`u128` could not take a NATIVE column on any dialect this crate carries at all, so a
//! native row would un-store the very ids the text road existed to keep storable — their existing
//! big-endian storage forms, [`BeU128`](crate::BeU128) and [`BeI128`](crate::BeI128), already this
//! crate's own answer to the identical problem at a VALUE column, fix the order without narrowing
//! the door: `to_blob`/`from_blob` is total over the whole width, so every value that stored as text
//! before stores as a blob now, on all three dialects uniformly.
//!
//! ### `u64` on MySQL: the measured asymmetry, and the SAME-DAY fast-follow that closes it
//!
//! [`BeU64`](crate::BeU64) has no [`StoredAs`](crate::StoredAs)/[`Carrier`](crate::Carrier) row on
//! MySQL at all — `comparison::sql::carrier`'s own table marks the cell `(not needed)` — because
//! MySQL's native `BIGINT UNSIGNED` already holds a `u64` losslessly and nobody wrote a second
//! escape for a dialect that did not need one. So `u64` cannot take the SAME uniform blob road
//! `i128`/`u128` do: on SQLite and PostgreSQL it is [`BeU64`](crate::BeU64), exactly as the ruling
//! above states, and on MySQL it is `u64` ITSELF — see the `impl IdColumn<sqlx::MySql> for u64`
//! beside [`be_road!`]'s own invocation, where the per-`Db` seat this note used to hold open is
//! taken, IN THE OPEN, the same day as the ruling that created the asymmetry. `to_blob`/`from_blob`
//! never runs on MySQL at all — the driver's own `Encode`/`Decode` for `u64` do the whole job, and
//! `BIGINT UNSIGNED` sorts numerically, so `Ord` still equals stored order there without an encoding
//! step to keep in agreement with it.
//!
//! ## The BSON pair, censused per dialect — which is what the `Db` parameter is the seat for
//!
//! `bson::Uuid` and `bson::oid::ObjectId` take the text road on every dialect, and the verdict has
//! two halves:
//!
//! - **On SQL there is no native road to take.** Neither type has an `sqlx::Type`/`Encode`/`Decode`
//!   row in any driver, and this crate writes none — they are BSON's types. `bson::Uuid` could be
//!   crossed to [`uuid::Uuid`] and ride ITS native rows (bson 3's byte accessors are ungated, so the
//!   crossing needs no feature), and that is declined here rather than impossible: it would be a
//!   second unruled stored-form change, and it would put two distinct Rust types in one
//!   indistinguishable column. `ObjectId` is twelve bytes, a width no dialect in this crate has a
//!   column row for at all.
//! - **On MongoDB the seat exists and has no occupant.** A document backend would be a different
//!   `Db`, and a per-`Db` split — native `BinData` for the document store, text for the dialects — is
//!   exactly what a trait parameterised by the database can express and what an attribute could not.
//!   `#[derive(ingraph::Id)]` writes NO document rows at all today (its own front end refuses the
//!   `mongo` word by name, *the seat is held rather than filled*), so there is no consumer for such
//!   a row and writing one would be unmeasured. Recorded, not written.
//!
//! # OPEN, because a downstream inner is a real position
//!
//! `Db` carries no bound and the trait is not sealed, where [`Id`](super::Id) itself is. The two are
//! not in tension: the VOCABULARY is closed because a member's ticket in is a measurement this
//! crate's backends made, and the STORED FORM is open because a downstream that has established a
//! form for its own type is the only party who can say what it is. A wrapper holding another crate's
//! newtype writes one row and its id stores.
//!
//! `#[derive(ingraph::Id)]` writes that row for its own wrapper, delegating to what it holds, so an
//! id over an id needs nothing: the chain resolves to whichever member it grounds in, exactly as
//! [`DelegatesId`](super::DelegatesId) does one duty over.
//!
//! **This is where the door narrowed, and the narrowing is stated rather than met by surprise.** An
//! inner this crate has never seen used to reach the storage rows on `Display` + `FromStr` alone,
//! since that is what the text road spent; it now needs a row here. One impl, three lines, named at
//! the refusal — and what it buys is that a downstream inner SAYS what it is stored as instead of
//! being assumed to be text.
//!
//! There is deliberately no blanket over `Display + FromStr`. It would be the text road for
//! everything and would collide with the native row above it (`E0119`), so the road a type takes
//! stays a per-type statement rather than a default one type had to opt out of.

use core::{convert::Infallible, str::FromStr};

#[cfg(test)]
mod tests;

/// **HOW AN ID OVER THIS TYPE REACHES A COLUMN OF `Db`** — the per-inner dispatch
/// `#[derive(ingraph::Id)]`'s three storage rows route through.
///
/// A wrapper's [`StoredAs`](crate::StoredAs), [`Carrier`](crate::Carrier) and
/// [`Assemble`](crate::Assemble) rows are all written over [`Stored`](Self::Stored): the word is
/// that type's word, the bind is that type's bind, and the read back is that type's read followed by
/// [`from_stored`](Self::from_stored). So the declared column, the value written into it and the
/// value read out of it are ONE decision made in ONE place, and a row that renders text into a
/// column declared for bytes is not expressible.
///
/// # The obligation, which is the round trip and nothing else
///
/// [`from_stored`](Self::from_stored) has to recover every value [`to_stored`](Self::to_stored)
/// produced: `from_stored(to_stored(&x)) == Ok(x)` for every `x`. An id is an ADDRESS, so a lossy
/// crossing here is two distinct keys resolving one row — the same corruption
/// [`DelegatesId`](super::DelegatesId)'s `unsafe` guards one duty over, which is why the text road's
/// members are the ones whose rendering is CANONICAL and parses back exactly.
///
/// Nothing else is asked. The stored form need not preserve the value's ORDER — that is
/// [`Id`](super::Id)'s admission matrix, settled before a type is a member at all — and it need not
/// be a form this crate has heard of.
///
/// # Examples
///
/// The two roads, read at the word a `CREATE TABLE` would write:
///
/// ```
/// # #[cfg(feature = "sqlite")] {
/// use ingraph::{IdColumn, StoredAs};
///
/// type Native = <uuid::Uuid as IdColumn<sqlx::Sqlite>>::Stored;
/// type Text = <i64 as IdColumn<sqlx::Sqlite>>::Stored;
///
/// assert_eq!(<Native as StoredAs<sqlx::Sqlite>>::WORDS, ["BLOB"]);
/// assert_eq!(<Text as StoredAs<sqlx::Sqlite>>::WORDS, ["TEXT"]);
/// # }
/// ```
///
/// A DOWNSTREAM inner joins by writing the road it takes — three lines, and every id wrapping it
/// stores:
///
/// ```
/// use ingraph::IdColumn;
///
/// #[derive(Clone, Debug, PartialEq, Eq)]
/// struct Slug(String);
///
/// impl<Db> IdColumn<Db> for Slug {
///   type Stored = String;
///   type Refusal = core::convert::Infallible;
///
///   fn to_stored(&self) -> String {
///     self.0.clone()
///   }
///
///   fn from_stored(stored: String) -> Result<Self, Self::Refusal> {
///     Ok(Self(stored))
///   }
/// }
///
/// let slug = Slug("a-b".to_owned());
/// let stored = <Slug as IdColumn<()>>::to_stored(&slug);
/// assert_eq!(<Slug as IdColumn<()>>::from_stored(stored), Ok(slug));
/// ```
#[diagnostic::on_unimplemented(
  message = "`{Self}` has no stored form, so an id holding one cannot reach a column of `{Db}`",
  label = "this id is stored through the value it holds",
  note = "a `#[derive(ingraph::Id)]` wrapper stores THROUGH ITS INNER: the word, the bind and the \
          read back are all the inner's stored form, so the row that is missing is the inner's and \
          not the wrapper's",
  note = "every member of the sealed id vocabulary has a row — the integers, the `NonZero` family, \
          `uuid::Uuid`, text, the `core::net` addresses and (under their features) `SmolStr`, \
          `bson::Uuid` and `bson::oid::ObjectId` — so a type reaching this refusal is one this \
          crate never admitted as a key",
  note = "a DOWNSTREAM inner joins by writing this row itself: `type Stored = String` with \
          `Display` rendering and `FromStr` reading back is the text road every text-shaped member \
          takes, and `type Stored = Self` is the road for a type that already IS a column"
)]
pub trait IdColumn<Db>: Sized {
  /// The form a column of `Db` actually HOLDS an id over this type in.
  ///
  /// It is this type that answers [`StoredAs`](crate::StoredAs),
  /// [`Carrier`](crate::Carrier) and [`Assemble`](crate::Assemble) for the wrapper, so a form with
  /// no row in a dialect is a wrapper that cannot be stored in that dialect — with the refusal
  /// naming the FORM, which is the thing that has no column, rather than the id.
  type Stored;

  /// What a stored form this type cannot read back is refused with.
  ///
  /// It reaches a caller as [`sqlx::Error::Decode`], which is why the bound is the boxed-error one
  /// rather than merely [`Display`](core::fmt::Display). A road that cannot fail says
  /// [`Infallible`](core::convert::Infallible) and pays nothing for it.
  type Refusal: core::error::Error + Send + Sync + 'static;

  /// This value, in the form a column holds.
  fn to_stored(&self) -> Self::Stored;

  /// The value a column held, read back.
  ///
  /// # Errors
  ///
  /// [`Refusal`](Self::Refusal), when the column holds a form this type does not admit — a text
  /// column holding something the canonical grammar refuses. A round trip through
  /// [`to_stored`](Self::to_stored) never reaches it; a hand-edited row does.
  fn from_stored(stored: Self::Stored) -> Result<Self, Self::Refusal>;
}

/// **THE TEXT ROAD** — rendered through [`Display`](core::fmt::Display), read back through
/// [`FromStr`], one `String` column.
///
/// The refusal is the type's OWN parse error rather than a minted one, which is the same choice
/// `#[derive(ingraph::Id)]`'s `FromStr` row makes: the spellings a column may hold are exactly the
/// ones this type admits, so the refusal for a spelling it does not admit is exactly its own.
macro_rules! text_road {
  ($( $( #[$attr:meta] )* $ty:ty ),+ $(,)?) => {
    $(
      $( #[$attr] )*
      impl<Db> IdColumn<Db> for $ty {
        type Stored = String;
        type Refusal = <$ty as FromStr>::Err;

        #[inline]
        fn to_stored(&self) -> String {
          ToString::to_string(self)
        }

        #[inline]
        fn from_stored(stored: String) -> Result<Self, Self::Refusal> {
          <$ty as FromStr>::from_str(&stored)
        }
      }
    )+
  };
}

/// **A MEMBER THAT ALREADY IS A COLUMN** — stored as itself, with no crossing to be lossy in.
///
/// [`Infallible`] is the refusal, and it is the honest one: there is no grammar between the value
/// and the column for a stored row to violate.
macro_rules! own_column {
  ($( $( #[$attr:meta] )* $ty:ty ),+ $(,)?) => {
    $(
      $( #[$attr] )*
      impl<Db> IdColumn<Db> for $ty {
        type Stored = Self;
        type Refusal = Infallible;

        #[inline]
        fn to_stored(&self) -> Self {
          Clone::clone(self)
        }

        #[inline]
        fn from_stored(stored: Self) -> Result<Self, Self::Refusal> {
          Ok(stored)
        }
      }
    )+
  };
}

/// **THE BIG-ENDIAN BLOB ROAD** — the 2026-08-30 ruling, stored through the type's own carrier
/// ([`BeU64`](crate::BeU64)/[`BeI128`](crate::BeI128)/[`BeU128`](crate::BeU128)), which already
/// exists as this crate's answer to the identical problem at a VALUE column.
///
/// [`Infallible`] is the refusal, for [`own_column!`]'s reason: `to_blob`/`from_blob` is TOTAL over
/// the whole width — every value of the integer has a blob and every blob of the right width is a
/// value — so there is no grammar between them for a stored row to violate.
///
/// The crossing is the EXISTING `From<u64> for BeU64` (and its two siblings, from `storage.rs`'s
/// `carrier_from!`), so this row states no conversion of its own. That is what makes the ruling's
/// three-way equality hold BY CONSTRUCTION rather than by two crossings a reader has to keep in
/// step by hand: [`CursorValue`](crate::CursorValue)'s row for the same three types delegates to
/// the identical `to_blob`/`from_blob` pair.
macro_rules! be_road {
  ($( $( #[$attr:meta] )* $ty:ty => $be:ty ),+ $(,)?) => {
    $(
      $( #[$attr] )*
      impl<Db> IdColumn<Db> for $ty {
        type Stored = $be;
        type Refusal = Infallible;

        #[inline]
        fn to_stored(&self) -> $be {
          <$be>::from(*self)
        }

        #[inline]
        fn from_stored(stored: $be) -> Result<Self, Self::Refusal> {
          Ok(<$ty>::from(stored))
        }
      }
    )+
  };
}

text_road! {
  /// The narrow integers, in decimal. Each has a native column on every dialect this crate carries
  /// (Postgres widens the four without one, per `column::stored`'s own table), so the text road
  /// costs them nothing a native row would buy — unlike their three wider siblings, which moved to
  /// the big-endian blob road below on the 2026-08-30 ruling this module note carries.
  i8, i16, i32, i64,
  u8, u16, u32,
  /// The `NonZero*` family, at the rendering of the integer each wraps: `Display` is that integer's
  /// and `FromStr` re-establishes the invariant coming back, refusing a stored `0` by the type's own
  /// answer rather than by a check written here.
  core::num::NonZeroI8,
  core::num::NonZeroI16,
  core::num::NonZeroI32,
  core::num::NonZeroI64,
  core::num::NonZeroI128,
  core::num::NonZeroU8,
  core::num::NonZeroU16,
  core::num::NonZeroU32,
  core::num::NonZeroU64,
  core::num::NonZeroU128,
  /// The six `core::net` addresses, at std's own canonical renderings — dotted quad, RFC 5952 for
  /// v6, and the bracketed `addr:port` pair for the two socket forms. Each parses back exactly,
  /// which is the round trip this road asks for; what a column of them does NOT inherit is the
  /// fixed-width byte order [`Id`](super::Id)'s matrix admitted them on, and that is the whole of
  /// the note above about the text road's cost.
  core::net::IpAddr,
  core::net::Ipv4Addr,
  core::net::Ipv6Addr,
  core::net::SocketAddr,
  core::net::SocketAddrV4,
  core::net::SocketAddrV6,
}

#[cfg(feature = "smol_str")]
text_road! {
  /// The O(1)-clone text member, under the feature that supplies the type. Its `FromStr` is
  /// [`Infallible`] — every string is one — so this row's refusal is uninhabited even though the
  /// road is the parsing one.
  smol_str::SmolStr,
}

#[cfg(feature = "mongo")]
text_road! {
  /// The BSON UUID, on the text road for the reason the module note censuses per dialect: it has no
  /// driver row in any SQL dialect, the crossing to `uuid::Uuid` that would give it one is declined
  /// rather than unavailable, and the document backend that could hold it natively has no consumer
  /// for such a row yet.
  bson::Uuid,
  /// The object id, whose twelve bytes are a width no dialect in this crate has a column row for at
  /// all — so the 24-character lowercase hex is the only road there is rather than a preference.
  bson::oid::ObjectId,
}

own_column! {
  /// The text road's own fixed point: a `String` id is stored as the `String` it is, and the
  /// crossing is the clone the bind would have made anyway.
  String,
  /// The other text member that IS a column, and the one the text road above could not serve: it
  /// renders through `Display` and has no `FromStr` at all, so a road that reads back by parsing
  /// would have no return leg. Stored as itself, the question does not arise — and the word is the
  /// same `TEXT`/`text`/`varchar(255)` either way, so nothing observable turns on it.
  smol_bytes::Utf8Bytes,
  /// **THE ONE MEMBER THAT MOVED** — the 2026-08-29 ruling, spent at the wrapper.
  ///
  /// Sixteen bytes into the form each backend has for them: PostgreSQL's own `uuid` type, MySQL's
  /// `binary(16)`, SQLite's `BLOB`. All three compare BYTEWISE over the same bytes in the same
  /// order, `uuid::Uuid`'s own `Ord` is that order, and [`CursorValue`](crate::CursorValue)'s
  /// sixteen-byte encoding is that encoding — so the Rust order, the three stored orders and a
  /// keyset page are ONE order.
  ///
  /// **For a UUIDv7 that order is TIME order**, the version's leading 48 bits being a big-endian
  /// millisecond, so `ORDER BY id` over a v7-inner id is newest-last with no second column. It is
  /// not claimed for v4, whose bytes are random and whose order is therefore arbitrary but still
  /// total and still agreed on by every backend — which is all a page needs.
  ///
  /// What it replaces is the canonical 36-character text, at 20 bytes a row and an index that
  /// sorted by ASCII digits rather than by the value.
  uuid::Uuid,
}

be_road! {
  /// **MOVED on the 2026-08-30 ruling.** Neither has ever had a column on any dialect this crate
  /// carries — the text road was the only way either stored at all — so this row keeps every value
  /// storable on every dialect while fixing the order the text road could not.
  i128 => crate::BeI128,
  u128 => crate::BeU128,
}

/// **`u64` TAKES THE PER-`Db` SEAT — the asymmetry the 2026-08-30 ruling named is ruled on.** SQLite
/// and PostgreSQL keep that ruling's big-endian blob, byte for byte what [`be_road!`] would have
/// written; MySQL gets the native `BIGINT UNSIGNED` row the module note held open instead, because
/// [`BeU64`](crate::BeU64) never needed a [`StoredAs`](crate::StoredAs) row there — MySQL's own
/// native column already served the VALUE-column road (`column::stored`'s and
/// `comparison::sql::carrier`'s own MySQL tables), and this impl reads through those existing rows
/// rather than minting a second escape for a dialect that never needed one.
///
/// # Why three impls and not one `impl<Db>`
///
/// A single generic impl cannot special-case one concrete `Db`: Rust has no specialization on
/// stable, so `impl<Db> IdColumn<Db> for u64` beside a second `impl IdColumn<sqlx::MySql> for u64`
/// is `E0119` — two implementations of the same trait for the same type, at every `Db` the first
/// already covers. Diverging by dialect therefore means giving up the blanket, which is the
/// "per-`Db` seat" this file's own module note held open — taken here for the first time, IN THE
/// OPEN: `stores_dialect_blind`'s `Db = ()` probe cannot see a row written this way, on purpose, so
/// `id::for_each_id_member!` sends `u64` through a line of its own and `audit_row!`'s `u64` arm asks
/// the three concrete dialects instead of the one blind one.
///
/// # The stored order is native `Ord` on all three, unchanged by the split
///
/// SQLite and PostgreSQL still sort by [`BeU64`](crate::BeU64)'s big-endian bytes, which are `u64`'s
/// own `Ord`. MySQL's `BIGINT UNSIGNED` sorts numerically by definition — there is no encoding step
/// to agree with the type's `Ord` because the column IS the value — so `ORDER BY` over a `u64`-inner
/// id agrees with `Ord` on all three, exactly as the 2026-08-30 ruling stated for the blob road,
/// reached here through the dialect's own column instead of through an encoding.
#[cfg(feature = "sqlite")]
impl IdColumn<sqlx::Sqlite> for u64 {
  type Stored = crate::BeU64;
  type Refusal = Infallible;

  #[inline]
  fn to_stored(&self) -> crate::BeU64 {
    crate::BeU64::from(*self)
  }

  #[inline]
  fn from_stored(stored: crate::BeU64) -> Result<Self, Self::Refusal> {
    Ok(u64::from(stored))
  }
}

/// The same big-endian blob as the SQLite row just above, on PostgreSQL's `BYTEA`.
#[cfg(feature = "postgres")]
impl IdColumn<sqlx::Postgres> for u64 {
  type Stored = crate::BeU64;
  type Refusal = Infallible;

  #[inline]
  fn to_stored(&self) -> crate::BeU64 {
    crate::BeU64::from(*self)
  }

  #[inline]
  fn from_stored(stored: crate::BeU64) -> Result<Self, Self::Refusal> {
    Ok(u64::from(stored))
  }
}

/// **THE NATIVE ROW** — `type Stored = Self`, [`own_column!`]'s own shape, for the reason
/// [`own_column!`] cannot be reached for it: that macro is `impl<Db>`, and this row is deliberately
/// for `sqlx::MySql` alone. [`Infallible`] for [`own_column!`]'s own reason — there is no grammar
/// between a `u64` and the `BIGINT UNSIGNED` it binds to for a stored row to violate.
#[cfg(feature = "mysql")]
impl IdColumn<sqlx::MySql> for u64 {
  type Stored = u64;
  type Refusal = Infallible;

  #[inline]
  fn to_stored(&self) -> u64 {
    *self
  }

  #[inline]
  fn from_stored(stored: u64) -> Result<Self, Self::Refusal> {
    Ok(stored)
  }
}

/// One member, stored at a `Db` THAT IS NOT A DATABASE — which is how the audit below asks its
/// question about every dialect at once.
///
/// `()` names no backend and has no dialect table anywhere in this crate, so a row that resolves for
/// it is a row written `impl<Db>`: DIALECT-BLIND, which is the shape every OTHER row in this file
/// takes and the shape *total coverage* means for them. A member whose road is written per dialect
/// FAILS this instantiation — deliberately, since taking the per-`Db` seat the module note holds
/// open is a change that should be made in the open rather than absorbed. `u64` is that member as of
/// the 2026-08-30 MySQL ruling, and [`stores_dialect`] plus [`audit_row!`]'s own `u64` arm are the
/// open change: not a wider probe here, but a NAMED exception beside it.
fn stores_dialect_blind<T: IdColumn<()>>() {}

/// The per-`Db` question [`stores_dialect_blind`] cannot ask — one member, one CONCRETE dialect,
/// spent three times over by [`audit_row!`]'s `u64` arm rather than once over `Db = ()`.
fn stores_dialect<T: IdColumn<Db>, Db>() {}

/// One demand per member — the audit's whole body.
///
/// # `u64` is answered by NAME, not by the blind probe every other member takes
///
/// `macro_rules!` arms are tried in order, and a literal `u64` in argument position matches ONLY the
/// raw token `id::for_each_id_member!`'s own `u64` line expands to — never a type this macro is
/// merely recursing over, since nothing here recurses. That is what makes the arm below safe to add
/// beside the general one without touching `for_each_id_member!`'s other three consumers (`id!`, the
/// segment audit, the field audit): none of them ask an `IdColumn`-shaped question, so `u64` reaches
/// them exactly as it did bundled with its siblings, and only this file's own callback needed a
/// second arm at all.
macro_rules! audit_row {
  (u64) => {
    #[cfg(feature = "sqlite")]
    const _: fn() = stores_dialect::<u64, sqlx::Sqlite>;
    #[cfg(feature = "postgres")]
    const _: fn() = stores_dialect::<u64, sqlx::Postgres>;
    #[cfg(feature = "mysql")]
    const _: fn() = stores_dialect::<u64, sqlx::MySql>;
  };
  ($($ty:ty),* $(,)?) => {
    $(const _: fn() = stores_dialect_blind::<$ty>;)*
  };
}

// THE COMPLETENESS AUDIT: every member of the sealed vocabulary has a row above, checked by the
// compiler rather than by a reader counting. A member admitted to `Id` tomorrow with no row here
// fails HERE, naming that member, rather than at whatever declaration first wraps it — which is the
// shape `store::fs`'s segment audit and `store::field`'s crossability audit already take over the
// same list.
//
// The gated rows carry their gate in the list, so the audit is complete over the member set of the
// build it is compiled in rather than over `--all-features`'s. `u64`'s own three gates are the same
// law spent inside ONE member's arm instead of at the `for_each_id_member!` call site.
//
// The five GENERIC members of the vocabulary — `Arc<T>`, `Rc<T>`, `Box<T>`, `[u8; N]` and
// `TypedId<I, E>` — are absent here rather than forgotten, and no witness is written for them: not
// one of the five carries BOTH `Display` and `FromStr`, so `#[derive(ingraph::Id)]` refuses a wrapper
// over any of them at the TEXT PAIR before a storage row is reached.
// `key_admission/derive/an_id_wrapper_with_no_text_form` is that refusal pinned, for `[u8; 32]`. A
// row here would answer a question no declaration can ask.
super::for_each_id_member!(audit_row);