hocon-parser 1.6.0

Full Lightbend HOCON specification-compliant parser for Rust
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
//! S13c — env-var list expansion `${X[]}` / `${?X[]}` conformance tests.
//!
//! Fixtures loaded from `tests/testdata/hocon/env-var-list/` (synced from
//! xx.hocon via `make testdata`). Expected JSON from
//! `tests/testdata/expected/env-var-list/` (also synced via `make testdata`).
//! Both directories are populated by the Makefile's tarball fetch from xx.hocon
//! main and persisted under the crate root so CI (which only checks out
//! rs.hocon) can resolve them without depending on a sibling xx.hocon worktree.
//!
//! Env injection uses `parse_file_with_env` (hermetic — no `std::env::set_var`).

use hocon::HoconValue;
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;

// ── Paths ─────────────────────────────────────────────────────────────────────

fn fixture_dir() -> PathBuf {
    PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/testdata/hocon/env-var-list")
}

fn expected_dir() -> PathBuf {
    // Synced by `make testdata` from xx.hocon main into a crate-local path so CI
    // (which only checks out rs.hocon, no sibling xx.hocon worktree) can find it.
    PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/testdata/expected/env-var-list")
}

fn fixture_path(name: &str) -> PathBuf {
    fixture_dir().join(format!("{}.conf", name))
}

fn env_path(name: &str) -> PathBuf {
    fixture_dir().join(format!("{}.env", name))
}

fn expected_path(name: &str) -> PathBuf {
    expected_dir().join(format!("{}-expected.json", name))
}

// ── Sidecar parser ────────────────────────────────────────────────────────────

/// Parse a KEY=VALUE sidecar file into a `HashMap<String, String>`.
///
/// Rules:
/// - Lines beginning with `#` (after optional leading ASCII space/tab) are comments.
/// - Blank lines are ignored.
/// - `KEY=VALUE` — value is everything after the first `=`; value may be empty.
/// - Keys and values are NOT unquoted / unescaped (fixtures use plain ASCII).
fn parse_env_sidecar(path: &std::path::Path) -> HashMap<String, String> {
    let content = fs::read_to_string(path)
        .unwrap_or_else(|e| panic!("failed to read env sidecar {}: {}", path.display(), e));
    let mut map = HashMap::new();
    for line in content.lines() {
        let trimmed = line.trim_start_matches([' ', '\t']);
        if trimmed.is_empty() || trimmed.starts_with('#') {
            continue;
        }
        if let Some(eq) = trimmed.find('=') {
            let key = trimmed[..eq].to_string();
            let val = trimmed[eq + 1..].to_string();
            map.insert(key, val);
        }
    }
    map
}

// ── JSON helpers (mirrors lightbend_test.rs) ─────────────────────────────────

fn normalize(v: &serde_json::Value) -> serde_json::Value {
    match v {
        serde_json::Value::Object(map) => {
            let mut m = serde_json::Map::new();
            for (k, val) in map {
                m.insert(k.clone(), normalize(val));
            }
            serde_json::Value::Object(m)
        }
        serde_json::Value::Array(arr) => {
            serde_json::Value::Array(arr.iter().map(normalize).collect())
        }
        serde_json::Value::Number(n) => {
            let f = n.as_f64().unwrap_or(0.0);
            serde_json::json!(f)
        }
        other => other.clone(),
    }
}

fn hocon_to_json(v: &hocon::HoconValue) -> serde_json::Value {
    match v {
        hocon::HoconValue::Object(map) => {
            let mut m = serde_json::Map::new();
            for (k, val) in map {
                m.insert(k.clone(), hocon_to_json(val));
            }
            serde_json::Value::Object(m)
        }
        hocon::HoconValue::Array(arr) => {
            serde_json::Value::Array(arr.iter().map(hocon_to_json).collect())
        }
        hocon::HoconValue::Scalar(sv) => match sv.value_type {
            hocon::ScalarType::Null => serde_json::Value::Null,
            hocon::ScalarType::Boolean => serde_json::Value::Bool(sv.raw == "true"),
            hocon::ScalarType::Number => {
                if !sv.raw.contains('.') && !sv.raw.contains('e') && !sv.raw.contains('E') {
                    if let Ok(n) = sv.raw.parse::<i64>() {
                        return serde_json::json!(n as f64);
                    }
                }
                if let Ok(f) = sv.raw.parse::<f64>() {
                    return serde_json::json!(f);
                }
                serde_json::Value::String(sv.raw.clone())
            }
            hocon::ScalarType::String => serde_json::Value::String(sv.raw.clone()),
            _ => serde_json::Value::String(sv.raw.clone()),
        },
        _ => unreachable!("unknown HoconValue variant"),
    }
}

fn key_to_lookup_path(key: &str) -> String {
    if key.is_empty()
        || key.contains('.')
        || key.contains('"')
        || key.contains('\\')
        || key.contains(' ')
        || key.contains('\t')
    {
        let escaped = key.replace('\\', "\\\\").replace('"', "\\\"");
        format!("\"{}\"", escaped)
    } else {
        key.to_string()
    }
}

fn config_to_json(config: &hocon::Config) -> serde_json::Value {
    let mut m = serde_json::Map::new();
    for key in config.keys() {
        let path = key_to_lookup_path(key);
        if let Some(val) = config.get(&path) {
            m.insert(key.to_string(), hocon_to_json(val));
        }
    }
    normalize(&serde_json::Value::Object(m))
}

// ── Fixture helpers ───────────────────────────────────────────────────────────

fn parse_fixture_with_env(name: &str) -> Result<hocon::Config, hocon::HoconError> {
    let env = parse_env_sidecar(&env_path(name));
    hocon::parse_file_with_env(fixture_path(name), &env)
}

fn load_expected_json(name: &str) -> serde_json::Value {
    let path = expected_path(name);
    let s = fs::read_to_string(&path)
        .unwrap_or_else(|e| panic!("failed to read expected {}: {}", path.display(), e));
    let v: serde_json::Value = serde_json::from_str(&s)
        .unwrap_or_else(|e| panic!("invalid JSON in {}: {}", path.display(), e));
    normalize(&v)
}

fn assert_fixture_matches(name: &str) {
    let cfg = parse_fixture_with_env(name)
        .unwrap_or_else(|e| panic!("s13c {}: unexpected parse/resolve error: {:?}", name, e));
    let got = config_to_json(&cfg);
    let expected = load_expected_json(name);
    assert_eq!(
        got,
        expected,
        "s13c {}: output mismatch\n  got:      {}\n  expected: {}",
        name,
        serde_json::to_string_pretty(&got).unwrap(),
        serde_json::to_string_pretty(&expected).unwrap(),
    );
}

// ── ev01: basic env-var list expansion ───────────────────────────────────────

/// ev01: `x = ${S13C_EV01_MY_LIST[]}` with _0=a, _1=b → `{"x": ["a","b"]}`.
#[test]
fn s13c_ev01_basic() {
    assert_fixture_matches("ev01-basic");
}

// ── Remaining success fixtures (ev02, ev04–ev11) ─────────────────────────────

/// ev02: stops at gap (_0 present, _1 absent, _2 present → only ["a"]).
#[test]
fn s13c_ev02_stops_at_gap() {
    assert_fixture_matches("ev02-stops-at-gap");
}

/// ev04: optional with no _0 → key absent (`{}`).
#[test]
fn s13c_ev04_optional_no_elements() {
    assert_fixture_matches("ev04-optional-no-elements");
}

/// ev05: config-defined wins (E6). `${X[]}` returns config value, not env list.
#[test]
fn s13c_ev05_config_defined_wins() {
    assert_fixture_matches("ev05-config-defined-wins");
}

/// ev06: concat prepend — `["x","y"] ${?S13C_EV06_MY_LIST[]}` → `["x","y","a"]`.
#[test]
fn s13c_ev06_concat_prepend() {
    assert_fixture_matches("ev06-concat-prepend");
}

/// ev07: concat append — `${?S13C_EV07_MY_LIST[]} ["x","y"]` → `["a","x","y"]`.
#[test]
fn s13c_ev07_concat_append() {
    assert_fixture_matches("ev07-concat-append");
}

/// ev09: E7 — whitespace before `[]` in fixture: `${S13C_EV09_MY_LIST []}`.
#[test]
fn s13c_ev09_whitespace_before_suffix() {
    assert_fixture_matches("ev09-whitespace-before-suffix");
}

/// ev10: empty-string element is preserved (stop on absent key, not empty value).
#[test]
fn s13c_ev10_empty_string_element() {
    assert_fixture_matches("ev10-empty-string-element");
}

/// ev11: include context — relativized fallback strips include prefix.
#[test]
fn s13c_ev11_include_context() {
    assert_fixture_matches("ev11-include-context");
}

// ── Unit 7: error fixture ─────────────────────────────────────────────────────

/// ev03: required `${S13C_EV03_MY_LIST[]}` with no _0 → ResolveError.
#[test]
fn s13c_ev03_required_no_elements_errors() {
    let result = parse_fixture_with_env("ev03-required-no-elements");
    assert!(
        matches!(result, Err(hocon::HoconError::Resolve(_))),
        "ev03: required list with no _0 must raise ResolveError, got: {:?}",
        result
    );
}

// ── Unit 8: S13c.5 — scalar env fallback suppressed when list_suffix=true ────

/// When `list_suffix=true` and config lookup misses AND no `_0` element exists,
/// the resolver must NOT fall through to the scalar env fallback.
/// Required form must raise ResolveError.
#[test]
fn s13c_s5_required_no_scalar_fallback() {
    let mut env = HashMap::new();
    env.insert("S13C_BARE".into(), "scalar".into());
    // No S13C_BARE_0 → list lookup finds nothing → must error (not "scalar").
    let result = hocon::parse_with_env("x = ${S13C_BARE[]}", &env);
    assert!(
        matches!(result, Err(hocon::HoconError::Resolve(_))),
        "S13c.5: required list with no _0 must raise ResolveError even when bare key exists, got: {:?}",
        result
    );
}

/// Optional form with `list_suffix=true` and no `_0` → key absent, not scalar fallback.
#[test]
fn s13c_s5_optional_no_scalar_fallback() {
    let mut env = HashMap::new();
    env.insert("S13C_BARE_OPT".into(), "scalar".into());
    // No S13C_BARE_OPT_0 → optional list lookup finds nothing → key removed.
    let cfg = hocon::parse_with_env("x = ${?S13C_BARE_OPT[]}", &env)
        .expect("s13c.5: optional list with no _0 must parse OK (key dropped)");
    // x must be absent (not "scalar")
    assert!(
        cfg.get("x").is_none(),
        "S13c.5: optional list with no _0 must drop key (got {:?})",
        cfg.get("x")
    );
}

// ── Unit 9: ev08 — self-ref concat with list suffix ──────────────────────────

/// ev08: `x = ["x"]; x = ${?x} ${?LIST[]}` → `["x","a"]`.
///
/// The prior value `x = ["x"]` is found by the self-ref look-back, so the array
/// concat resolves correctly. Ships as a regular ✅ success test.
#[test]
fn s13c_ev08_self_ref_concat() {
    assert_fixture_matches("ev08-self-append");
}

// ── Multi-agent-review regressions ───────────────────────────────────────────
//
// The following tests pin three bugs caught during /multi-agent-review of this
// branch (Codex Critical C1 + Important I1/I2; convergent with ts.hocon).

/// C1: `${X}` and `${X[]}` must NOT collide in the substitution cache.
///
/// Before the fix, the cache key was `segments_to_key(s.segments)` only, so
/// whichever form resolved first poisoned the cache for the other. Verified
/// in both directions to ensure neither path wins by accident.
#[test]
fn s13c_cache_disambiguation_scalar_then_list() {
    let mut env = HashMap::new();
    env.insert("S13C_CACHE_X".to_string(), "scalar-val".to_string());
    env.insert("S13C_CACHE_X_0".to_string(), "a".to_string());
    env.insert("S13C_CACHE_X_1".to_string(), "b".to_string());
    let cfg = hocon::parse_with_env("a = ${S13C_CACHE_X}\nb = ${S13C_CACHE_X[]}", &env)
        .expect("parse_with_env");
    assert_eq!(cfg.get_string("a").unwrap(), "scalar-val");
    let b = cfg.get_list("b").expect("b should be list");
    let texts: Vec<String> = b
        .iter()
        .map(|v| match v {
            HoconValue::Scalar(sv) => sv.raw.clone(),
            _ => panic!("expected scalar element in b"),
        })
        .collect();
    assert_eq!(texts, vec!["a", "b"]);
}

#[test]
fn s13c_cache_disambiguation_list_then_scalar() {
    let mut env = HashMap::new();
    env.insert("S13C_CACHE2_X".to_string(), "scalar-val".to_string());
    env.insert("S13C_CACHE2_X_0".to_string(), "a".to_string());
    env.insert("S13C_CACHE2_X_1".to_string(), "b".to_string());
    let cfg = hocon::parse_with_env("a = ${S13C_CACHE2_X[]}\nb = ${S13C_CACHE2_X}", &env)
        .expect("parse_with_env");
    let a = cfg.get_list("a").expect("a should be list");
    let texts: Vec<String> = a
        .iter()
        .map(|v| match v {
            HoconValue::Scalar(sv) => sv.raw.clone(),
            _ => panic!("expected scalar element in a"),
        })
        .collect();
    assert_eq!(texts, vec!["a", "b"]);
    assert_eq!(cfg.get_string("b").unwrap(), "scalar-val");
}

/// Bracket-quoted cache disambiguation (Copilot rs#88 round-1 finding).
///
/// `${"X[]"}` is a quoted segment whose literal text is `X[]`; resolved via
/// env lookup of the bare key `X[]` (no `_N` suffix expansion). `${X[]}` is the
/// list-suffix form on bare path `X`; resolved via env scan of `X_0, X_1, …`.
/// These two MUST occupy distinct cache slots — before the round-2 fix
/// (`segments_to_key` quote trigger gained `[` and `]`), both produced the
/// raw cache key `X[]` because `segments_to_key` didn't escape brackets.
/// Now `${"X[]"}` keys as `"X[]"` (quoted) and `${X[]}` keys as `X[]` (raw +
/// list_suffix `[]` append). This test pins both directions so the regression
/// would surface if either the bracket trigger or the `[]` append is removed.
#[test]
fn s13c_cache_disambiguation_quoted_brackets_then_list() {
    let mut env = HashMap::new();
    env.insert("X[]".to_string(), "literal-bracket-key".to_string());
    env.insert("X_0".to_string(), "first".to_string());
    env.insert("X_1".to_string(), "second".to_string());
    let cfg = hocon::parse_with_env("a = ${\"X[]\"}\nb = ${X[]}", &env).expect("parse_with_env");
    assert_eq!(cfg.get_string("a").unwrap(), "literal-bracket-key");
    let b = cfg
        .get_list("b")
        .expect("b should be list, not the cached scalar");
    let texts: Vec<String> = b
        .iter()
        .map(|v| match v {
            HoconValue::Scalar(sv) => sv.raw.clone(),
            _ => panic!("expected scalar element in b"),
        })
        .collect();
    assert_eq!(texts, vec!["first", "second"]);
}

#[test]
fn s13c_cache_disambiguation_list_then_quoted_brackets() {
    let mut env = HashMap::new();
    env.insert("X[]".to_string(), "literal-bracket-key".to_string());
    env.insert("X_0".to_string(), "first".to_string());
    env.insert("X_1".to_string(), "second".to_string());
    let cfg = hocon::parse_with_env("a = ${X[]}\nb = ${\"X[]\"}", &env).expect("parse_with_env");
    let a = cfg.get_list("a").expect("a should be list");
    let texts: Vec<String> = a
        .iter()
        .map(|v| match v {
            HoconValue::Scalar(sv) => sv.raw.clone(),
            _ => panic!("expected scalar element in a"),
        })
        .collect();
    assert_eq!(texts, vec!["first", "second"]);
    assert_eq!(
        cfg.get_string("b").unwrap(),
        "literal-bracket-key",
        "b should be scalar, not the cached list"
    );
}

/// `${X.[]}` must be rejected as empty-segment-before-suffix at parse time.
///
/// The empty-segment guard at the `'[' =>` arm fires when `!cur_started` (no
/// segment text is being accumulated), uniformly handling both `${[]}` (no
/// segments at all) and `${X.[]}` (trailing dot just reset cur_started but
/// segments already has entries from prior parsing).
///
/// Tests assert specifically `Err(HoconError::Parse(_))` rather than any error
/// because an empty env map could otherwise let resolution fail with
/// HoconError::Resolve and mask a lexer regression (Copilot review on rs#88).
#[test]
fn s13c_lex_trailing_dot_before_suffix_errors() {
    let env = HashMap::new();
    let err = hocon::parse_with_env("x = ${A.[]}", &env);
    assert!(
        matches!(err, Err(hocon::HoconError::Parse(_))),
        "expected HoconError::Parse for ${{A.[]}}, got {:?}",
        err
    );
}

#[test]
fn s13c_lex_trailing_dot_space_before_suffix_errors() {
    let env = HashMap::new();
    let err = hocon::parse_with_env("x = ${A . []}", &env);
    assert!(
        matches!(err, Err(hocon::HoconError::Parse(_))),
        "expected HoconError::Parse for ${{A . []}}, got {:?}",
        err
    );
}

/// E7 narrow-allow-list — only ASCII SPACE / TAB allowed before `[]`.
///
/// The `[` arm validates pending_ws and rejects any non-{space,tab} char.
/// General subst-body inter-segment whitespace is broader (S6 set: NBSP, CR,
/// Zs, BOM, …) but at the `[` arm we are strict per extra-spec E7.
///
/// Tests assert specifically `Err(HoconError::Parse(_))` for the same reason as
/// the trailing-dot tests above (Copilot review on rs#88).
#[test]
fn s13c_lex_nbsp_before_suffix_errors() {
    let env = HashMap::new();
    let err = hocon::parse_with_env("x = ${A\u{00A0}[]}", &env);
    assert!(
        matches!(err, Err(hocon::HoconError::Parse(_))),
        "expected HoconError::Parse for ${{A\\u00A0[]}} (NBSP), got {:?}",
        err
    );
}

#[test]
fn s13c_lex_cr_before_suffix_errors() {
    let env = HashMap::new();
    let err = hocon::parse_with_env("x = ${A\r[]}", &env);
    assert!(
        matches!(err, Err(hocon::HoconError::Parse(_))),
        "expected HoconError::Parse for ${{A\\r[]}} (CR), got {:?}",
        err
    );
}

#[test]
fn s13c_lex_zs_em_space_before_suffix_errors() {
    let env = HashMap::new();
    let err = hocon::parse_with_env("x = ${A\u{2003}[]}", &env);
    assert!(
        matches!(err, Err(hocon::HoconError::Parse(_))),
        "expected HoconError::Parse for ${{A\\u2003[]}} (em-space), got {:?}",
        err
    );
}

/// E7 positive sanity: ASCII space + tab should still pass.
#[test]
fn s13c_lex_e7_ascii_space_tab_before_suffix_ok() {
    let mut env = HashMap::new();
    env.insert("S13C_E7_OK_0".to_string(), "v".to_string());
    let cfg = hocon::parse_with_env("x = ${S13C_E7_OK []}", &env)
        .expect("space before [] should be accepted");
    assert!(cfg.has("x"));
    let cfg2 = hocon::parse_with_env("x = ${S13C_E7_OK\t[]}", &env)
        .expect("tab before [] should be accepted");
    assert!(cfg2.has("x"));
}

/// `${"a"[]}` — quoted segment followed by suffix. Sanity-pin positive.
#[test]
fn s13c_lex_quoted_segment_with_suffix_ok() {
    let mut env = HashMap::new();
    env.insert("a_0".to_string(), "v".to_string());
    let cfg = hocon::parse_with_env(r#"x = ${"a"[]}"#, &env)
        .expect("quoted segment + suffix should be accepted");
    let list = cfg.get_list("x").expect("x should be list");
    assert_eq!(list.len(), 1);
    match &list[0] {
        HoconValue::Scalar(sv) => assert_eq!(sv.raw, "v"),
        _ => panic!("expected scalar element"),
    }
}

// ── E6 cross-source: ev12c (xx.hocon#22) ─────────────────────────────────────

/// ev12c — E6 cross-source: `${X[]}` in an included file falls back to root
/// config when `X` is defined in the including (parent) file at root, AND
/// must win over a competing env-var list expansion candidate.
///
/// Fixture has no `.env` sidecar; this test seeds explicit env entries
/// (`S13C_EV12C_X_0 = "env-val"`) so the assertion proves resolver ORDER,
/// not just S14c.2 reachability. With config-first ordering (Lightbend 1.4.6
/// reference behavior) the result is `["root-val"]`; with a hypothetical
/// env-list-first ordering it would be `["env-val"]`.
///
/// `SubstitutionResolver::resolve_substitution` runs (in order): primary
/// lookup → S14c.2 original-path fallback → listSuffix env expansion →
/// scalar env fallback. The S14c.2 hit at root wins before the listSuffix
/// branch runs. Pinned here as a cross-impl regression after xx.hocon#22
/// (cluster C1) shipped the fixture.
#[test]
fn s13c_ev12c_e6_cross_source_include_config_wins() {
    // Seed an env-list candidate that would beat config IF the resolver
    // erroneously consulted listSuffix before S14c.2. Per E6 / Lightbend 1.4.6
    // semantics, root config `S13C_EV12C_X = ["root-val"]` must win.
    let mut env = HashMap::new();
    env.insert("S13C_EV12C_X_0".to_string(), "env-val".to_string());

    let cfg = hocon::parse_file_with_env(fixture_path("ev12c-include-config-defined-wins"), &env)
        .expect("ev12c: cross-source resolution should succeed");
    let got = config_to_json(&cfg);
    let expected = load_expected_json("ev12c-include-config-defined-wins");
    assert_eq!(
        got,
        expected,
        "ev12c: cross-source config-defined wins mismatch (env-list candidate present — \
         a failure here likely means listSuffix ran before S14c.2)\n  \
         got:      {}\n  expected: {}",
        serde_json::to_string_pretty(&got).unwrap(),
        serde_json::to_string_pretty(&expected).unwrap(),
    );
}

// Note: resolver-order unit test (spec OQ-4) was considered but dropped as
// redundant: ev05 already pins same-source config-wins-over-env (with sidecar
// env vars set), and ev12c above pins cross-source config-wins via S14c.2.
// Together they cover the full ordering: primary → S14c.2 → listSuffix.