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
//! Spawner Linker — a Service-internal helper that takes a compiled
//! `CompiledAgentTable` (the base `SpawnerAdapter`), wraps it with
//! `SpawnerLayer`s via the `LayerRegistry`, and returns the finished
//! `Arc<dyn SpawnerAdapter>`.
//!
//! The old inline loop inside `task_launch.rs` scattered the linker
//! responsibility across the Service path. This module consolidates
//! it into one place, so the Blueprint → Compiled → Linked
//! three-stage split is expressed at the file boundary.
//!
//! # Path
//!
//! ```text
//! Compiler.compile(&Blueprint) → CompiledBlueprint { router: Arc<CompiledAgentTable>, ... }
//! │
//! │ link(router, blueprint.spawner_hints.layers, engine)
//! ▼
//! `Arc<dyn SpawnerAdapter>` (base + every base_factories[*] + every lookup_hint(hints)[*] wrapped)
//! │
//! ▼ EngineDispatcher::with_spawner
//! engine.dispatch_attempt_with(..., &linked) → flow eval
//! ```
//!
//! Unregistered hint keys are **silently skipped** — the
//! `LayerRegistry` default is lenient, so Blueprints stay portable. A
//! strict mode is a carry.
use crateEngine;
use crateSpawnerStack;
use crateSpawnerAdapter;
use Arc;
/// Wrap the compiled base `SpawnerAdapter` with Layers and return the
/// finished value.
///
/// - `base`: `Compiler.compile()`'s `CompiledBlueprint.router`
/// (`Arc<CompiledAgentTable>`), upcast to `Arc<dyn SpawnerAdapter>`.
/// - `layer_hints`: `Blueprint.spawner_hints.layers` — the capability
/// key strings.
/// - `engine`: needed both to look factories up on the
/// `LayerRegistry` and to run them (each base/hint factory takes
/// `&Engine` and returns `Arc<dyn SpawnerLayer>`).
///
/// Order: `base_factories` first (wrapped for every Blueprint), then
/// `lookup_hint` (the layers this Blueprint declares).