helm-schema-ir 0.0.4

Generate an accurate JSON schema for any helm chart
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
mod contract;
mod contract_signals;
mod expr_eval;
mod expr_eval_helper_hooks;
mod fragment_expr_eval;
mod fragment_scope_eval;
mod resource_identity;
mod symbolic_local_state;

use crate::{Guard, SymbolicIrContext, ValueKind, YamlPath};
use color_eyre::eyre;
use helm_schema_core::{DYNAMIC_MAPPING_VALUE_SEGMENT, GuardDnf, Predicate};
use indoc::indoc;

/// The raw per-branch guard stacks of one helper meta (branch predicates in
/// canonical guard order plus the defaulted marker), the same lowering the
/// fragment projection's pathless reads use. Test-side replacement for the
/// retired emission-side `contract_guard_sets` (which additionally applied
/// the deleted sibling/suppression prune algebra).
pub(crate) fn raw_guard_sets(
    meta: &crate::helper_meta::HelperOutputMeta,
    source_expr: &str,
) -> Vec<Vec<Guard>> {
    let branches: Vec<Vec<Predicate>> = if meta.predicates.is_empty() {
        vec![Vec::new()]
    } else {
        meta.predicates
            .iter()
            .map(|branch| branch.iter().cloned().collect())
            .collect()
    };
    let mut condition = GuardDnf::from_contract_predicate_disjunction_preserving_evidence(branches);
    if meta.defaulted {
        condition = condition.conjoined_with_guards([Guard::Default {
            path: source_expr.to_string(),
        }]);
    }
    condition.guard_conjunctions()
}
use helm_schema_ast::DefineIndex;
use test_util::prelude::sim_assert_eq;

/// Simple template IR generation test.
#[test]
fn simple_template_ir() {
    let src = indoc! {r"
        {{- if .Values.enabled }}
        foo: {{ .Values.name }}
        {{- end }}
    "};
    let idx = DefineIndex::new();
    let ir = SymbolicIrContext::new(&idx)
        .generate_contract_ir(src)
        .finalize();

    assert!(ir.uses().iter().any(|u| u.source_expr == "enabled"
        && u.single_guard_conjunction()
            == vec![Guard::Truthy {
                path: "enabled".to_string()
            }]));
    assert!(ir.uses().iter().any(|u| u.source_expr == "name"
        && u.path == YamlPath(vec!["foo".to_string()])
        && u.kind == ValueKind::Scalar
        && u.single_guard_conjunction()
            == vec![Guard::Truthy {
                path: "enabled".to_string()
            }]));
}

#[test]
fn direct_tpl_files_get_executes_json_template_source() {
    let src = indoc! {r#"
        apiVersion: v1
        kind: Secret
        data:
          clients.json: {{ tpl (.Files.Get "config/client-auth.json") . | b64enc }}
    "#};
    let file = indoc! {r"
        {{- range $user := .Values.users }}
        {{ $user.username }}: {{ $user.password }}
        {{- end }}
    "};
    let mut index = DefineIndex::new();
    index.add_file_source("config/client-auth.json", file);
    let ir = SymbolicIrContext::new(&index)
        .generate_contract_ir(src)
        .finalize();

    for path in ["users.*.username", "users.*.password"] {
        assert!(
            ir.uses().iter().any(|use_| use_.source_expr == path),
            "the tpl-executed file should contribute {path}: {ir:#?}"
        );
    }
}

#[test]
fn base_path_include_executes_implicit_template_source() {
    let src = indoc! {r#"
        apiVersion: v1
        kind: ConfigMap
        data:
          initialize: |-
            {{ include (print $.Template.BasePath "/_create.txt") . | nindent 4 }}
    "#};
    let partial = indoc! {r"
        {{- range $bucket := .Values.buckets }}
        create {{ $bucket.name }}
        {{- end }}
    "};
    let mut index = DefineIndex::new();
    index.add_file_source("templates/_create.txt", partial);
    let ir = SymbolicIrContext::new(&index)
        .generate_contract_ir(src)
        .finalize();

    assert!(
        ir.uses()
            .iter()
            .any(|use_| use_.source_expr == "buckets.*.name"),
        "the implicit template body should contribute its member access: {ir:#?}"
    );
}

#[test]
fn dynamic_mapping_value_projects_structural_member_path() {
    let src = indoc! {r"
        apiVersion: v1
        kind: ConfigMap
        data:
          {{- range $key, $value := .Values.entries }}
          {{ $key }}: {{ $value }}
          {{- end }}
    "};
    let idx = DefineIndex::new();
    let ir = SymbolicIrContext::new(&idx)
        .generate_contract_ir(src)
        .finalize();

    assert!(ir.uses().iter().any(|use_| {
        use_.source_expr == "entries.*"
            && use_.path
                == YamlPath(vec![
                    "data".to_string(),
                    DYNAMIC_MAPPING_VALUE_SEGMENT.to_string(),
                ])
            && use_.kind == ValueKind::Scalar
    }));
}

#[test]
fn document_output_projection_preserves_resource_claim() {
    let src = indoc! {r"
        apiVersion: v1
        kind: Service
        metadata:
          name: {{ .Values.serviceName }}
    "};
    let idx = DefineIndex::new();
    let ir = SymbolicIrContext::new(&idx)
        .generate_contract_ir(src)
        .finalize();

    let name_use = ir
        .uses()
        .iter()
        .find(|use_| use_.source_expr == "serviceName")
        .expect("serviceName use");

    sim_assert_eq!(
        have: name_use.path,
        want: YamlPath(vec!["metadata".to_string(), "name".to_string()])
    );
    let resource = name_use.resource.as_ref().expect("resource claim");
    sim_assert_eq!(have: resource.api_version, want: "v1");
    sim_assert_eq!(have: resource.kind, want: "Service");
}

#[test]
fn scalar_helper_document_projection_preserves_resource_claim() {
    let helpers = indoc! {r#"
        {{- define "common.serviceName" -}}
        {{ .Values.serviceName }}
        {{- end -}}
    "#};
    let src = indoc! {r#"
        apiVersion: v1
        kind: Service
        metadata:
          name: {{ include "common.serviceName" . }}
    "#};
    let mut idx = DefineIndex::new();
    idx.add_file_source("<inline:0>", helpers);
    let ir = SymbolicIrContext::new(&idx)
        .generate_contract_ir(src)
        .finalize();

    let name_use = ir
        .uses()
        .iter()
        .find(|use_| use_.source_expr == "serviceName")
        .expect("serviceName use");

    sim_assert_eq!(
        have: name_use.path,
        want: YamlPath(vec!["metadata".to_string(), "name".to_string()])
    );
    let resource = name_use.resource.as_ref().expect("resource claim");
    sim_assert_eq!(have: resource.api_version, want: "v1");
    sim_assert_eq!(have: resource.kind, want: "Service");
}

#[test]
fn document_guard_survives_helper_sibling_claim_scoping() {
    let helpers = indoc! {r#"
        {{- define "guarded.port" -}}
        {{- if .enabled -}}
        {{- .port -}}
        {{- end -}}
        {{- end -}}
    "#};
    let src = indoc! {r#"
        {{- if .Values.enabled }}
        apiVersion: v1
        kind: Service
        spec:
          value: {{ include "guarded.port" (dict "enabled" .Values.enabled "port" .Values.port) }}
        {{- end }}
    "#};
    let mut index = DefineIndex::new();
    index.add_file_source("<inline:0>", helpers);
    let ir = SymbolicIrContext::new(&index)
        .generate_contract_ir(src)
        .finalize();

    let port = ir
        .uses()
        .iter()
        .find(|use_| use_.source_expr == "port" && !use_.path.0.is_empty())
        .unwrap_or_else(|| panic!("expected rendered port use: {ir:#?}"));
    assert!(
        port.single_guard_conjunction().contains(&Guard::Truthy {
            path: "enabled".to_string(),
        }),
        "the document guard executes outside the helper's sibling claims: {port:#?}"
    );
}

#[test]
fn document_branch_guard_survives_local_helper_reassignment() {
    let helpers = indoc! {r#"
        {{- define "selected.value" -}}
        {{- .Values.payload -}}
        {{- end -}}
    "#};
    let src = indoc! {r#"
        {{- $selected := "" -}}
        {{- if eq .Values.mode "active" -}}
        {{- $selected = include "selected.value" . -}}
        {{- end -}}
        {{- if $selected }}
        apiVersion: v1
        kind: ConfigMap
        data:
          value: {{ $selected }}
        {{- end }}
    "#};
    let mut index = DefineIndex::new();
    index.add_file_source("<inline:0>", helpers);
    let ir = SymbolicIrContext::new(&index)
        .generate_contract_ir(src)
        .finalize();

    let payload = ir
        .uses()
        .iter()
        .find(|use_| {
            use_.source_expr == "payload"
                && use_.path == YamlPath(vec!["data".to_string(), "value".to_string()])
        })
        .unwrap_or_else(|| panic!("expected rendered payload use: {ir:#?}"));
    assert!(
        payload.single_guard_conjunction().contains(&Guard::Eq {
            path: "mode".to_string(),
            value: helm_schema_core::GuardValue::string("active"),
        }),
        "the assignment branch must remain on the local's rendered value: {payload:#?}"
    );
}

#[test]
fn document_local_coalesce_preserves_ordered_candidate_selection() {
    let src = indoc! {r"
        {{- $selected := coalesce .Values.primary .Values.fallback -}}
        apiVersion: v1
        kind: Secret
        data:
          value: {{ $selected | b64enc | quote }}
    "};
    let ir = SymbolicIrContext::new(&DefineIndex::new())
        .generate_contract_ir(src)
        .finalize();

    let primary = ir
        .uses()
        .iter()
        .find(|use_| use_.source_expr == "primary" && !use_.path.0.is_empty())
        .unwrap_or_else(|| panic!("expected rendered primary use: {ir:#?}"));
    sim_assert_eq!(
        have: primary.condition.guard_conjunctions(),
        want: vec![vec![
            Guard::Truthy {
                path: "primary".to_string(),
            },
            Guard::Default {
                path: "primary".to_string(),
            },
        ]]
    );

    let fallback = ir
        .uses()
        .iter()
        .find(|use_| use_.source_expr == "fallback" && !use_.path.0.is_empty())
        .unwrap_or_else(|| panic!("expected rendered fallback use: {ir:#?}"));
    sim_assert_eq!(
        have: fallback.condition.guard_conjunctions(),
        want: vec![vec![
            Guard::Truthy {
                path: "fallback".to_string(),
            },
            Guard::Not {
                path: "primary".to_string(),
            },
            Guard::Default {
                path: "fallback".to_string(),
            },
        ]]
    );
}

#[test]
fn helper_type_dispatch_keeps_or_candidate_selection_on_each_row() {
    let helpers = indoc! {r#"
        {{- define "selected.value" -}}
        {{- $selected := or .Values.primary .Values.fallback -}}
        {{- if $selected -}}
        {{- $type := typeOf $selected -}}
        {{- if eq $type "string" -}}
        {{ tpl $selected . }}
        {{- else -}}
        {{ toYaml $selected }}
        {{- end -}}
        {{- end -}}
        {{- end -}}
    "#};
    let src = indoc! {r#"
        apiVersion: v1
        kind: ConfigMap
        data:
          value: {{ include "selected.value" . | quote }}
    "#};
    let mut index = DefineIndex::new();
    index.add_file_source("<inline:0>", helpers);
    let ir = SymbolicIrContext::new(&index)
        .generate_contract_ir(src)
        .finalize();

    let primary = ir
        .uses()
        .iter()
        .filter(|use_| use_.source_expr == "primary" && !use_.path.0.is_empty())
        .collect::<Vec<_>>();
    assert!(!primary.is_empty(), "expected primary rows: {ir:#?}");
    assert!(
        primary.iter().all(|use_| {
            use_.condition
                .disjuncts()
                .iter()
                .all(|branch| branch.contains(&Predicate::truthy_path("primary")))
        }),
        "every rendered primary row must retain its selection predicate: {primary:#?}"
    );

    let fallback = ir
        .uses()
        .iter()
        .filter(|use_| use_.source_expr == "fallback" && !use_.path.0.is_empty())
        .collect::<Vec<_>>();
    assert!(!fallback.is_empty(), "expected fallback rows: {ir:#?}");
    assert!(
        fallback.iter().all(|use_| {
            use_.condition
                .disjuncts()
                .iter()
                .all(|branch| branch.contains(&Predicate::truthy_path("primary").negated()))
        }),
        "every rendered fallback row must retain the earlier empty predicate: {fallback:#?}"
    );
}

#[test]
fn opaque_include_guard_abstains_from_provider_schema_evidence() {
    // The arm renders a VALUES-dependent token, so the helper is not a
    // literal dispatch and the include guard stays undecodable. (A pure
    // literal arm now decodes exactly and no longer exercises abstention.)
    let helpers = indoc! {r#"
        {{- define "resource.enabled" -}}
        {{- if .Values.enabled -}}
        {{ .Values.marker }}
        {{- end -}}
        {{- end -}}
    "#};
    let src = indoc! {r#"
        {{- if include "resource.enabled" . }}
        apiVersion: v1
        kind: ConfigMap
        data:
          value: {{ .Values.payload }}
        {{- end }}
    "#};
    let mut index = DefineIndex::new();
    index.add_file_source("<inline:0>", helpers);
    let finalized = SymbolicIrContext::new(&index)
        .generate_contract_ir(src)
        .finalize();

    let payload = finalized
        .uses()
        .iter()
        .find(|use_| {
            use_.source_expr == "payload"
                && use_.path == YamlPath(vec!["data".to_string(), "value".to_string()])
        })
        .unwrap_or_else(|| panic!("expected rendered payload use: {finalized:#?}"));
    assert!(
        payload
            .condition
            .disjuncts()
            .iter()
            .all(|conjunction| conjunction.iter().any(Predicate::contains_approximation)),
        "the unlowerable include result must remain approximate in memory: {payload:#?}"
    );
    assert!(
        finalized
            .schema_signals()
            .schema_evidence_by_value_path()
            .get("payload")
            .is_none_or(|evidence| evidence.provider_schema_uses.is_empty()),
        "an approximate resource guard must not leak provider constraints: {finalized:#?}"
    );
}

#[test]
fn scalar_helper_document_projection_preserves_scope_guard() {
    let helpers = indoc! {r#"
        {{- define "common.serviceName" -}}
        {{ .Values.serviceName }}
        {{- end -}}
    "#};
    let src = indoc! {r#"
        apiVersion: v1
        kind: Service
        metadata:
          {{- if .Values.enabled }}
          name: {{ include "common.serviceName" . }}
          {{- end }}
    "#};
    let mut idx = DefineIndex::new();
    idx.add_file_source("<inline:0>", helpers);
    let ir = SymbolicIrContext::new(&idx)
        .generate_contract_ir(src)
        .finalize();

    let name_use = ir
        .uses()
        .iter()
        .find(|use_| use_.source_expr == "serviceName")
        .expect("serviceName use");

    sim_assert_eq!(
        have: name_use.single_guard_conjunction(),
        want: vec![Guard::Truthy {
            path: "enabled".to_string()
        }]
    );
}

#[test]
fn labels_helper_does_not_apply_custom_label_guard_to_name_helper_dependency() -> eyre::Result<()> {
    let src = indoc! {r#"
        {{- if .Values.networkPolicy.enabled }}
        apiVersion: networking.k8s.io/v1
        kind: NetworkPolicy
        metadata:
          name: {{ template "common.names.fullname" . }}
          labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
        spec:
          podSelector:
            matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }}
        {{- end }}
    "#};
    let mut idx = DefineIndex::new();
    let sources = test_util::DefineSourceSpec {
        helper_templates: &[],
        helper_template_dirs: &[("charts/common/templates", "tpl")],
        file_sources: &[],
    }
    .load()?;
    for source in sources {
        idx.add_file_source(&source.path, &source.source);
    }
    let ir = SymbolicIrContext::new(&idx)
        .generate_contract_ir(src)
        .finalize();

    let name_override_uses = ir
        .uses()
        .iter()
        .filter(|use_| use_.source_expr == "nameOverride")
        .collect::<Vec<_>>();

    let pathless_name_override_uses = name_override_uses
        .iter()
        .filter(|use_| use_.path.0.is_empty())
        .collect::<Vec<_>>();
    assert!(
        pathless_name_override_uses.iter().all(|use_| !use_
            .condition
            .guard_conjunctions()
            .iter()
            .flatten()
            .any(|guard| matches!(guard, Guard::Truthy { path } if path == "commonLabels"))),
        "commonLabels is the custom-label source, not a guard for the pathless common.names.name dependency: {pathless_name_override_uses:#?}"
    );
    let selected_default_branch = [
        Guard::Truthy {
            path: "nameOverride".to_string(),
        },
        Guard::Truthy {
            path: "networkPolicy.enabled".to_string(),
        },
        Guard::Default {
            path: "nameOverride".to_string(),
        },
    ];
    assert!(
        name_override_uses.iter().any(|use_| {
            use_.path == YamlPath(Vec::new())
                && use_
                    .condition
                    .guard_conjunctions()
                    .iter()
                    .any(|guards| guards == &selected_default_branch)
        }),
        "expected pathless nameOverride dependency to keep its selected default branch under the document execution guard: {name_override_uses:#?}"
    );
    let app_name_path = YamlPath(vec![
        "metadata".to_string(),
        "labels".to_string(),
        "app.kubernetes.io/name".to_string(),
    ]);
    assert!(
        name_override_uses
            .iter()
            .filter(|use_| use_.path == app_name_path)
            .all(|use_| !use_
                .condition
                .guard_conjunctions()
                .iter()
                .flatten()
                .any(|guard| matches!(guard, Guard::Not { path } if path == "nameOverride"))),
        "a customLabels branch should not keep nameOverride=false after common.names.name is projected: {name_override_uses:#?}"
    );
    Ok(())
}

#[test]
fn transitive_scalar_helper_default_projects_default_guard() {
    let helpers = indoc! {r#"
        {{- define "liba.fullname" -}}
        {{- include "libb.name" . -}}
        {{- end -}}

        {{- define "libb.name" -}}
        {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
        {{- end -}}
    "#};
    let src = indoc! {r#"
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: {{ include "liba.fullname" . }}
    "#};
    let mut idx = DefineIndex::new();
    idx.add_file_source("<inline:0>", helpers);
    let ir = SymbolicIrContext::new(&idx)
        .generate_contract_ir(src)
        .finalize();

    assert!(
        ir.uses().iter().any(|use_| {
            use_.source_expr == "nameOverride"
                && use_.path == YamlPath(vec!["metadata".to_string(), "name".to_string()])
                && use_.single_guard_conjunction().contains(&Guard::Default {
                    path: "nameOverride".to_string(),
                })
        }),
        "expected transitive helper default to survive into rendered contract use, got {:?}",
        ir.uses()
    );
}

#[test]
fn nonempty_choice_list_range_preserves_computed_mutation() {
    let helpers = indoc! {r#"
        {{- define "mutate.patch" -}}
        {{- $patch := .Values.patch -}}
        {{- $keys := list "path" -}}
        {{- if .Values.copy -}}
        {{- $keys = append $keys "from" -}}
        {{- end -}}
        {{- range $key := $keys -}}
        {{- $_ := set $patch (printf "%sKey" $key) "derived" -}}
        {{- end -}}
        {{- $patch.pathKey -}}
        {{- end -}}
    "#};
    let mut index = DefineIndex::new();
    index.add_file_source("<inline:0>", helpers);

    let ir = SymbolicIrContext::new(&index)
        .generate_contract_ir(r#"{{ include "mutate.patch" . }}"#)
        .finalize();

    assert!(
        ir.uses()
            .iter()
            .all(|use_| use_.source_expr != "patch.pathKey"),
        "the guaranteed path iteration sets pathKey before its later read: {ir:#?}"
    );
}

/// A file-backed include piped into a hashing transform renders the file as
/// TEXT for the hash: every path the file splices influences the annotation
/// but never lands there raw, so the caller-side row must carry the
/// Serialized kind (a Scalar row would stamp the annotation slot's provider
/// string schema onto trivy-operator's whole `ConfigMap` surface).
#[test]
fn checksum_include_rows_stay_serialized_at_the_annotation_slot() {
    let mut idx = DefineIndex::new();
    idx.add_file_source(
        "templates/configmaps/config.yaml",
        indoc! {r#"
            kind: ConfigMap
            apiVersion: v1
            metadata:
              name: config
              labels: {{- include "repro.labels" . | nindent 4 }}
            data:
              NAMES: {{ .Values.scanSecrets | toJson | quote }}
        "#},
    );
    idx.add_file_source(
        "<inline:0>",
        indoc! {r#"
            {{- define "repro.labels" -}}
            app: repro
            {{- end -}}"#},
    );
    let src = indoc! {r#"
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: test
        spec:
          template:
            metadata:
              annotations:
                checksum/config: {{ include (print $.Template.BasePath "/configmaps/config.yaml") . | sha256sum }}
    "#};
    let ir = SymbolicIrContext::new(&idx)
        .generate_contract_ir(src)
        .finalize();

    let annotation_kinds: Vec<ValueKind> = ir
        .uses()
        .iter()
        .filter(|contract_use| {
            contract_use.source_expr == "scanSecrets"
                && contract_use
                    .path
                    .0
                    .last()
                    .is_some_and(|segment| segment == "checksum/config")
        })
        .map(|contract_use| contract_use.kind)
        .collect();
    assert!(
        annotation_kinds
            .iter()
            .all(|kind| *kind == ValueKind::Serialized),
        "hashed file renders constrain nothing at the annotation slot: {annotation_kinds:?}"
    );
    assert!(
        !annotation_kinds.is_empty(),
        "the checksum include must still attribute its file's paths"
    );
}