compose-lens 0.3.0

Loss-aware parsing, processing, validation, and rendering of Compose projects
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
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
//! Structured values for the final closed-schema Compose keys.

use super::{BooleanValue, Command, ComposeScalar, Environment, FieldReference, Located};
use crate::source::SourceSpan;
use std::fmt;

/// An authored service `label_file` value with its scalar or list form retained.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LabelFiles {
    span: SourceSpan,
    form: LabelFilesForm,
    unmodeled_items: Vec<SourceSpan>,
}

impl LabelFiles {
    pub(crate) const fn new(span: SourceSpan, form: LabelFilesForm, unmodeled_items: Vec<SourceSpan>) -> Self {
        Self {
            span,
            form,
            unmodeled_items,
        }
    }

    /// Returns the complete authored field-value span.
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }

    /// Returns the exact scalar or ordered-list form without reading label files.
    #[must_use]
    pub const fn form(&self) -> &LabelFilesForm {
        &self.form
    }

    /// Returns spans for malformed list items retained in the syntax document.
    #[must_use]
    pub fn unmodeled_items(&self) -> &[SourceSpan] {
        &self.unmodeled_items
    }
}

/// The exact authored syntax form of service `label_file`.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum LabelFilesForm {
    /// One label-file path scalar.
    Scalar(Located<String>),
    /// An ordered list of label-file paths, including an explicitly empty list.
    List(Vec<Located<String>>),
}

/// Top-level Compose includes in their short and long forms.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Includes {
    span: SourceSpan,
    items: Vec<IncludeItem>,
    unmodeled_fields: Vec<FieldReference>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl Includes {
    pub(crate) fn new(span: SourceSpan, items: Vec<IncludeItem>, unmodeled_fields: Vec<FieldReference>) -> Self {
        Self {
            span,
            items,
            unmodeled_fields,
        }
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub fn items(&self) -> &[IncludeItem] {
        &self.items
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}

/// One authored include declaration.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum IncludeItem {
    /// A short scalar path.
    Short(Located<String>),
    /// A long include mapping.
    Long(IncludeLong),
    /// An invalid form retained in the syntax document and reported diagnostically.
    Unmodeled,
}

/// Long-form include values. Paths remain inert source data: no documents or env files are read.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct IncludeLong {
    span: SourceSpan,
    paths: Vec<Located<String>>,
    env_files: Vec<Located<String>>,
    project_directory: Option<Located<String>>,
    unmodeled_fields: Vec<FieldReference>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl IncludeLong {
    pub(crate) fn new(
        span: SourceSpan,
        paths: Vec<Located<String>>,
        env_files: Vec<Located<String>>,
        project_directory: Option<Located<String>>,
        unmodeled_fields: Vec<FieldReference>,
    ) -> Self {
        Self {
            span,
            paths,
            env_files,
            project_directory,
            unmodeled_fields,
        }
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub fn paths(&self) -> &[Located<String>] {
        &self.paths
    }
    #[must_use]
    pub fn env_files(&self) -> &[Located<String>] {
        &self.env_files
    }
    #[must_use]
    pub const fn project_directory(&self) -> Option<&Located<String>> {
        self.project_directory.as_ref()
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}

/// Top-level model definitions keyed by their Compose model name.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ModelDefinitions {
    span: SourceSpan,
    definitions: Vec<ModelDefinition>,
    unmodeled_fields: Vec<FieldReference>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl ModelDefinitions {
    pub(crate) fn new(
        span: SourceSpan,
        definitions: Vec<ModelDefinition>,
        unmodeled_fields: Vec<FieldReference>,
    ) -> Self {
        Self {
            span,
            definitions,
            unmodeled_fields,
        }
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub fn definitions(&self) -> &[ModelDefinition] {
        &self.definitions
    }
    #[must_use]
    pub fn definition(&self, name: &str) -> Option<&ModelDefinition> {
        self.definitions
            .iter()
            .find(|definition| definition.key.value() == name)
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}

/// One source-aware top-level model definition.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ModelDefinition {
    key: Located<String>,
    span: SourceSpan,
    name: Option<Located<String>>,
    model: Option<Located<String>>,
    context_size: Option<Located<ComposeScalar>>,
    runtime_flags: Vec<Located<String>>,
    unmodeled_fields: Vec<FieldReference>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl ModelDefinition {
    pub(crate) fn new(key: Located<String>, span: SourceSpan) -> Self {
        Self {
            key,
            span,
            name: None,
            model: None,
            context_size: None,
            runtime_flags: Vec::new(),
            unmodeled_fields: Vec::new(),
        }
    }
    pub(crate) fn set_name(&mut self, value: Located<String>) {
        self.name = Some(value);
    }
    pub(crate) fn set_model(&mut self, value: Located<String>) {
        self.model = Some(value);
    }
    pub(crate) fn set_context_size(&mut self, value: Located<ComposeScalar>) {
        self.context_size = Some(value);
    }
    pub(crate) fn set_runtime_flags(&mut self, values: Vec<Located<String>>) {
        self.runtime_flags = values;
    }
    pub(crate) fn push_unmodeled(&mut self, field: FieldReference) {
        self.unmodeled_fields.push(field);
    }
    #[must_use]
    pub const fn key(&self) -> &Located<String> {
        &self.key
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub const fn name(&self) -> Option<&Located<String>> {
        self.name.as_ref()
    }
    #[must_use]
    pub const fn model(&self) -> Option<&Located<String>> {
        self.model.as_ref()
    }
    #[must_use]
    pub const fn context_size(&self) -> Option<&Located<ComposeScalar>> {
        self.context_size.as_ref()
    }
    #[must_use]
    pub fn runtime_flags(&self) -> &[Located<String>] {
        &self.runtime_flags
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}

/// Per-service bindings to top-level model definitions.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ServiceModels {
    span: SourceSpan,
    bindings: Vec<ServiceModelBinding>,
    unmodeled_fields: Vec<FieldReference>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl ServiceModels {
    pub(crate) fn new(
        span: SourceSpan,
        bindings: Vec<ServiceModelBinding>,
        unmodeled_fields: Vec<FieldReference>,
    ) -> Self {
        Self {
            span,
            bindings,
            unmodeled_fields,
        }
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub fn bindings(&self) -> &[ServiceModelBinding] {
        &self.bindings
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}

/// One service model binding from a scalar list or mapping form.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ServiceModelBinding {
    model: Located<String>,
    span: SourceSpan,
    endpoint_var: Option<Located<String>>,
    model_var: Option<Located<String>>,
    unmodeled_fields: Vec<FieldReference>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl ServiceModelBinding {
    pub(crate) fn new(model: Located<String>, span: SourceSpan) -> Self {
        Self {
            model,
            span,
            endpoint_var: None,
            model_var: None,
            unmodeled_fields: Vec::new(),
        }
    }
    pub(crate) fn set_endpoint_var(&mut self, value: Located<String>) {
        self.endpoint_var = Some(value);
    }
    pub(crate) fn set_model_var(&mut self, value: Located<String>) {
        self.model_var = Some(value);
    }
    pub(crate) fn push_unmodeled(&mut self, field: FieldReference) {
        self.unmodeled_fields.push(field);
    }
    #[must_use]
    pub const fn model(&self) -> &Located<String> {
        &self.model
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub const fn endpoint_var(&self) -> Option<&Located<String>> {
        self.endpoint_var.as_ref()
    }
    #[must_use]
    pub const fn model_var(&self) -> Option<&Located<String>> {
        self.model_var.as_ref()
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}

/// Service GPU declarations in scalar `all` or detailed list form.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Gpus {
    /// The portable scalar selector, normally `all`.
    All(Located<String>),
    /// Ordered long-form selectors.
    Devices {
        /// Span of the complete selector sequence.
        span: SourceSpan,
        /// Selectors in authored order.
        devices: Vec<GpuDevice>,
        /// Exact spans of malformed selector items retained in the syntax document.
        unmodeled_items: Vec<SourceSpan>,
    },
}

#[allow(missing_docs, reason = "the enum contract covers the shared span accessor")]
impl Gpus {
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        match self {
            Self::All(value) => value.span(),
            Self::Devices { span, .. } => *span,
        }
    }

    /// Returns malformed selector-item spans retained without device allocation interpretation.
    #[must_use]
    pub fn unmodeled_items(&self) -> &[SourceSpan] {
        match self {
            Self::All(_) => &[],
            Self::Devices { unmodeled_items, .. } => unmodeled_items,
        }
    }
}

/// One source-aware long-form GPU selector.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GpuDevice {
    span: SourceSpan,
    capabilities: Vec<Located<String>>,
    count: Option<Located<ComposeScalar>>,
    device_ids: Vec<Located<String>>,
    driver: Option<Located<String>>,
    options: Option<GpuOptions>,
    unmodeled_fields: Vec<FieldReference>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl GpuDevice {
    pub(crate) fn new(span: SourceSpan) -> Self {
        Self {
            span,
            capabilities: Vec::new(),
            count: None,
            device_ids: Vec::new(),
            driver: None,
            options: None,
            unmodeled_fields: Vec::new(),
        }
    }
    pub(crate) fn set_capabilities(&mut self, values: Vec<Located<String>>) {
        self.capabilities = values;
    }
    pub(crate) fn set_count(&mut self, value: Located<ComposeScalar>) {
        self.count = Some(value);
    }
    pub(crate) fn set_device_ids(&mut self, values: Vec<Located<String>>) {
        self.device_ids = values;
    }
    pub(crate) fn set_driver(&mut self, value: Located<String>) {
        self.driver = Some(value);
    }
    pub(crate) fn set_options(&mut self, value: GpuOptions) {
        self.options = Some(value);
    }
    pub(crate) fn push_unmodeled(&mut self, field: FieldReference) {
        self.unmodeled_fields.push(field);
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub fn capabilities(&self) -> &[Located<String>] {
        &self.capabilities
    }
    #[must_use]
    pub const fn count(&self) -> Option<&Located<ComposeScalar>> {
        self.count.as_ref()
    }
    #[must_use]
    pub fn device_ids(&self) -> &[Located<String>] {
        &self.device_ids
    }
    #[must_use]
    pub const fn driver(&self) -> Option<&Located<String>> {
        self.driver.as_ref()
    }
    #[must_use]
    pub const fn options(&self) -> Option<&GpuOptions> {
        self.options.as_ref()
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}

/// GPU selector options in their authored mapping or list form.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum GpuOptions {
    /// Ordered mapping entries with scalar values.
    Mapping(Vec<super::KeyValueEntry>),
    /// Ordered raw string option entries.
    List(Vec<Located<String>>),
}

impl GpuOptions {
    /// Returns mapping entries when the selector used mapping syntax.
    #[must_use]
    pub fn as_mapping(&self) -> Option<&[super::KeyValueEntry]> {
        let Self::Mapping(entries) = self else {
            return None;
        };
        Some(entries)
    }

    /// Returns list entries when the selector used list syntax.
    #[must_use]
    pub fn as_list(&self) -> Option<&[Located<String>]> {
        let Self::List(items) = self else {
            return None;
        };
        Some(items)
    }
}

/// Side-effect-free `develop` watch configuration.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Develop {
    span: SourceSpan,
    watch: Vec<DevelopWatch>,
    unmodeled_fields: Vec<FieldReference>,
    unmodeled_items: Vec<SourceSpan>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl Develop {
    pub(crate) fn new(
        span: SourceSpan,
        watch: Vec<DevelopWatch>,
        unmodeled_fields: Vec<FieldReference>,
        unmodeled_items: Vec<SourceSpan>,
    ) -> Self {
        Self {
            span,
            watch,
            unmodeled_fields,
            unmodeled_items,
        }
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub fn watch(&self) -> &[DevelopWatch] {
        &self.watch
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }

    /// Returns exact spans of malformed watch items retained in the syntax document.
    #[must_use]
    pub fn unmodeled_items(&self) -> &[SourceSpan] {
        &self.unmodeled_items
    }
}

/// One declared watch action. The type deliberately never watches a path or executes a command.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DevelopWatch {
    span: SourceSpan,
    action: Option<Located<String>>,
    path: Option<Located<String>>,
    target: Option<Located<String>>,
    ignore: Vec<Located<String>>,
    include: Vec<Located<String>>,
    initial_sync: Option<Located<BooleanValue>>,
    exec: Option<DevelopWatchExec>,
    unmodeled_fields: Vec<FieldReference>,
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl DevelopWatch {
    pub(crate) fn new(span: SourceSpan) -> Self {
        Self {
            span,
            action: None,
            path: None,
            target: None,
            ignore: Vec::new(),
            include: Vec::new(),
            initial_sync: None,
            exec: None,
            unmodeled_fields: Vec::new(),
        }
    }
    pub(crate) fn set_action(&mut self, value: Located<String>) {
        self.action = Some(value);
    }
    pub(crate) fn set_path(&mut self, value: Located<String>) {
        self.path = Some(value);
    }
    pub(crate) fn set_target(&mut self, value: Located<String>) {
        self.target = Some(value);
    }
    pub(crate) fn set_ignore(&mut self, values: Vec<Located<String>>) {
        self.ignore = values;
    }
    pub(crate) fn set_include(&mut self, values: Vec<Located<String>>) {
        self.include = values;
    }
    pub(crate) fn set_initial_sync(&mut self, value: Located<BooleanValue>) {
        self.initial_sync = Some(value);
    }
    pub(crate) fn set_exec(&mut self, value: DevelopWatchExec) {
        self.exec = Some(value);
    }
    pub(crate) fn push_unmodeled(&mut self, field: FieldReference) {
        self.unmodeled_fields.push(field);
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub const fn action(&self) -> Option<&Located<String>> {
        self.action.as_ref()
    }
    #[must_use]
    pub const fn path(&self) -> Option<&Located<String>> {
        self.path.as_ref()
    }
    #[must_use]
    pub const fn target(&self) -> Option<&Located<String>> {
        self.target.as_ref()
    }
    #[must_use]
    pub fn ignore(&self) -> &[Located<String>] {
        &self.ignore
    }
    #[must_use]
    pub fn include(&self) -> &[Located<String>] {
        &self.include
    }
    #[must_use]
    pub const fn initial_sync(&self) -> Option<&Located<BooleanValue>> {
        self.initial_sync.as_ref()
    }
    #[must_use]
    pub const fn exec(&self) -> Option<&DevelopWatchExec> {
        self.exec.as_ref()
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}

/// Side-effect-free `develop.watch.exec` configuration.
///
/// This only retains the hook declaration. It never starts a watcher, executes
/// a command, resolves a user, or reads an environment file.
#[derive(Clone, PartialEq, Eq)]
pub struct DevelopWatchExec {
    span: SourceSpan,
    command: Option<Command>,
    user: Option<Located<String>>,
    privileged: Option<Located<BooleanValue>>,
    working_dir: Option<Located<String>>,
    environment: Option<Environment>,
    unmodeled_fields: Vec<FieldReference>,
}

impl fmt::Debug for DevelopWatchExec {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        let mut debug = formatter.debug_struct("DevelopWatchExec");
        debug
            .field("span", &self.span)
            .field("command", &self.command)
            .field("user", &self.user)
            .field("privileged", &self.privileged)
            .field("working_dir", &self.working_dir)
            .field("environment", &self.environment.as_ref().map(|_| "<redacted>"))
            .field("unmodeled_fields", &self.unmodeled_fields)
            .finish()
    }
}

#[allow(
    missing_docs,
    reason = "the documented type contract covers its conventional accessors"
)]
impl DevelopWatchExec {
    pub(crate) fn new(span: SourceSpan) -> Self {
        Self {
            span,
            command: None,
            user: None,
            privileged: None,
            working_dir: None,
            environment: None,
            unmodeled_fields: Vec::new(),
        }
    }
    pub(crate) fn set_command(&mut self, value: Command) {
        self.command = Some(value);
    }
    pub(crate) fn set_user(&mut self, value: Located<String>) {
        self.user = Some(value);
    }
    pub(crate) fn set_privileged(&mut self, value: Located<BooleanValue>) {
        self.privileged = Some(value);
    }
    pub(crate) fn set_working_dir(&mut self, value: Located<String>) {
        self.working_dir = Some(value);
    }
    pub(crate) fn set_environment(&mut self, value: Environment) {
        self.environment = Some(value);
    }
    pub(crate) fn push_unmodeled(&mut self, value: FieldReference) {
        self.unmodeled_fields.push(value);
    }
    #[must_use]
    pub const fn span(&self) -> SourceSpan {
        self.span
    }
    #[must_use]
    pub const fn command(&self) -> Option<&Command> {
        self.command.as_ref()
    }
    #[must_use]
    pub const fn user(&self) -> Option<&Located<String>> {
        self.user.as_ref()
    }
    #[must_use]
    pub const fn privileged(&self) -> Option<&Located<BooleanValue>> {
        self.privileged.as_ref()
    }
    #[must_use]
    pub const fn working_dir(&self) -> Option<&Located<String>> {
        self.working_dir.as_ref()
    }
    #[must_use]
    pub const fn environment(&self) -> Option<&Environment> {
        self.environment.as_ref()
    }
    #[must_use]
    pub fn unmodeled_fields(&self) -> &[FieldReference] {
        &self.unmodeled_fields
    }
}