|
1 | 1 | // src/ingest.typ |
2 | | -// TOML ingestion layer. Parses TOML strings into core constructor dicts. |
| 2 | +// Data ingestion layer. Parses TOML/YAML strings into core constructor dicts. |
3 | 3 | // |
4 | | -// Public symbol: from-toml(raw) |
| 4 | +// Public symbols: from-toml(raw), from-yaml(raw) |
5 | 5 | // |
6 | 6 | // This is a core module — it imports sibling src/primitives.typ directly |
7 | 7 | // (same layer as render.typ and validate.typ). It calls constructors to |
8 | 8 | // ensure all validation fires on the parsed data. |
9 | 9 | // |
10 | | -// Partial TOML: missing sections produce missing keys in the result dict. |
| 10 | +// Partial data: missing sections produce missing keys in the result dict. |
11 | 11 | // Full assembly: when all required sections are present, builds a prompt |
12 | 12 | // via p-prompt(). Metadata ([rationale], constraint severity) is preserved |
13 | 13 | // in the result but never rendered. |
|
16 | 16 |
|
17 | 17 |
|
18 | 18 | // ───────────────────────────────────────────── |
19 | | -// from-toml |
| 19 | +// _from-data (private) |
20 | 20 | // |
21 | | -// raw: string — TOML-encoded prompt data |
| 21 | +// data: dictionary — parsed prompt data (from toml() or yaml()) |
22 | 22 | // |
23 | 23 | // Returns a dictionary with optional keys: |
24 | 24 | // context, schema, constraints, steps, inputs, checkpoints, |
25 | 25 | // aspect, prompt, meta, constraints-meta |
26 | 26 | // |
27 | | -// Missing TOML sections → absent keys (no panic). |
| 27 | +// Missing sections → absent keys (no panic). |
28 | 28 | // Present sections with invalid data → panic via constructor validation. |
29 | 29 | // ───────────────────────────────────────────── |
30 | 30 |
|
31 | | -#let from-toml(raw) = { |
32 | | - let data = toml(bytes(raw)) |
| 31 | +#let _from-data(data) = { |
33 | 32 | let result = (:) |
34 | 33 |
|
35 | 34 | // ── aspect metadata ── |
|
140 | 139 |
|
141 | 140 | result |
142 | 141 | } |
| 142 | + |
| 143 | + |
| 144 | +// ───────────────────────────────────────────── |
| 145 | +// from-toml |
| 146 | +// |
| 147 | +// raw: string — TOML-encoded prompt data |
| 148 | +// ───────────────────────────────────────────── |
| 149 | + |
| 150 | +#let from-toml(raw) = _from-data(toml(bytes(raw))) |
| 151 | + |
| 152 | + |
| 153 | +// ───────────────────────────────────────────── |
| 154 | +// from-yaml |
| 155 | +// |
| 156 | +// raw: string — YAML-encoded prompt data |
| 157 | +// ───────────────────────────────────────────── |
| 158 | + |
| 159 | +#let from-yaml(raw) = _from-data(yaml(bytes(raw))) |
0 commit comments