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
//! # Build catalogs
//!
//! The catalog of things bunsen can build, as a stack of catalog layers: how
//! a catalog is read, validated, queried and resolved, and how a build is
//! chosen from it. Probing, building, caching and model loading are out of
//! its scope.
//!
//! - [`document`]: the catalog document ([`BunsenCatalog`]) and the serde form
//! it is read from and written to, as YAML or JSON. Every entry names its
//! kind; groups and builds may nest their children.
//! - [`layer`]: one loaded catalog, flattened to full names.
//! - [`stack`]: [`BunsenCatalogStack`], an ordered list of layers. Each new
//! layer is checked against the layers below it; queries fall through the
//! list. A group written in several places has one declaring occurrence and
//! any number of extending occurrences.
//! - [`resolve`]: [`ResolvedBuild`], a build with its template-class chain,
//! memberships, facets, tags, presets and dependencies resolved.
//! - [`presets`]: folding preset sets along a chain (axis uses narrow, never
//! widen), and selecting from the result.
//! - [`lookup`]: finding entries by shorter names, and naming them for people.
//! - [`select`]: the selection pipeline: a query of stages over weighted rows,
//! composed from a tool's preset prefix, its defaults and a request. Axis
//! flags such as `--think` are explained shortcuts into presets.
//! - [`builtin`]: the built-in catalog, `bunsen-catalog`'s layers, imported
//! ([`builtin_stack`]).
//! - `testing::fixtures` (the `testing` feature): example catalogs, for tests,
//! examples and these docs.
//! - [`release_time`], [`tags`], [`name`]: the value types and rules the rest
//! is built from. Preset patches are [merge
//! patches](crate::support::merge_patch).
//!
//! [`catalog_format`] describes the catalog document and the stack, and
//! [`usage`] is the guide: the API from importing catalogs to choosing a build,
//! and the select language.
//!
//! # Example
//!
//! ```
//! use bunsen::data::catalog::{
//! BunsenCatalogStack,
//! presets::PresetSelection,
//! };
//! use serde_json::json;
//!
//! let mut stack = BunsenCatalogStack::new();
//! stack
//! .push_yaml(
//! "prelude",
//! r#"
//! $contracts:
//! demo-lm: { $kind: contract, $description: "What the demo loader reads." }
//! family: { $kind: facet, $description: "A line of related models." }
//! thinking: { $kind: axis, $axis: bool, $description: "Think first." }
//! template_class_root:
//! $kind: template_class
//! $description: "The root of every chain."
//! $required_facets: [family]
//! "#,
//! )
//! .unwrap();
//! stack
//! .push_yaml(
//! "models",
//! r#"
//! demo:
//! $kind: namespace
//! $facet: family
//! $description: "A demo family."
//! thinker:
//! $kind: build
//! $description: "Always thinks."
//! $contract: demo-lm
//! $presets:
//! $axes: { thinking: { $offers: [thinking], $default: thinking } }
//! thinking: { $description: "Think.", $patch: { think: true } }
//! "#,
//! )
//! .unwrap();
//!
//! let name = stack.find_build("thinker").unwrap();
//! let build = stack.resolve_build(&name).unwrap();
//! assert_eq!(build.tag("thinking"), Some(&json!("always")));
//! assert_eq!(build.tag("family"), Some(&json!("demo")));
//! assert_eq!(build.tag("contract"), Some(&json!("demo-lm")));
//! let off = build
//! .presets
//! .check_selection(&PresetSelection::of(["no-thinking"]));
//! assert!(off.unwrap_err().message().contains("fixed at `thinking`"));
//! ```
pub use ;
pub use BunsenCatalog;
pub use ;
pub use ;
pub use ResolvedBuild;
pub use BunsenCatalogStack;