Skip to main content

omena_query/
types.rs

1use super::*;
2use omena_evidence_graph::{
3    EvidenceAnalysisPrecisionV0, EvidenceDemandEdgeV0, EvidenceNodeKeyV0, EvidenceNodeSeedV0,
4    GuaranteeKindV0, build_evidence_graph_from_edges_v0,
5};
6use omena_query_transform_runner::normalize_omena_transform_bundle_path;
7use omena_sif::OmenaSifV1;
8use std::collections::{BTreeMap, BTreeSet};
9
10mod runtime_state_serialization;
11#[cfg(test)]
12pub(crate) use runtime_state_serialization::runtime_state_result_certainty_labels;
13pub(crate) use runtime_state_serialization::runtime_state_unknown_activation_declaration_id;
14
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[serde(rename_all = "camelCase")]
17pub struct DesignSystemMinimumDescriptionV0 {
18    pub schema_version: &'static str,
19    pub product: &'static str,
20    pub layer_marker: &'static str,
21    pub feature_gate: &'static str,
22    pub model_bits: f64,
23    pub residual_bits: f64,
24    pub total_bits: f64,
25    pub unit: &'static str,
26    pub model_class: ModelClassV0,
27    pub rule_count: usize,
28    pub observation_count: usize,
29    pub canonical_form_present: bool,
30    pub cascade_proof_obligation_count: usize,
31    pub sass_namespace_partition: SassNamespaceBitsV0,
32    pub generated_at_iso: &'static str,
33    pub source_pin: SourcePinV0,
34    pub weights_calibration_pin: &'static str,
35    pub weights_version: &'static str,
36    pub semiring_instance: &'static str,
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
40#[serde(rename_all = "camelCase")]
41pub enum ModelClassV0 {
42    TwoPartUniform,
43    TwoPartMultinomial,
44    Nml,
45}
46
47#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
48#[serde(rename_all = "camelCase")]
49pub struct SassNamespaceBitsV0 {
50    pub namespace_count: usize,
51    pub partition_count: usize,
52    pub deterministic_partition: bool,
53}
54
55#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
56#[serde(rename_all = "camelCase")]
57pub struct SourcePinV0 {
58    pub source_uri: String,
59    pub source_hash: String,
60}
61
62#[derive(Debug, Clone, PartialEq, Serialize)]
63#[serde(rename_all = "camelCase")]
64pub struct CanonicalFormV0 {
65    pub schema_version: &'static str,
66    pub product: &'static str,
67    pub layer_marker: &'static str,
68    pub feature_gate: &'static str,
69    pub pass_id: &'static str,
70    pub before: String,
71    pub canonical_after: String,
72    pub fallback_after: String,
73    pub canonical_matches_fallback: bool,
74    pub mdl_bits: f64,
75    pub ast_size_bits: f64,
76    pub bits_saved_vs_fallback: f64,
77    pub unit: &'static str,
78    pub iteration_count: usize,
79    pub eclass_count: usize,
80    pub enode_count: usize,
81    pub cascade_safe_witness: &'static str,
82    pub egg_analysis_witness: &'static str,
83}
84
85#[derive(Debug, Serialize)]
86#[serde(rename_all = "camelCase")]
87pub struct OmenaQueryBoundarySummaryV0 {
88    pub schema_version: &'static str,
89    pub product: &'static str,
90    pub query_engine_name: &'static str,
91    pub schema_version_policy: OmenaQuerySchemaVersionPolicyV0,
92    pub input_version: String,
93    pub abstract_value_domain: AbstractValueDomainSummaryV0,
94    pub selected_query_adapter_capabilities: SelectedQueryAdapterCapabilitiesV0,
95    pub delegated_fragment_products: Vec<&'static str>,
96    pub expression_semantics_query_count: usize,
97    pub source_resolution_query_count: usize,
98    pub selector_usage_query_count: usize,
99    pub total_query_count: usize,
100    pub ready_surfaces: Vec<&'static str>,
101    pub style_completion_consumer_decisions: Vec<OmenaQueryStyleCompletionConsumerDecisionV0>,
102    pub cme_coupled_surfaces: Vec<&'static str>,
103    pub next_decoupling_targets: Vec<&'static str>,
104}
105
106#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
107#[serde(rename_all = "camelCase")]
108pub struct OmenaQueryStyleCompletionConsumerDecisionV0 {
109    pub consumer: &'static str,
110    pub surface: &'static str,
111    pub decision: &'static str,
112    pub rationale: &'static str,
113}
114
115#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
116#[serde(rename_all = "camelCase")]
117pub struct OmenaQuerySassModuleConformanceReportV0 {
118    pub schema_version: &'static str,
119    pub product: &'static str,
120    pub claim_level: &'static str,
121    pub theorem_claimed: bool,
122    pub normative_source: &'static str,
123    pub modeled_count: usize,
124    pub gap_count: usize,
125    pub decided_out_count: usize,
126    pub policy_count: usize,
127    pub rows: Vec<OmenaQuerySassModuleConformanceRowV0>,
128    pub ready_surfaces: Vec<&'static str>,
129}
130
131#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
132#[serde(rename_all = "camelCase")]
133pub struct OmenaQuerySassModuleConformanceRowV0 {
134    pub key: &'static str,
135    pub category: &'static str,
136    pub status: &'static str,
137    pub normative_anchor: &'static str,
138    pub implementation: &'static str,
139    pub witness: &'static str,
140    pub decision: &'static str,
141}
142
143#[derive(Debug, Serialize)]
144#[serde(rename_all = "camelCase")]
145pub struct OmenaQueryEvaluationRuntimeSummaryV0 {
146    pub schema_version: &'static str,
147    pub product: &'static str,
148    pub input_version: String,
149    pub selected_query_adapter_capabilities: SelectedQueryAdapterCapabilitiesV0,
150    pub runtime_products: Vec<&'static str>,
151    pub source_resolution_expression_count: usize,
152    pub source_resolution_unresolved_expression_count: usize,
153    pub expression_domain_revision: u64,
154    pub expression_domain_graph_count: usize,
155    pub expression_domain_dirty_graph_count: usize,
156    pub expression_domain_reused_graph_count: usize,
157    pub style_document_summary_source: &'static str,
158    pub ready_surfaces: Vec<&'static str>,
159    pub retired_couplings: Vec<&'static str>,
160}
161
162#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
163#[serde(rename_all = "camelCase")]
164pub struct SelectedQueryAdapterCapabilitiesV0 {
165    pub schema_version: &'static str,
166    pub product: &'static str,
167    pub default_candidate_backend: &'static str,
168    pub schema_version_policy: OmenaQuerySchemaVersionPolicyV0,
169    pub schema_version_checks: Vec<OmenaQuerySchemaVersionCheckV0>,
170    pub backend_kinds: Vec<SelectedQueryBackendCapabilityV0>,
171    pub runner_commands: Vec<SelectedQueryRunnerCommandV0>,
172    pub expression_semantics_payload_contracts: Vec<&'static str>,
173    pub required_input_contracts: Vec<&'static str>,
174    pub adapter_readiness: Vec<&'static str>,
175    pub routing_status: &'static str,
176}
177
178#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
179#[serde(rename_all = "camelCase")]
180pub struct OmenaQuerySchemaVersionPolicyV0 {
181    pub schema_version: &'static str,
182    pub product: &'static str,
183    pub current_version: &'static str,
184    pub current_version_label: &'static str,
185    pub accepted_versions: Vec<&'static str>,
186    pub deprecated_versions: Vec<&'static str>,
187    pub rejected_version_policy: &'static str,
188    pub missing_version_policy: &'static str,
189    pub migration_policy: Vec<&'static str>,
190    pub compatibility_gate: &'static str,
191}
192
193#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
194#[serde(rename_all = "camelCase")]
195pub struct OmenaQuerySchemaVersionCheckV0 {
196    pub schema_version: &'static str,
197    pub product: &'static str,
198    pub requested_version: Option<String>,
199    pub current_version: &'static str,
200    pub accepted: bool,
201    pub status: &'static str,
202    pub migration_action: &'static str,
203    pub reason: &'static str,
204}
205
206#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
207#[serde(rename_all = "camelCase")]
208pub struct SelectedQueryBackendCapabilityV0 {
209    pub backend_kind: &'static str,
210    pub source_resolution: bool,
211    pub expression_semantics: bool,
212    pub selector_usage: bool,
213    pub style_semantic_graph: bool,
214}
215
216#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
217#[serde(rename_all = "camelCase")]
218pub struct SelectedQueryRunnerCommandV0 {
219    pub surface: &'static str,
220    pub command: &'static str,
221    pub input_contract: &'static str,
222    pub output_product: &'static str,
223}
224
225#[derive(Debug, Serialize)]
226#[serde(rename_all = "camelCase")]
227pub struct OmenaQueryStyleSemanticGraphBatchOutputV0 {
228    pub schema_version: &'static str,
229    pub product: &'static str,
230    pub cross_file_summary: OmenaQueryCrossFileSummaryV0,
231    pub css_modules_resolution: OmenaQueryCssModulesCrossFileResolutionV0,
232    pub sass_module_resolution: OmenaQuerySassModuleCrossFileResolutionV0,
233    pub graphs: Vec<OmenaQueryStyleSemanticGraphBatchEntryV0>,
234}
235
236#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
237#[serde(rename_all = "camelCase")]
238pub struct OmenaQueryCategoricalDesignSystemCrossProjectSummaryV0 {
239    pub schema_version: &'static str,
240    pub product: &'static str,
241    pub claim_scope: &'static str,
242    pub source_product: &'static str,
243    pub theory_product: &'static str,
244    pub project_count: usize,
245    pub product_path_evidence_ready: bool,
246    pub models: Vec<OmenaQueryCategoricalDesignSystemModelV0>,
247    pub invariant_summary: OmenaQueryCategoricalDesignSystemInvariantSummaryV0,
248    pub deferred_residuals: Vec<&'static str>,
249}
250
251#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
252#[serde(rename_all = "camelCase")]
253pub struct OmenaQueryM4AxisCReadinessSummaryV0 {
254    pub schema_version: &'static str,
255    pub product: &'static str,
256    pub status: &'static str,
257    pub required_edge_kind_count: usize,
258    pub required_edge_kind_counts: Vec<OmenaQueryCrossFileSummaryEdgeKindCountV0>,
259    pub workspace_edge_count: usize,
260    pub issue_63_provenance_round_trip_ready: bool,
261    pub issue_65_summary_edge_equivalence_ready: bool,
262    pub summary_hash_invalidation_ready: bool,
263    pub summary_hash_samples: OmenaQueryM4AxisCSummaryHashSamplesV0,
264    pub checked_surfaces: Vec<&'static str>,
265    pub next_priorities: Vec<&'static str>,
266}
267
268#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
269#[serde(rename_all = "camelCase")]
270pub struct OmenaQueryM4AxisCSummaryHashSamplesV0 {
271    pub baseline: String,
272    pub source_selector_change: String,
273    pub style_edge_change: String,
274    pub package_manifest_change: String,
275}
276
277#[derive(Debug, Serialize)]
278#[serde(rename_all = "camelCase")]
279pub struct OmenaQueryStyleSemanticGraphBatchEntryV0 {
280    pub style_path: String,
281    pub graph: Option<StyleSemanticGraphSummaryV0>,
282}
283
284#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
285#[serde(rename_all = "camelCase")]
286pub struct OmenaQueryCssModulesCrossFileResolutionV0 {
287    pub schema_version: &'static str,
288    pub product: &'static str,
289    pub status: &'static str,
290    pub resolution_scope: &'static str,
291    pub style_count: usize,
292    pub import_edge_count: usize,
293    pub resolved_import_edge_count: usize,
294    pub unresolved_import_edge_count: usize,
295    pub matched_name_count: usize,
296    pub edges: Vec<OmenaQueryCssModulesImportEdgeResolutionV0>,
297    pub composes_closure_edge_count: usize,
298    pub value_closure_edge_count: usize,
299    pub icss_closure_edge_count: usize,
300    pub composes_cycle_count: usize,
301    pub value_cycle_count: usize,
302    pub icss_cycle_count: usize,
303    pub composes_closure_edges: Vec<OmenaQueryCssModulesComposesClosureEdgeV0>,
304    pub value_closure_edges: Vec<OmenaQueryCssModulesValueClosureEdgeV0>,
305    pub icss_closure_edges: Vec<OmenaQueryCssModulesIcssClosureEdgeV0>,
306    pub cycles: Vec<OmenaQueryCssModulesCycleV0>,
307    pub capabilities: OmenaQueryCssModulesCrossFileResolutionCapabilitiesV0,
308    pub next_priorities: Vec<&'static str>,
309}
310
311#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
312#[serde(rename_all = "camelCase")]
313pub struct OmenaQueryCssModulesImportEdgeResolutionV0 {
314    pub from_style_path: String,
315    pub import_kind: &'static str,
316    pub source: String,
317    pub resolved_style_path: Option<String>,
318    pub status: &'static str,
319    pub import_graph_distance: Option<usize>,
320    pub import_graph_order: Option<usize>,
321    pub imported_names: Vec<String>,
322    pub exported_names: Vec<String>,
323    pub matched_names: Vec<String>,
324}
325
326#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
327#[serde(rename_all = "camelCase")]
328pub struct OmenaQueryCssModulesComposesClosureEdgeV0 {
329    pub from_style_path: String,
330    pub owner_selector_name: String,
331    pub target_style_path: String,
332    pub target_selector_name: String,
333    pub depth: usize,
334    pub path: Vec<String>,
335}
336
337#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
338#[serde(rename_all = "camelCase")]
339pub struct OmenaQueryCssModulesValueClosureEdgeV0 {
340    pub from_style_path: String,
341    pub value_name: String,
342    pub target_style_path: String,
343    pub target_value_name: String,
344    pub depth: usize,
345    pub path: Vec<String>,
346}
347
348#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
349#[serde(rename_all = "camelCase")]
350pub struct OmenaQueryCssModulesIcssClosureEdgeV0 {
351    pub from_style_path: String,
352    pub name: String,
353    pub target_style_path: String,
354    pub target_name: String,
355    pub depth: usize,
356    pub path: Vec<String>,
357}
358
359#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
360#[serde(rename_all = "camelCase")]
361pub struct OmenaQueryCssModulesCycleV0 {
362    pub kind: &'static str,
363    pub path: Vec<String>,
364}
365
366#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
367#[serde(rename_all = "camelCase")]
368pub struct OmenaQueryCssModulesCrossFileResolutionCapabilitiesV0 {
369    pub semantic_layer_owned: bool,
370    pub import_source_resolution_ready: bool,
371    pub cross_file_resolution_ready: bool,
372    pub composes_closure_ready: bool,
373    pub composes_name_match_ready: bool,
374    pub value_name_match_ready: bool,
375    pub icss_name_match_ready: bool,
376    pub transitive_closure_ready: bool,
377    pub value_graph_closure_ready: bool,
378    pub icss_export_import_closure_ready: bool,
379    pub cycle_detection_ready: bool,
380}
381
382#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
383#[serde(rename_all = "camelCase")]
384pub struct OmenaQuerySassModuleCrossFileResolutionV0 {
385    pub schema_version: &'static str,
386    pub product: &'static str,
387    pub status: &'static str,
388    pub resolution_scope: &'static str,
389    pub style_count: usize,
390    pub module_edge_count: usize,
391    pub resolved_module_edge_count: usize,
392    pub unresolved_module_edge_count: usize,
393    pub external_module_edge_count: usize,
394    pub symlink_chain_edge_count: usize,
395    pub symlink_chain_link_count: usize,
396    pub configured_module_instance_count: usize,
397    pub edges: Vec<OmenaQuerySassModuleEdgeResolutionV0>,
398    pub graph_closure_edge_count: usize,
399    pub cycle_count: usize,
400    pub visibility_filter_count: usize,
401    pub graph_closure_edges: Vec<OmenaQuerySassModuleGraphClosureEdgeV0>,
402    pub cycles: Vec<OmenaQuerySassModuleCycleV0>,
403    pub capabilities: OmenaQuerySassModuleCrossFileResolutionCapabilitiesV0,
404    pub next_priorities: Vec<&'static str>,
405}
406
407#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
408#[serde(rename_all = "camelCase")]
409pub struct OmenaQuerySassModuleEdgeResolutionV0 {
410    pub from_style_path: String,
411    pub edge_kind: &'static str,
412    pub source: String,
413    pub rule_ordinal: usize,
414    pub namespace_kind: Option<&'static str>,
415    pub namespace: Option<String>,
416    pub forward_prefix: Option<String>,
417    pub visibility_filter_kind: Option<&'static str>,
418    pub visibility_filter_names: Vec<String>,
419    pub resolved_style_path: Option<String>,
420    pub status: &'static str,
421    pub resolution_kind: &'static str,
422    pub candidate_count: usize,
423    pub symlink_chain_link_count: usize,
424    pub symlink_chain_links: Vec<OmenaQuerySymlinkChainLinkV0>,
425    pub configuration_signature: String,
426    pub configuration_variable_count: usize,
427    pub invalid_configuration_variable_names: Vec<String>,
428    pub module_instance_identity_key: Option<String>,
429}
430
431#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
432#[serde(rename_all = "camelCase")]
433pub struct OmenaQuerySymlinkChainLinkV0 {
434    pub link_path: String,
435    pub target_path: String,
436    pub target_was_absolute: bool,
437}
438
439#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
440#[serde(rename_all = "camelCase")]
441pub struct OmenaQuerySassModuleGraphClosureEdgeV0 {
442    pub from_style_path: String,
443    pub target_style_path: String,
444    pub edge_kind: &'static str,
445    pub depth: usize,
446    pub path: Vec<String>,
447    pub namespace_kind: Option<&'static str>,
448    pub namespace: Option<String>,
449    pub forward_prefix: Option<String>,
450    pub visibility_filter_kind: Option<&'static str>,
451    pub visibility_filter_names: Vec<String>,
452    pub configuration_signature: String,
453    pub configuration_variable_count: usize,
454    pub invalid_configuration_variable_names: Vec<String>,
455    pub module_instance_identity_key: Option<String>,
456}
457
458#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
459#[serde(rename_all = "camelCase")]
460pub struct OmenaQuerySassModuleCycleV0 {
461    pub path: Vec<String>,
462}
463
464#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
465#[serde(rename_all = "camelCase")]
466pub struct OmenaQuerySassModuleCrossFileResolutionCapabilitiesV0 {
467    pub omena_parser_module_edge_consumption_ready: bool,
468    pub resolver_backed_source_resolution_ready: bool,
469    pub package_manifest_resolution_ready: bool,
470    pub external_module_filtering_ready: bool,
471    pub graph_closure_ready: bool,
472    pub cycle_detection_ready: bool,
473    pub namespace_show_hide_filter_ready: bool,
474    pub configured_module_instance_identity_ready: bool,
475    pub symlink_chain_metadata_ready: bool,
476}
477
478#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
479#[serde(rename_all = "camelCase")]
480pub struct OmenaQueryStyleDocumentSummaryV0 {
481    pub schema_version: &'static str,
482    pub product: &'static str,
483    pub language: &'static str,
484    pub selector_names: Vec<String>,
485    pub custom_property_decl_names: Vec<String>,
486    pub custom_property_ref_names: Vec<String>,
487    pub sass_module_use_sources: Vec<String>,
488    pub sass_module_forward_sources: Vec<String>,
489    pub diagnostic_count: usize,
490}
491
492#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
493#[serde(rename_all = "camelCase")]
494pub struct FastFactsV0 {
495    pub schema_version: &'static str,
496    pub product: &'static str,
497    pub tier: &'static str,
498    pub style_path: String,
499    pub language: &'static str,
500    pub selector_count: usize,
501    pub custom_property_count: usize,
502    pub sass_symbol_count: usize,
503    pub module_edge_count: usize,
504    pub parser_error_count: usize,
505}
506
507#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
508#[serde(rename_all = "camelCase")]
509pub struct AnalyzedGraphV0 {
510    pub schema_version: &'static str,
511    pub product: &'static str,
512    pub tier: &'static str,
513    pub style_path: String,
514    pub fast_facts: FastFactsV0,
515    pub graph_kinds: Vec<&'static str>,
516    pub node_count: usize,
517    pub edge_count: usize,
518    pub cycle_count: usize,
519}
520
521#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
522#[serde(rename_all = "camelCase")]
523pub struct StyleEditDistanceSummaryV0 {
524    pub schema_version: &'static str,
525    pub product: &'static str,
526    pub tier: &'static str,
527    pub metric_kind: &'static str,
528    pub claim_level: &'static str,
529    pub public_safety_claim_ready: bool,
530    pub left_style_path: String,
531    pub right_style_path: String,
532    pub left_fast_facts: FastFactsV0,
533    pub right_fast_facts: FastFactsV0,
534    pub left_analyzed_graph: AnalyzedGraphV0,
535    pub right_analyzed_graph: AnalyzedGraphV0,
536    pub selector_delta: usize,
537    pub custom_property_delta: usize,
538    pub sass_symbol_delta: usize,
539    pub module_edge_delta: usize,
540    pub parser_error_delta: usize,
541    pub graph_node_delta: usize,
542    pub graph_edge_delta: usize,
543    pub graph_cycle_delta: usize,
544    pub total_distance: usize,
545}
546
547#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
548#[serde(rename_all = "camelCase")]
549pub struct StyleEditDistanceCascadeMarginBridgeV0 {
550    pub schema_version: &'static str,
551    pub product: &'static str,
552    pub bridge_kind: &'static str,
553    pub claim_level: &'static str,
554    pub theorem_claimed: bool,
555    pub public_safety_claim_ready: bool,
556    pub metric_product: &'static str,
557    pub metric_kind: &'static str,
558    pub margin_product: &'static str,
559    pub margin_kind: &'static str,
560    pub dominant_axis: &'static str,
561    pub edit_distance_total: usize,
562    pub cascade_margin_signed_distance: i64,
563    pub cascade_margin_abs_distance: u64,
564    pub lipschitz_constant_name: &'static str,
565    pub lipschitz_constant: Option<u64>,
566    pub lipschitz_bound: Option<u64>,
567    pub checked: bool,
568    pub calibration_stage: &'static str,
569    pub incremental_priority_input: IncrementalEditDistancePriorityInputV0,
570}
571
572#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
573#[serde(rename_all = "camelCase")]
574pub struct OmenaQueryFragileGuardedWinnerDiagnosticV0 {
575    pub schema_version: &'static str,
576    pub product: &'static str,
577    pub diagnostic_kind: &'static str,
578    pub claim_level: &'static str,
579    pub baseline_winner_declaration_id: String,
580    pub robustness_radius: u32,
581    pub fragile_threshold: u32,
582    pub witness: Vec<omena_cascade::GuardedCascadePerturbationV0>,
583    pub calibration_stage: &'static str,
584    pub public_safety_claim_ready: bool,
585    pub false_alarm_boundary: &'static str,
586    pub message: String,
587}
588
589#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
590#[serde(rename_all = "camelCase")]
591pub struct OmenaQueryCascadeConfidenceV0 {
592    pub schema_version: &'static str,
593    pub product: &'static str,
594    pub feature_gate: &'static str,
595    pub confidence_kind: &'static str,
596    pub claim_level: &'static str,
597    pub theorem_claimed: bool,
598    pub public_safety_claim_ready: bool,
599    pub calibration_stage: &'static str,
600    pub margin_product: &'static str,
601    pub margin_kind: &'static str,
602    pub dominant_axis: &'static str,
603    pub dominant_axis_weight_basis_points: u16,
604    pub sigmoid_temperature_basis_points: u16,
605    pub signed_distance: i64,
606    pub abs_distance: u64,
607    pub confidence_score_basis_points: u16,
608    pub confidence_bucket: &'static str,
609    pub winner_declaration_id: String,
610    pub challenger_declaration_id: Option<String>,
611}
612
613#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
614#[serde(rename_all = "camelCase")]
615pub struct OmenaQueryCustomPropertyAnnotationSummaryV0 {
616    pub schema_version: &'static str,
617    pub product: &'static str,
618    pub style_path: String,
619    pub annotation_count: usize,
620    pub annotations: Vec<OmenaQueryCustomPropertyAnnotationV0>,
621}
622
623#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
624#[serde(rename_all = "camelCase")]
625pub struct OmenaQueryCustomPropertyAnnotationV0 {
626    pub name: String,
627    pub declaration_count: usize,
628    pub reference_count: usize,
629    pub annotation_kind: &'static str,
630    pub participates_in_fixed_point: bool,
631}
632
633#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
634#[serde(rename_all = "camelCase")]
635pub struct OmenaQueryStyleContextIndexV0 {
636    pub schema_version: &'static str,
637    pub product: &'static str,
638    pub style_path: String,
639    pub language: &'static str,
640    pub context_index_source: &'static str,
641    pub context_index: StyleContextIndexV0,
642}
643
644#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
645#[serde(rename_all = "camelCase")]
646pub struct OmenaQueryConsumerCheckSummaryV0 {
647    pub schema_version: &'static str,
648    pub product: &'static str,
649    pub style_path: String,
650    pub dialect: &'static str,
651    pub token_count: usize,
652    pub parser_error_count: usize,
653    pub class_selector_count: usize,
654    pub custom_property_count: usize,
655    pub keyframe_count: usize,
656    pub ready_surfaces: Vec<&'static str>,
657}
658
659#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
660#[serde(rename_all = "camelCase")]
661pub struct OmenaQueryConsumerBuildSummaryV0 {
662    pub schema_version: &'static str,
663    pub product: &'static str,
664    pub style_path: String,
665    pub dialect: &'static str,
666    pub requested_pass_ids: Vec<String>,
667    pub effective_pass_ids: Vec<String>,
668    pub target_query: Option<OmenaQueryTransformTargetQueryPlanV0>,
669    pub unknown_pass_ids: Vec<String>,
670    pub execution: TransformExecutionSummaryV0,
671    pub semantic_removal_count: usize,
672    #[serde(skip_serializing_if = "Option::is_none")]
673    pub bundle: Option<TransformBundleSourceSummaryV0>,
674    #[serde(skip_serializing_if = "Option::is_none")]
675    pub bundle_emission_path: Option<OmenaQueryBundleEmissionPathV0>,
676    #[serde(skip_serializing_if = "Option::is_none")]
677    pub source_map_v3: Option<OmenaQueryTransformSourceMapV3V0>,
678    #[serde(skip_serializing_if = "Option::is_none")]
679    pub open_world_snapshot: Option<OmenaQueryOpenWorldSnapshotV0>,
680    pub ready_surfaces: Vec<&'static str>,
681}
682
683#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
684#[serde(rename_all = "camelCase")]
685pub enum OmenaQueryBuildVerificationProfileV0 {
686    #[default]
687    Descriptive,
688    Strict,
689}
690
691#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
692#[serde(rename_all = "camelCase")]
693pub enum OmenaQueryBundleEmissionPathV0 {
694    #[default]
695    ImportInlineLegacy,
696    LinkedOrder,
697}
698
699impl OmenaQueryBundleEmissionPathV0 {
700    pub const fn as_wire_label(self) -> &'static str {
701        match self {
702            Self::ImportInlineLegacy => "importInlineLegacy",
703            Self::LinkedOrder => "linkedOrder",
704        }
705    }
706}
707
708#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize)]
709#[serde(rename_all = "camelCase")]
710pub struct OmenaQueryBuildAdmissionRequirementsV0 {
711    pub refuse_unknown_pass_ids: bool,
712    pub require_closed_world_evidence: bool,
713    pub require_complete_decisions: bool,
714}
715
716impl OmenaQueryBuildAdmissionRequirementsV0 {
717    pub const fn strict() -> Self {
718        Self {
719            refuse_unknown_pass_ids: true,
720            require_closed_world_evidence: true,
721            require_complete_decisions: true,
722        }
723    }
724}
725
726#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)]
727#[serde(default, rename_all = "camelCase")]
728pub struct OmenaQueryConsumerBuildOptionsV0 {
729    pub verification_profile: OmenaQueryBuildVerificationProfileV0,
730    pub bundle_emission_path: OmenaQueryBundleEmissionPathV0,
731}
732
733#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
734#[serde(rename_all = "camelCase", tag = "kind")]
735pub enum OmenaQueryClosedWorldBlockerV0 {
736    EmptyEntrypoints,
737    MissingEntrypoint {
738        source_path: String,
739    },
740    AmbiguousModulePath {
741        source_path: String,
742    },
743    MissingDependency {
744        source_path: String,
745        import_source: String,
746    },
747    MissingModuleInstance {
748        module: omena_parser::ModuleInstanceKeyV0,
749    },
750    MissingModuleDependency {
751        module: omena_parser::ModuleInstanceKeyV0,
752        dependency: omena_parser::ModuleInstanceKeyV0,
753    },
754    ClosedWorldPassUnavailable {
755        requested_pass_ids: Vec<String>,
756    },
757}
758
759#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
760#[serde(rename_all = "camelCase", tag = "status")]
761pub enum OmenaQueryClosedWorldOutcomeV0 {
762    Closed {
763        bundle: Box<omena_parser::ClosedWorldBundleV0>,
764    },
765    Open {
766        blockers: Vec<OmenaQueryClosedWorldBlockerV0>,
767    },
768}
769
770impl OmenaQueryClosedWorldOutcomeV0 {
771    pub fn bundle(&self) -> Option<&omena_parser::ClosedWorldBundleV0> {
772        match self {
773            Self::Closed { bundle } => Some(bundle.as_ref()),
774            Self::Open { .. } => None,
775        }
776    }
777
778    pub fn blockers(&self) -> &[OmenaQueryClosedWorldBlockerV0] {
779        match self {
780            Self::Closed { .. } => &[],
781            Self::Open { blockers } => blockers,
782        }
783    }
784
785    pub fn is_open(&self) -> bool {
786        matches!(self, Self::Open { .. })
787    }
788}
789
790#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
791#[serde(rename_all = "camelCase")]
792pub struct OmenaQueryBundleArtifactV0 {
793    pub schema_version: &'static str,
794    pub product: &'static str,
795    pub style_path: String,
796    pub emission_path: OmenaQueryBundleEmissionPathV0,
797    pub output_css: String,
798    pub bundle: TransformBundleSourceSummaryV0,
799    pub source_map_v3: OmenaQueryTransformSourceMapV3V0,
800    pub code_split_outputs: Vec<OmenaQueryBundleCodeSplitWorkspacePlanOutputV0>,
801    pub asset_rewrites: Vec<TransformBundleAssetUrlRewriteSummaryV0>,
802    pub per_pass_provenance: Vec<TransformPassExecutionOutcomeV0>,
803    /// Compatibility projection that retains entry-scoped execution fields.
804    ///
805    /// Linked consumers should read `BundleExecutionSummaryV0` from
806    /// `OmenaQueryBundleExecutionScopeEvidenceV0::bundle_execution`. This field
807    /// remains serialized unchanged; deprecation does not alter the wire shape,
808    /// and removal is reserved for a future major release.
809    pub execution: TransformExecutionSummaryV0,
810    pub ready_surfaces: Vec<&'static str>,
811}
812
813#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
814#[serde(rename_all = "camelCase")]
815pub struct OmenaQueryBundleResultV0 {
816    pub artifact: OmenaQueryBundleArtifactV0,
817    pub closed_world_outcome: OmenaQueryClosedWorldOutcomeV0,
818    pub closed_world_decision_parity: OmenaQueryClosedWorldDecisionParityV0,
819}
820
821#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
822#[serde(rename_all = "camelCase")]
823#[non_exhaustive]
824pub struct OmenaQueryBundleTokenOwnershipResultV0 {
825    pub bundle_result: OmenaQueryBundleResultV0,
826    pub ownership_census: omena_query_transform_runner::CssModuleTokenOwnershipCensusV0,
827}
828
829impl OmenaQueryBundleTokenOwnershipResultV0 {
830    pub(crate) fn new(
831        bundle_result: OmenaQueryBundleResultV0,
832        ownership_census: omena_query_transform_runner::CssModuleTokenOwnershipCensusV0,
833    ) -> Self {
834        Self {
835            bundle_result,
836            ownership_census,
837        }
838    }
839}
840
841#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
842#[serde(rename_all = "camelCase")]
843#[non_exhaustive]
844pub enum OmenaQueryExecutionEvidenceScopeV0 {
845    Entry,
846    Bundle,
847}
848
849#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
850#[serde(rename_all = "camelCase")]
851#[non_exhaustive]
852pub struct OmenaQueryExecutionFieldScopeV0 {
853    pub field_name: &'static str,
854    pub scope: OmenaQueryExecutionEvidenceScopeV0,
855    pub derivation: &'static str,
856}
857
858#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
859#[serde(rename_all = "camelCase")]
860#[non_exhaustive]
861pub struct OmenaQueryBundleModuleExecutionByteFactsV0 {
862    pub module_instance: omena_parser::ModuleInstanceKeyV0,
863    pub input_byte_len: usize,
864    pub output_byte_len: usize,
865    pub generated_start: usize,
866    pub generated_end: usize,
867}
868
869#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
870#[serde(rename_all = "camelCase")]
871#[non_exhaustive]
872pub struct OmenaQueryBundleCompositeExecutionByteFactsV0 {
873    pub module_count: usize,
874    pub summed_module_input_byte_len: usize,
875    pub summed_module_output_byte_len: usize,
876    pub inter_module_separator_byte_len: usize,
877    pub materialized_output_byte_len: usize,
878}
879
880#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
881#[serde(rename_all = "camelCase")]
882#[non_exhaustive]
883pub enum OmenaQueryLinkedSourceMapGranularityV0 {
884    CstAnchors,
885    WholeModuleFallback,
886}
887
888#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
889#[serde(rename_all = "camelCase")]
890#[non_exhaustive]
891pub struct OmenaQueryLinkedSourceMapDispositionV0 {
892    pub module_instance: omena_parser::ModuleInstanceKeyV0,
893    pub granularity: OmenaQueryLinkedSourceMapGranularityV0,
894    #[serde(skip_serializing_if = "Option::is_none")]
895    pub fallback_reason: Option<&'static str>,
896    pub segment_count: usize,
897}
898
899/// One linked module's complete transform execution.
900///
901/// Per-module truth remains available because most transform execution fields
902/// have no defensible bundle-level fold.
903#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
904#[serde(rename_all = "camelCase")]
905#[non_exhaustive]
906pub struct BundleModuleExecutionV0 {
907    pub module_instance: omena_parser::ModuleInstanceKeyV0,
908    pub execution: TransformExecutionSummaryV0,
909}
910
911/// Region and count evidence owned by linked bundle materialization.
912///
913/// This type deliberately carries neither CSS text nor a byte total. The
914/// materialized CSS remains on the bundle artifact, and
915/// `OmenaQueryBundleCompositeExecutionByteFactsV0` remains the sole byte
916/// accounting authority.
917#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
918#[serde(rename_all = "camelCase")]
919#[non_exhaustive]
920pub struct BundleEmissionExecutionV0 {
921    pub module_regions: Vec<LinkedEmissionModuleRegionV0>,
922    pub order_entry_regions: Vec<LinkedEmissionOrderEntryRegionV0>,
923    pub emitted_module_count: usize,
924    pub global_order_entry_count: usize,
925}
926
927/// Bundle-level transform execution for the linked emission path.
928///
929/// The aggregate fields are intentionally narrower than
930/// `TransformExecutionSummaryV0`: each one has an authored fold and a product
931/// run where the folded value differs from the entry module. This summary says
932/// nothing about the legacy emission path, and fields without a defensible fold
933/// remain available only through `module_executions`. The current product
934/// corpus bounds which `aggregate_*` fields have witnesses; it is not a claim
935/// that the set is exhaustive. Fold tokens document the intended operation,
936/// but witnesses remain load-bearing: the current corpus distinguishes the
937/// refusal-count sum, while mutation and semantic-removal values happen to make
938/// `sum` and `max` agree.
939#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
940#[serde(rename_all = "camelCase")]
941#[non_exhaustive]
942pub struct BundleExecutionSummaryV0 {
943    pub schema_version: &'static str,
944    pub product: &'static str,
945    pub entry_module_instance: omena_parser::ModuleInstanceKeyV0,
946    pub module_executions: Vec<BundleModuleExecutionV0>,
947    pub emission_execution: BundleEmissionExecutionV0,
948    /// Fold: `sum` over each module execution's mutation count.
949    pub aggregate_mutation_count: usize,
950    /// Fold: `orderedUnion` over executed pass identifiers in module order.
951    pub aggregate_executed_pass_ids: Vec<&'static str>,
952    /// Fold: `sum` over each module execution's semantic removal count.
953    pub aggregate_semantic_removal_count: usize,
954    /// Fold: `sum` over each module execution's closed-world refusal count.
955    pub aggregate_closed_world_refusal_count: usize,
956}
957
958#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
959#[serde(rename_all = "camelCase")]
960#[non_exhaustive]
961pub struct OmenaQueryBundleExecutionScopeEvidenceV0 {
962    pub schema_version: &'static str,
963    pub product: &'static str,
964    pub entry_module_instance: omena_parser::ModuleInstanceKeyV0,
965    pub field_scopes: Vec<OmenaQueryExecutionFieldScopeV0>,
966    pub module_executions: Vec<OmenaQueryBundleModuleExecutionByteFactsV0>,
967    pub bundle_composite: OmenaQueryBundleCompositeExecutionByteFactsV0,
968    pub bundle_execution: BundleExecutionSummaryV0,
969    pub source_map_dispositions: Vec<OmenaQueryLinkedSourceMapDispositionV0>,
970}
971
972#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
973#[serde(rename_all = "camelCase")]
974#[non_exhaustive]
975pub struct OmenaQueryBundleExecutionScopeResultV0 {
976    pub bundle_result: OmenaQueryBundleResultV0,
977    #[serde(skip_serializing_if = "Option::is_none")]
978    pub execution_scope: Option<OmenaQueryBundleExecutionScopeEvidenceV0>,
979    #[serde(skip_serializing_if = "Option::is_none")]
980    pub reachability_attribution: Option<OmenaQueryModuleReachabilityAttributionReportV0>,
981}
982
983#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
984#[serde(rename_all = "camelCase")]
985#[non_exhaustive]
986pub struct OmenaQueryModuleAttributedBundleResultV0 {
987    bundle_result: OmenaQueryBundleResultV0,
988    reachability_attribution: OmenaQueryModuleReachabilityAttributionReportV0,
989}
990
991impl OmenaQueryModuleAttributedBundleResultV0 {
992    pub(crate) fn new(
993        bundle_result: OmenaQueryBundleResultV0,
994        reachability_attribution: OmenaQueryModuleReachabilityAttributionReportV0,
995    ) -> Self {
996        Self {
997            bundle_result,
998            reachability_attribution,
999        }
1000    }
1001
1002    pub fn bundle_result(&self) -> &OmenaQueryBundleResultV0 {
1003        &self.bundle_result
1004    }
1005
1006    pub fn reachability_attribution(&self) -> &OmenaQueryModuleReachabilityAttributionReportV0 {
1007        &self.reachability_attribution
1008    }
1009
1010    pub fn into_bundle_result(self) -> OmenaQueryBundleResultV0 {
1011        self.bundle_result
1012    }
1013}
1014
1015#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
1016#[serde(rename_all = "camelCase")]
1017pub struct OmenaQueryClosedWorldDecisionParityV0 {
1018    pub legacy_open_decision: bool,
1019    pub typed_outcome_open: bool,
1020    pub equivalent: bool,
1021}
1022
1023#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1024#[serde(rename_all = "camelCase")]
1025pub struct OmenaQueryBundleEvidenceGateV0 {
1026    pub name: &'static str,
1027    pub passed: bool,
1028}
1029
1030#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1031#[serde(rename_all = "camelCase")]
1032pub struct OmenaQueryBundleReachabilityEvidenceV0 {
1033    pub guarantee: GuaranteeKindV0,
1034    pub interpretation: &'static str,
1035    pub module_instances: Vec<omena_parser::ModuleInstanceKeyV0>,
1036    pub closure_hash: String,
1037}
1038
1039#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1040#[serde(rename_all = "camelCase")]
1041pub struct OmenaQueryBundleEvidenceManifestV0 {
1042    pub schema_version: &'static str,
1043    pub product: &'static str,
1044    pub style_path: String,
1045    pub outcome_status: &'static str,
1046    pub reachability: Option<OmenaQueryBundleReachabilityEvidenceV0>,
1047    pub gates: Vec<OmenaQueryBundleEvidenceGateV0>,
1048    pub blockers: Vec<OmenaQueryClosedWorldBlockerV0>,
1049    pub interface_hashes: Vec<omena_parser::ClosedWorldInterfaceHashEntryV0>,
1050    pub source_precision: Option<omena_parser::ClosedWorldSourcePrecisionSummaryV0>,
1051}
1052
1053#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1054#[serde(rename_all = "camelCase")]
1055pub struct OmenaQueryBundleWithEvidenceV0 {
1056    #[serde(flatten)]
1057    pub artifact: OmenaQueryBundleArtifactV0,
1058    pub closed_world_outcome: OmenaQueryClosedWorldOutcomeV0,
1059    pub closed_world_decision_parity: OmenaQueryClosedWorldDecisionParityV0,
1060    pub evidence: OmenaQueryBundleEvidenceManifestV0,
1061}
1062
1063#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1064#[serde(rename_all = "camelCase")]
1065pub struct OmenaQueryBundleCodeSplitWorkspacePlanV0 {
1066    pub schema_version: &'static str,
1067    pub product: &'static str,
1068    pub primary_entry_style_path: String,
1069    pub configured_entry_count: usize,
1070    pub output_count: usize,
1071    pub shared_boundary_count: usize,
1072    pub outputs: Vec<OmenaQueryBundleCodeSplitWorkspacePlanOutputV0>,
1073    pub ready_surfaces: Vec<&'static str>,
1074}
1075
1076#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1077#[serde(rename_all = "camelCase")]
1078pub struct OmenaQueryBundleCodeSplitWorkspacePlanOutputV0 {
1079    pub source_path: String,
1080    pub is_entry: bool,
1081    pub split_boundary: &'static str,
1082    pub reachable_from_entries: Vec<String>,
1083}
1084
1085#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1086#[serde(rename_all = "camelCase")]
1087pub struct OmenaQueryTransformPassSummaryV0 {
1088    pub id: &'static str,
1089    pub title: &'static str,
1090    pub reads_semantic_graph: bool,
1091    pub reads_cascade_model: bool,
1092    pub explicit_opt_in_required: bool,
1093    pub dialect_restriction: Option<&'static str>,
1094    pub spec_snapshot: Option<&'static str>,
1095    pub opt_in_policy: Option<&'static str>,
1096}
1097
1098#[derive(Debug, Clone, PartialEq, Serialize)]
1099#[serde(rename_all = "camelCase")]
1100pub struct OmenaQueryTransformPlanSummaryV0 {
1101    pub schema_version: &'static str,
1102    pub product: &'static str,
1103    pub style_path: String,
1104    pub dialect: &'static str,
1105    pub bundle: TransformBundleSourceSummaryV0,
1106    pub target: TransformTargetPlanV0,
1107    pub target_query: Option<OmenaQueryTransformTargetQueryPlanV0>,
1108    pub egg: TransformEggPlanV0,
1109    pub egg_witnesses: Vec<EggRewriteSourceWitnessV0>,
1110    pub custom_property_fixed_point: OmenaQueryCustomPropertyLeastFixedPointSummaryV0,
1111    pub print: TransformPrintArtifactV0,
1112    pub execution: TransformExecutionSummaryV0,
1113    pub semantic_removal_count: usize,
1114    pub combined_plan: TransformPassPlanV0,
1115    pub combined_pass_ids: Vec<&'static str>,
1116    pub combined_violated_dag_edge_count: usize,
1117    pub ready_surfaces: Vec<&'static str>,
1118}
1119
1120#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1121#[serde(rename_all = "camelCase")]
1122pub struct OmenaQueryTransformExecuteSummaryV0 {
1123    pub schema_version: &'static str,
1124    pub product: &'static str,
1125    pub style_path: String,
1126    pub requested_pass_ids: Vec<String>,
1127    pub unknown_pass_ids: Vec<String>,
1128    pub execution: TransformExecutionSummaryV0,
1129    pub semantic_removal_count: usize,
1130    #[serde(skip_serializing_if = "Option::is_none")]
1131    pub open_world_snapshot: Option<OmenaQueryOpenWorldSnapshotV0>,
1132    pub ready_surfaces: Vec<&'static str>,
1133}
1134
1135#[cfg(feature = "transform-catalog-trace")]
1136#[derive(Debug, Clone, PartialEq, Serialize)]
1137#[serde(rename_all = "camelCase")]
1138pub struct OmenaQueryTransformCatalogTransformExecuteSummaryV0 {
1139    pub schema_version: &'static str,
1140    pub product: &'static str,
1141    pub product_scope: &'static str,
1142    pub default_product_mechanism: bool,
1143    pub global_transform_theorem_claimed: bool,
1144    pub execution: OmenaQueryTransformExecuteSummaryV0,
1145    /// Compatibility field owned by `omena-query` maintainers. Remove not
1146    /// before 1.0, after downstream migration and zero audited non-compat uses.
1147    #[deprecated(
1148        since = "0.4.0",
1149        note = "use transform_catalog_trace(); removal is not before 1.0 and requires downstream migration plus zero audited non-compatibility uses"
1150    )]
1151    pub lawvere_trace: OmenaQueryTransformCatalogModelTraceV0,
1152    pub parallel_plan: OmenaQueryTransformCatalogTransformPassParallelPlanV0,
1153    pub reorderability_certificates: Vec<OmenaQueryTransformCatalogReorderabilityCertificateV0>,
1154    pub differential_witnesses: Vec<OmenaQueryTransformCatalogDifferentialCommutativityWitnessV0>,
1155    pub ready_surfaces: Vec<&'static str>,
1156}
1157
1158/// Pre-1.0 nominal compatibility summary for the former trace surface.
1159/// Owner: `omena-query` maintainers. Removal condition: not before 1.0,
1160/// after downstream migration and zero audited in-repo non-compatibility uses.
1161#[cfg(feature = "transform-catalog-trace")]
1162#[allow(deprecated)]
1163#[deprecated(
1164    since = "0.4.0",
1165    note = "use OmenaQueryTransformCatalogTransformExecuteSummaryV0; removal is not before 1.0 and requires downstream migration plus zero audited non-compatibility uses"
1166)]
1167#[derive(Debug, Clone, PartialEq, Serialize)]
1168#[serde(rename_all = "camelCase")]
1169pub struct OmenaQueryLawvereTransformExecuteSummaryV0 {
1170    pub schema_version: &'static str,
1171    pub product: &'static str,
1172    pub product_scope: &'static str,
1173    pub default_product_mechanism: bool,
1174    pub global_transform_theorem_claimed: bool,
1175    pub execution: OmenaQueryTransformExecuteSummaryV0,
1176    pub lawvere_trace: omena_query_transform_runner::LawvereModelTraceV0,
1177    pub parallel_plan: omena_query_transform_runner::TransformPassParallelPlanV0,
1178    pub reorderability_certificates: Vec<omena_query_transform_runner::ReorderabilityCertificateV0>,
1179    pub differential_witnesses:
1180        Vec<omena_query_transform_runner::LawvereDifferentialCommutativityWitnessV0>,
1181    pub ready_surfaces: Vec<&'static str>,
1182}
1183
1184#[cfg(feature = "transform-catalog-trace")]
1185impl OmenaQueryTransformCatalogTransformExecuteSummaryV0 {
1186    #[allow(deprecated)]
1187    pub fn transform_catalog_trace(&self) -> &OmenaQueryTransformCatalogModelTraceV0 {
1188        transform_catalog_trace_from_legacy_field_v0(self)
1189    }
1190}
1191
1192#[cfg(feature = "transform-catalog-trace")]
1193#[allow(deprecated)]
1194#[deprecated(
1195    since = "0.4.0",
1196    note = "compatibility field adapter owned by omena-query maintainers; removal is not before 1.0 and requires downstream migration plus zero audited non-compatibility uses"
1197)]
1198fn transform_catalog_trace_from_legacy_field_v0(
1199    summary: &OmenaQueryTransformCatalogTransformExecuteSummaryV0,
1200) -> &OmenaQueryTransformCatalogModelTraceV0 {
1201    &summary.lawvere_trace
1202}
1203
1204#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1205#[serde(rename_all = "camelCase")]
1206pub struct OmenaQueryTransformContextFromSourcesSummaryV0 {
1207    pub schema_version: &'static str,
1208    pub product: &'static str,
1209    pub target_style_path: String,
1210    pub style_count: usize,
1211    pub context: TransformExecutionContextV0,
1212    pub import_inline_count: usize,
1213    pub class_name_rewrite_count: usize,
1214    pub css_module_composes_resolution_count: usize,
1215    pub css_module_value_resolution_count: usize,
1216    pub design_token_route_count: usize,
1217    pub reachable_class_name_count: usize,
1218    pub reachable_keyframe_name_count: usize,
1219    pub reachable_value_name_count: usize,
1220    pub reachable_custom_property_name_count: usize,
1221    pub ready_surfaces: Vec<&'static str>,
1222}
1223
1224#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1225#[serde(rename_all = "camelCase")]
1226pub struct OmenaQueryTransformContextFromEngineInputSummaryV0 {
1227    pub schema_version: &'static str,
1228    pub product: &'static str,
1229    pub input_version: String,
1230    pub target_style_path: String,
1231    pub closed_world_requested: bool,
1232    pub style_source_count: usize,
1233    pub projection_count: usize,
1234    pub selected_projection_count: usize,
1235    pub import_inline_count: usize,
1236    pub class_name_rewrite_count: usize,
1237    pub css_module_composes_resolution_count: usize,
1238    pub css_module_value_resolution_count: usize,
1239    pub design_token_route_count: usize,
1240    pub reachable_class_name_count: usize,
1241    pub reachable_keyframe_name_count: usize,
1242    pub reachable_value_name_count: usize,
1243    pub reachable_custom_property_name_count: usize,
1244    pub reachability_sources: Vec<OmenaQuerySemanticReachabilitySourceV0>,
1245    pub context: TransformExecutionContextV0,
1246    pub ready_surfaces: Vec<&'static str>,
1247}
1248
1249#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1250#[serde(rename_all = "camelCase")]
1251pub struct OmenaQuerySemanticReachabilitySourceV0 {
1252    pub graph_id: String,
1253    pub file_path: String,
1254    pub node_id: String,
1255    pub target_style_paths: Vec<String>,
1256    pub value_kind: &'static str,
1257    #[serde(skip_serializing_if = "Option::is_none")]
1258    pub reduced_product: Option<ReducedClassValueProductV0>,
1259    pub selector_names: Vec<String>,
1260    pub certainty: SelectorProjectionCertaintyV0,
1261}
1262
1263#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
1264#[serde(rename_all = "camelCase")]
1265#[non_exhaustive]
1266pub enum OmenaQueryModuleReachabilityAttributionKindV0 {
1267    TargetedProjection,
1268    UnattributedProjectionFanout,
1269    TargetedAndUnattributedProjection,
1270    NoApplicableProjection,
1271}
1272
1273#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1274#[serde(rename_all = "camelCase")]
1275#[non_exhaustive]
1276pub struct OmenaQueryModuleReachabilityAttributionV0 {
1277    style_path: String,
1278    class_names: Vec<String>,
1279    targeted_projection_count: usize,
1280    unattributed_projection_count: usize,
1281    attribution_kind: OmenaQueryModuleReachabilityAttributionKindV0,
1282}
1283
1284impl OmenaQueryModuleReachabilityAttributionV0 {
1285    pub(crate) fn new(
1286        style_path: String,
1287        class_names: Vec<String>,
1288        targeted_projection_count: usize,
1289        unattributed_projection_count: usize,
1290    ) -> Self {
1291        let attribution_kind = match (
1292            targeted_projection_count > 0,
1293            unattributed_projection_count > 0,
1294        ) {
1295            (true, true) => {
1296                OmenaQueryModuleReachabilityAttributionKindV0::TargetedAndUnattributedProjection
1297            }
1298            (true, false) => OmenaQueryModuleReachabilityAttributionKindV0::TargetedProjection,
1299            (false, true) => {
1300                OmenaQueryModuleReachabilityAttributionKindV0::UnattributedProjectionFanout
1301            }
1302            (false, false) => OmenaQueryModuleReachabilityAttributionKindV0::NoApplicableProjection,
1303        };
1304        Self {
1305            style_path,
1306            class_names,
1307            targeted_projection_count,
1308            unattributed_projection_count,
1309            attribution_kind,
1310        }
1311    }
1312
1313    pub fn style_path(&self) -> &str {
1314        self.style_path.as_str()
1315    }
1316
1317    pub fn class_names(&self) -> &[String] {
1318        self.class_names.as_slice()
1319    }
1320
1321    pub fn targeted_projection_count(&self) -> usize {
1322        self.targeted_projection_count
1323    }
1324
1325    pub fn unattributed_projection_count(&self) -> usize {
1326        self.unattributed_projection_count
1327    }
1328
1329    pub fn attribution_kind(&self) -> OmenaQueryModuleReachabilityAttributionKindV0 {
1330        self.attribution_kind
1331    }
1332
1333    pub fn was_attempted(&self) -> bool {
1334        self.targeted_projection_count > 0 || self.unattributed_projection_count > 0
1335    }
1336}
1337
1338#[derive(Debug, Clone, PartialEq, Eq)]
1339pub(crate) struct OmenaQueryEngineInputModuleAttributionV0 {
1340    declared_class_names_by_style_path: BTreeMap<String, Vec<String>>,
1341    targeted_class_names_by_style_path: BTreeMap<String, Vec<String>>,
1342    targeted_projection_count_by_style_path: BTreeMap<String, usize>,
1343}
1344
1345impl OmenaQueryEngineInputModuleAttributionV0 {
1346    pub(crate) fn new(
1347        declared_class_names_by_style_path: BTreeMap<String, Vec<String>>,
1348        targeted_class_names_by_style_path: BTreeMap<String, Vec<String>>,
1349        targeted_projection_count_by_style_path: BTreeMap<String, usize>,
1350    ) -> Self {
1351        Self {
1352            declared_class_names_by_style_path,
1353            targeted_class_names_by_style_path,
1354            targeted_projection_count_by_style_path,
1355        }
1356    }
1357}
1358
1359#[derive(Debug, Clone, PartialEq, Eq)]
1360#[non_exhaustive]
1361pub struct OmenaQueryEngineInputModuleReachabilityV0 {
1362    summary: OmenaQueryTransformContextFromEngineInputSummaryV0,
1363    known_style_paths: Vec<String>,
1364    declared_class_names_by_style_path: BTreeMap<String, Vec<String>>,
1365    targeted_class_names_by_style_path: BTreeMap<String, Vec<String>>,
1366    targeted_projection_count_by_style_path: BTreeMap<String, usize>,
1367    unattributed_class_names: Vec<String>,
1368    unattributed_projection_count: usize,
1369    projected_class_names: Vec<String>,
1370    projection_summary_evaluation_count: usize,
1371}
1372
1373impl OmenaQueryEngineInputModuleReachabilityV0 {
1374    pub(crate) fn new(
1375        summary: OmenaQueryTransformContextFromEngineInputSummaryV0,
1376        known_style_paths: Vec<String>,
1377        module_attribution: OmenaQueryEngineInputModuleAttributionV0,
1378        unattributed_class_names: Vec<String>,
1379        unattributed_projection_count: usize,
1380        projected_class_names: Vec<String>,
1381    ) -> Self {
1382        let OmenaQueryEngineInputModuleAttributionV0 {
1383            declared_class_names_by_style_path,
1384            targeted_class_names_by_style_path,
1385            targeted_projection_count_by_style_path,
1386        } = module_attribution;
1387        Self {
1388            summary,
1389            known_style_paths,
1390            declared_class_names_by_style_path,
1391            targeted_class_names_by_style_path,
1392            targeted_projection_count_by_style_path,
1393            unattributed_class_names,
1394            unattributed_projection_count,
1395            projected_class_names,
1396            projection_summary_evaluation_count: 1,
1397        }
1398    }
1399
1400    pub fn summary(&self) -> &OmenaQueryTransformContextFromEngineInputSummaryV0 {
1401        &self.summary
1402    }
1403
1404    pub fn context(&self) -> &TransformExecutionContextV0 {
1405        &self.summary.context
1406    }
1407
1408    pub fn into_summary(self) -> OmenaQueryTransformContextFromEngineInputSummaryV0 {
1409        self.summary
1410    }
1411
1412    pub fn projected_class_names(&self) -> &[String] {
1413        self.projected_class_names.as_slice()
1414    }
1415
1416    pub fn projection_summary_evaluation_count(&self) -> usize {
1417        self.projection_summary_evaluation_count
1418    }
1419
1420    pub fn module_attribution(
1421        &self,
1422        style_path: &str,
1423    ) -> OmenaQueryModuleReachabilityAttributionV0 {
1424        let style_path = resolve_omena_query_style_path_against_known(
1425            style_path,
1426            self.known_style_paths.as_slice(),
1427        )
1428        .unwrap_or_else(|| normalize_omena_query_style_path(style_path));
1429        let mut class_names = self.unattributed_class_names.clone();
1430        if let Some(targeted_class_names) = self
1431            .targeted_class_names_by_style_path
1432            .get(style_path.as_str())
1433        {
1434            class_names.extend(targeted_class_names.iter().cloned());
1435        }
1436        class_names.sort();
1437        class_names.dedup();
1438        OmenaQueryModuleReachabilityAttributionV0::new(
1439            style_path.clone(),
1440            class_names,
1441            self.targeted_projection_count_by_style_path
1442                .get(style_path.as_str())
1443                .copied()
1444                .unwrap_or_default(),
1445            self.unattributed_projection_count,
1446        )
1447    }
1448
1449    pub(crate) fn targeted_style_paths(&self) -> impl Iterator<Item = &str> {
1450        self.targeted_projection_count_by_style_path
1451            .keys()
1452            .map(String::as_str)
1453    }
1454
1455    pub(crate) fn flat_class_names_for_style_paths<'a>(
1456        &self,
1457        style_paths: impl IntoIterator<Item = &'a str>,
1458        candidate_class_names: &[String],
1459    ) -> Vec<String> {
1460        let style_paths =
1461            module_attribution_domain_style_paths(style_paths, self.known_style_paths.as_slice());
1462
1463        candidate_class_names
1464            .iter()
1465            .filter(|class_name| {
1466                let mut declared_owner_paths = self
1467                    .declared_class_names_by_style_path
1468                    .iter()
1469                    .filter(|(_, names)| {
1470                        class_name_collection_contains(names.iter().map(String::as_str), class_name)
1471                    })
1472                    .map(|(style_path, _)| style_path);
1473                let Some(first_owner_path) = declared_owner_paths.next() else {
1474                    return true;
1475                };
1476                style_paths.contains(first_owner_path)
1477                    || declared_owner_paths.any(|style_path| style_paths.contains(style_path))
1478            })
1479            .cloned()
1480            .collect::<BTreeSet<_>>()
1481            .into_iter()
1482            .collect()
1483    }
1484}
1485
1486pub(crate) fn normalize_omena_query_style_path(style_path: &str) -> String {
1487    normalize_omena_transform_bundle_path(style_path)
1488}
1489
1490pub(crate) fn resolve_omena_query_style_path_against_known(
1491    style_path: &str,
1492    known_style_paths: &[String],
1493) -> Option<String> {
1494    let normalized = normalize_omena_query_style_path(style_path);
1495    unique_style_path_match(known_style_paths, |known| {
1496        normalize_omena_query_style_path(known) == normalized
1497    })
1498    .or_else(|| {
1499        unique_style_path_match(known_style_paths, |known| {
1500            normalize_omena_query_style_path(known).eq_ignore_ascii_case(normalized.as_str())
1501        })
1502    })
1503    .or_else(|| {
1504        unique_style_path_match(known_style_paths, |known| {
1505            style_path_component_suffix_matches(
1506                normalize_omena_query_style_path(known).as_str(),
1507                normalized.as_str(),
1508                false,
1509            )
1510        })
1511    })
1512    .or_else(|| {
1513        unique_style_path_match(known_style_paths, |known| {
1514            style_path_component_suffix_matches(
1515                normalize_omena_query_style_path(known).as_str(),
1516                normalized.as_str(),
1517                true,
1518            )
1519        })
1520    })
1521}
1522
1523fn attribution_domain_style_paths(style_path: &str, known_style_paths: &[String]) -> Vec<String> {
1524    let normalized = normalize_omena_query_style_path(style_path);
1525    for matches in [
1526        matching_style_paths(known_style_paths, |known| {
1527            normalize_omena_query_style_path(known) == normalized
1528        }),
1529        matching_style_paths(known_style_paths, |known| {
1530            normalize_omena_query_style_path(known).eq_ignore_ascii_case(normalized.as_str())
1531        }),
1532        matching_style_paths(known_style_paths, |known| {
1533            style_path_component_suffix_matches(
1534                normalize_omena_query_style_path(known).as_str(),
1535                normalized.as_str(),
1536                false,
1537            )
1538        }),
1539        matching_style_paths(known_style_paths, |known| {
1540            style_path_component_suffix_matches(
1541                normalize_omena_query_style_path(known).as_str(),
1542                normalized.as_str(),
1543                true,
1544            )
1545        }),
1546    ] {
1547        if !matches.is_empty() {
1548            return matches;
1549        }
1550    }
1551    vec![normalized]
1552}
1553
1554// Admission and placement share this domain so every admitted name either
1555// fans out as ownerless or has at least one matching entry to receive it.
1556fn module_attribution_domain_style_paths<'a>(
1557    style_paths: impl IntoIterator<Item = &'a str>,
1558    known_style_paths: &[String],
1559) -> BTreeSet<String> {
1560    style_paths
1561        .into_iter()
1562        .flat_map(|style_path| attribution_domain_style_paths(style_path, known_style_paths))
1563        .collect()
1564}
1565
1566fn matching_style_paths(
1567    known_style_paths: &[String],
1568    matches: impl Fn(&String) -> bool,
1569) -> Vec<String> {
1570    known_style_paths
1571        .iter()
1572        .filter(|known| matches(known))
1573        .map(|known| normalize_omena_query_style_path(known))
1574        .collect::<BTreeSet<_>>()
1575        .into_iter()
1576        .collect()
1577}
1578
1579fn unique_style_path_match(
1580    known_style_paths: &[String],
1581    matches: impl Fn(&String) -> bool,
1582) -> Option<String> {
1583    let mut matching = known_style_paths.iter().filter(|known| matches(known));
1584    let first = matching.next()?;
1585    matching.next().is_none().then(|| first.clone())
1586}
1587
1588fn style_path_component_suffix_matches(left: &str, right: &str, ignore_case: bool) -> bool {
1589    let left = left.trim_matches('/');
1590    let right = right.trim_matches('/');
1591    let (left, right) = if ignore_case {
1592        (left.to_ascii_lowercase(), right.to_ascii_lowercase())
1593    } else {
1594        (left.to_string(), right.to_string())
1595    };
1596    left == right
1597        || left
1598            .strip_suffix(right.as_str())
1599            .is_some_and(|prefix| prefix.ends_with('/'))
1600        || right
1601            .strip_suffix(left.as_str())
1602            .is_some_and(|prefix| prefix.ends_with('/'))
1603}
1604
1605#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1606#[serde(rename_all = "camelCase")]
1607#[non_exhaustive]
1608pub struct OmenaQueryModuleReachabilityAttributionReportV0 {
1609    entries: Vec<OmenaQueryModuleReachabilityAttributionV0>,
1610    projection_summary_evaluation_count: usize,
1611    projected_class_names: Vec<String>,
1612    unattributed_class_names: Vec<String>,
1613    flat_class_names: Vec<String>,
1614    attributed_class_names: Vec<String>,
1615    lost_class_names: Vec<String>,
1616    unmatched_target_style_paths: Vec<String>,
1617    attempted_module_count: usize,
1618    attributed_empty_module_count: usize,
1619}
1620
1621impl OmenaQueryModuleReachabilityAttributionReportV0 {
1622    pub(crate) fn from_style_paths<'a>(
1623        attribution: &OmenaQueryEngineInputModuleReachabilityV0,
1624        style_paths: impl IntoIterator<Item = &'a str>,
1625        flat_class_names: &[String],
1626    ) -> Self {
1627        let mut style_paths = module_attribution_domain_style_paths(
1628            style_paths,
1629            attribution.known_style_paths.as_slice(),
1630        )
1631        .into_iter()
1632        .collect::<Vec<_>>();
1633        style_paths.sort();
1634        style_paths.dedup();
1635        let mut entries = style_paths
1636            .iter()
1637            .map(|style_path| attribution.module_attribution(style_path))
1638            .collect::<Vec<_>>();
1639        entries.sort_by(|left, right| left.style_path().cmp(right.style_path()));
1640        entries.dedup_by(|left, right| left.style_path() == right.style_path());
1641
1642        let mut flat_class_names = flat_class_names.to_vec();
1643        flat_class_names.sort();
1644        flat_class_names.dedup();
1645        let directly_attributed_class_names = entries
1646            .iter()
1647            .flat_map(|entry| entry.class_names.iter().cloned())
1648            .collect::<BTreeSet<_>>();
1649        for class_name in &flat_class_names {
1650            if class_name_collection_contains(
1651                directly_attributed_class_names.iter().map(String::as_str),
1652                class_name,
1653            ) {
1654                continue;
1655            }
1656            let declared_owner_paths = attribution
1657                .declared_class_names_by_style_path
1658                .iter()
1659                .filter(|(_, names)| {
1660                    class_name_collection_contains(names.iter().map(String::as_str), class_name)
1661                })
1662                .map(|(style_path, _)| normalize_omena_query_style_path(style_path))
1663                .collect::<BTreeSet<_>>();
1664            for entry in &mut entries {
1665                if declared_owner_paths.is_empty()
1666                    || declared_owner_paths
1667                        .contains(&normalize_omena_query_style_path(entry.style_path.as_str()))
1668                {
1669                    entry.class_names.push(class_name.clone());
1670                    entry.class_names.sort();
1671                    entry.class_names.dedup();
1672                }
1673            }
1674        }
1675
1676        let style_path_set = entries
1677            .iter()
1678            .map(OmenaQueryModuleReachabilityAttributionV0::style_path)
1679            .collect::<BTreeSet<_>>();
1680        let attributed_class_names = entries
1681            .iter()
1682            .flat_map(|entry| entry.class_names.iter().cloned())
1683            .collect::<BTreeSet<_>>()
1684            .into_iter()
1685            .collect::<Vec<_>>();
1686        let unmatched_target_style_paths = attribution
1687            .targeted_style_paths()
1688            .filter(|path| !style_path_set.contains(path))
1689            .map(str::to_string)
1690            .collect::<Vec<_>>();
1691        let attempted_module_count = entries.iter().filter(|entry| entry.was_attempted()).count();
1692        let attributed_empty_module_count = entries
1693            .iter()
1694            .filter(|entry| entry.was_attempted() && entry.class_names.is_empty())
1695            .count();
1696        Self {
1697            entries,
1698            projection_summary_evaluation_count: attribution.projection_summary_evaluation_count(),
1699            projected_class_names: attribution.projected_class_names.clone(),
1700            unattributed_class_names: attribution.unattributed_class_names.clone(),
1701            flat_class_names,
1702            attributed_class_names,
1703            lost_class_names: Vec::new(),
1704            unmatched_target_style_paths,
1705            attempted_module_count,
1706            attributed_empty_module_count,
1707        }
1708    }
1709
1710    pub fn entries(&self) -> &[OmenaQueryModuleReachabilityAttributionV0] {
1711        self.entries.as_slice()
1712    }
1713
1714    pub fn entry_for_style_path(
1715        &self,
1716        style_path: &str,
1717    ) -> Option<&OmenaQueryModuleReachabilityAttributionV0> {
1718        let known_style_paths = self
1719            .entries
1720            .iter()
1721            .map(|entry| entry.style_path().to_string())
1722            .collect::<Vec<_>>();
1723        let style_path =
1724            resolve_omena_query_style_path_against_known(style_path, known_style_paths.as_slice())
1725                .unwrap_or_else(|| normalize_omena_query_style_path(style_path));
1726        self.entries
1727            .binary_search_by(|entry| entry.style_path().cmp(style_path.as_str()))
1728            .ok()
1729            .map(|index| &self.entries[index])
1730    }
1731
1732    pub fn projection_summary_evaluation_count(&self) -> usize {
1733        self.projection_summary_evaluation_count
1734    }
1735
1736    pub fn projected_class_names(&self) -> &[String] {
1737        self.projected_class_names.as_slice()
1738    }
1739
1740    /// Names from source projections that could not be assigned to one style module.
1741    pub fn unattributed_class_names(&self) -> &[String] {
1742        self.unattributed_class_names.as_slice()
1743    }
1744
1745    /// Class names whose declared owners intersect the current build-source domain.
1746    pub fn flat_class_names(&self) -> &[String] {
1747        self.flat_class_names.as_slice()
1748    }
1749
1750    pub fn attributed_class_names(&self) -> &[String] {
1751        self.attributed_class_names.as_slice()
1752    }
1753
1754    /// Always-empty compatibility view for the shared admission/placement domain.
1755    ///
1756    /// This does not establish whether linked output retained every live declaration;
1757    /// emission-level checks own that separate guarantee.
1758    pub fn lost_class_names(&self) -> &[String] {
1759        self.lost_class_names.as_slice()
1760    }
1761
1762    pub fn unmatched_target_style_paths(&self) -> &[String] {
1763        self.unmatched_target_style_paths.as_slice()
1764    }
1765
1766    pub fn attempted_module_count(&self) -> usize {
1767        self.attempted_module_count
1768    }
1769
1770    pub fn attributed_empty_module_count(&self) -> usize {
1771        self.attributed_empty_module_count
1772    }
1773}
1774
1775fn class_name_collection_contains<'a>(
1776    names: impl IntoIterator<Item = &'a str>,
1777    candidate: &str,
1778) -> bool {
1779    let candidate = omena_syntax::ident::ClassNameV0::new(candidate);
1780    names
1781        .into_iter()
1782        .any(|name| omena_syntax::ident::ClassNameV0::new(name).same_as(&candidate))
1783}
1784
1785#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
1786#[serde(rename_all = "camelCase")]
1787pub struct OmenaQueryStyleSourceInputV0 {
1788    pub style_path: String,
1789    pub style_source: String,
1790}
1791
1792#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
1793#[serde(rename_all = "camelCase")]
1794pub struct OmenaQueryExternalSifInputV0 {
1795    pub canonical_url: String,
1796    pub sif: OmenaSifV1,
1797}
1798
1799#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
1800#[serde(rename_all = "camelCase")]
1801pub struct OmenaQuerySourceDocumentInputV0 {
1802    pub source_path: String,
1803    pub source_source: String,
1804    /// Precomputed source syntax facts from the LSP workspace/source index. When
1805    /// present, query consumers can avoid reparsing source text while preserving
1806    /// the existing text-backed fallback for non-indexed callers.
1807    #[serde(default, skip_deserializing, skip_serializing_if = "Option::is_none")]
1808    pub source_syntax_index: Option<OmenaQuerySourceSyntaxIndexV0>,
1809    #[serde(default)]
1810    pub has_unresolved_style_import: bool,
1811}
1812
1813#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1814#[serde(rename_all = "camelCase")]
1815pub struct OmenaQueryOmenaParserStyleFactsV0 {
1816    pub schema_version: &'static str,
1817    pub product: &'static str,
1818    pub dialect: &'static str,
1819    pub class_selector_names: Vec<String>,
1820    pub id_selector_names: Vec<String>,
1821    pub placeholder_selector_names: Vec<String>,
1822    pub keyframe_names: Vec<String>,
1823    pub animation_reference_names: Vec<String>,
1824    pub css_module_value_definition_names: Vec<String>,
1825    pub css_module_value_reference_names: Vec<String>,
1826    pub css_module_value_import_sources: Vec<String>,
1827    pub css_module_value_import_edges: Vec<OmenaQueryCssModuleValueImportEdgeFactV0>,
1828    pub css_module_value_definition_edges: Vec<OmenaQueryCssModuleValueDefinitionEdgeFactV0>,
1829    pub css_module_composes_target_names: Vec<String>,
1830    pub css_module_composes_import_sources: Vec<String>,
1831    pub css_module_composes_edges: Vec<OmenaQueryCssModuleComposesEdgeFactV0>,
1832    pub icss_export_names: Vec<String>,
1833    pub icss_import_local_names: Vec<String>,
1834    pub icss_import_remote_names: Vec<String>,
1835    pub icss_import_sources: Vec<String>,
1836    pub icss_import_edges: Vec<OmenaQueryIcssImportEdgeFactV0>,
1837    pub icss_export_edges: Vec<OmenaQueryIcssExportEdgeFactV0>,
1838    pub variable_names: Vec<String>,
1839    pub sass_symbol_declaration_names: Vec<String>,
1840    pub sass_symbol_reference_names: Vec<String>,
1841    pub sass_symbol_facts: Vec<OmenaQuerySassSymbolFactV0>,
1842    pub sass_symbol_resolution: OmenaQuerySassSymbolResolutionV0,
1843    pub sass_module_use_sources: Vec<String>,
1844    pub sass_module_forward_sources: Vec<String>,
1845    pub sass_module_import_sources: Vec<String>,
1846    pub sass_module_edges: Vec<OmenaQuerySassModuleEdgeFactV0>,
1847    pub custom_property_names: Vec<String>,
1848    pub custom_property_decl_names: Vec<String>,
1849    pub custom_property_ref_names: Vec<String>,
1850    pub at_rule_names: Vec<String>,
1851    pub parser_error_count: usize,
1852}
1853
1854#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1855#[serde(rename_all = "camelCase")]
1856pub struct OmenaQuerySassSymbolFactV0 {
1857    pub kind: &'static str,
1858    pub symbol_kind: &'static str,
1859    pub name: String,
1860    pub role: &'static str,
1861    pub namespace: Option<String>,
1862}
1863
1864#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1865#[serde(rename_all = "camelCase")]
1866pub struct OmenaQuerySassSymbolResolutionV0 {
1867    pub schema_version: &'static str,
1868    pub product: &'static str,
1869    pub resolution_scope: &'static str,
1870    pub declaration_count: usize,
1871    pub reference_count: usize,
1872    pub resolved_reference_count: usize,
1873    pub unresolved_reference_count: usize,
1874    pub edges: Vec<OmenaQuerySassSymbolResolutionEdgeV0>,
1875    pub capabilities: OmenaQuerySassSymbolResolutionCapabilitiesV0,
1876}
1877
1878#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1879#[serde(rename_all = "camelCase")]
1880pub struct OmenaQuerySassSymbolResolutionEdgeV0 {
1881    pub symbol_kind: &'static str,
1882    pub name: String,
1883    pub namespace: Option<String>,
1884    pub reference_kind: &'static str,
1885    pub reference_role: &'static str,
1886    pub reference_source_order: usize,
1887    pub declaration_kind: Option<&'static str>,
1888    pub declaration_source_order: Option<usize>,
1889    pub status: &'static str,
1890}
1891
1892#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1893#[serde(rename_all = "camelCase")]
1894pub struct OmenaQuerySassSymbolResolutionCapabilitiesV0 {
1895    pub same_file_lexical_resolution_ready: bool,
1896    pub declaration_before_reference_ready: bool,
1897    pub unresolved_reference_reporting_ready: bool,
1898    pub cross_file_module_resolution_ready: bool,
1899}
1900
1901#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1902#[serde(rename_all = "camelCase")]
1903pub struct OmenaQuerySassModuleEdgeFactV0 {
1904    pub kind: &'static str,
1905    pub source: String,
1906    pub namespace_kind: Option<&'static str>,
1907    pub namespace: Option<String>,
1908    pub forward_prefix: Option<String>,
1909    pub visibility_filter_kind: Option<&'static str>,
1910    pub visibility_filter_names: Vec<String>,
1911}
1912
1913#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1914#[serde(rename_all = "camelCase")]
1915pub struct OmenaQuerySassModuleSourceEdgeV0 {
1916    pub kind: &'static str,
1917    pub source: String,
1918    pub byte_span: ParserByteSpanV0,
1919    pub namespace_kind: Option<&'static str>,
1920    pub namespace: Option<String>,
1921    pub forward_prefix: Option<String>,
1922    pub visibility_filter_kind: Option<&'static str>,
1923    pub visibility_filter_names: Vec<String>,
1924    pub media_qualified: bool,
1925}
1926
1927#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1928#[serde(rename_all = "camelCase")]
1929pub struct OmenaQueryCssModuleValueImportEdgeFactV0 {
1930    pub remote_name: String,
1931    pub local_name: String,
1932    pub import_source: String,
1933}
1934
1935#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1936#[serde(rename_all = "camelCase")]
1937pub struct OmenaQueryCssModuleValueDefinitionEdgeFactV0 {
1938    pub definition_name: String,
1939    pub reference_names: Vec<String>,
1940}
1941
1942#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1943#[serde(rename_all = "camelCase")]
1944pub struct OmenaQueryCssModuleComposesEdgeFactV0 {
1945    pub kind: &'static str,
1946    pub owner_selector_names: Vec<String>,
1947    pub target_names: Vec<String>,
1948    pub import_source: Option<String>,
1949}
1950
1951#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1952#[serde(rename_all = "camelCase")]
1953pub struct OmenaQueryIcssImportEdgeFactV0 {
1954    pub local_name: String,
1955    pub remote_name: String,
1956    pub import_source: String,
1957}
1958
1959#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1960#[serde(rename_all = "camelCase")]
1961pub struct OmenaQueryIcssExportEdgeFactV0 {
1962    pub export_name: String,
1963    pub reference_names: Vec<String>,
1964}
1965
1966#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
1967#[serde(rename_all = "camelCase")]
1968pub struct OmenaQueryStyleHoverCandidateV0 {
1969    pub kind: &'static str,
1970    pub name: String,
1971    pub range: ParserRangeV0,
1972    pub source: &'static str,
1973    pub namespace: Option<String>,
1974}
1975
1976#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1977#[serde(rename_all = "camelCase")]
1978pub struct OmenaQueryStyleHoverCandidatesV0 {
1979    pub schema_version: &'static str,
1980    pub product: &'static str,
1981    pub language: &'static str,
1982    pub candidates: Vec<OmenaQueryStyleHoverCandidateV0>,
1983}
1984
1985#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1986#[serde(rename_all = "camelCase")]
1987pub struct OmenaQueryStyleHoverRenderPartsV0 {
1988    pub schema_version: &'static str,
1989    pub product: &'static str,
1990    pub snippet: String,
1991    pub value: Option<String>,
1992    pub signature: Option<String>,
1993    #[serde(skip_serializing_if = "Vec::is_empty")]
1994    pub property_value_narrowings: Vec<AbstractPropertyValueNarrowingV0>,
1995    pub render_source: &'static str,
1996}
1997
1998#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1999#[serde(rename_all = "camelCase")]
2000pub struct OmenaQueryCascadeNarrowingEvidenceV0 {
2001    pub schema_version: &'static str,
2002    pub product: &'static str,
2003    pub selector: String,
2004    pub selector_class_names: Vec<String>,
2005    pub property_name: String,
2006    pub condition_context: Vec<String>,
2007    pub declaration_ids: Vec<String>,
2008    pub element_class_iteration: ReducedClassValueProductIterationV0,
2009    pub property_value_narrowing: AbstractPropertyValueNarrowingV0,
2010    #[serde(skip_serializing_if = "Option::is_none")]
2011    pub runtime_state: Option<OmenaQueryRuntimeStateScenarioEvidenceV0>,
2012}
2013
2014#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2015#[serde(rename_all = "camelCase")]
2016pub struct OmenaQueryStaticConditionPruningEvidenceV0 {
2017    pub schema_version: &'static str,
2018    pub product: &'static str,
2019    pub condition_context: Vec<String>,
2020    pub assumption: &'static str,
2021    pub verdict: &'static str,
2022    pub pruned: bool,
2023    pub anchor_context: bool,
2024}
2025
2026/// Why a cascade result could not use a complete named-layer ordering.
2027#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2028#[serde(rename_all = "camelCase")]
2029pub struct OmenaQueryCascadeLayerTopologyIncompleteV0 {
2030    /// Number of unresolved layer-topology facts observed by the semantic index.
2031    pub unresolved_count: usize,
2032}
2033
2034#[derive(Debug, Clone, PartialEq, Eq)]
2035pub struct OmenaQueryRuntimeStateScenarioEvidenceV0 {
2036    pub schema_version: &'static str,
2037    pub product: &'static str,
2038    pub selector: String,
2039    pub selector_class_names: Vec<String>,
2040    pub property_name: String,
2041    pub scenario_join_kind: &'static str,
2042    pub confidence_tier: &'static str,
2043    pub confidence_tier_within_modeled_environment: &'static str,
2044    pub static_boundary: OmenaQueryRuntimeStateStaticBoundaryV0,
2045    pub driver_summaries: Vec<OmenaQueryRuntimeStateDriverSummaryV0>,
2046    pub scenarios: Vec<OmenaQueryRuntimeStateScenarioV0>,
2047    pub static_condition_pruning: Vec<OmenaQueryStaticConditionPruningEvidenceV0>,
2048    pub inline_style_overrides: Vec<OmenaQueryInlineStyleRuntimeOverrideV0>,
2049    pub cascade_layer_topology_incomplete: Option<OmenaQueryCascadeLayerTopologyIncompleteV0>,
2050    pub guarded_winner_authority: Option<omena_cascade::GuardedCascadeWinnerAuthorityV0>,
2051    pub fragile_guarded_winner_diagnostics: Vec<OmenaQueryFragileGuardedWinnerDiagnosticV0>,
2052}
2053
2054#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2055#[serde(rename_all = "camelCase")]
2056pub struct OmenaQueryRuntimeStateStaticBoundaryV0 {
2057    pub boundary_kind: &'static str,
2058    pub static_value_assuming_no_runtime_override: bool,
2059    pub tracks_dom_mutation: bool,
2060    pub tracks_class_list_mutation: bool,
2061}
2062
2063#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2064#[serde(rename_all = "camelCase")]
2065pub struct OmenaQueryRuntimeStateDriverSummaryV0 {
2066    pub driver: &'static str,
2067    pub status: &'static str,
2068    pub scenario_count: usize,
2069    pub provenance: Vec<&'static str>,
2070}
2071
2072#[derive(Debug, Clone, PartialEq, Eq)]
2073pub struct OmenaQueryRuntimeStateScenarioV0 {
2074    pub scenario_kind: &'static str,
2075    pub pseudo_state: Option<String>,
2076    pub condition_context: Vec<String>,
2077    pub declaration_ids: Vec<String>,
2078    pub winner_declaration_id: Option<String>,
2079    pub winner_value: Option<String>,
2080    pub property_value_narrowing: AbstractPropertyValueNarrowingV0,
2081}
2082
2083#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2084#[serde(rename_all = "camelCase")]
2085pub struct OmenaQueryInlineStyleRuntimeOverrideV0 {
2086    pub source_path: String,
2087    pub range: ParserRangeV0,
2088    pub property_name: String,
2089    pub value: Option<String>,
2090    pub cascade_tier: &'static str,
2091    /// Whether the static source text ended with a CSS `!important` suffix.
2092    ///
2093    /// This is a source-text observation, not a claim about browser setter behavior.
2094    pub important: bool,
2095    pub static_value: bool,
2096}
2097
2098impl OmenaQueryInlineStyleRuntimeOverrideV0 {
2099    /// Whether the originating static source text ended with `!important`.
2100    ///
2101    /// The flag describes source syntax, not browser setter behavior.
2102    pub fn important_suffix_present(&self) -> bool {
2103        self.important
2104    }
2105}
2106
2107#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2108#[serde(rename_all = "camelCase")]
2109pub struct OmenaQueryStyleDiagnosticV0 {
2110    pub code: &'static str,
2111    pub severity: &'static str,
2112    pub provenance: Vec<&'static str>,
2113    pub range: ParserRangeV0,
2114    pub message: String,
2115    #[serde(skip_serializing_if = "Vec::is_empty")]
2116    pub tags: Vec<u8>,
2117    pub create_custom_property: Option<OmenaQueryCreateCustomPropertyActionV0>,
2118    #[serde(skip_serializing_if = "Option::is_none")]
2119    pub cascade_narrowing: Option<OmenaQueryCascadeNarrowingEvidenceV0>,
2120    #[serde(skip_serializing_if = "Option::is_none")]
2121    pub cascade_confidence: Option<OmenaQueryCascadeConfidenceV0>,
2122    #[serde(skip_serializing_if = "Option::is_none")]
2123    pub polynomial_provenance: Option<OmenaQueryPolynomialProvenanceV0>,
2124    #[serde(skip_serializing_if = "Option::is_none")]
2125    pub cross_file_scc: Option<OmenaQueryCrossFileSccEvidenceV0>,
2126}
2127
2128pub type OmenaQueryLinearProvenanceV0 = LinearProvenanceV0<NaturalCountProvenanceSemiringV0>;
2129pub type OmenaQueryPolynomialProvenanceV0 = PolynomialProvenanceV0;
2130
2131pub fn summarize_omena_query_linear_provenance(
2132    provenance: &[&'static str],
2133) -> OmenaQueryLinearProvenanceV0 {
2134    let labels = project_omena_query_diagnostic_provenance_from_evidence_graph(
2135        "linearProvenance",
2136        provenance.to_vec(),
2137    );
2138    summarize_omena_query_linear_provenance_with_support_count(labels.as_slice(), 1)
2139}
2140
2141pub fn summarize_omena_query_linear_provenance_with_support_count(
2142    provenance: &[&'static str],
2143    support_count: u8,
2144) -> OmenaQueryLinearProvenanceV0 {
2145    let path = if support_count == 0 {
2146        LinearProvenancePathV0::unsupported(provenance)
2147    } else {
2148        LinearProvenancePathV0::supported(provenance, support_count)
2149    };
2150    OmenaQueryLinearProvenanceV0::from_composed_paths(&[path])
2151}
2152
2153pub fn summarize_omena_query_polynomial_provenance(
2154    provenance: &[&'static str],
2155) -> OmenaQueryPolynomialProvenanceV0 {
2156    let labels = project_omena_query_diagnostic_provenance_from_evidence_graph(
2157        "polynomialProvenance",
2158        provenance.to_vec(),
2159    );
2160    let linear_provenance = summarize_omena_query_linear_provenance(labels.as_slice());
2161    summarize_polynomial_provenance_from_linear_v0(&linear_provenance, "diagnosticDefaultThreeTier")
2162}
2163
2164pub fn summarize_omena_query_linear_provenance_semiring_laws() -> ProvenanceSemiringLawReportV0 {
2165    verify_provenance_semiring_laws_on_fixtures(
2166        &NaturalCountProvenanceSemiringV0::new(),
2167        &[0, 1, 2, 3],
2168    )
2169}
2170
2171pub fn round_trip_omena_query_linear_provenance_labels(
2172    linear_provenance: &OmenaQueryLinearProvenanceV0,
2173) -> Vec<&'static str> {
2174    linear_provenance.labels()
2175}
2176
2177impl OmenaQueryStyleDiagnosticV0 {
2178    pub fn linear_provenance(&self) -> OmenaQueryLinearProvenanceV0 {
2179        summarize_omena_query_linear_provenance(self.provenance.as_slice())
2180    }
2181
2182    pub fn polynomial_provenance(&self) -> OmenaQueryPolynomialProvenanceV0 {
2183        summarize_omena_query_polynomial_provenance(self.provenance.as_slice())
2184    }
2185}
2186
2187pub(crate) fn apply_omena_query_checker_product_gate_to_style_diagnostics(
2188    diagnostics: &mut [OmenaQueryStyleDiagnosticV0],
2189) {
2190    for diagnostic in diagnostics {
2191        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
2192            diagnostic.code,
2193            &mut diagnostic.provenance,
2194        );
2195        diagnostic.polynomial_provenance = Some(diagnostic.polynomial_provenance());
2196    }
2197}
2198
2199#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2200#[serde(rename_all = "camelCase")]
2201pub struct OmenaQueryStyleDiagnosticsForFileV0 {
2202    pub schema_version: &'static str,
2203    pub product: &'static str,
2204    pub file_uri: String,
2205    pub file_kind: &'static str,
2206    pub diagnostic_count: usize,
2207    pub diagnostics: Vec<OmenaQueryStyleDiagnosticV0>,
2208    pub ready_surfaces: Vec<&'static str>,
2209    #[serde(skip_serializing_if = "Option::is_none")]
2210    pub suppression_summary: Option<OmenaQueryDiagnosticSuppressionSummaryV0>,
2211}
2212
2213#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2214#[serde(rename_all = "camelCase")]
2215pub struct OmenaQueryDiagnosticSuppressionSummaryV0 {
2216    pub original_diagnostic_count: usize,
2217    pub emitted_diagnostic_count: usize,
2218    pub suppressed_diagnostic_count: usize,
2219    pub unused_expect_error_count: usize,
2220    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2221    pub suppression_reasons: Vec<OmenaQueryDiagnosticSuppressionReasonV0>,
2222}
2223
2224#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2225#[serde(rename_all = "camelCase")]
2226pub struct OmenaQueryDiagnosticSuppressionReasonV0 {
2227    pub directive_kind: &'static str,
2228    pub codes: Vec<String>,
2229    pub reason: String,
2230    pub range: ParserRangeV0,
2231}
2232
2233#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2234pub enum OmenaQueryDiagnosticSuppressionModeV0 {
2235    Apply,
2236    ReportOnly,
2237}
2238
2239impl OmenaQueryDiagnosticSuppressionModeV0 {
2240    pub const fn as_str(self) -> &'static str {
2241        match self {
2242            Self::Apply => "apply",
2243            Self::ReportOnly => "reportOnly",
2244        }
2245    }
2246
2247    pub const fn suppresses_diagnostics(self) -> bool {
2248        matches!(self, Self::Apply)
2249    }
2250}
2251
2252#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2253#[serde(rename_all = "camelCase")]
2254pub struct OmenaQueryCompletionCandidateV0 {
2255    pub file_uri: String,
2256    pub name: String,
2257    pub kind: &'static str,
2258    pub range: ParserRangeV0,
2259    pub source: &'static str,
2260    #[serde(skip_serializing_if = "Option::is_none")]
2261    pub documentation: Option<String>,
2262}
2263
2264#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2265#[serde(rename_all = "camelCase")]
2266pub struct OmenaQueryCompletionItemV0 {
2267    pub label: String,
2268    pub insert_text: String,
2269    pub sort_text: String,
2270    pub detail: &'static str,
2271    #[serde(skip_serializing_if = "Option::is_none")]
2272    pub documentation: Option<String>,
2273    pub item_kind: &'static str,
2274    pub ranking_source: &'static str,
2275    pub source: &'static str,
2276}
2277
2278#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2279#[serde(rename_all = "camelCase")]
2280pub struct OmenaQueryCompletionAtPositionV0 {
2281    pub schema_version: &'static str,
2282    pub product: &'static str,
2283    pub file_uri: String,
2284    pub file_kind: &'static str,
2285    pub query_position: ParserPositionV0,
2286    pub context_kind: &'static str,
2287    pub prefix: Option<String>,
2288    pub is_incomplete: bool,
2289    pub item_count: usize,
2290    pub items: Vec<OmenaQueryCompletionItemV0>,
2291    pub ready_surfaces: Vec<&'static str>,
2292}
2293
2294#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2295#[serde(rename_all = "camelCase")]
2296pub struct OmenaQueryReferenceLocationV0 {
2297    pub uri: String,
2298    pub range: ParserRangeV0,
2299    pub name: String,
2300    pub role: &'static str,
2301    pub source: &'static str,
2302}
2303
2304#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2305#[serde(rename_all = "camelCase")]
2306pub struct OmenaQueryRefsForClassV0 {
2307    pub schema_version: &'static str,
2308    pub product: &'static str,
2309    pub selector_name: String,
2310    pub target_style_uri: Option<String>,
2311    pub include_declaration: bool,
2312    pub location_count: usize,
2313    pub locations: Vec<OmenaQueryReferenceLocationV0>,
2314    pub ready_surfaces: Vec<&'static str>,
2315}
2316
2317#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2318#[serde(rename_all = "camelCase")]
2319pub struct OmenaQueryRenamePlanV0 {
2320    pub schema_version: &'static str,
2321    pub product: &'static str,
2322    pub selector_name: String,
2323    pub new_name: String,
2324    pub target_style_uri: Option<String>,
2325    pub edit_count: usize,
2326    pub edits: Vec<OmenaQueryWorkspaceTextEditV0>,
2327    pub ready_surfaces: Vec<&'static str>,
2328}
2329
2330#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2331#[serde(rename_all = "camelCase")]
2332pub struct OmenaQueryCodeActionPlanV0 {
2333    pub schema_version: &'static str,
2334    pub product: &'static str,
2335    pub file_uri: String,
2336    pub file_kind: &'static str,
2337    pub action_count: usize,
2338    pub actions: Vec<OmenaQueryCodeActionV0>,
2339    pub ready_surfaces: Vec<&'static str>,
2340}
2341
2342#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2343#[serde(rename_all = "camelCase")]
2344pub struct OmenaQueryCodeActionV0 {
2345    pub title: String,
2346    pub kind: &'static str,
2347    pub edits: Vec<OmenaQueryWorkspaceTextEditV0>,
2348    pub source: &'static str,
2349}
2350
2351#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2352#[serde(rename_all = "camelCase")]
2353pub struct OmenaQueryStyleInsightsV0 {
2354    pub schema_version: &'static str,
2355    pub product: &'static str,
2356    pub style_uri: String,
2357    pub insight_count: usize,
2358    pub insights: Vec<OmenaQueryInsightV0>,
2359    pub ready_surfaces: Vec<&'static str>,
2360}
2361
2362#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2363#[serde(rename_all = "camelCase")]
2364pub struct OmenaQueryInsightV0 {
2365    pub kind: &'static str,
2366    pub title: String,
2367    pub message: String,
2368    pub range: ParserRangeV0,
2369    pub confidence: &'static str,
2370    pub scope: &'static str,
2371    pub source: &'static str,
2372    pub provenance: Vec<&'static str>,
2373    #[serde(skip_serializing_if = "Option::is_none")]
2374    pub primary_edit: Option<OmenaQueryWorkspaceTextEditV0>,
2375    pub shorthand_combinable: Option<OmenaQueryShorthandCombinableV0>,
2376    #[serde(skip_serializing_if = "Option::is_none")]
2377    pub cascade_insight: Option<OmenaQueryCascadeInsightV0>,
2378}
2379
2380#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2381#[serde(rename_all = "camelCase")]
2382pub struct OmenaQueryShorthandCombinableV0 {
2383    pub shorthand_property: String,
2384    pub longhand_properties: Vec<String>,
2385    pub values: Vec<String>,
2386    pub combined_value: String,
2387    pub declaration_count: usize,
2388}
2389
2390#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2391#[serde(rename_all = "camelCase")]
2392pub struct OmenaQueryCascadeInsightV0 {
2393    pub relationship: &'static str,
2394    pub selector: String,
2395    pub property: String,
2396    pub related_selector: Option<String>,
2397    pub related_property: Option<String>,
2398    pub source_order: u32,
2399    pub related_source_order: Option<u32>,
2400}
2401
2402#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2403#[serde(rename_all = "camelCase")]
2404pub struct OmenaQueryCascadeAtPositionV0 {
2405    pub schema_version: &'static str,
2406    pub product: &'static str,
2407    pub style_path: String,
2408    pub query_position: ParserPositionV0,
2409    pub status: &'static str,
2410    pub cascade_engine: &'static str,
2411    pub reference_name: Option<String>,
2412    pub reference_range: Option<ParserRangeV0>,
2413    pub winner_declaration_source_order: Option<usize>,
2414    pub winner_declaration_file_path: Option<String>,
2415    pub winner_declaration_range: Option<ParserRangeV0>,
2416    pub winner_context_kind: Option<&'static str>,
2417    /// Opaque cascade ordering token; consumers must not interpret it as a layer-count magnitude.
2418    pub winner_declaration_layer_rank: Option<i32>,
2419    pub winner_declaration_layer_name: Option<String>,
2420    pub candidate_declaration_count: usize,
2421    pub shadowed_declaration_source_orders: Vec<usize>,
2422    pub referenced_declaration_property: Option<String>,
2423    pub referenced_declaration_value: Option<String>,
2424    pub referenced_declaration_computed_value_status: Option<&'static str>,
2425    pub referenced_declaration_computed_value: Option<String>,
2426    pub referenced_declaration_invalid_at_computed_value_time: bool,
2427    pub referenced_declaration_computed_value_indeterminate: bool,
2428    #[serde(skip_serializing_if = "Option::is_none")]
2429    pub referenced_declaration_computed_value_indeterminate_reason: Option<&'static str>,
2430    pub referenced_declaration_computed_value_derivation_steps: Vec<&'static str>,
2431    pub custom_property_fixed_point_iteration_count: usize,
2432    pub custom_property_fixed_point_guaranteed_invalid_count: usize,
2433    pub reference_custom_property_fixed_point_status: Option<&'static str>,
2434    pub reference_custom_property_fixed_point_value: Option<String>,
2435    #[serde(skip_serializing_if = "Option::is_none")]
2436    pub refinement_evidence: Option<CascadeDimensionalRefinementBridgeV0>,
2437    #[serde(skip_serializing_if = "Option::is_none")]
2438    pub categorical_evidence:
2439        Option<omena_query_checker_orchestrator::CategoricalCascadeEvidenceV0>,
2440}
2441
2442#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2443#[serde(rename_all = "camelCase")]
2444pub struct OmenaQueryCreateCustomPropertyActionV0 {
2445    pub uri: String,
2446    pub range: ParserRangeV0,
2447    pub new_text: String,
2448    pub property_name: String,
2449}
2450
2451#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2452#[serde(rename_all = "camelCase")]
2453pub struct OmenaQuerySourceDiagnosticV0 {
2454    pub code: &'static str,
2455    pub severity: &'static str,
2456    pub provenance: Vec<&'static str>,
2457    pub range: ParserRangeV0,
2458    pub message: String,
2459    #[serde(skip_serializing_if = "Option::is_none")]
2460    pub precision: Option<OmenaQueryAnalysisPrecisionV0>,
2461    #[serde(skip_serializing_if = "Option::is_none")]
2462    pub suggestion: Option<String>,
2463    pub create_selector: Option<OmenaQueryCreateSelectorActionV0>,
2464}
2465
2466impl OmenaQuerySourceDiagnosticV0 {
2467    pub fn linear_provenance(&self) -> OmenaQueryLinearProvenanceV0 {
2468        summarize_omena_query_linear_provenance(self.provenance.as_slice())
2469    }
2470}
2471
2472pub(crate) fn source_diagnostic_precision(
2473    value_domain: &str,
2474    flow_sensitivity: &str,
2475    context_sensitivity: &str,
2476) -> OmenaQueryAnalysisPrecisionV0 {
2477    let precision =
2478        source_diagnostic_precision_node(value_domain, flow_sensitivity, context_sensitivity);
2479    OmenaQueryAnalysisPrecisionV0 {
2480        product: precision.product,
2481        value_domain: precision.value_domain,
2482        flow_sensitivity: precision.flow_sensitivity,
2483        context_sensitivity: precision.context_sensitivity,
2484        revision_axis: precision.revision_axis,
2485    }
2486}
2487
2488pub fn fact_precision_from_evidence_analysis_precision(
2489    precision: &EvidenceAnalysisPrecisionV0,
2490) -> omena_query_core::FactPrecision {
2491    omena_query_core::fact_precision_from_analysis_precision(&OmenaQueryAnalysisPrecisionV0 {
2492        product: precision.product.clone(),
2493        value_domain: precision.value_domain.clone(),
2494        flow_sensitivity: precision.flow_sensitivity.clone(),
2495        context_sensitivity: precision.context_sensitivity.clone(),
2496        revision_axis: precision.revision_axis.clone(),
2497    })
2498}
2499
2500pub(crate) const OMENA_QUERY_TYPE_ORACLE_UNKNOWN_VALUE_DOMAIN: &str = "unknown";
2501pub(crate) const OMENA_QUERY_TSGO_PROVIDER_UNAVAILABLE_PROVENANCE: &str =
2502    "tsgo-provider.unavailable->unknown-precision";
2503
2504pub(crate) fn apply_omena_query_checker_product_gate_to_source_diagnostics(
2505    diagnostics: &mut [OmenaQuerySourceDiagnosticV0],
2506) {
2507    for diagnostic in diagnostics {
2508        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
2509            diagnostic.code,
2510            &mut diagnostic.provenance,
2511        );
2512    }
2513}
2514
2515pub(crate) fn project_omena_query_provenance_from_evidence_graph(
2516    provenance: &[&'static str],
2517) -> Vec<&'static str> {
2518    let input_identity = provenance.first().copied().unwrap_or("emptyProvenance");
2519    project_omena_query_diagnostic_provenance_from_evidence_graph(
2520        input_identity,
2521        provenance.to_vec(),
2522    )
2523}
2524
2525fn populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
2526    product_diagnostic_code: &str,
2527    provenance: &mut Vec<&'static str>,
2528) {
2529    let gate =
2530        omena_query_checker_orchestrator::gate_omena_query_checker_product_diagnostic_code_v0(
2531            product_diagnostic_code,
2532        );
2533    if !gate.enforcement_passed {
2534        provenance.push("omena-query-checker-orchestrator.product-diagnostic-gate-failed");
2535    } else {
2536        for label in gate.provenance {
2537            if !provenance.contains(&label) {
2538                provenance.push(label);
2539            }
2540        }
2541    }
2542    *provenance = project_omena_query_diagnostic_provenance_from_evidence_graph(
2543        product_diagnostic_code,
2544        provenance.clone(),
2545    );
2546}
2547
2548fn source_diagnostic_precision_node(
2549    value_domain: &str,
2550    flow_sensitivity: &str,
2551    context_sensitivity: &str,
2552) -> EvidenceAnalysisPrecisionV0 {
2553    let precision = EvidenceAnalysisPrecisionV0::new(
2554        "omena-query.analysis-precision",
2555        value_domain,
2556        flow_sensitivity,
2557        context_sensitivity,
2558        "OmenaQuerySourceDiagnosticsForFileV0.input",
2559    );
2560    let Some(node) = project_omena_query_evidence_node(
2561        "sourceDiagnosticPrecision",
2562        value_domain,
2563        &[],
2564        Some(precision.clone()),
2565    ) else {
2566        return precision;
2567    };
2568    node.precision.unwrap_or(precision)
2569}
2570
2571fn project_omena_query_diagnostic_provenance_from_evidence_graph(
2572    input_identity: &str,
2573    provenance: Vec<&'static str>,
2574) -> Vec<&'static str> {
2575    let Some(node) = project_omena_query_evidence_node(
2576        "diagnosticProvenance",
2577        input_identity,
2578        provenance.as_slice(),
2579        None,
2580    ) else {
2581        return provenance;
2582    };
2583    node.provenance
2584        .iter()
2585        .filter_map(|label| {
2586            provenance
2587                .iter()
2588                .copied()
2589                .find(|candidate| *candidate == label.as_str())
2590        })
2591        .collect()
2592}
2593
2594fn project_omena_query_evidence_node(
2595    query_identity: &str,
2596    input_identity: &str,
2597    provenance: &[&'static str],
2598    precision: Option<EvidenceAnalysisPrecisionV0>,
2599) -> Option<omena_evidence_graph::EvidenceNodeV0> {
2600    let key = EvidenceNodeKeyV0::new(query_identity, input_identity);
2601    let Ok(graph) = build_evidence_graph_from_edges_v0(
2602        [EvidenceNodeSeedV0::with_precision(
2603            key.clone(),
2604            provenance
2605                .iter()
2606                .map(|label| (*label).to_string())
2607                .collect(),
2608            precision,
2609            GuaranteeKindV0::for_label_less_family(),
2610        )],
2611        [EvidenceDemandEdgeV0::new(
2612            query_identity,
2613            key,
2614            "diagnostic-evidence",
2615        )],
2616    ) else {
2617        return None;
2618    };
2619    graph.nodes.into_iter().next()
2620}
2621
2622#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2623#[serde(rename_all = "camelCase")]
2624pub struct OmenaQueryCreateSelectorActionV0 {
2625    pub uri: String,
2626    pub range: ParserRangeV0,
2627    pub new_text: String,
2628    pub selector_name: String,
2629}
2630
2631#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
2632#[serde(rename_all = "camelCase")]
2633pub struct OmenaQuerySourceMissingSelectorDiagnosticCandidateV0 {
2634    pub target_style_uri: String,
2635    pub target_style_source: String,
2636    pub selector_name: String,
2637    pub source_reference_range: ParserRangeV0,
2638}
2639
2640#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2641#[serde(rename_all = "camelCase")]
2642pub struct OmenaQuerySourceDiagnosticsForFileV0 {
2643    pub schema_version: &'static str,
2644    pub product: &'static str,
2645    pub file_uri: String,
2646    pub file_kind: &'static str,
2647    pub diagnostic_count: usize,
2648    pub diagnostics: Vec<OmenaQuerySourceDiagnosticV0>,
2649    pub ready_surfaces: Vec<&'static str>,
2650}
2651
2652#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
2653#[serde(rename_all = "camelCase")]
2654pub struct OmenaQuerySourceSelectorCandidateV0 {
2655    pub kind: &'static str,
2656    pub name: String,
2657    pub range: ParserRangeV0,
2658    pub source: &'static str,
2659    pub target_style_uri: Option<String>,
2660}
2661
2662#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
2663#[serde(rename_all = "camelCase")]
2664pub struct OmenaQuerySourceSelectorReferenceCandidateV0 {
2665    pub uri: String,
2666    pub kind: &'static str,
2667    pub name: String,
2668    pub range: ParserRangeV0,
2669    pub source: &'static str,
2670    pub target_style_uri: Option<String>,
2671}
2672
2673impl OmenaQuerySourceSelectorReferenceCandidateV0 {
2674    pub fn projection_surface(&self) -> OmenaQuerySourceSelectorReferenceSurfaceV0 {
2675        match self.source {
2676            "omenaTsgoTypeFactProjection" => {
2677                OmenaQuerySourceSelectorReferenceSurfaceV0::OmenaTsgoTypeFactProjection
2678            }
2679            _ => OmenaQuerySourceSelectorReferenceSurfaceV0::OmenaQuerySourceSyntaxIndex,
2680        }
2681    }
2682}
2683
2684#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2685#[serde(rename_all = "camelCase")]
2686pub struct OmenaQueryStyleSelectorDefinitionV0 {
2687    pub uri: String,
2688    pub name: String,
2689    pub range: ParserRangeV0,
2690}
2691
2692#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2693#[serde(rename_all = "camelCase")]
2694pub struct OmenaQuerySourceProviderCandidateResolutionV0 {
2695    pub schema_version: &'static str,
2696    pub product: &'static str,
2697    pub matched: Vec<OmenaQuerySourceSelectorCandidateV0>,
2698    pub unresolved: Vec<OmenaQuerySourceSelectorCandidateV0>,
2699}
2700
2701#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2702#[serde(rename_all = "camelCase")]
2703pub struct OmenaQuerySourceSelectorReferenceEditTargetV0 {
2704    pub uri: String,
2705    pub name: String,
2706    pub range: ParserRangeV0,
2707    pub target_style_uri: Option<String>,
2708}
2709
2710#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2711#[serde(rename_all = "camelCase")]
2712pub struct OmenaQuerySourceSelectorOccurrenceIndexV0 {
2713    pub schema_version: &'static str,
2714    pub product: &'static str,
2715    pub moniker_count: usize,
2716    pub occurrence_count: usize,
2717    pub workspace_index: OmenaWorkspaceOccurrenceIndexV0,
2718    pub occurrences: Vec<OmenaQuerySourceSelectorOccurrenceV0>,
2719    pub ready_surfaces: Vec<&'static str>,
2720}
2721
2722#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
2723#[serde(rename_all = "camelCase")]
2724pub struct OmenaQuerySourceSelectorOccurrenceV0 {
2725    pub moniker: String,
2726    pub uri: String,
2727    pub selector_name: String,
2728    pub range: ParserRangeV0,
2729    pub kind: OmenaWorkspaceOccurrenceKindV0,
2730    pub role: OmenaWorkspaceOccurrenceRoleV0,
2731    pub source: OmenaWorkspaceOccurrenceSurfaceV0,
2732    pub target_style_uri: Option<String>,
2733    pub rename_target: bool,
2734}
2735
2736#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2737#[serde(rename_all = "camelCase")]
2738pub struct OmenaQueryCustomPropertyOccurrenceIndexV0 {
2739    pub schema_version: &'static str,
2740    pub product: &'static str,
2741    pub occurrence_count: usize,
2742    pub occurrences: Vec<OmenaQueryCustomPropertyOccurrenceV0>,
2743    pub ready_surfaces: Vec<&'static str>,
2744}
2745
2746#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
2747#[serde(rename_all = "camelCase")]
2748pub struct OmenaQueryCustomPropertyOccurrenceV0 {
2749    pub uri: String,
2750    pub name: String,
2751    pub range: ParserRangeV0,
2752    pub byte_span: ParserByteSpanV0,
2753    pub kind: &'static str,
2754    pub has_fallback: bool,
2755    pub source: &'static str,
2756}
2757
2758#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
2759#[serde(rename_all = "camelCase")]
2760pub struct OmenaWorkspaceOccurrenceIndexV0 {
2761    pub schema_version: &'static str,
2762    pub product: &'static str,
2763    pub moniker_count: usize,
2764    pub occurrence_count: usize,
2765    pub by_moniker: BTreeMap<String, Vec<OmenaWorkspaceOccurrenceV0>>,
2766    pub by_file: BTreeMap<String, Vec<String>>,
2767    pub ready_surfaces: Vec<&'static str>,
2768}
2769
2770#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
2771#[serde(rename_all = "camelCase")]
2772pub struct OmenaWorkspaceOccurrenceV0 {
2773    pub moniker: String,
2774    pub uri: String,
2775    pub name: String,
2776    pub range: ParserRangeV0,
2777    pub kind: OmenaWorkspaceOccurrenceKindV0,
2778    pub role: OmenaWorkspaceOccurrenceRoleV0,
2779    pub surface: OmenaWorkspaceOccurrenceSurfaceV0,
2780    #[serde(skip_serializing_if = "Option::is_none")]
2781    pub family: Option<OmenaWorkspaceOccurrenceFamilyV0>,
2782    #[serde(skip_serializing_if = "Option::is_none")]
2783    pub namespace: Option<String>,
2784    #[serde(skip_serializing_if = "Option::is_none")]
2785    pub target_style_uri: Option<String>,
2786    pub rename_target: bool,
2787}
2788
2789#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
2790#[serde(rename_all = "camelCase")]
2791pub enum OmenaWorkspaceOccurrenceKindV0 {
2792    SourceSelectorReference,
2793    SourceSelectorPrefixReference,
2794    CustomPropertyDeclaration,
2795    CustomPropertyReference,
2796    SassVariableDeclaration,
2797    SassVariableReference,
2798    SassMixinDeclaration,
2799    SassMixinInclude,
2800    SassFunctionDeclaration,
2801    SassFunctionCall,
2802}
2803
2804impl OmenaWorkspaceOccurrenceKindV0 {
2805    pub fn as_str(self) -> &'static str {
2806        match self {
2807            Self::SourceSelectorReference => "sourceSelectorReference",
2808            Self::SourceSelectorPrefixReference => "sourceSelectorPrefixReference",
2809            Self::CustomPropertyDeclaration => "customPropertyDeclaration",
2810            Self::CustomPropertyReference => "customPropertyReference",
2811            Self::SassVariableDeclaration => "sassVariableDeclaration",
2812            Self::SassVariableReference => "sassVariableReference",
2813            Self::SassMixinDeclaration => "sassMixinDeclaration",
2814            Self::SassMixinInclude => "sassMixinInclude",
2815            Self::SassFunctionDeclaration => "sassFunctionDeclaration",
2816            Self::SassFunctionCall => "sassFunctionCall",
2817        }
2818    }
2819}
2820
2821#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
2822#[serde(rename_all = "camelCase")]
2823pub enum OmenaWorkspaceOccurrenceRoleV0 {
2824    Definition,
2825    Reference,
2826}
2827
2828impl OmenaWorkspaceOccurrenceRoleV0 {
2829    pub fn as_str(self) -> &'static str {
2830        match self {
2831            Self::Definition => "definition",
2832            Self::Reference => "reference",
2833        }
2834    }
2835}
2836
2837#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
2838#[serde(rename_all = "camelCase")]
2839pub enum OmenaWorkspaceOccurrenceSurfaceV0 {
2840    OmenaQuerySourceSyntaxIndex,
2841    OmenaLspStyleIndex,
2842}
2843
2844impl OmenaWorkspaceOccurrenceSurfaceV0 {
2845    pub fn as_str(self) -> &'static str {
2846        match self {
2847            Self::OmenaQuerySourceSyntaxIndex => "omenaQuerySourceSyntaxIndex",
2848            Self::OmenaLspStyleIndex => "omenaLspStyleIndex",
2849        }
2850    }
2851}
2852
2853#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
2854#[serde(rename_all = "camelCase")]
2855pub enum OmenaWorkspaceOccurrenceFamilyV0 {
2856    CssModuleSelector,
2857    CustomProperty,
2858    Variable,
2859    Mixin,
2860    Function,
2861    Symbol,
2862}
2863
2864impl OmenaWorkspaceOccurrenceFamilyV0 {
2865    pub fn as_str(self) -> &'static str {
2866        match self {
2867            Self::CssModuleSelector => "cssModuleSelector",
2868            Self::CustomProperty => "customProperty",
2869            Self::Variable => "variable",
2870            Self::Mixin => "mixin",
2871            Self::Function => "function",
2872            Self::Symbol => "symbol",
2873        }
2874    }
2875}
2876
2877#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2878#[serde(rename_all = "camelCase")]
2879pub struct OmenaQueryWorkspaceTextEditV0 {
2880    pub uri: String,
2881    pub range: ParserRangeV0,
2882    pub new_text: String,
2883}
2884
2885#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2886#[serde(rename_all = "camelCase")]
2887pub struct OmenaQuerySassModuleUseEdgeV0 {
2888    pub source: String,
2889    pub namespace_kind: &'static str,
2890    pub namespace: Option<String>,
2891}
2892
2893#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2894#[serde(rename_all = "camelCase")]
2895pub struct OmenaQuerySassModuleSourcesV0 {
2896    pub schema_version: &'static str,
2897    pub product: &'static str,
2898    pub module_use_edges: Vec<OmenaQuerySassModuleUseEdgeV0>,
2899    pub module_forward_sources: Vec<String>,
2900}
2901
2902#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
2903#[serde(rename_all = "camelCase")]
2904pub struct OmenaQueryStylePackageManifestV0 {
2905    pub package_json_path: String,
2906    pub package_json_source: String,
2907}
2908
2909#[cfg(test)]
2910mod evidence_graph_projection_tests {
2911    use super::*;
2912
2913    #[test]
2914    fn diagnostic_provenance_projection_preserves_legacy_labels() {
2915        let labels = vec![
2916            "omena-query.source-syntax-index",
2917            "omena-query.style-selector-definitions",
2918        ];
2919
2920        assert_eq!(
2921            project_omena_query_diagnostic_provenance_from_evidence_graph(
2922                "missingSelector",
2923                labels.clone(),
2924            ),
2925            labels
2926        );
2927    }
2928
2929    #[test]
2930    fn checker_product_gate_projection_matches_legacy_extension() {
2931        let code = "missingSelector";
2932        let mut expected = vec![
2933            "omena-query.source-syntax-index",
2934            "omena-query.style-selector-definitions",
2935        ];
2936        let gate =
2937            omena_query_checker_orchestrator::gate_omena_query_checker_product_diagnostic_code_v0(
2938                code,
2939            );
2940        if !gate.enforcement_passed {
2941            expected.push("omena-query-checker-orchestrator.product-diagnostic-gate-failed");
2942        } else {
2943            for label in gate.provenance {
2944                if !expected.contains(&label) {
2945                    expected.push(label);
2946                }
2947            }
2948        }
2949
2950        let mut actual = vec![
2951            "omena-query.source-syntax-index",
2952            "omena-query.style-selector-definitions",
2953        ];
2954        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(code, &mut actual);
2955
2956        assert_eq!(actual, expected);
2957    }
2958
2959    #[test]
2960    fn source_diagnostic_precision_projects_byte_identical_shape() -> Result<(), serde_json::Error>
2961    {
2962        let precision = source_diagnostic_precision(
2963            "classValueResolution",
2964            "sourceSyntaxIndex",
2965            "perSourceReference",
2966        );
2967        let serialized = serde_json::to_value(&precision)?;
2968
2969        assert_eq!(
2970            serialized,
2971            serde_json::json!({
2972                "product": "omena-query.analysis-precision",
2973                "valueDomain": "classValueResolution",
2974                "flowSensitivity": "sourceSyntaxIndex",
2975                "contextSensitivity": "perSourceReference",
2976                "revisionAxis": "OmenaQuerySourceDiagnosticsForFileV0.input"
2977            })
2978        );
2979        Ok(())
2980    }
2981}