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
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
use crate::Context;
use core::{
  convert::Infallible,
  sync::atomic::{AtomicUsize, Ordering},
};

use smol_bytes::Utf8Bytes;

use super::super::{
  AsyncConstructor, Enablement, LaunchError, NodeSection, NodeWiring, Plan, Resources,
};
use crate::{
  AsyncFulltextStore, AsyncResource, ChannelGraph, DeclaredResource, Delivery, DriverKind, Effect,
  FanoutKind, FulltextTable, GraphBuilder, Identifiable, NodeId, Operator, ResourceCatalog,
  ResourceDemand, ResourceSource, SlotName, Transformer, Wired, bare_options,
};

macro_rules! unit {
  ($name:ident) => {
    struct $name;

    impl Operator for $name {
      type Error = Infallible;
      type In = u8;
      type Out = u8;

      fn accept(
        &mut self,
        _ctx: &Context,
        _delivery: Delivery<Self::In>,
        _emitter: &mut crate::Emitter<u8>,
      ) -> Result<(), Self::Error> {
        Ok(())
      }
    }

    /// The facts a hand-wired node states — the mount predicate is
    /// `O: Declared + Driven<O::Mode>`, so a node that is not emitted says what it is too, in the
    /// mode a bare declaration has.
    impl crate::Declared for $name {
      const EFFECT: crate::Effect = crate::Effect::Pure;

      type Channels = crate::Unchanneled;
      type Mode = crate::Block;
      type Options = ();
      type Pair = crate::Buffered;
      type Wires<O> = crate::Downstream<O>;
      type Attribution<O> = ();
    }
  };
}

unit!(DecodeUnit);
unit!(CaptionsUnit);

/// A shared model: what a `Shared<Egemma>` field on an enabled node asks the walk to load.
///
/// It carries the dimension it was BUILT with, which is what lets a test tell one load from
/// another without a counter — and a counter would be a process-global under a test harness that
/// runs its tests at once.
struct Egemma(usize);

impl AsyncResource for Egemma {
  type Error = Infallible;
  type Options = usize;

  async fn build(_ctx: &Resources, dim: usize) -> Result<Self, Self::Error> {
    Ok(Self(dim))
  }
}

impl DeclaredResource for Egemma {}

/// A declared resource this file's deployments never demand — the sleeping half of the catalog.
struct Whisper;

impl AsyncResource for Whisper {
  type Error = Infallible;
  type Options = ();

  async fn build(_ctx: &Resources, (): ()) -> Result<Self, Self::Error> {
    Ok(Self)
  }
}

impl DeclaredResource for Whisper {}

/// A resource whose OWN construction reaches the map — the census's gap ② closed, and the reason
/// `build` gained a seat at all: a tokenizer whose vocabulary comes off a model already loaded is
/// the ordinary shape, and before the seat existed it could only be wired by hand.
struct Tokenizer(usize);

impl AsyncResource for Tokenizer {
  type Error = Infallible;
  type Options = ();

  async fn build(ctx: &Resources, (): ()) -> Result<Self, Self::Error> {
    // RESOURCES-FIRST is the launch's own ordering, and it is what makes this honest: whatever the
    // walk built BEFORE this call is in the map, and whatever it has not reached yet is not.
    Ok(Self(ctx.shared::<Egemma>().map_or(0, |model| model.0)))
  }
}

impl DeclaredResource for Tokenizer {}

/// A resource whose own load refuses.
struct Corrupt;

/// The author's own currency, which [`AsyncResource::Error`] bounds by nothing.
#[derive(Debug, derive_more::Display)]
#[display("the weights are corrupt")]
struct CorruptError;

impl core::error::Error for CorruptError {}

impl AsyncResource for Corrupt {
  type Error = CorruptError;
  type Options = ();

  async fn build(_ctx: &Resources, (): ()) -> Result<Self, Self::Error> {
    Err(CorruptError)
  }
}

impl DeclaredResource for Corrupt {}

/// A node with knobs whose options carry a [`Default`] — so a BARE section has something to run it
/// at.
#[derive(Debug)]
struct Decode {
  threads: usize,
  dim: usize,
}

struct DecodeOptions {
  threads: usize,
}

impl Default for DecodeOptions {
  fn default() -> Self {
    Self { threads: 4 }
  }
}

impl AsyncConstructor for Decode {
  type Error = Infallible;
  type Options = DecodeOptions;

  async fn with_options(ctx: &Resources, options: DecodeOptions) -> Result<Self, Self::Error> {
    Ok(Self {
      threads: options.threads,
      // `unwrap_or` rather than `?`: what a missing resource does to a construction is the context's
      // own test, and this one reads which pass built what.
      dim: ctx.shared::<Egemma>().map_or(0, |model| model.0),
    })
  }
}

/// A node whose options have NO [`Default`] — the mandatory-knob shape: legal to declare, and its
/// sections must carry `options`.
#[derive(Debug)]
struct Ingest {
  root: String,
}

struct IngestOptions {
  root: String,
}

impl AsyncConstructor for Ingest {
  type Error = Infallible;
  type Options = IngestOptions;

  async fn with_options(_ctx: &Resources, options: IngestOptions) -> Result<Self, Self::Error> {
    Ok(Self { root: options.root })
  }
}

/// A ZERO-KNOB node — `type Options = ()`, launched by being named and nothing more.
#[derive(Debug)]
struct Watchdog;

impl AsyncConstructor for Watchdog {
  type Error = Infallible;
  type Options = ();

  async fn with_options(_ctx: &Resources, (): ()) -> Result<Self, Self::Error> {
    Ok(Self)
  }
}

/// How many times a `Later` was constructed — what a fail-fast claim reads to say the walk never
/// reached the node after the failure.
///
/// A process-global under a harness that runs its tests at once, so it is readable only because
/// exactly ONE test builds a `Later`. A second one would have to bring its own node type.
static LATER_BUILDS: AtomicUsize = AtomicUsize::new(0);

/// A node whose construction refuses.
#[derive(Debug)]
struct Fickle;

/// The author's own currency again, and the type a caller downcasts back to.
#[derive(Debug, PartialEq, Eq, derive_more::Display)]
#[display("the device is busy")]
struct FickleError;

impl core::error::Error for FickleError {}

impl AsyncConstructor for Fickle {
  type Error = FickleError;
  type Options = ();

  async fn with_options(_ctx: &Resources, (): ()) -> Result<Self, Self::Error> {
    Err(FickleError)
  }
}

/// A node that counts its own constructions.
#[derive(Debug)]
struct Later;

impl AsyncConstructor for Later {
  type Error = Infallible;
  type Options = ();

  async fn with_options(_ctx: &Resources, (): ()) -> Result<Self, Self::Error> {
    LATER_BUILDS.fetch_add(1, Ordering::Relaxed);
    Ok(Self)
  }
}

/// `decode → captions`, both LANDING, so the arrangement passes every validate row on its own and
/// what a test here is about is the create walk rather than the checks before it.
fn graph() -> ChannelGraph {
  let mut builder = GraphBuilder::new();
  let decode = builder.source::<DecodeUnit>("decode", DriverKind::Thread);
  let captions = builder.node::<CaptionsUnit>("captions", DriverKind::Async);
  builder.edge(&decode, &captions, FanoutKind::Broadcast);
  builder.validate().expect("a pair validates")
}

/// A checked deployment of [`graph`] that launches `launched`, where `demands` are the resources
/// the node at `demanding` holds a `Shared` field of.
fn deployment(launched: &[&str], demanding: usize, demands: &[ResourceDemand]) -> Wired {
  let graph = graph();
  let enablement = launched.iter().fold(Enablement::new(), |enablement, node| {
    enablement.launching(*node)
  });
  let mut plan = Plan::new(graph).with_enablement(enablement).with_resources(
    ResourceCatalog::new()
      .with::<Egemma>("egemma", ResourceSource::Prepare)
      .with::<Whisper>("whisper", ResourceSource::Prepare)
      .with::<Corrupt>("corrupt", ResourceSource::Prepare),
  );
  for node in 0..2 {
    plan = plan.wiring(NodeId::new(node), NodeWiring::new(Effect::Lands).landing());
  }
  for demand in demands {
    plan = plan.demanding(NodeId::new(demanding), *demand);
  }
  plan.validate().expect("the arrangement checks out")
}

/// The whole catalog launched, with `decode` demanding the model.
fn demanding_egemma() -> Wired {
  deployment(
    &["decode", "captions"],
    0,
    &[ResourceDemand::of::<Egemma>()],
  )
}

/// A resource an ENABLED node demands is built, and the handle is where a construction looks.
#[tokio::test]
async fn a_demanded_resource_is_built_and_lands_in_the_context() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  assert!(
    walk
      .resource::<Egemma, _>(|| 768)
      .await
      .expect("the model loads")
  );
  assert!(walk.context().holds::<Egemma>());
  assert_eq!(
    walk.context().shared::<Egemma>().expect("it is there").0,
    768
  );
}

/// THE LAZY LAW: a declared resource nobody demands is not built — and its FACTORY never runs, so a
/// deployment that launches none of a catalog's model users needs no options for any of them.
#[tokio::test]
async fn an_undemanded_resource_is_not_built_and_its_factory_never_runs() {
  let wired = demanding_egemma();
  let mut walk = wired.create();
  let mut asked = false;

  assert!(
    !walk
      .resource::<Whisper, _>(|| asked = true)
      .await
      .expect("nothing to refuse")
  );
  assert!(!asked, "an undemanded resource asked for its options");
  assert!(!walk.context().holds::<Whisper>());
}

/// A `Shared<R>` field on a node this deployment does not launch asks for nothing — the lazy law
/// reads ENABLEMENT and not the declaration.
#[tokio::test]
async fn a_demand_from_a_node_that_does_not_launch_builds_nothing() {
  // The demand is `captions`', and no section names `captions`.
  let wired = deployment(&["decode"], 1, &[ResourceDemand::of::<Egemma>()]);
  let mut walk = wired.create();

  assert!(
    !walk
      .resource::<Egemma, _>(|| 768)
      .await
      .expect("nothing to refuse")
  );
  assert!(!walk.context().holds::<Egemma>());
}

/// ONCE per resource type, however many times the walk is told about it: a second call finds the
/// handle already there and loads nothing.
///
/// Read off the VALUE rather than a build count: the second telling asks for a different dimension,
/// so a rebuild would be visible in the handle the context hands back.
#[tokio::test]
async fn a_resource_is_built_once_however_often_the_walk_is_told_about_it() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  assert!(walk.resource::<Egemma, _>(|| 768).await.expect("it loads"));
  assert!(
    !walk
      .resource::<Egemma, _>(|| 1024)
      .await
      .expect("nothing to refuse")
  );

  assert_eq!(
    walk.context().shared::<Egemma>().expect("it is there").0,
    768,
    "the second telling replaced the first build"
  );
}

/// A resource whose own load refuses names the RESOURCE — the party that failed is the thing being
/// built, not whichever node happened to demand it.
#[tokio::test]
async fn a_refused_resource_build_names_the_resource() {
  let wired = deployment(
    &["decode", "captions"],
    0,
    &[ResourceDemand::of::<Corrupt>()],
  );
  let mut walk = wired.create();

  let refused = walk
    .resource::<Corrupt, _>(|| ())
    .await
    .expect_err("the weights are corrupt");

  assert!(refused.is_loading());
  assert!(
    refused.refusals().is_empty(),
    "a create failure is not a list"
  );
  let rendered = refused.to_string();
  assert!(rendered.contains("Corrupt"), "{rendered}");
  assert!(rendered.contains("the weights are corrupt"), "{rendered}");
}

/// A section that states its options goes through `with_options` carrying them.
#[tokio::test]
async fn a_section_that_states_its_options_builds_the_node_with_them() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  let decode = walk
    .node::<Decode>(
      "decode",
      Some(NodeSection::new(DecodeOptions { threads: 8 })),
      bare_options!(Decode),
    )
    .await
    .expect("it builds")
    .expect("the deployment names it");

  assert_eq!(decode.threads, 8);
}

/// A BARE section — present, no `options` — runs the node at its options' own [`Default`], which is
/// [`AsyncConstructor::new`]'s condition restated as data.
#[tokio::test]
async fn a_bare_section_runs_the_node_at_its_options_default() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  let decode = walk
    .node::<Decode>(
      "decode",
      Some(NodeSection::default()),
      bare_options!(Decode),
    )
    .await
    .expect("it builds")
    .expect("the deployment names it");

  assert_eq!(decode.threads, DecodeOptions::default().threads);
  assert_eq!(decode.threads, 4);
}

/// A ZERO-KNOB node is launched by being named: `()` is `Default`, so `[watchdog]` alone is the
/// whole of its deployment.
#[tokio::test]
async fn a_zero_knob_node_is_launched_by_being_named() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  let watchdog = walk
    .node::<Watchdog>(
      "watchdog",
      Some(NodeSection::default()),
      bare_options!(Watchdog),
    )
    .await
    .expect("nothing can refuse")
    .expect("the deployment names it");

  assert!(matches!(watchdog, Watchdog));
}

/// Mandatory knobs, enforced where the record puts them: an options type with no [`Default`] is
/// legal to declare, and a BARE section over one is a CREATE-TIME refusal naming the mount and the
/// options type whose knobs are now the deployment's to write.
#[tokio::test]
async fn a_bare_section_over_mandatory_knobs_is_refused_by_name() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  let refused = walk
    .node::<Ingest>(
      "ingest",
      Some(NodeSection::default()),
      bare_options!(Ingest),
    )
    .await
    .expect_err("its knobs are mandatory");

  assert!(refused.is_construction());
  let rendered = refused.to_string();
  assert!(rendered.contains("`ingest`"), "{rendered}");
  assert!(rendered.contains("IngestOptions"), "{rendered}");
}

/// The same node with its `options` written builds — which is what makes the refusal above a
/// missing VALUE rather than a type the walk cannot build at all.
#[tokio::test]
async fn mandatory_knobs_written_in_the_section_build_the_node() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  let ingest = walk
    .node::<Ingest>(
      "ingest",
      Some(NodeSection::new(IngestOptions {
        root: "/srv/media".to_owned(),
      })),
      bare_options!(Ingest),
    )
    .await
    .expect("it builds")
    .expect("the deployment names it");

  assert_eq!(ingest.root, "/srv/media");
}

/// PRESENCE IS ENABLEMENT: a node no section names is a node the walk does not build.
#[tokio::test]
async fn a_node_no_section_names_is_not_built() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  let decode = walk
    .node::<Decode>("decode", None, bare_options!(Decode))
    .await
    .expect("nothing to refuse");

  assert!(decode.is_none());
}

/// A WRITTEN section builds, and there is no second axis that could stop it.
///
/// THE MUTATION this pins is the soft switch coming back: presence is the whole question, so a
/// section that is there is a node that is built, whatever else the document put beside `options`.
#[tokio::test]
async fn a_written_section_builds_the_node() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  let decode = walk
    .node::<Decode>(
      "decode",
      Some(NodeSection::new(DecodeOptions { threads: 8 })),
      bare_options!(Decode),
    )
    .await
    .expect("it builds")
    .expect("the deployment names it");

  assert_eq!(decode.threads, 8);
}

/// A refused construction names the MOUNT — the word a deployment's section is written under — and
/// keeps the author's own error walkable underneath.
#[tokio::test]
async fn a_refused_construction_names_the_mount_and_keeps_the_typed_source() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  let refused = walk
    .node::<Fickle>(
      "captions",
      Some(NodeSection::default()),
      bare_options!(Fickle),
    )
    .await
    .expect_err("the device is busy");

  assert!(refused.is_construction());
  assert!(refused.to_string().contains("`captions`"));
  let typed = core::error::Error::source(&refused)
    .and_then(core::error::Error::source)
    .and_then(|error| error.downcast_ref::<FickleError>());
  assert_eq!(typed, Some(&FickleError));
}

/// THE ORDER, as the reason for it: a construction reaches the resource an earlier pass built, which
/// is why resources come first and not as a matter of taste.
#[tokio::test]
async fn a_construction_reaches_the_resource_the_walk_built_before_it() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  walk.resource::<Egemma, _>(|| 768).await.expect("it loads");
  let decode = walk
    .node::<Decode>(
      "decode",
      Some(NodeSection::default()),
      bare_options!(Decode),
    )
    .await
    .expect("it builds")
    .expect("the deployment names it");

  assert_eq!(decode.dim, 768);
}

/// CREATE FAILS FAST: the first refusal ends the walk, so nothing after it is constructed. The
/// validate walk's opposite, and for the opposite reason — these steps build.
#[tokio::test]
async fn the_walk_stops_at_the_first_refusal() {
  let wired = demanding_egemma();
  let before = LATER_BUILDS.load(Ordering::Relaxed);

  // The shape an emitted launch has: one `?` per mount, in mount order.
  async fn launch(wired: &Wired) -> Result<(Option<Fickle>, Option<Later>), LaunchError> {
    let mut walk = wired.create();
    let fickle = walk
      .node::<Fickle>(
        "captions",
        Some(NodeSection::default()),
        bare_options!(Fickle),
      )
      .await?;
    let later = walk
      .node::<Later>("decode", Some(NodeSection::default()), bare_options!(Later))
      .await?;
    Ok((fickle, later))
  }

  let refused = launch(&wired).await.expect_err("the device is busy");

  assert!(refused.is_construction());
  assert_eq!(
    LATER_BUILDS.load(Ordering::Relaxed),
    before,
    "the walk built a node after the failure"
  );
}

/// The filled context leaves the walk for the round that wires what it built.
#[tokio::test]
async fn the_walk_hands_its_context_on() {
  let wired = demanding_egemma();
  let mut walk = wired.create();
  walk.resource::<Egemma, _>(|| 768).await.expect("it loads");

  let ctx = walk.into_context();

  assert_eq!(ctx.len(), 1);
  assert!(ctx.holds::<Egemma>());
}

/// A record with a full-text slot, for the mint site's own test.
struct Caption {
  frame: u32,
}

impl Identifiable for Caption {
  type Id = u32;

  fn id_ref(&self) -> &u32 {
    &self.frame
  }
}

impl Transformer for Caption {
  type Graphql = ();
  type Key = u32;
  type Lineage = ();
  type Record = Self;

  fn key(&self) -> u32 {
    self.frame
  }
}

impl FulltextTable for Caption {
  const SLOT: &'static SlotName = SlotName::new("captions");
}

/// A store whose per-slot handle is the NAME it was opened under, which is the one fact the mint
/// site is answerable for.
struct Shelf;

/// What [`Shelf`] hands back — a stateless handle, as the seam's own note says one is.
struct Opened(Utf8Bytes);

impl AsyncFulltextStore for Shelf {
  type Error = Infallible;
  type Handle = Opened;
  type Options = ();

  async fn open((): ()) -> Result<Self, Self::Error> {
    Ok(Self)
  }

  fn fulltext(&self, slot: impl Into<Utf8Bytes>) -> Opened {
    Opened(slot.into())
  }
}

/// THE ONE MINT SITE: the slot is opened under the DECLARATION's own name, so the brand and the
/// path it was opened on come from the same place and cannot be given different answers.
#[tokio::test]
async fn a_slot_is_opened_under_the_declarations_own_name() {
  let wired = demanding_egemma();
  let walk = wired.create();

  let slot = walk.async_fulltext_slot::<Shelf, Caption>(&Shelf);

  assert_eq!(slot.engine().0.as_str(), Caption::SLOT.as_ref());
  assert_eq!(slot.engine().0.as_str(), "captions");
}

/// The probe answers the question the walk cannot ask: `Default` where there is one, and nothing
/// where there is not.
#[test]
fn the_bare_probe_answers_default_where_there_is_one() {
  assert!(bare_options!(Decode).is_some());
  assert_eq!(bare_options!(Watchdog), Some(()));
  assert!(bare_options!(Ingest).is_none());
}

/// **A RESOURCE'S OWN `build` READS THE MAP** — the seat's whole point, and the ordering that makes
/// it truthful.
///
/// The walk builds resources one at a time and inserts each as it goes, so a construction sees the
/// ones the walk reached BEFORE it and no others. That is a fact about ORDER rather than a promise
/// about content: the seat says *whatever has been built so far*, which is exactly what a
/// `[resources]` block read top to bottom means — and a lookup for something further down is the
/// map's own refusal, never a wait and never a panic.
#[tokio::test]
async fn a_resource_build_reaches_what_the_walk_built_before_it() {
  let wired = demanding_egemma();
  let mut walk = wired.create();

  // BEFORE the model: nothing this construction wants is in the map yet, and the honest answer is
  // the refusal naming the type.
  let early = Tokenizer::build(walk.context(), ())
    .await
    .expect("nothing refuses");
  assert_eq!(
    early.0, 0,
    "the walk had built nothing yet, so the lookup refused and the resource said so"
  );

  // AFTER the model, the same construction reads it — the same seat, one insertion later.
  assert!(
    walk
      .resource::<Egemma, _>(|| 768)
      .await
      .expect("the model loads")
  );
  let late = Tokenizer::build(walk.context(), ())
    .await
    .expect("nothing refuses");
  assert_eq!(
    late.0, 768,
    "the map the walk had filled is the one the construction read"
  );
}