ingraph-derive 0.1.0

The attribute and derive macros for ingraph: the words a record, node, key, filter and vocabulary declaration is written in.
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
//! The words this round respelled and the word it added, read straight off the pass.
//!
//! A file of its own rather than more of [`crate::tests`], for the layout rule this crate keeps: a
//! module's own suite sits beside it. What is asserted here is the GRAMMAR — which spellings the
//! pass takes, which it refuses, and whether the refusal names the older spelling an author is
//! migrating from.

use ingraph_codegen::prelude::*;

/// The pass under test, at the kind these words belong to.
fn operator(input: &syn::DeriveInput) -> syn::Result<RecordModel> {
  let (host, options) = crate::host::split(input);
  crate::parse::parse(&host, &options, NodeKind::Operator)
}

/// Every refusal one declaration collects, as text.
fn refusals(input: syn::DeriveInput) -> Vec<String> {
  operator(&input)
    .expect_err("the declaration is refused")
    .into_iter()
    .map(|e| e.to_string())
    .collect()
}

/// Whether any of `messages` names `rule`.
fn names(messages: &[String], rule: &str) -> bool {
  messages.iter().any(|message| message.contains(rule))
}

/// The products of a model, in declaration order.
fn products(model: &RecordModel) -> Vec<String> {
  model
    .products
    .as_ref()
    .map(|products| {
      products
        .products
        .iter()
        .map(|product| product.variant.to_string())
        .collect()
    })
    .unwrap_or_default()
}

/// One product is one quoted type — the arity most declarations have, written without punctuation
/// for a plural they do not carry.
#[test]
fn one_product_is_written_as_one_string() {
  let model = operator(&syn::parse_quote! {
    #[ingraph(emits = "media::Caption")]
    struct Describe { #[ingraph(id)] id: Uuid7 }
  })
  .expect("one quoted product is legal");
  assert_eq!(products(&model), ["Caption"]);
  assert!(!model.products.expect("the word was read").is_sum());
}

/// Several products are the list, in the order written — which is the order every ordinal counts.
#[test]
fn several_products_are_written_as_a_list() {
  let model = operator(&syn::parse_quote! {
    #[ingraph(emits = ["Caption", "media::Summary", "Digest"])]
    struct Describe { #[ingraph(id)] id: Uuid7 }
  })
  .expect("a quoted product list is legal");
  assert_eq!(products(&model), ["Caption", "Summary", "Digest"]);
}

/// The container spelling is answered BY NAME, because an author who wrote one has a declaration to
/// migrate rather than a word this grammar has never heard of.
#[test]
fn the_container_spelling_of_emits_names_itself_as_the_older_one() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(emits(Caption, Summary))]
    struct Describe { #[ingraph(id)] id: Uuid7 }
  });
  for rule in [
    "`emits = \"…\"` names this node's ONE product",
    "the older spelling",
  ] {
    assert!(names(&messages, rule), "missing `{rule}` in: {messages:?}");
  }
}

/// A value that is not a string at all gets the same sentence: the word's whole shape is one rule.
#[test]
fn a_product_that_is_not_a_string_gets_the_words_own_sentence() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(emits = Caption)]
    struct Describe { #[ingraph(id)] id: Uuid7 }
  });
  assert!(names(&messages, "the older spelling"), "{messages:?}");
}

/// `emits` twice is one node stating its products twice.
#[test]
fn emits_is_declared_once() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(emits = "Caption", emits = "Summary")]
    struct Describe { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "`emits` is declared more than once"),
    "{messages:?}"
  );
}

/// A selected product is a REFERENCE to the upstream's own vocabulary, so it is quoted.
#[test]
fn a_selected_product_is_quoted() {
  let model = operator(&syn::parse_quote! {
    #[ingraph(subscribe(
      upstream(node = "vision::Detector", out = "Boxes"),
      upstream(node = "vision::Detector", out = "Masks"),
    ))]
    struct Caption { #[ingraph(id)] id: Uuid7 }
  })
  .expect("two products of one upstream are two edges");
  assert_eq!(
    model
      .subscriptions
      .expect("the container was read")
      .upstreams
      .iter()
      .map(|source| source.variant.to_string())
      .collect::<Vec<_>>(),
    ["Boxes", "Masks"],
  );
}

/// The bare spelling names itself as the older one, exactly as the container spelling does.
#[test]
fn the_bare_spelling_of_out_names_itself_as_the_older_one() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(subscribe(upstream(node = "vision::Detector", out = Boxes)))]
    struct Caption { #[ingraph(id)] id: Uuid7 }
  });
  for rule in ["`out = \"<Variant>\"`", "the older spelling"] {
    assert!(names(&messages, rule), "missing `{rule}` in: {messages:?}");
  }
}

/// A quoted value that is not one identifier is not an arm of anything.
#[test]
fn a_selected_product_is_one_word() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(subscribe(upstream(node = "vision::Detector", out = "vision::Boxes")))]
    struct Caption { #[ingraph(id)] id: Uuid7 }
  });
  assert!(names(&messages, "`out = \"<Variant>\"`"), "{messages:?}");
}

/// The entries a model settled, as `(name, variant)` pairs in declaration order.
fn clocks(model: &RecordModel) -> Vec<(String, String)> {
  model
    .polls
    .as_ref()
    .map(|polls| {
      polls
        .entries
        .iter()
        .map(|entry| (entry.name.to_string(), entry.variant.to_string()))
        .collect()
    })
    .unwrap_or_default()
}

/// The word sits BESIDE the fan-in container, one entry per clock, and declaration order is the
/// contract — a poll source is not an upstream, so it never enters `subscribe(…)`.
#[test]
fn the_clocks_sit_beside_the_container_in_declaration_order() {
  let model = operator(&syn::parse_quote! {
    #[ingraph(
      subscribe(upstream(node = "media::Frame"), upstream(node = "asr::Segment")),
      poll(orphans, every = "10m", light, async(inline)),
      poll(sweep_stale, cron = "0 3 * * *", light, async(inline)),
    )]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  })
  .expect("poll entries beside a container are legal");
  assert_eq!(
    clocks(&model),
    [
      ("orphans".to_owned(), "Orphans".to_owned()),
      ("sweep_stale".to_owned(), "SweepStale".to_owned()),
    ]
  );
  // The container is untouched by the clocks: a tick moves no message, so it is in no `In` enum.
  assert_eq!(
    model
      .subscriptions
      .expect("the container was read")
      .upstreams
      .len(),
    2
  );
}

/// A node with clocks and NO upstream at all is the maintenance shape the word exists for.
#[test]
fn a_node_may_be_driven_by_its_clock_alone() {
  let model = operator(&syn::parse_quote! {
    #[ingraph(poll(compact, every = "1h", light, async(inline)))]
    struct Compactor { #[ingraph(id)] id: Uuid7 }
  })
  .expect("a clock is a whole reason to exist");
  assert_eq!(
    clocks(&model),
    [("compact".to_owned(), "Compact".to_owned())]
  );
  assert!(model.subscriptions.is_none());
}

/// Both schedule words is two answers to one question, and nothing decides between them.
#[test]
fn an_entry_runs_on_one_clock_and_never_two() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(orphans, every = "10m", cron = "0 3 * * *", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "names both `every` and `cron`"),
    "{messages:?}"
  );
}

/// Neither schedule word is a clock that never fires, which is spelled by writing no entry.
#[test]
fn an_entry_with_no_cadence_is_refused() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(orphans))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "says nothing about when it is due"),
    "{messages:?}"
  );
}

/// A poll that fires as fast as the machine allows is a SPIN — refused by name, at the string.
#[test]
fn a_zero_interval_is_a_spin_and_is_refused() {
  for written in ["0s", "0", "PT0S"] {
    let interval = syn::LitStr::new(written, proc_macro2::Span::call_site());
    let messages = refusals(syn::parse_quote! {
      #[ingraph(poll(orphans, every = #interval, light, async(inline)))]
      struct Reaper { #[ingraph(id)] id: Uuid7 }
    });
    assert!(
      names(&messages, "is a SPIN") && names(&messages, written),
      "{written}: {messages:?}"
    );
  }
}

/// A negative interval is a deadline in the past forever — the same rule, the same sentence.
#[test]
fn a_negative_interval_is_refused_by_the_same_rule() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(orphans, every = "-PT2S", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(names(&messages, "is a SPIN"), "{messages:?}");
}

/// A duration the grammar cannot read carries jiff's own diagnosis and the offending string.
#[test]
fn an_unreadable_interval_quotes_what_was_written() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(orphans, every = "ten minutes", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "`every = \"ten minutes\"` is not a duration"),
    "{messages:?}"
  );
}

/// The interval speaks the framework's ONE duration grammar, calendar units and all.
#[test]
fn the_interval_speaks_the_one_duration_grammar() {
  for (written, seconds) in [
    ("10m", 600u64),
    ("1h 30m", 5_400),
    ("PT1H", 3_600),
    ("1d", 86_400),
    ("500ms", 0),
  ] {
    let interval = syn::LitStr::new(written, proc_macro2::Span::call_site());
    let model = operator(&syn::parse_quote! {
      #[ingraph(poll(orphans, every = #interval, light, async(inline)))]
      struct Reaper { #[ingraph(id)] id: Uuid7 }
    })
    .unwrap_or_else(|e| panic!("{written}: {e}"));
    let PollCadence::Every(read) = &model
      .polls
      .as_ref()
      .expect("one clock")
      .entries
      .first()
      .expect("one entry")
      .cadence
    else {
      panic!("{written} is an interval");
    };
    assert_eq!(read.as_secs(), seconds, "{written}");
  }
}

/// A garbage cron refuses AT EXPANSION with the offending string quoted.
#[test]
fn a_garbage_cron_is_refused_with_the_string_quoted() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(nightly, cron = "99 3 * * *", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "`cron = \"99 3 * * *\"` is not a schedule"),
    "{messages:?}"
  );
}

/// The dialect is the classic five fields; a zone is the `tz` word and never a sixth field.
#[test]
fn the_dialect_is_five_fields_and_the_zone_is_a_word() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(nightly, cron = "0 3 * * * Asia/Shanghai", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(names(&messages, "classic 5 fields"), "{messages:?}");
  assert!(names(&messages, "`tz = \"<IANA>\"`"), "{messages:?}");

  let model = operator(&syn::parse_quote! {
    #[ingraph(poll(nightly, cron = "0 3 * * *", tz = "Asia/Shanghai", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  })
  .expect("a zone beside a calendar expression is legal");
  let PollCadence::Calendar { expression, zone } = &model
    .polls
    .as_ref()
    .expect("one clock")
    .entries
    .first()
    .expect("one entry")
    .cadence
  else {
    panic!("a calendar entry");
  };
  assert_eq!(expression, "0 3 * * *");
  assert_eq!(zone.as_deref(), Some("Asia/Shanghai"));
}

/// No zone word is the SYSTEM's zone, resolved where the program runs — the model carries no
/// answer, because the build machine's zone is not the deployment's.
#[test]
fn a_calendar_entry_with_no_zone_carries_none() {
  let model = operator(&syn::parse_quote! {
    #[ingraph(poll(nightly, cron = "0 3 * * *", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  })
  .expect("a calendar expression with no zone is legal");
  let PollCadence::Calendar { zone, .. } = &model
    .polls
    .as_ref()
    .expect("one clock")
    .entries
    .first()
    .expect("one entry")
    .cadence
  else {
    panic!("a calendar entry");
  };
  assert!(zone.is_none());
}

/// An interval has no wall clock, so `tz` beside one qualifies nothing and is refused.
#[test]
fn a_zone_beside_an_interval_is_refused() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(orphans, every = "10m", tz = "Asia/Shanghai", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "`tz` has nothing to qualify there"),
    "{messages:?}"
  );
}

/// A poll inbound carries NO ack, and the word is refused by name rather than read past.
#[test]
fn ack_inside_a_poll_entry_is_a_named_refusal() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(orphans, every = "10m", ack(manual), light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "a poll inbound carries NO ack") && names(&messages, "the NEXT TICK"),
    "{messages:?}"
  );
}

/// Two entries whose names come out as one word are refused, naming both.
#[test]
fn two_entries_cannot_mint_one_word() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(
      poll(sweep_stale, every = "10m", light, async(inline)),
      poll(sweepStale, every = "1h", light, async(inline))
    )]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "both come out as `SweepStale`"),
    "{messages:?}"
  );
}

/// An entry that mints nothing has no word for a tick to arrive under.
#[test]
fn an_entry_that_mints_nothing_is_refused() {
  for declaration in [
    syn::parse_quote! {
      #[ingraph(poll(every = "10m"))]
      struct Reaper { #[ingraph(id)] id: Uuid7 }
    },
    syn::parse_quote! {
      #[ingraph(poll())]
      struct Reaper { #[ingraph(id)] id: Uuid7 }
    },
  ] {
    let messages = refusals(declaration);
    assert!(names(&messages, "opens with the NAME"), "{messages:?}");
  }
}

/// One entry mints ONE name — a second bare word is a second clock, which is a second entry.
#[test]
fn an_entry_mints_one_name() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(orphans, stale, every = "10m", light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(names(&messages, "mints ONE name"), "{messages:?}");
}

/// Every word the entry does not know is refused with the list of the ones it does.
#[test]
fn the_entry_refuses_what_it_cannot_name() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(poll(orphans, every = "10m", write, listen(channel), light, async(inline)))]
    struct Reaper { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "unknown entry in `poll(…)`"),
    "{messages:?}"
  );
}

// ---------------------------------------------------------------------------------------------
// `stream` — the FACE word
// ---------------------------------------------------------------------------------------------

/// The pass at a kind that STORES, for the rules this word answers differently there.
fn record(input: &syn::DeriveInput) -> syn::Result<RecordModel> {
  let (host, options) = crate::host::split(input);
  crate::parse::parse(&host, &options, NodeKind::Record)
}

/// Every refusal a STORING declaration collects, as text.
fn record_refusals(input: syn::DeriveInput) -> Vec<String> {
  record(&input)
    .expect_err("the declaration is refused")
    .into_iter()
    .map(|e| e.to_string())
    .collect()
}

/// **THE TWO AXES.** `stream` picks the PAIR and `async` picks the HALF, so the four cells are two
/// independent `Option`s on the model rather than one four-armed word.
#[test]
fn the_face_word_and_the_mode_word_are_two_axes() {
  let buffered = operator(&syn::parse_quote! {
    struct Describe { #[ingraph(id)] id: Uuid7 }
  })
  .expect("a bare declaration is legal");
  assert!(buffered.streaming.is_none());
  assert!(buffered.asynchronous.is_none());

  let streaming = operator(&syn::parse_quote! {
    #[ingraph(stream)]
    struct Demux { #[ingraph(id)] id: Uuid7 }
  })
  .expect("the face word is legal on an operator");
  assert!(streaming.streaming.is_some());
  assert!(streaming.asynchronous.is_none());

  let awaited = operator(&syn::parse_quote! {
    #[ingraph(stream, async)]
    struct Demux { #[ingraph(id)] id: Uuid7 }
  })
  .expect("the two words multiply");
  assert!(awaited.streaming.is_some());
  assert!(awaited.asynchronous.is_some());
}

/// It composes with the vocabulary it was ruled beside — the edge and the products, verbatim.
#[test]
fn the_face_word_composes_with_the_edge_and_the_products() {
  let model = operator(&syn::parse_quote! {
    #[ingraph(stream, subscribe = "media::File", emits = ["Packet", "Caption"])]
    struct Demux { #[ingraph(id)] id: Uuid7 }
  })
  .expect("the word costs the rest of the grammar nothing");
  assert!(model.streaming.is_some());
  assert!(model.subscribe.is_some());
  assert_eq!(products(&model), ["Packet", "Caption"]);
}

/// BARE, for `async`'s reason: the seats a lane runs under are values, and an attribute cannot name
/// one.
#[test]
fn the_face_word_carries_nothing() {
  for declaration in [
    syn::parse_quote! {
      #[ingraph(stream = "wide")]
      struct Demux { #[ingraph(id)] id: Uuid7 }
    },
    syn::parse_quote! {
      #[ingraph(stream(in_flight = 4))]
      struct Demux { #[ingraph(id)] id: Uuid7 }
    },
  ] {
    let messages = refusals(declaration);
    assert!(names(&messages, "`stream` is a bare word"), "{messages:?}");
  }
}

/// One declaration wears one PAIR.
#[test]
fn the_face_word_is_written_once() {
  let messages = refusals(syn::parse_quote! {
    #[ingraph(stream, stream)]
    struct Demux { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "one declaration wears one pair"),
    "{messages:?}"
  );
}

/// **IT IS AN `operator`'s WORD.** Every other kind publishes an address, and the storing ones land
/// rows through a write lane the stream lane does not carry.
#[test]
fn the_face_word_is_an_operators() {
  let messages = record_refusals(syn::parse_quote! {
    #[ingraph(sqlite, stream)]
    struct Chunk { #[ingraph(id)] id: Uuid7 }
  });
  assert!(
    names(&messages, "`stream` is an `operator`'s word"),
    "{messages:?}"
  );
}

/// **THE BUFFERED-ONLY WORD.** A tick is one call against the node's own value, which the driver
/// LENDS for that call — and a stream-faced node's bodies are the lane's warm set, each owned by a
/// delivery's run for that delivery's whole life.
#[test]
fn a_streaming_node_does_not_also_poll() {
  for declaration in [
    syn::parse_quote! {
      #[ingraph(stream, poll(orphans, every = "10m", light, async(inline)))]
      struct Demux { #[ingraph(id)] id: Uuid7 }
    },
    // The other order, which is the whole reason the rule is read after the walk rather than at the
    // token: an author may type a pair either way round and gets one sentence for it.
    syn::parse_quote! {
      #[ingraph(poll(orphans, every = "10m", light, async(inline)), stream)]
      struct Demux { #[ingraph(id)] id: Uuid7 }
    },
  ] {
    let messages = refusals(declaration);
    assert!(
      names(&messages, "`poll(…)` is the BUFFERED pair's word"),
      "{messages:?}"
    );
  }
}

/// **THE ONE-STORAGE LAW NAMES THE AGGREGATE'S STORAGE, AND ITS STORAGE IS ROWS.** Every refusal
/// that sends an author away from a storage word they wrote in the wrong place ends with this
/// sentence, so the clause a kind contributes to it is the clause that tells them what they already
/// have — and an aggregate already has rows, arriving from the fold rather than one per message.
///
/// The ADVICE half is the one that would have been wrong by silence. It splits on
/// `derives_its_key`, and an aggregate names an upstream like a derived index does; had it taken the
/// borrowed-key branch, the sentence would have told an author to declare a sibling that shares a
/// key the aggregate does not lend.
#[test]
fn the_one_storage_law_calls_an_aggregates_storage_its_folded_rows() {
  let sentence = crate::parse::owns_one_storage(NodeKind::Aggregate);

  assert!(
    sentence.contains("an aggregate's is the folded rows it keeps"),
    "{sentence}"
  );
  assert!(
    sentence.contains("The storage node subscribes to this aggregate and shares its key"),
    "{sentence}"
  );
}

/// **EVERY KIND CONTRIBUTES A CLAUSE, AND NO TWO KINDS CONTRIBUTE THE SAME SENTENCE.** The law is
/// one law and only its consequence differs, which is only true while each kind's consequence is
/// actually stated: a kind added later that fell into a neighbour's arm would read as a refusal
/// about a different declaration, and it would still compile and still read.
#[test]
fn the_one_storage_law_says_something_of_its_own_about_each_kind() {
  let kinds = [
    NodeKind::Operator,
    NodeKind::Entity,
    NodeKind::Record,
    NodeKind::Aggregate,
    NodeKind::Fulltext,
    NodeKind::Vector,
    NodeKind::Blob,
  ];

  for kind in kinds {
    let sentence = crate::parse::owns_one_storage(kind);
    assert!(
      sentence.contains(&format!("{} {}'s is", kind.article(), kind.noun())),
      "{kind:?} is not named in its own law: {sentence}"
    );
  }

  for (at, one) in kinds.iter().enumerate() {
    for other in &kinds[at + 1..] {
      assert_ne!(
        crate::parse::owns_one_storage(*one),
        crate::parse::owns_one_storage(*other),
        "{one:?} and {other:?} read alike"
      );
    }
  }
}