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_sif::OmenaSifV1;
7use std::collections::BTreeMap;
8
9#[derive(Debug, Clone, PartialEq, Serialize)]
10#[serde(rename_all = "camelCase")]
11pub struct DesignSystemMinimumDescriptionV0 {
12    pub schema_version: &'static str,
13    pub product: &'static str,
14    pub layer_marker: &'static str,
15    pub feature_gate: &'static str,
16    pub model_bits: f64,
17    pub residual_bits: f64,
18    pub total_bits: f64,
19    pub unit: &'static str,
20    pub model_class: ModelClassV0,
21    pub rule_count: usize,
22    pub observation_count: usize,
23    pub canonical_form_present: bool,
24    pub cascade_proof_obligation_count: usize,
25    pub sass_namespace_partition: SassNamespaceBitsV0,
26    pub generated_at_iso: &'static str,
27    pub source_pin: SourcePinV0,
28    pub weights_calibration_pin: &'static str,
29    pub weights_version: &'static str,
30    pub semiring_instance: &'static str,
31}
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
34#[serde(rename_all = "camelCase")]
35pub enum ModelClassV0 {
36    TwoPartUniform,
37    TwoPartMultinomial,
38    Nml,
39}
40
41#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
42#[serde(rename_all = "camelCase")]
43pub struct SassNamespaceBitsV0 {
44    pub namespace_count: usize,
45    pub partition_count: usize,
46    pub deterministic_partition: bool,
47}
48
49#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
50#[serde(rename_all = "camelCase")]
51pub struct SourcePinV0 {
52    pub source_uri: String,
53    pub source_hash: String,
54}
55
56#[derive(Debug, Clone, PartialEq, Serialize)]
57#[serde(rename_all = "camelCase")]
58pub struct CanonicalFormV0 {
59    pub schema_version: &'static str,
60    pub product: &'static str,
61    pub layer_marker: &'static str,
62    pub feature_gate: &'static str,
63    pub pass_id: &'static str,
64    pub before: String,
65    pub canonical_after: String,
66    pub fallback_after: String,
67    pub canonical_matches_fallback: bool,
68    pub mdl_bits: f64,
69    pub ast_size_bits: f64,
70    pub bits_saved_vs_fallback: f64,
71    pub unit: &'static str,
72    pub iteration_count: usize,
73    pub eclass_count: usize,
74    pub enode_count: usize,
75    pub cascade_safe_witness: &'static str,
76    pub egg_analysis_witness: &'static str,
77}
78
79#[derive(Debug, Serialize)]
80#[serde(rename_all = "camelCase")]
81pub struct OmenaQueryBoundarySummaryV0 {
82    pub schema_version: &'static str,
83    pub product: &'static str,
84    pub query_engine_name: &'static str,
85    pub schema_version_policy: OmenaQuerySchemaVersionPolicyV0,
86    pub input_version: String,
87    pub abstract_value_domain: AbstractValueDomainSummaryV0,
88    pub selected_query_adapter_capabilities: SelectedQueryAdapterCapabilitiesV0,
89    pub delegated_fragment_products: Vec<&'static str>,
90    pub expression_semantics_query_count: usize,
91    pub source_resolution_query_count: usize,
92    pub selector_usage_query_count: usize,
93    pub total_query_count: usize,
94    pub ready_surfaces: Vec<&'static str>,
95    pub style_completion_consumer_decisions: Vec<OmenaQueryStyleCompletionConsumerDecisionV0>,
96    pub cme_coupled_surfaces: Vec<&'static str>,
97    pub next_decoupling_targets: Vec<&'static str>,
98}
99
100#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
101#[serde(rename_all = "camelCase")]
102pub struct OmenaQueryStyleCompletionConsumerDecisionV0 {
103    pub consumer: &'static str,
104    pub surface: &'static str,
105    pub decision: &'static str,
106    pub rationale: &'static str,
107}
108
109#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
110#[serde(rename_all = "camelCase")]
111pub struct OmenaQuerySassModuleConformanceReportV0 {
112    pub schema_version: &'static str,
113    pub product: &'static str,
114    pub claim_level: &'static str,
115    pub theorem_claimed: bool,
116    pub normative_source: &'static str,
117    pub modeled_count: usize,
118    pub gap_count: usize,
119    pub decided_out_count: usize,
120    pub policy_count: usize,
121    pub rows: Vec<OmenaQuerySassModuleConformanceRowV0>,
122    pub ready_surfaces: Vec<&'static str>,
123}
124
125#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
126#[serde(rename_all = "camelCase")]
127pub struct OmenaQuerySassModuleConformanceRowV0 {
128    pub key: &'static str,
129    pub category: &'static str,
130    pub status: &'static str,
131    pub normative_anchor: &'static str,
132    pub implementation: &'static str,
133    pub witness: &'static str,
134    pub decision: &'static str,
135}
136
137#[derive(Debug, Serialize)]
138#[serde(rename_all = "camelCase")]
139pub struct OmenaQueryEvaluationRuntimeSummaryV0 {
140    pub schema_version: &'static str,
141    pub product: &'static str,
142    pub input_version: String,
143    pub selected_query_adapter_capabilities: SelectedQueryAdapterCapabilitiesV0,
144    pub runtime_products: Vec<&'static str>,
145    pub source_resolution_expression_count: usize,
146    pub source_resolution_unresolved_expression_count: usize,
147    pub expression_domain_revision: u64,
148    pub expression_domain_graph_count: usize,
149    pub expression_domain_dirty_graph_count: usize,
150    pub expression_domain_reused_graph_count: usize,
151    pub style_document_summary_source: &'static str,
152    pub ready_surfaces: Vec<&'static str>,
153    pub retired_couplings: Vec<&'static str>,
154}
155
156#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
157#[serde(rename_all = "camelCase")]
158pub struct SelectedQueryAdapterCapabilitiesV0 {
159    pub schema_version: &'static str,
160    pub product: &'static str,
161    pub default_candidate_backend: &'static str,
162    pub schema_version_policy: OmenaQuerySchemaVersionPolicyV0,
163    pub schema_version_checks: Vec<OmenaQuerySchemaVersionCheckV0>,
164    pub backend_kinds: Vec<SelectedQueryBackendCapabilityV0>,
165    pub runner_commands: Vec<SelectedQueryRunnerCommandV0>,
166    pub expression_semantics_payload_contracts: Vec<&'static str>,
167    pub required_input_contracts: Vec<&'static str>,
168    pub adapter_readiness: Vec<&'static str>,
169    pub routing_status: &'static str,
170}
171
172#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
173#[serde(rename_all = "camelCase")]
174pub struct OmenaQuerySchemaVersionPolicyV0 {
175    pub schema_version: &'static str,
176    pub product: &'static str,
177    pub current_version: &'static str,
178    pub current_version_label: &'static str,
179    pub accepted_versions: Vec<&'static str>,
180    pub deprecated_versions: Vec<&'static str>,
181    pub rejected_version_policy: &'static str,
182    pub missing_version_policy: &'static str,
183    pub migration_policy: Vec<&'static str>,
184    pub compatibility_gate: &'static str,
185}
186
187#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
188#[serde(rename_all = "camelCase")]
189pub struct OmenaQuerySchemaVersionCheckV0 {
190    pub schema_version: &'static str,
191    pub product: &'static str,
192    pub requested_version: Option<String>,
193    pub current_version: &'static str,
194    pub accepted: bool,
195    pub status: &'static str,
196    pub migration_action: &'static str,
197    pub reason: &'static str,
198}
199
200#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
201#[serde(rename_all = "camelCase")]
202pub struct SelectedQueryBackendCapabilityV0 {
203    pub backend_kind: &'static str,
204    pub source_resolution: bool,
205    pub expression_semantics: bool,
206    pub selector_usage: bool,
207    pub style_semantic_graph: bool,
208}
209
210#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
211#[serde(rename_all = "camelCase")]
212pub struct SelectedQueryRunnerCommandV0 {
213    pub surface: &'static str,
214    pub command: &'static str,
215    pub input_contract: &'static str,
216    pub output_product: &'static str,
217}
218
219#[derive(Debug, Serialize)]
220#[serde(rename_all = "camelCase")]
221pub struct OmenaQueryStyleSemanticGraphBatchOutputV0 {
222    pub schema_version: &'static str,
223    pub product: &'static str,
224    pub cross_file_summary: OmenaQueryCrossFileSummaryV0,
225    pub css_modules_resolution: OmenaQueryCssModulesCrossFileResolutionV0,
226    pub sass_module_resolution: OmenaQuerySassModuleCrossFileResolutionV0,
227    pub graphs: Vec<OmenaQueryStyleSemanticGraphBatchEntryV0>,
228}
229
230#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
231#[serde(rename_all = "camelCase")]
232pub struct OmenaQueryCategoricalDesignSystemCrossProjectSummaryV0 {
233    pub schema_version: &'static str,
234    pub product: &'static str,
235    pub claim_scope: &'static str,
236    pub source_product: &'static str,
237    pub theory_product: &'static str,
238    pub project_count: usize,
239    pub product_path_evidence_ready: bool,
240    pub models: Vec<OmenaQueryCategoricalDesignSystemModelV0>,
241    pub invariant_summary: OmenaQueryCategoricalDesignSystemInvariantSummaryV0,
242    pub deferred_residuals: Vec<&'static str>,
243}
244
245#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
246#[serde(rename_all = "camelCase")]
247pub struct OmenaQueryM4AxisCReadinessSummaryV0 {
248    pub schema_version: &'static str,
249    pub product: &'static str,
250    pub status: &'static str,
251    pub required_edge_kind_count: usize,
252    pub required_edge_kind_counts: Vec<OmenaQueryCrossFileSummaryEdgeKindCountV0>,
253    pub workspace_edge_count: usize,
254    pub issue_63_provenance_round_trip_ready: bool,
255    pub issue_65_summary_edge_equivalence_ready: bool,
256    pub summary_hash_invalidation_ready: bool,
257    pub summary_hash_samples: OmenaQueryM4AxisCSummaryHashSamplesV0,
258    pub checked_surfaces: Vec<&'static str>,
259    pub next_priorities: Vec<&'static str>,
260}
261
262#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
263#[serde(rename_all = "camelCase")]
264pub struct OmenaQueryM4AxisCSummaryHashSamplesV0 {
265    pub baseline: String,
266    pub source_selector_change: String,
267    pub style_edge_change: String,
268    pub package_manifest_change: String,
269}
270
271#[derive(Debug, Serialize)]
272#[serde(rename_all = "camelCase")]
273pub struct OmenaQueryStyleSemanticGraphBatchEntryV0 {
274    pub style_path: String,
275    pub graph: Option<StyleSemanticGraphSummaryV0>,
276}
277
278#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
279#[serde(rename_all = "camelCase")]
280pub struct OmenaQueryCssModulesCrossFileResolutionV0 {
281    pub schema_version: &'static str,
282    pub product: &'static str,
283    pub status: &'static str,
284    pub resolution_scope: &'static str,
285    pub style_count: usize,
286    pub import_edge_count: usize,
287    pub resolved_import_edge_count: usize,
288    pub unresolved_import_edge_count: usize,
289    pub matched_name_count: usize,
290    pub edges: Vec<OmenaQueryCssModulesImportEdgeResolutionV0>,
291    pub composes_closure_edge_count: usize,
292    pub value_closure_edge_count: usize,
293    pub icss_closure_edge_count: usize,
294    pub composes_cycle_count: usize,
295    pub value_cycle_count: usize,
296    pub icss_cycle_count: usize,
297    pub composes_closure_edges: Vec<OmenaQueryCssModulesComposesClosureEdgeV0>,
298    pub value_closure_edges: Vec<OmenaQueryCssModulesValueClosureEdgeV0>,
299    pub icss_closure_edges: Vec<OmenaQueryCssModulesIcssClosureEdgeV0>,
300    pub cycles: Vec<OmenaQueryCssModulesCycleV0>,
301    pub capabilities: OmenaQueryCssModulesCrossFileResolutionCapabilitiesV0,
302    pub next_priorities: Vec<&'static str>,
303}
304
305#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
306#[serde(rename_all = "camelCase")]
307pub struct OmenaQueryCssModulesImportEdgeResolutionV0 {
308    pub from_style_path: String,
309    pub import_kind: &'static str,
310    pub source: String,
311    pub resolved_style_path: Option<String>,
312    pub status: &'static str,
313    pub import_graph_distance: Option<usize>,
314    pub import_graph_order: Option<usize>,
315    pub imported_names: Vec<String>,
316    pub exported_names: Vec<String>,
317    pub matched_names: Vec<String>,
318}
319
320#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
321#[serde(rename_all = "camelCase")]
322pub struct OmenaQueryCssModulesComposesClosureEdgeV0 {
323    pub from_style_path: String,
324    pub owner_selector_name: String,
325    pub target_style_path: String,
326    pub target_selector_name: String,
327    pub depth: usize,
328    pub path: Vec<String>,
329}
330
331#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
332#[serde(rename_all = "camelCase")]
333pub struct OmenaQueryCssModulesValueClosureEdgeV0 {
334    pub from_style_path: String,
335    pub value_name: String,
336    pub target_style_path: String,
337    pub target_value_name: String,
338    pub depth: usize,
339    pub path: Vec<String>,
340}
341
342#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
343#[serde(rename_all = "camelCase")]
344pub struct OmenaQueryCssModulesIcssClosureEdgeV0 {
345    pub from_style_path: String,
346    pub name: String,
347    pub target_style_path: String,
348    pub target_name: String,
349    pub depth: usize,
350    pub path: Vec<String>,
351}
352
353#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
354#[serde(rename_all = "camelCase")]
355pub struct OmenaQueryCssModulesCycleV0 {
356    pub kind: &'static str,
357    pub path: Vec<String>,
358}
359
360#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
361#[serde(rename_all = "camelCase")]
362pub struct OmenaQueryCssModulesCrossFileResolutionCapabilitiesV0 {
363    pub semantic_layer_owned: bool,
364    pub import_source_resolution_ready: bool,
365    pub cross_file_resolution_ready: bool,
366    pub composes_closure_ready: bool,
367    pub composes_name_match_ready: bool,
368    pub value_name_match_ready: bool,
369    pub icss_name_match_ready: bool,
370    pub transitive_closure_ready: bool,
371    pub value_graph_closure_ready: bool,
372    pub icss_export_import_closure_ready: bool,
373    pub cycle_detection_ready: bool,
374}
375
376#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
377#[serde(rename_all = "camelCase")]
378pub struct OmenaQuerySassModuleCrossFileResolutionV0 {
379    pub schema_version: &'static str,
380    pub product: &'static str,
381    pub status: &'static str,
382    pub resolution_scope: &'static str,
383    pub style_count: usize,
384    pub module_edge_count: usize,
385    pub resolved_module_edge_count: usize,
386    pub unresolved_module_edge_count: usize,
387    pub external_module_edge_count: usize,
388    pub symlink_chain_edge_count: usize,
389    pub symlink_chain_link_count: usize,
390    pub configured_module_instance_count: usize,
391    pub edges: Vec<OmenaQuerySassModuleEdgeResolutionV0>,
392    pub graph_closure_edge_count: usize,
393    pub cycle_count: usize,
394    pub visibility_filter_count: usize,
395    pub graph_closure_edges: Vec<OmenaQuerySassModuleGraphClosureEdgeV0>,
396    pub cycles: Vec<OmenaQuerySassModuleCycleV0>,
397    pub capabilities: OmenaQuerySassModuleCrossFileResolutionCapabilitiesV0,
398    pub next_priorities: Vec<&'static str>,
399}
400
401#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
402#[serde(rename_all = "camelCase")]
403pub struct OmenaQuerySassModuleEdgeResolutionV0 {
404    pub from_style_path: String,
405    pub edge_kind: &'static str,
406    pub source: String,
407    pub rule_ordinal: usize,
408    pub namespace_kind: Option<&'static str>,
409    pub namespace: Option<String>,
410    pub forward_prefix: Option<String>,
411    pub visibility_filter_kind: Option<&'static str>,
412    pub visibility_filter_names: Vec<String>,
413    pub resolved_style_path: Option<String>,
414    pub status: &'static str,
415    pub resolution_kind: &'static str,
416    pub candidate_count: usize,
417    pub symlink_chain_link_count: usize,
418    pub symlink_chain_links: Vec<OmenaQuerySymlinkChainLinkV0>,
419    pub configuration_signature: String,
420    pub configuration_variable_count: usize,
421    pub invalid_configuration_variable_names: Vec<String>,
422    pub module_instance_identity_key: Option<String>,
423}
424
425#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
426#[serde(rename_all = "camelCase")]
427pub struct OmenaQuerySymlinkChainLinkV0 {
428    pub link_path: String,
429    pub target_path: String,
430    pub target_was_absolute: bool,
431}
432
433#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
434#[serde(rename_all = "camelCase")]
435pub struct OmenaQuerySassModuleGraphClosureEdgeV0 {
436    pub from_style_path: String,
437    pub target_style_path: String,
438    pub edge_kind: &'static str,
439    pub depth: usize,
440    pub path: Vec<String>,
441    pub namespace_kind: Option<&'static str>,
442    pub namespace: Option<String>,
443    pub forward_prefix: Option<String>,
444    pub visibility_filter_kind: Option<&'static str>,
445    pub visibility_filter_names: Vec<String>,
446    pub configuration_signature: String,
447    pub configuration_variable_count: usize,
448    pub invalid_configuration_variable_names: Vec<String>,
449    pub module_instance_identity_key: Option<String>,
450}
451
452#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
453#[serde(rename_all = "camelCase")]
454pub struct OmenaQuerySassModuleCycleV0 {
455    pub path: Vec<String>,
456}
457
458#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
459#[serde(rename_all = "camelCase")]
460pub struct OmenaQuerySassModuleCrossFileResolutionCapabilitiesV0 {
461    pub omena_parser_module_edge_consumption_ready: bool,
462    pub resolver_backed_source_resolution_ready: bool,
463    pub package_manifest_resolution_ready: bool,
464    pub external_module_filtering_ready: bool,
465    pub graph_closure_ready: bool,
466    pub cycle_detection_ready: bool,
467    pub namespace_show_hide_filter_ready: bool,
468    pub configured_module_instance_identity_ready: bool,
469    pub symlink_chain_metadata_ready: bool,
470}
471
472#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
473#[serde(rename_all = "camelCase")]
474pub struct OmenaQueryStyleDocumentSummaryV0 {
475    pub schema_version: &'static str,
476    pub product: &'static str,
477    pub language: &'static str,
478    pub selector_names: Vec<String>,
479    pub custom_property_decl_names: Vec<String>,
480    pub custom_property_ref_names: Vec<String>,
481    pub sass_module_use_sources: Vec<String>,
482    pub sass_module_forward_sources: Vec<String>,
483    pub diagnostic_count: usize,
484}
485
486#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
487#[serde(rename_all = "camelCase")]
488pub struct FastFactsV0 {
489    pub schema_version: &'static str,
490    pub product: &'static str,
491    pub tier: &'static str,
492    pub style_path: String,
493    pub language: &'static str,
494    pub selector_count: usize,
495    pub custom_property_count: usize,
496    pub sass_symbol_count: usize,
497    pub module_edge_count: usize,
498    pub parser_error_count: usize,
499}
500
501#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
502#[serde(rename_all = "camelCase")]
503pub struct AnalyzedGraphV0 {
504    pub schema_version: &'static str,
505    pub product: &'static str,
506    pub tier: &'static str,
507    pub style_path: String,
508    pub fast_facts: FastFactsV0,
509    pub graph_kinds: Vec<&'static str>,
510    pub node_count: usize,
511    pub edge_count: usize,
512    pub cycle_count: usize,
513}
514
515#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
516#[serde(rename_all = "camelCase")]
517pub struct StyleEditDistanceSummaryV0 {
518    pub schema_version: &'static str,
519    pub product: &'static str,
520    pub tier: &'static str,
521    pub metric_kind: &'static str,
522    pub claim_level: &'static str,
523    pub public_safety_claim_ready: bool,
524    pub left_style_path: String,
525    pub right_style_path: String,
526    pub left_fast_facts: FastFactsV0,
527    pub right_fast_facts: FastFactsV0,
528    pub left_analyzed_graph: AnalyzedGraphV0,
529    pub right_analyzed_graph: AnalyzedGraphV0,
530    pub selector_delta: usize,
531    pub custom_property_delta: usize,
532    pub sass_symbol_delta: usize,
533    pub module_edge_delta: usize,
534    pub parser_error_delta: usize,
535    pub graph_node_delta: usize,
536    pub graph_edge_delta: usize,
537    pub graph_cycle_delta: usize,
538    pub total_distance: usize,
539}
540
541#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
542#[serde(rename_all = "camelCase")]
543pub struct StyleEditDistanceCascadeMarginBridgeV0 {
544    pub schema_version: &'static str,
545    pub product: &'static str,
546    pub bridge_kind: &'static str,
547    pub claim_level: &'static str,
548    pub theorem_claimed: bool,
549    pub public_safety_claim_ready: bool,
550    pub metric_product: &'static str,
551    pub metric_kind: &'static str,
552    pub margin_product: &'static str,
553    pub margin_kind: &'static str,
554    pub dominant_axis: &'static str,
555    pub edit_distance_total: usize,
556    pub cascade_margin_signed_distance: i64,
557    pub cascade_margin_abs_distance: u64,
558    pub lipschitz_constant_name: &'static str,
559    pub lipschitz_constant: Option<u64>,
560    pub lipschitz_bound: Option<u64>,
561    pub checked: bool,
562    pub calibration_stage: &'static str,
563    pub incremental_priority_input: IncrementalEditDistancePriorityInputV0,
564}
565
566#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
567#[serde(rename_all = "camelCase")]
568pub struct OmenaQueryCascadeConfidenceV0 {
569    pub schema_version: &'static str,
570    pub product: &'static str,
571    pub feature_gate: &'static str,
572    pub confidence_kind: &'static str,
573    pub claim_level: &'static str,
574    pub theorem_claimed: bool,
575    pub public_safety_claim_ready: bool,
576    pub calibration_stage: &'static str,
577    pub margin_product: &'static str,
578    pub margin_kind: &'static str,
579    pub dominant_axis: &'static str,
580    pub dominant_axis_weight_basis_points: u16,
581    pub sigmoid_temperature_basis_points: u16,
582    pub signed_distance: i64,
583    pub abs_distance: u64,
584    pub confidence_score_basis_points: u16,
585    pub confidence_bucket: &'static str,
586    pub winner_declaration_id: String,
587    pub challenger_declaration_id: Option<String>,
588}
589
590#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
591#[serde(rename_all = "camelCase")]
592pub struct OmenaQueryCustomPropertyAnnotationSummaryV0 {
593    pub schema_version: &'static str,
594    pub product: &'static str,
595    pub style_path: String,
596    pub annotation_count: usize,
597    pub annotations: Vec<OmenaQueryCustomPropertyAnnotationV0>,
598}
599
600#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
601#[serde(rename_all = "camelCase")]
602pub struct OmenaQueryCustomPropertyAnnotationV0 {
603    pub name: String,
604    pub declaration_count: usize,
605    pub reference_count: usize,
606    pub annotation_kind: &'static str,
607    pub participates_in_fixed_point: bool,
608}
609
610#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
611#[serde(rename_all = "camelCase")]
612pub struct OmenaQueryStyleContextIndexV0 {
613    pub schema_version: &'static str,
614    pub product: &'static str,
615    pub style_path: String,
616    pub language: &'static str,
617    pub context_index_source: &'static str,
618    pub context_index: StyleContextIndexV0,
619}
620
621#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
622#[serde(rename_all = "camelCase")]
623pub struct OmenaQueryConsumerCheckSummaryV0 {
624    pub schema_version: &'static str,
625    pub product: &'static str,
626    pub style_path: String,
627    pub dialect: &'static str,
628    pub token_count: usize,
629    pub parser_error_count: usize,
630    pub class_selector_count: usize,
631    pub custom_property_count: usize,
632    pub keyframe_count: usize,
633    pub ready_surfaces: Vec<&'static str>,
634}
635
636#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
637#[serde(rename_all = "camelCase")]
638pub struct OmenaQueryConsumerBuildSummaryV0 {
639    pub schema_version: &'static str,
640    pub product: &'static str,
641    pub style_path: String,
642    pub dialect: &'static str,
643    pub requested_pass_ids: Vec<String>,
644    pub effective_pass_ids: Vec<String>,
645    pub target_query: Option<OmenaQueryTransformTargetQueryPlanV0>,
646    pub unknown_pass_ids: Vec<String>,
647    pub execution: TransformExecutionSummaryV0,
648    pub semantic_removal_count: usize,
649    #[serde(skip_serializing_if = "Option::is_none")]
650    pub bundle: Option<TransformBundleSourceSummaryV0>,
651    #[serde(skip_serializing_if = "Option::is_none")]
652    pub bundle_emission_path: Option<OmenaQueryBundleEmissionPathV0>,
653    #[serde(skip_serializing_if = "Option::is_none")]
654    pub source_map_v3: Option<OmenaQueryTransformSourceMapV3V0>,
655    #[serde(skip_serializing_if = "Option::is_none")]
656    pub open_world_snapshot: Option<OmenaQueryOpenWorldSnapshotV0>,
657    pub ready_surfaces: Vec<&'static str>,
658}
659
660#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
661#[serde(rename_all = "camelCase")]
662pub enum OmenaQueryBuildVerificationProfileV0 {
663    #[default]
664    Descriptive,
665    Strict,
666}
667
668#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
669#[serde(rename_all = "camelCase")]
670pub enum OmenaQueryBundleEmissionPathV0 {
671    #[default]
672    ImportInlineLegacy,
673    LinkedOrder,
674}
675
676impl OmenaQueryBundleEmissionPathV0 {
677    pub const fn as_wire_label(self) -> &'static str {
678        match self {
679            Self::ImportInlineLegacy => "importInlineLegacy",
680            Self::LinkedOrder => "linkedOrder",
681        }
682    }
683}
684
685#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize)]
686#[serde(rename_all = "camelCase")]
687pub struct OmenaQueryBuildAdmissionRequirementsV0 {
688    pub refuse_unknown_pass_ids: bool,
689    pub require_closed_world_evidence: bool,
690    pub require_complete_decisions: bool,
691}
692
693impl OmenaQueryBuildAdmissionRequirementsV0 {
694    pub const fn strict() -> Self {
695        Self {
696            refuse_unknown_pass_ids: true,
697            require_closed_world_evidence: true,
698            require_complete_decisions: true,
699        }
700    }
701}
702
703#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)]
704#[serde(default, rename_all = "camelCase")]
705pub struct OmenaQueryConsumerBuildOptionsV0 {
706    pub verification_profile: OmenaQueryBuildVerificationProfileV0,
707    pub bundle_emission_path: OmenaQueryBundleEmissionPathV0,
708}
709
710#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
711#[serde(rename_all = "camelCase", tag = "kind")]
712pub enum OmenaQueryClosedWorldBlockerV0 {
713    EmptyEntrypoints,
714    MissingEntrypoint {
715        source_path: String,
716    },
717    AmbiguousModulePath {
718        source_path: String,
719    },
720    MissingDependency {
721        source_path: String,
722        import_source: String,
723    },
724    MissingModuleInstance {
725        module: omena_parser::ModuleInstanceKeyV0,
726    },
727    MissingModuleDependency {
728        module: omena_parser::ModuleInstanceKeyV0,
729        dependency: omena_parser::ModuleInstanceKeyV0,
730    },
731    ClosedWorldPassUnavailable {
732        requested_pass_ids: Vec<String>,
733    },
734}
735
736#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
737#[serde(rename_all = "camelCase", tag = "status")]
738pub enum OmenaQueryClosedWorldOutcomeV0 {
739    Closed {
740        bundle: Box<omena_parser::ClosedWorldBundleV0>,
741    },
742    Open {
743        blockers: Vec<OmenaQueryClosedWorldBlockerV0>,
744    },
745}
746
747impl OmenaQueryClosedWorldOutcomeV0 {
748    pub fn bundle(&self) -> Option<&omena_parser::ClosedWorldBundleV0> {
749        match self {
750            Self::Closed { bundle } => Some(bundle.as_ref()),
751            Self::Open { .. } => None,
752        }
753    }
754
755    pub fn blockers(&self) -> &[OmenaQueryClosedWorldBlockerV0] {
756        match self {
757            Self::Closed { .. } => &[],
758            Self::Open { blockers } => blockers,
759        }
760    }
761
762    pub fn is_open(&self) -> bool {
763        matches!(self, Self::Open { .. })
764    }
765}
766
767#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
768#[serde(rename_all = "camelCase")]
769pub struct OmenaQueryBundleArtifactV0 {
770    pub schema_version: &'static str,
771    pub product: &'static str,
772    pub style_path: String,
773    pub emission_path: OmenaQueryBundleEmissionPathV0,
774    pub output_css: String,
775    pub bundle: TransformBundleSourceSummaryV0,
776    pub source_map_v3: OmenaQueryTransformSourceMapV3V0,
777    pub code_split_outputs: Vec<OmenaQueryBundleCodeSplitWorkspacePlanOutputV0>,
778    pub asset_rewrites: Vec<TransformBundleAssetUrlRewriteSummaryV0>,
779    pub per_pass_provenance: Vec<TransformPassExecutionOutcomeV0>,
780    pub execution: TransformExecutionSummaryV0,
781    pub ready_surfaces: Vec<&'static str>,
782}
783
784#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
785#[serde(rename_all = "camelCase")]
786pub struct OmenaQueryBundleResultV0 {
787    pub artifact: OmenaQueryBundleArtifactV0,
788    pub closed_world_outcome: OmenaQueryClosedWorldOutcomeV0,
789    pub closed_world_decision_parity: OmenaQueryClosedWorldDecisionParityV0,
790}
791
792#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
793#[serde(rename_all = "camelCase")]
794pub struct OmenaQueryClosedWorldDecisionParityV0 {
795    pub legacy_open_decision: bool,
796    pub typed_outcome_open: bool,
797    pub equivalent: bool,
798}
799
800#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
801#[serde(rename_all = "camelCase")]
802pub struct OmenaQueryBundleEvidenceGateV0 {
803    pub name: &'static str,
804    pub passed: bool,
805}
806
807#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
808#[serde(rename_all = "camelCase")]
809pub struct OmenaQueryBundleReachabilityEvidenceV0 {
810    pub guarantee: GuaranteeKindV0,
811    pub interpretation: &'static str,
812    pub module_instances: Vec<omena_parser::ModuleInstanceKeyV0>,
813    pub closure_hash: String,
814}
815
816#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
817#[serde(rename_all = "camelCase")]
818pub struct OmenaQueryBundleEvidenceManifestV0 {
819    pub schema_version: &'static str,
820    pub product: &'static str,
821    pub style_path: String,
822    pub outcome_status: &'static str,
823    pub reachability: Option<OmenaQueryBundleReachabilityEvidenceV0>,
824    pub gates: Vec<OmenaQueryBundleEvidenceGateV0>,
825    pub blockers: Vec<OmenaQueryClosedWorldBlockerV0>,
826    pub interface_hashes: Vec<omena_parser::ClosedWorldInterfaceHashEntryV0>,
827    pub source_precision: Option<omena_parser::ClosedWorldSourcePrecisionSummaryV0>,
828}
829
830#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
831#[serde(rename_all = "camelCase")]
832pub struct OmenaQueryBundleWithEvidenceV0 {
833    #[serde(flatten)]
834    pub artifact: OmenaQueryBundleArtifactV0,
835    pub closed_world_outcome: OmenaQueryClosedWorldOutcomeV0,
836    pub closed_world_decision_parity: OmenaQueryClosedWorldDecisionParityV0,
837    pub evidence: OmenaQueryBundleEvidenceManifestV0,
838}
839
840#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
841#[serde(rename_all = "camelCase")]
842pub struct OmenaQueryBundleCodeSplitWorkspacePlanV0 {
843    pub schema_version: &'static str,
844    pub product: &'static str,
845    pub primary_entry_style_path: String,
846    pub configured_entry_count: usize,
847    pub output_count: usize,
848    pub shared_boundary_count: usize,
849    pub outputs: Vec<OmenaQueryBundleCodeSplitWorkspacePlanOutputV0>,
850    pub ready_surfaces: Vec<&'static str>,
851}
852
853#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
854#[serde(rename_all = "camelCase")]
855pub struct OmenaQueryBundleCodeSplitWorkspacePlanOutputV0 {
856    pub source_path: String,
857    pub is_entry: bool,
858    pub split_boundary: &'static str,
859    pub reachable_from_entries: Vec<String>,
860}
861
862#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
863#[serde(rename_all = "camelCase")]
864pub struct OmenaQueryTransformPassSummaryV0 {
865    pub id: &'static str,
866    pub title: &'static str,
867    pub reads_semantic_graph: bool,
868    pub reads_cascade_model: bool,
869    pub explicit_opt_in_required: bool,
870    pub dialect_restriction: Option<&'static str>,
871    pub spec_snapshot: Option<&'static str>,
872    pub opt_in_policy: Option<&'static str>,
873}
874
875#[derive(Debug, Clone, PartialEq, Serialize)]
876#[serde(rename_all = "camelCase")]
877pub struct OmenaQueryTransformPlanSummaryV0 {
878    pub schema_version: &'static str,
879    pub product: &'static str,
880    pub style_path: String,
881    pub dialect: &'static str,
882    pub bundle: TransformBundleSourceSummaryV0,
883    pub target: TransformTargetPlanV0,
884    pub target_query: Option<OmenaQueryTransformTargetQueryPlanV0>,
885    pub egg: TransformEggPlanV0,
886    pub egg_witnesses: Vec<EggRewriteSourceWitnessV0>,
887    pub custom_property_fixed_point: OmenaQueryCustomPropertyLeastFixedPointSummaryV0,
888    pub print: TransformPrintArtifactV0,
889    pub execution: TransformExecutionSummaryV0,
890    pub semantic_removal_count: usize,
891    pub combined_plan: TransformPassPlanV0,
892    pub combined_pass_ids: Vec<&'static str>,
893    pub combined_violated_dag_edge_count: usize,
894    pub ready_surfaces: Vec<&'static str>,
895}
896
897#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
898#[serde(rename_all = "camelCase")]
899pub struct OmenaQueryTransformExecuteSummaryV0 {
900    pub schema_version: &'static str,
901    pub product: &'static str,
902    pub style_path: String,
903    pub requested_pass_ids: Vec<String>,
904    pub unknown_pass_ids: Vec<String>,
905    pub execution: TransformExecutionSummaryV0,
906    pub semantic_removal_count: usize,
907    #[serde(skip_serializing_if = "Option::is_none")]
908    pub open_world_snapshot: Option<OmenaQueryOpenWorldSnapshotV0>,
909    pub ready_surfaces: Vec<&'static str>,
910}
911
912#[cfg(feature = "lawvere-trace")]
913#[derive(Debug, Clone, PartialEq, Serialize)]
914#[serde(rename_all = "camelCase")]
915pub struct OmenaQueryLawvereTransformExecuteSummaryV0 {
916    pub schema_version: &'static str,
917    pub product: &'static str,
918    pub product_scope: &'static str,
919    pub default_product_mechanism: bool,
920    pub global_transform_theorem_claimed: bool,
921    pub execution: OmenaQueryTransformExecuteSummaryV0,
922    pub lawvere_trace: OmenaQueryLawvereModelTraceV0,
923    pub parallel_plan: OmenaQueryLawvereTransformPassParallelPlanV0,
924    pub reorderability_certificates: Vec<OmenaQueryLawvereReorderabilityCertificateV0>,
925    pub differential_witnesses: Vec<OmenaQueryLawvereDifferentialCommutativityWitnessV0>,
926    pub ready_surfaces: Vec<&'static str>,
927}
928
929#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
930#[serde(rename_all = "camelCase")]
931pub struct OmenaQueryTransformContextFromSourcesSummaryV0 {
932    pub schema_version: &'static str,
933    pub product: &'static str,
934    pub target_style_path: String,
935    pub style_count: usize,
936    pub context: TransformExecutionContextV0,
937    pub import_inline_count: usize,
938    pub class_name_rewrite_count: usize,
939    pub css_module_composes_resolution_count: usize,
940    pub css_module_value_resolution_count: usize,
941    pub design_token_route_count: usize,
942    pub reachable_class_name_count: usize,
943    pub reachable_keyframe_name_count: usize,
944    pub reachable_value_name_count: usize,
945    pub reachable_custom_property_name_count: usize,
946    pub ready_surfaces: Vec<&'static str>,
947}
948
949#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
950#[serde(rename_all = "camelCase")]
951pub struct OmenaQueryTransformContextFromEngineInputSummaryV0 {
952    pub schema_version: &'static str,
953    pub product: &'static str,
954    pub input_version: String,
955    pub target_style_path: String,
956    pub closed_world_requested: bool,
957    pub style_source_count: usize,
958    pub projection_count: usize,
959    pub selected_projection_count: usize,
960    pub import_inline_count: usize,
961    pub class_name_rewrite_count: usize,
962    pub css_module_composes_resolution_count: usize,
963    pub css_module_value_resolution_count: usize,
964    pub design_token_route_count: usize,
965    pub reachable_class_name_count: usize,
966    pub reachable_keyframe_name_count: usize,
967    pub reachable_value_name_count: usize,
968    pub reachable_custom_property_name_count: usize,
969    pub reachability_sources: Vec<OmenaQuerySemanticReachabilitySourceV0>,
970    pub context: TransformExecutionContextV0,
971    pub ready_surfaces: Vec<&'static str>,
972}
973
974#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
975#[serde(rename_all = "camelCase")]
976pub struct OmenaQuerySemanticReachabilitySourceV0 {
977    pub graph_id: String,
978    pub file_path: String,
979    pub node_id: String,
980    pub target_style_paths: Vec<String>,
981    pub value_kind: &'static str,
982    #[serde(skip_serializing_if = "Option::is_none")]
983    pub reduced_product: Option<ReducedClassValueProductV0>,
984    pub selector_names: Vec<String>,
985    pub certainty: SelectorProjectionCertaintyV0,
986}
987
988#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
989#[serde(rename_all = "camelCase")]
990pub struct OmenaQueryStyleSourceInputV0 {
991    pub style_path: String,
992    pub style_source: String,
993}
994
995#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
996#[serde(rename_all = "camelCase")]
997pub struct OmenaQueryExternalSifInputV0 {
998    pub canonical_url: String,
999    pub sif: OmenaSifV1,
1000}
1001
1002#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
1003#[serde(rename_all = "camelCase")]
1004pub struct OmenaQuerySourceDocumentInputV0 {
1005    pub source_path: String,
1006    pub source_source: String,
1007    /// Precomputed source syntax facts from the LSP workspace/source index. When
1008    /// present, query consumers can avoid reparsing source text while preserving
1009    /// the existing text-backed fallback for non-indexed callers.
1010    #[serde(default, skip_deserializing, skip_serializing_if = "Option::is_none")]
1011    pub source_syntax_index: Option<OmenaQuerySourceSyntaxIndexV0>,
1012    #[serde(default)]
1013    pub has_unresolved_style_import: bool,
1014}
1015
1016#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1017#[serde(rename_all = "camelCase")]
1018pub struct OmenaQueryOmenaParserStyleFactsV0 {
1019    pub schema_version: &'static str,
1020    pub product: &'static str,
1021    pub dialect: &'static str,
1022    pub class_selector_names: Vec<String>,
1023    pub id_selector_names: Vec<String>,
1024    pub placeholder_selector_names: Vec<String>,
1025    pub keyframe_names: Vec<String>,
1026    pub animation_reference_names: Vec<String>,
1027    pub css_module_value_definition_names: Vec<String>,
1028    pub css_module_value_reference_names: Vec<String>,
1029    pub css_module_value_import_sources: Vec<String>,
1030    pub css_module_value_import_edges: Vec<OmenaQueryCssModuleValueImportEdgeFactV0>,
1031    pub css_module_value_definition_edges: Vec<OmenaQueryCssModuleValueDefinitionEdgeFactV0>,
1032    pub css_module_composes_target_names: Vec<String>,
1033    pub css_module_composes_import_sources: Vec<String>,
1034    pub css_module_composes_edges: Vec<OmenaQueryCssModuleComposesEdgeFactV0>,
1035    pub icss_export_names: Vec<String>,
1036    pub icss_import_local_names: Vec<String>,
1037    pub icss_import_remote_names: Vec<String>,
1038    pub icss_import_sources: Vec<String>,
1039    pub icss_import_edges: Vec<OmenaQueryIcssImportEdgeFactV0>,
1040    pub icss_export_edges: Vec<OmenaQueryIcssExportEdgeFactV0>,
1041    pub variable_names: Vec<String>,
1042    pub sass_symbol_declaration_names: Vec<String>,
1043    pub sass_symbol_reference_names: Vec<String>,
1044    pub sass_symbol_facts: Vec<OmenaQuerySassSymbolFactV0>,
1045    pub sass_symbol_resolution: OmenaQuerySassSymbolResolutionV0,
1046    pub sass_module_use_sources: Vec<String>,
1047    pub sass_module_forward_sources: Vec<String>,
1048    pub sass_module_import_sources: Vec<String>,
1049    pub sass_module_edges: Vec<OmenaQuerySassModuleEdgeFactV0>,
1050    pub custom_property_names: Vec<String>,
1051    pub custom_property_decl_names: Vec<String>,
1052    pub custom_property_ref_names: Vec<String>,
1053    pub at_rule_names: Vec<String>,
1054    pub parser_error_count: usize,
1055}
1056
1057#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1058#[serde(rename_all = "camelCase")]
1059pub struct OmenaQuerySassSymbolFactV0 {
1060    pub kind: &'static str,
1061    pub symbol_kind: &'static str,
1062    pub name: String,
1063    pub role: &'static str,
1064    pub namespace: Option<String>,
1065}
1066
1067#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1068#[serde(rename_all = "camelCase")]
1069pub struct OmenaQuerySassSymbolResolutionV0 {
1070    pub schema_version: &'static str,
1071    pub product: &'static str,
1072    pub resolution_scope: &'static str,
1073    pub declaration_count: usize,
1074    pub reference_count: usize,
1075    pub resolved_reference_count: usize,
1076    pub unresolved_reference_count: usize,
1077    pub edges: Vec<OmenaQuerySassSymbolResolutionEdgeV0>,
1078    pub capabilities: OmenaQuerySassSymbolResolutionCapabilitiesV0,
1079}
1080
1081#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1082#[serde(rename_all = "camelCase")]
1083pub struct OmenaQuerySassSymbolResolutionEdgeV0 {
1084    pub symbol_kind: &'static str,
1085    pub name: String,
1086    pub namespace: Option<String>,
1087    pub reference_kind: &'static str,
1088    pub reference_role: &'static str,
1089    pub reference_source_order: usize,
1090    pub declaration_kind: Option<&'static str>,
1091    pub declaration_source_order: Option<usize>,
1092    pub status: &'static str,
1093}
1094
1095#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1096#[serde(rename_all = "camelCase")]
1097pub struct OmenaQuerySassSymbolResolutionCapabilitiesV0 {
1098    pub same_file_lexical_resolution_ready: bool,
1099    pub declaration_before_reference_ready: bool,
1100    pub unresolved_reference_reporting_ready: bool,
1101    pub cross_file_module_resolution_ready: bool,
1102}
1103
1104#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1105#[serde(rename_all = "camelCase")]
1106pub struct OmenaQuerySassModuleEdgeFactV0 {
1107    pub kind: &'static str,
1108    pub source: String,
1109    pub namespace_kind: Option<&'static str>,
1110    pub namespace: Option<String>,
1111    pub forward_prefix: Option<String>,
1112    pub visibility_filter_kind: Option<&'static str>,
1113    pub visibility_filter_names: Vec<String>,
1114}
1115
1116#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1117#[serde(rename_all = "camelCase")]
1118pub struct OmenaQuerySassModuleSourceEdgeV0 {
1119    pub kind: &'static str,
1120    pub source: String,
1121    pub byte_span: ParserByteSpanV0,
1122    pub namespace_kind: Option<&'static str>,
1123    pub namespace: Option<String>,
1124    pub forward_prefix: Option<String>,
1125    pub visibility_filter_kind: Option<&'static str>,
1126    pub visibility_filter_names: Vec<String>,
1127    pub media_qualified: bool,
1128}
1129
1130#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1131#[serde(rename_all = "camelCase")]
1132pub struct OmenaQueryCssModuleValueImportEdgeFactV0 {
1133    pub remote_name: String,
1134    pub local_name: String,
1135    pub import_source: String,
1136}
1137
1138#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1139#[serde(rename_all = "camelCase")]
1140pub struct OmenaQueryCssModuleValueDefinitionEdgeFactV0 {
1141    pub definition_name: String,
1142    pub reference_names: Vec<String>,
1143}
1144
1145#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1146#[serde(rename_all = "camelCase")]
1147pub struct OmenaQueryCssModuleComposesEdgeFactV0 {
1148    pub kind: &'static str,
1149    pub owner_selector_names: Vec<String>,
1150    pub target_names: Vec<String>,
1151    pub import_source: Option<String>,
1152}
1153
1154#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1155#[serde(rename_all = "camelCase")]
1156pub struct OmenaQueryIcssImportEdgeFactV0 {
1157    pub local_name: String,
1158    pub remote_name: String,
1159    pub import_source: String,
1160}
1161
1162#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1163#[serde(rename_all = "camelCase")]
1164pub struct OmenaQueryIcssExportEdgeFactV0 {
1165    pub export_name: String,
1166    pub reference_names: Vec<String>,
1167}
1168
1169#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
1170#[serde(rename_all = "camelCase")]
1171pub struct OmenaQueryStyleHoverCandidateV0 {
1172    pub kind: &'static str,
1173    pub name: String,
1174    pub range: ParserRangeV0,
1175    pub source: &'static str,
1176    pub namespace: Option<String>,
1177}
1178
1179#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1180#[serde(rename_all = "camelCase")]
1181pub struct OmenaQueryStyleHoverCandidatesV0 {
1182    pub schema_version: &'static str,
1183    pub product: &'static str,
1184    pub language: &'static str,
1185    pub candidates: Vec<OmenaQueryStyleHoverCandidateV0>,
1186}
1187
1188#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1189#[serde(rename_all = "camelCase")]
1190pub struct OmenaQueryStyleHoverRenderPartsV0 {
1191    pub schema_version: &'static str,
1192    pub product: &'static str,
1193    pub snippet: String,
1194    pub value: Option<String>,
1195    pub signature: Option<String>,
1196    #[serde(skip_serializing_if = "Vec::is_empty")]
1197    pub property_value_narrowings: Vec<AbstractPropertyValueNarrowingV0>,
1198    pub render_source: &'static str,
1199}
1200
1201#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1202#[serde(rename_all = "camelCase")]
1203pub struct OmenaQueryCascadeNarrowingEvidenceV0 {
1204    pub schema_version: &'static str,
1205    pub product: &'static str,
1206    pub selector: String,
1207    pub selector_class_names: Vec<String>,
1208    pub property_name: String,
1209    pub condition_context: Vec<String>,
1210    pub declaration_ids: Vec<String>,
1211    pub element_class_iteration: ReducedClassValueProductIterationV0,
1212    pub property_value_narrowing: AbstractPropertyValueNarrowingV0,
1213    #[serde(skip_serializing_if = "Option::is_none")]
1214    pub runtime_state: Option<OmenaQueryRuntimeStateScenarioEvidenceV0>,
1215}
1216
1217#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1218#[serde(rename_all = "camelCase")]
1219pub struct OmenaQueryStaticConditionPruningEvidenceV0 {
1220    pub schema_version: &'static str,
1221    pub product: &'static str,
1222    pub condition_context: Vec<String>,
1223    pub assumption: &'static str,
1224    pub verdict: &'static str,
1225    pub pruned: bool,
1226    pub anchor_context: bool,
1227}
1228
1229#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1230#[serde(rename_all = "camelCase")]
1231pub struct OmenaQueryRuntimeStateScenarioEvidenceV0 {
1232    pub schema_version: &'static str,
1233    pub product: &'static str,
1234    pub selector: String,
1235    pub selector_class_names: Vec<String>,
1236    pub property_name: String,
1237    pub scenario_join_kind: &'static str,
1238    pub confidence_tier: &'static str,
1239    pub confidence_tier_within_modeled_environment: &'static str,
1240    pub static_boundary: OmenaQueryRuntimeStateStaticBoundaryV0,
1241    pub driver_summaries: Vec<OmenaQueryRuntimeStateDriverSummaryV0>,
1242    pub scenarios: Vec<OmenaQueryRuntimeStateScenarioV0>,
1243    #[serde(skip_serializing_if = "Vec::is_empty")]
1244    pub static_condition_pruning: Vec<OmenaQueryStaticConditionPruningEvidenceV0>,
1245    #[serde(skip_serializing_if = "Vec::is_empty")]
1246    pub inline_style_overrides: Vec<OmenaQueryInlineStyleRuntimeOverrideV0>,
1247}
1248
1249#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1250#[serde(rename_all = "camelCase")]
1251pub struct OmenaQueryRuntimeStateStaticBoundaryV0 {
1252    pub boundary_kind: &'static str,
1253    pub static_value_assuming_no_runtime_override: bool,
1254    pub tracks_dom_mutation: bool,
1255    pub tracks_class_list_mutation: bool,
1256}
1257
1258#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1259#[serde(rename_all = "camelCase")]
1260pub struct OmenaQueryRuntimeStateDriverSummaryV0 {
1261    pub driver: &'static str,
1262    pub status: &'static str,
1263    pub scenario_count: usize,
1264    pub provenance: Vec<&'static str>,
1265}
1266
1267#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1268#[serde(rename_all = "camelCase")]
1269pub struct OmenaQueryRuntimeStateScenarioV0 {
1270    pub scenario_kind: &'static str,
1271    #[serde(skip_serializing_if = "Option::is_none")]
1272    pub pseudo_state: Option<String>,
1273    pub condition_context: Vec<String>,
1274    pub declaration_ids: Vec<String>,
1275    #[serde(skip_serializing_if = "Option::is_none")]
1276    pub winner_declaration_id: Option<String>,
1277    #[serde(skip_serializing_if = "Option::is_none")]
1278    pub winner_value: Option<String>,
1279    pub property_value_narrowing: AbstractPropertyValueNarrowingV0,
1280}
1281
1282#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1283#[serde(rename_all = "camelCase")]
1284pub struct OmenaQueryInlineStyleRuntimeOverrideV0 {
1285    pub source_path: String,
1286    pub range: ParserRangeV0,
1287    pub property_name: String,
1288    pub value: Option<String>,
1289    pub cascade_tier: &'static str,
1290    pub static_value: bool,
1291}
1292
1293#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1294#[serde(rename_all = "camelCase")]
1295pub struct OmenaQueryStyleDiagnosticV0 {
1296    pub code: &'static str,
1297    pub severity: &'static str,
1298    pub provenance: Vec<&'static str>,
1299    pub range: ParserRangeV0,
1300    pub message: String,
1301    #[serde(skip_serializing_if = "Vec::is_empty")]
1302    pub tags: Vec<u8>,
1303    pub create_custom_property: Option<OmenaQueryCreateCustomPropertyActionV0>,
1304    #[serde(skip_serializing_if = "Option::is_none")]
1305    pub cascade_narrowing: Option<OmenaQueryCascadeNarrowingEvidenceV0>,
1306    #[serde(skip_serializing_if = "Option::is_none")]
1307    pub cascade_confidence: Option<OmenaQueryCascadeConfidenceV0>,
1308    #[serde(skip_serializing_if = "Option::is_none")]
1309    pub polynomial_provenance: Option<OmenaQueryPolynomialProvenanceV0>,
1310    #[serde(skip_serializing_if = "Option::is_none")]
1311    pub cross_file_scc: Option<OmenaQueryCrossFileSccEvidenceV0>,
1312}
1313
1314pub type OmenaQueryLinearProvenanceV0 = LinearProvenanceV0<NaturalCountProvenanceSemiringV0>;
1315pub type OmenaQueryPolynomialProvenanceV0 = PolynomialProvenanceV0;
1316
1317pub fn summarize_omena_query_linear_provenance(
1318    provenance: &[&'static str],
1319) -> OmenaQueryLinearProvenanceV0 {
1320    let labels = project_omena_query_diagnostic_provenance_from_evidence_graph(
1321        "linearProvenance",
1322        provenance.to_vec(),
1323    );
1324    summarize_omena_query_linear_provenance_with_support_count(labels.as_slice(), 1)
1325}
1326
1327pub fn summarize_omena_query_linear_provenance_with_support_count(
1328    provenance: &[&'static str],
1329    support_count: u8,
1330) -> OmenaQueryLinearProvenanceV0 {
1331    let path = if support_count == 0 {
1332        LinearProvenancePathV0::unsupported(provenance)
1333    } else {
1334        LinearProvenancePathV0::supported(provenance, support_count)
1335    };
1336    OmenaQueryLinearProvenanceV0::from_composed_paths(&[path])
1337}
1338
1339pub fn summarize_omena_query_polynomial_provenance(
1340    provenance: &[&'static str],
1341) -> OmenaQueryPolynomialProvenanceV0 {
1342    let labels = project_omena_query_diagnostic_provenance_from_evidence_graph(
1343        "polynomialProvenance",
1344        provenance.to_vec(),
1345    );
1346    let linear_provenance = summarize_omena_query_linear_provenance(labels.as_slice());
1347    summarize_polynomial_provenance_from_linear_v0(&linear_provenance, "diagnosticDefaultThreeTier")
1348}
1349
1350pub fn summarize_omena_query_linear_provenance_semiring_laws() -> ProvenanceSemiringLawReportV0 {
1351    verify_provenance_semiring_laws_on_fixtures(
1352        &NaturalCountProvenanceSemiringV0::new(),
1353        &[0, 1, 2, 3],
1354    )
1355}
1356
1357pub fn round_trip_omena_query_linear_provenance_labels(
1358    linear_provenance: &OmenaQueryLinearProvenanceV0,
1359) -> Vec<&'static str> {
1360    linear_provenance.labels()
1361}
1362
1363impl OmenaQueryStyleDiagnosticV0 {
1364    pub fn linear_provenance(&self) -> OmenaQueryLinearProvenanceV0 {
1365        summarize_omena_query_linear_provenance(self.provenance.as_slice())
1366    }
1367
1368    pub fn polynomial_provenance(&self) -> OmenaQueryPolynomialProvenanceV0 {
1369        summarize_omena_query_polynomial_provenance(self.provenance.as_slice())
1370    }
1371}
1372
1373pub(crate) fn apply_omena_query_checker_product_gate_to_style_diagnostics(
1374    diagnostics: &mut [OmenaQueryStyleDiagnosticV0],
1375) {
1376    for diagnostic in diagnostics {
1377        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
1378            diagnostic.code,
1379            &mut diagnostic.provenance,
1380        );
1381        diagnostic.polynomial_provenance = Some(diagnostic.polynomial_provenance());
1382    }
1383}
1384
1385#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1386#[serde(rename_all = "camelCase")]
1387pub struct OmenaQueryStyleDiagnosticsForFileV0 {
1388    pub schema_version: &'static str,
1389    pub product: &'static str,
1390    pub file_uri: String,
1391    pub file_kind: &'static str,
1392    pub diagnostic_count: usize,
1393    pub diagnostics: Vec<OmenaQueryStyleDiagnosticV0>,
1394    pub ready_surfaces: Vec<&'static str>,
1395    #[serde(skip_serializing_if = "Option::is_none")]
1396    pub suppression_summary: Option<OmenaQueryDiagnosticSuppressionSummaryV0>,
1397}
1398
1399#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1400#[serde(rename_all = "camelCase")]
1401pub struct OmenaQueryDiagnosticSuppressionSummaryV0 {
1402    pub original_diagnostic_count: usize,
1403    pub emitted_diagnostic_count: usize,
1404    pub suppressed_diagnostic_count: usize,
1405    pub unused_expect_error_count: usize,
1406    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1407    pub suppression_reasons: Vec<OmenaQueryDiagnosticSuppressionReasonV0>,
1408}
1409
1410#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1411#[serde(rename_all = "camelCase")]
1412pub struct OmenaQueryDiagnosticSuppressionReasonV0 {
1413    pub directive_kind: &'static str,
1414    pub codes: Vec<String>,
1415    pub reason: String,
1416    pub range: ParserRangeV0,
1417}
1418
1419#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1420pub enum OmenaQueryDiagnosticSuppressionModeV0 {
1421    Apply,
1422    ReportOnly,
1423}
1424
1425impl OmenaQueryDiagnosticSuppressionModeV0 {
1426    pub const fn as_str(self) -> &'static str {
1427        match self {
1428            Self::Apply => "apply",
1429            Self::ReportOnly => "reportOnly",
1430        }
1431    }
1432
1433    pub const fn suppresses_diagnostics(self) -> bool {
1434        matches!(self, Self::Apply)
1435    }
1436}
1437
1438#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1439#[serde(rename_all = "camelCase")]
1440pub struct OmenaQueryCompletionCandidateV0 {
1441    pub file_uri: String,
1442    pub name: String,
1443    pub kind: &'static str,
1444    pub range: ParserRangeV0,
1445    pub source: &'static str,
1446    #[serde(skip_serializing_if = "Option::is_none")]
1447    pub documentation: Option<String>,
1448}
1449
1450#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1451#[serde(rename_all = "camelCase")]
1452pub struct OmenaQueryCompletionItemV0 {
1453    pub label: String,
1454    pub insert_text: String,
1455    pub sort_text: String,
1456    pub detail: &'static str,
1457    #[serde(skip_serializing_if = "Option::is_none")]
1458    pub documentation: Option<String>,
1459    pub item_kind: &'static str,
1460    pub ranking_source: &'static str,
1461    pub source: &'static str,
1462}
1463
1464#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1465#[serde(rename_all = "camelCase")]
1466pub struct OmenaQueryCompletionAtPositionV0 {
1467    pub schema_version: &'static str,
1468    pub product: &'static str,
1469    pub file_uri: String,
1470    pub file_kind: &'static str,
1471    pub query_position: ParserPositionV0,
1472    pub context_kind: &'static str,
1473    pub prefix: Option<String>,
1474    pub is_incomplete: bool,
1475    pub item_count: usize,
1476    pub items: Vec<OmenaQueryCompletionItemV0>,
1477    pub ready_surfaces: Vec<&'static str>,
1478}
1479
1480#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1481#[serde(rename_all = "camelCase")]
1482pub struct OmenaQueryReferenceLocationV0 {
1483    pub uri: String,
1484    pub range: ParserRangeV0,
1485    pub name: String,
1486    pub role: &'static str,
1487    pub source: &'static str,
1488}
1489
1490#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1491#[serde(rename_all = "camelCase")]
1492pub struct OmenaQueryRefsForClassV0 {
1493    pub schema_version: &'static str,
1494    pub product: &'static str,
1495    pub selector_name: String,
1496    pub target_style_uri: Option<String>,
1497    pub include_declaration: bool,
1498    pub location_count: usize,
1499    pub locations: Vec<OmenaQueryReferenceLocationV0>,
1500    pub ready_surfaces: Vec<&'static str>,
1501}
1502
1503#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1504#[serde(rename_all = "camelCase")]
1505pub struct OmenaQueryRenamePlanV0 {
1506    pub schema_version: &'static str,
1507    pub product: &'static str,
1508    pub selector_name: String,
1509    pub new_name: String,
1510    pub target_style_uri: Option<String>,
1511    pub edit_count: usize,
1512    pub edits: Vec<OmenaQueryWorkspaceTextEditV0>,
1513    pub ready_surfaces: Vec<&'static str>,
1514}
1515
1516#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1517#[serde(rename_all = "camelCase")]
1518pub struct OmenaQueryCodeActionPlanV0 {
1519    pub schema_version: &'static str,
1520    pub product: &'static str,
1521    pub file_uri: String,
1522    pub file_kind: &'static str,
1523    pub action_count: usize,
1524    pub actions: Vec<OmenaQueryCodeActionV0>,
1525    pub ready_surfaces: Vec<&'static str>,
1526}
1527
1528#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1529#[serde(rename_all = "camelCase")]
1530pub struct OmenaQueryCodeActionV0 {
1531    pub title: String,
1532    pub kind: &'static str,
1533    pub edits: Vec<OmenaQueryWorkspaceTextEditV0>,
1534    pub source: &'static str,
1535}
1536
1537#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1538#[serde(rename_all = "camelCase")]
1539pub struct OmenaQueryStyleInsightsV0 {
1540    pub schema_version: &'static str,
1541    pub product: &'static str,
1542    pub style_uri: String,
1543    pub insight_count: usize,
1544    pub insights: Vec<OmenaQueryInsightV0>,
1545    pub ready_surfaces: Vec<&'static str>,
1546}
1547
1548#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1549#[serde(rename_all = "camelCase")]
1550pub struct OmenaQueryInsightV0 {
1551    pub kind: &'static str,
1552    pub title: String,
1553    pub message: String,
1554    pub range: ParserRangeV0,
1555    pub confidence: &'static str,
1556    pub scope: &'static str,
1557    pub source: &'static str,
1558    pub provenance: Vec<&'static str>,
1559    #[serde(skip_serializing_if = "Option::is_none")]
1560    pub primary_edit: Option<OmenaQueryWorkspaceTextEditV0>,
1561    pub shorthand_combinable: Option<OmenaQueryShorthandCombinableV0>,
1562    #[serde(skip_serializing_if = "Option::is_none")]
1563    pub cascade_insight: Option<OmenaQueryCascadeInsightV0>,
1564}
1565
1566#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1567#[serde(rename_all = "camelCase")]
1568pub struct OmenaQueryShorthandCombinableV0 {
1569    pub shorthand_property: String,
1570    pub longhand_properties: Vec<String>,
1571    pub values: Vec<String>,
1572    pub combined_value: String,
1573    pub declaration_count: usize,
1574}
1575
1576#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1577#[serde(rename_all = "camelCase")]
1578pub struct OmenaQueryCascadeInsightV0 {
1579    pub relationship: &'static str,
1580    pub selector: String,
1581    pub property: String,
1582    pub related_selector: Option<String>,
1583    pub related_property: Option<String>,
1584    pub source_order: u32,
1585    pub related_source_order: Option<u32>,
1586}
1587
1588#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1589#[serde(rename_all = "camelCase")]
1590pub struct OmenaQueryCascadeAtPositionV0 {
1591    pub schema_version: &'static str,
1592    pub product: &'static str,
1593    pub style_path: String,
1594    pub query_position: ParserPositionV0,
1595    pub status: &'static str,
1596    pub cascade_engine: &'static str,
1597    pub reference_name: Option<String>,
1598    pub reference_range: Option<ParserRangeV0>,
1599    pub winner_declaration_source_order: Option<usize>,
1600    pub winner_declaration_file_path: Option<String>,
1601    pub winner_declaration_range: Option<ParserRangeV0>,
1602    pub winner_context_kind: Option<&'static str>,
1603    pub winner_declaration_layer_rank: Option<i32>,
1604    pub winner_declaration_layer_name: Option<String>,
1605    pub candidate_declaration_count: usize,
1606    pub shadowed_declaration_source_orders: Vec<usize>,
1607    pub referenced_declaration_property: Option<String>,
1608    pub referenced_declaration_value: Option<String>,
1609    pub referenced_declaration_computed_value_status: Option<&'static str>,
1610    pub referenced_declaration_computed_value: Option<String>,
1611    pub referenced_declaration_invalid_at_computed_value_time: bool,
1612    pub referenced_declaration_computed_value_indeterminate: bool,
1613    #[serde(skip_serializing_if = "Option::is_none")]
1614    pub referenced_declaration_computed_value_indeterminate_reason: Option<&'static str>,
1615    pub referenced_declaration_computed_value_derivation_steps: Vec<&'static str>,
1616    pub custom_property_fixed_point_iteration_count: usize,
1617    pub custom_property_fixed_point_guaranteed_invalid_count: usize,
1618    pub reference_custom_property_fixed_point_status: Option<&'static str>,
1619    pub reference_custom_property_fixed_point_value: Option<String>,
1620    #[serde(skip_serializing_if = "Option::is_none")]
1621    pub refinement_evidence: Option<CascadeDimensionalRefinementBridgeV0>,
1622    #[serde(skip_serializing_if = "Option::is_none")]
1623    pub categorical_evidence:
1624        Option<omena_query_checker_orchestrator::CategoricalCascadeEvidenceV0>,
1625}
1626
1627#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1628#[serde(rename_all = "camelCase")]
1629pub struct OmenaQueryCreateCustomPropertyActionV0 {
1630    pub uri: String,
1631    pub range: ParserRangeV0,
1632    pub new_text: String,
1633    pub property_name: String,
1634}
1635
1636#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1637#[serde(rename_all = "camelCase")]
1638pub struct OmenaQuerySourceDiagnosticV0 {
1639    pub code: &'static str,
1640    pub severity: &'static str,
1641    pub provenance: Vec<&'static str>,
1642    pub range: ParserRangeV0,
1643    pub message: String,
1644    #[serde(skip_serializing_if = "Option::is_none")]
1645    pub precision: Option<OmenaQueryAnalysisPrecisionV0>,
1646    #[serde(skip_serializing_if = "Option::is_none")]
1647    pub suggestion: Option<String>,
1648    pub create_selector: Option<OmenaQueryCreateSelectorActionV0>,
1649}
1650
1651impl OmenaQuerySourceDiagnosticV0 {
1652    pub fn linear_provenance(&self) -> OmenaQueryLinearProvenanceV0 {
1653        summarize_omena_query_linear_provenance(self.provenance.as_slice())
1654    }
1655}
1656
1657pub(crate) fn source_diagnostic_precision(
1658    value_domain: &str,
1659    flow_sensitivity: &str,
1660    context_sensitivity: &str,
1661) -> OmenaQueryAnalysisPrecisionV0 {
1662    let precision =
1663        source_diagnostic_precision_node(value_domain, flow_sensitivity, context_sensitivity);
1664    OmenaQueryAnalysisPrecisionV0 {
1665        product: precision.product,
1666        value_domain: precision.value_domain,
1667        flow_sensitivity: precision.flow_sensitivity,
1668        context_sensitivity: precision.context_sensitivity,
1669        revision_axis: precision.revision_axis,
1670    }
1671}
1672
1673pub fn fact_precision_from_evidence_analysis_precision(
1674    precision: &EvidenceAnalysisPrecisionV0,
1675) -> omena_query_core::FactPrecision {
1676    omena_query_core::fact_precision_from_analysis_precision(&OmenaQueryAnalysisPrecisionV0 {
1677        product: precision.product.clone(),
1678        value_domain: precision.value_domain.clone(),
1679        flow_sensitivity: precision.flow_sensitivity.clone(),
1680        context_sensitivity: precision.context_sensitivity.clone(),
1681        revision_axis: precision.revision_axis.clone(),
1682    })
1683}
1684
1685pub(crate) const OMENA_QUERY_TYPE_ORACLE_UNKNOWN_VALUE_DOMAIN: &str = "unknown";
1686pub(crate) const OMENA_QUERY_TSGO_PROVIDER_UNAVAILABLE_PROVENANCE: &str =
1687    "tsgo-provider.unavailable->unknown-precision";
1688
1689pub(crate) fn apply_omena_query_checker_product_gate_to_source_diagnostics(
1690    diagnostics: &mut [OmenaQuerySourceDiagnosticV0],
1691) {
1692    for diagnostic in diagnostics {
1693        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
1694            diagnostic.code,
1695            &mut diagnostic.provenance,
1696        );
1697    }
1698}
1699
1700pub(crate) fn project_omena_query_provenance_from_evidence_graph(
1701    provenance: &[&'static str],
1702) -> Vec<&'static str> {
1703    let input_identity = provenance.first().copied().unwrap_or("emptyProvenance");
1704    project_omena_query_diagnostic_provenance_from_evidence_graph(
1705        input_identity,
1706        provenance.to_vec(),
1707    )
1708}
1709
1710fn populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
1711    product_diagnostic_code: &str,
1712    provenance: &mut Vec<&'static str>,
1713) {
1714    let gate =
1715        omena_query_checker_orchestrator::gate_omena_query_checker_product_diagnostic_code_v0(
1716            product_diagnostic_code,
1717        );
1718    if !gate.enforcement_passed {
1719        provenance.push("omena-query-checker-orchestrator.product-diagnostic-gate-failed");
1720    } else {
1721        for label in gate.provenance {
1722            if !provenance.contains(&label) {
1723                provenance.push(label);
1724            }
1725        }
1726    }
1727    *provenance = project_omena_query_diagnostic_provenance_from_evidence_graph(
1728        product_diagnostic_code,
1729        provenance.clone(),
1730    );
1731}
1732
1733fn source_diagnostic_precision_node(
1734    value_domain: &str,
1735    flow_sensitivity: &str,
1736    context_sensitivity: &str,
1737) -> EvidenceAnalysisPrecisionV0 {
1738    let precision = EvidenceAnalysisPrecisionV0::new(
1739        "omena-query.analysis-precision",
1740        value_domain,
1741        flow_sensitivity,
1742        context_sensitivity,
1743        "OmenaQuerySourceDiagnosticsForFileV0.input",
1744    );
1745    let Some(node) = project_omena_query_evidence_node(
1746        "sourceDiagnosticPrecision",
1747        value_domain,
1748        &[],
1749        Some(precision.clone()),
1750    ) else {
1751        return precision;
1752    };
1753    node.precision.unwrap_or(precision)
1754}
1755
1756fn project_omena_query_diagnostic_provenance_from_evidence_graph(
1757    input_identity: &str,
1758    provenance: Vec<&'static str>,
1759) -> Vec<&'static str> {
1760    let Some(node) = project_omena_query_evidence_node(
1761        "diagnosticProvenance",
1762        input_identity,
1763        provenance.as_slice(),
1764        None,
1765    ) else {
1766        return provenance;
1767    };
1768    node.provenance
1769        .iter()
1770        .filter_map(|label| {
1771            provenance
1772                .iter()
1773                .copied()
1774                .find(|candidate| *candidate == label.as_str())
1775        })
1776        .collect()
1777}
1778
1779fn project_omena_query_evidence_node(
1780    query_identity: &str,
1781    input_identity: &str,
1782    provenance: &[&'static str],
1783    precision: Option<EvidenceAnalysisPrecisionV0>,
1784) -> Option<omena_evidence_graph::EvidenceNodeV0> {
1785    let key = EvidenceNodeKeyV0::new(query_identity, input_identity);
1786    let Ok(graph) = build_evidence_graph_from_edges_v0(
1787        [EvidenceNodeSeedV0::with_precision(
1788            key.clone(),
1789            provenance
1790                .iter()
1791                .map(|label| (*label).to_string())
1792                .collect(),
1793            precision,
1794            GuaranteeKindV0::for_label_less_family(),
1795        )],
1796        [EvidenceDemandEdgeV0::new(
1797            query_identity,
1798            key,
1799            "diagnostic-evidence",
1800        )],
1801    ) else {
1802        return None;
1803    };
1804    graph.nodes.into_iter().next()
1805}
1806
1807#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1808#[serde(rename_all = "camelCase")]
1809pub struct OmenaQueryCreateSelectorActionV0 {
1810    pub uri: String,
1811    pub range: ParserRangeV0,
1812    pub new_text: String,
1813    pub selector_name: String,
1814}
1815
1816#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
1817#[serde(rename_all = "camelCase")]
1818pub struct OmenaQuerySourceMissingSelectorDiagnosticCandidateV0 {
1819    pub target_style_uri: String,
1820    pub target_style_source: String,
1821    pub selector_name: String,
1822    pub source_reference_range: ParserRangeV0,
1823}
1824
1825#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1826#[serde(rename_all = "camelCase")]
1827pub struct OmenaQuerySourceDiagnosticsForFileV0 {
1828    pub schema_version: &'static str,
1829    pub product: &'static str,
1830    pub file_uri: String,
1831    pub file_kind: &'static str,
1832    pub diagnostic_count: usize,
1833    pub diagnostics: Vec<OmenaQuerySourceDiagnosticV0>,
1834    pub ready_surfaces: Vec<&'static str>,
1835}
1836
1837#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
1838#[serde(rename_all = "camelCase")]
1839pub struct OmenaQuerySourceSelectorCandidateV0 {
1840    pub kind: &'static str,
1841    pub name: String,
1842    pub range: ParserRangeV0,
1843    pub source: &'static str,
1844    pub target_style_uri: Option<String>,
1845}
1846
1847#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
1848#[serde(rename_all = "camelCase")]
1849pub struct OmenaQuerySourceSelectorReferenceCandidateV0 {
1850    pub uri: String,
1851    pub kind: &'static str,
1852    pub name: String,
1853    pub range: ParserRangeV0,
1854    pub source: &'static str,
1855    pub target_style_uri: Option<String>,
1856}
1857
1858#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1859#[serde(rename_all = "camelCase")]
1860pub struct OmenaQueryStyleSelectorDefinitionV0 {
1861    pub uri: String,
1862    pub name: String,
1863    pub range: ParserRangeV0,
1864}
1865
1866#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1867#[serde(rename_all = "camelCase")]
1868pub struct OmenaQuerySourceProviderCandidateResolutionV0 {
1869    pub schema_version: &'static str,
1870    pub product: &'static str,
1871    pub matched: Vec<OmenaQuerySourceSelectorCandidateV0>,
1872    pub unresolved: Vec<OmenaQuerySourceSelectorCandidateV0>,
1873}
1874
1875#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1876#[serde(rename_all = "camelCase")]
1877pub struct OmenaQuerySourceSelectorReferenceEditTargetV0 {
1878    pub uri: String,
1879    pub name: String,
1880    pub range: ParserRangeV0,
1881    pub target_style_uri: Option<String>,
1882}
1883
1884#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1885#[serde(rename_all = "camelCase")]
1886pub struct OmenaQuerySourceSelectorOccurrenceIndexV0 {
1887    pub schema_version: &'static str,
1888    pub product: &'static str,
1889    pub moniker_count: usize,
1890    pub occurrence_count: usize,
1891    pub workspace_index: OmenaWorkspaceOccurrenceIndexV0,
1892    pub occurrences: Vec<OmenaQuerySourceSelectorOccurrenceV0>,
1893    pub ready_surfaces: Vec<&'static str>,
1894}
1895
1896#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
1897#[serde(rename_all = "camelCase")]
1898pub struct OmenaQuerySourceSelectorOccurrenceV0 {
1899    pub moniker: String,
1900    pub uri: String,
1901    pub selector_name: String,
1902    pub range: ParserRangeV0,
1903    pub kind: OmenaWorkspaceOccurrenceKindV0,
1904    pub role: OmenaWorkspaceOccurrenceRoleV0,
1905    pub source: OmenaWorkspaceOccurrenceSurfaceV0,
1906    pub target_style_uri: Option<String>,
1907    pub rename_target: bool,
1908}
1909
1910#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1911#[serde(rename_all = "camelCase")]
1912pub struct OmenaQueryCustomPropertyOccurrenceIndexV0 {
1913    pub schema_version: &'static str,
1914    pub product: &'static str,
1915    pub occurrence_count: usize,
1916    pub occurrences: Vec<OmenaQueryCustomPropertyOccurrenceV0>,
1917    pub ready_surfaces: Vec<&'static str>,
1918}
1919
1920#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
1921#[serde(rename_all = "camelCase")]
1922pub struct OmenaQueryCustomPropertyOccurrenceV0 {
1923    pub uri: String,
1924    pub name: String,
1925    pub range: ParserRangeV0,
1926    pub byte_span: ParserByteSpanV0,
1927    pub kind: &'static str,
1928    pub has_fallback: bool,
1929    pub source: &'static str,
1930}
1931
1932#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
1933#[serde(rename_all = "camelCase")]
1934pub struct OmenaWorkspaceOccurrenceIndexV0 {
1935    pub schema_version: &'static str,
1936    pub product: &'static str,
1937    pub moniker_count: usize,
1938    pub occurrence_count: usize,
1939    pub by_moniker: BTreeMap<String, Vec<OmenaWorkspaceOccurrenceV0>>,
1940    pub by_file: BTreeMap<String, Vec<String>>,
1941    pub ready_surfaces: Vec<&'static str>,
1942}
1943
1944#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
1945#[serde(rename_all = "camelCase")]
1946pub struct OmenaWorkspaceOccurrenceV0 {
1947    pub moniker: String,
1948    pub uri: String,
1949    pub name: String,
1950    pub range: ParserRangeV0,
1951    pub kind: OmenaWorkspaceOccurrenceKindV0,
1952    pub role: OmenaWorkspaceOccurrenceRoleV0,
1953    pub surface: OmenaWorkspaceOccurrenceSurfaceV0,
1954    #[serde(skip_serializing_if = "Option::is_none")]
1955    pub family: Option<OmenaWorkspaceOccurrenceFamilyV0>,
1956    #[serde(skip_serializing_if = "Option::is_none")]
1957    pub namespace: Option<String>,
1958    #[serde(skip_serializing_if = "Option::is_none")]
1959    pub target_style_uri: Option<String>,
1960    pub rename_target: bool,
1961}
1962
1963#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
1964#[serde(rename_all = "camelCase")]
1965pub enum OmenaWorkspaceOccurrenceKindV0 {
1966    SourceSelectorReference,
1967    SourceSelectorPrefixReference,
1968    CustomPropertyDeclaration,
1969    CustomPropertyReference,
1970    SassVariableDeclaration,
1971    SassVariableReference,
1972    SassMixinDeclaration,
1973    SassMixinInclude,
1974    SassFunctionDeclaration,
1975    SassFunctionCall,
1976}
1977
1978impl OmenaWorkspaceOccurrenceKindV0 {
1979    pub fn as_str(self) -> &'static str {
1980        match self {
1981            Self::SourceSelectorReference => "sourceSelectorReference",
1982            Self::SourceSelectorPrefixReference => "sourceSelectorPrefixReference",
1983            Self::CustomPropertyDeclaration => "customPropertyDeclaration",
1984            Self::CustomPropertyReference => "customPropertyReference",
1985            Self::SassVariableDeclaration => "sassVariableDeclaration",
1986            Self::SassVariableReference => "sassVariableReference",
1987            Self::SassMixinDeclaration => "sassMixinDeclaration",
1988            Self::SassMixinInclude => "sassMixinInclude",
1989            Self::SassFunctionDeclaration => "sassFunctionDeclaration",
1990            Self::SassFunctionCall => "sassFunctionCall",
1991        }
1992    }
1993}
1994
1995#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
1996#[serde(rename_all = "camelCase")]
1997pub enum OmenaWorkspaceOccurrenceRoleV0 {
1998    Definition,
1999    Reference,
2000}
2001
2002impl OmenaWorkspaceOccurrenceRoleV0 {
2003    pub fn as_str(self) -> &'static str {
2004        match self {
2005            Self::Definition => "definition",
2006            Self::Reference => "reference",
2007        }
2008    }
2009}
2010
2011#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
2012#[serde(rename_all = "camelCase")]
2013pub enum OmenaWorkspaceOccurrenceSurfaceV0 {
2014    OmenaQuerySourceSyntaxIndex,
2015    OmenaLspStyleIndex,
2016}
2017
2018impl OmenaWorkspaceOccurrenceSurfaceV0 {
2019    pub fn as_str(self) -> &'static str {
2020        match self {
2021            Self::OmenaQuerySourceSyntaxIndex => "omenaQuerySourceSyntaxIndex",
2022            Self::OmenaLspStyleIndex => "omenaLspStyleIndex",
2023        }
2024    }
2025}
2026
2027#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
2028#[serde(rename_all = "camelCase")]
2029pub enum OmenaWorkspaceOccurrenceFamilyV0 {
2030    CssModuleSelector,
2031    CustomProperty,
2032    Variable,
2033    Mixin,
2034    Function,
2035    Symbol,
2036}
2037
2038impl OmenaWorkspaceOccurrenceFamilyV0 {
2039    pub fn as_str(self) -> &'static str {
2040        match self {
2041            Self::CssModuleSelector => "cssModuleSelector",
2042            Self::CustomProperty => "customProperty",
2043            Self::Variable => "variable",
2044            Self::Mixin => "mixin",
2045            Self::Function => "function",
2046            Self::Symbol => "symbol",
2047        }
2048    }
2049}
2050
2051#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2052#[serde(rename_all = "camelCase")]
2053pub struct OmenaQueryWorkspaceTextEditV0 {
2054    pub uri: String,
2055    pub range: ParserRangeV0,
2056    pub new_text: String,
2057}
2058
2059#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2060#[serde(rename_all = "camelCase")]
2061pub struct OmenaQuerySassModuleUseEdgeV0 {
2062    pub source: String,
2063    pub namespace_kind: &'static str,
2064    pub namespace: Option<String>,
2065}
2066
2067#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
2068#[serde(rename_all = "camelCase")]
2069pub struct OmenaQuerySassModuleSourcesV0 {
2070    pub schema_version: &'static str,
2071    pub product: &'static str,
2072    pub module_use_edges: Vec<OmenaQuerySassModuleUseEdgeV0>,
2073    pub module_forward_sources: Vec<String>,
2074}
2075
2076#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
2077#[serde(rename_all = "camelCase")]
2078pub struct OmenaQueryStylePackageManifestV0 {
2079    pub package_json_path: String,
2080    pub package_json_source: String,
2081}
2082
2083#[cfg(test)]
2084mod evidence_graph_projection_tests {
2085    use super::*;
2086
2087    #[test]
2088    fn diagnostic_provenance_projection_preserves_legacy_labels() {
2089        let labels = vec![
2090            "omena-query.source-syntax-index",
2091            "omena-query.style-selector-definitions",
2092        ];
2093
2094        assert_eq!(
2095            project_omena_query_diagnostic_provenance_from_evidence_graph(
2096                "missingSelector",
2097                labels.clone(),
2098            ),
2099            labels
2100        );
2101    }
2102
2103    #[test]
2104    fn checker_product_gate_projection_matches_legacy_extension() {
2105        let code = "missingSelector";
2106        let mut expected = vec![
2107            "omena-query.source-syntax-index",
2108            "omena-query.style-selector-definitions",
2109        ];
2110        let gate =
2111            omena_query_checker_orchestrator::gate_omena_query_checker_product_diagnostic_code_v0(
2112                code,
2113            );
2114        if !gate.enforcement_passed {
2115            expected.push("omena-query-checker-orchestrator.product-diagnostic-gate-failed");
2116        } else {
2117            for label in gate.provenance {
2118                if !expected.contains(&label) {
2119                    expected.push(label);
2120                }
2121            }
2122        }
2123
2124        let mut actual = vec![
2125            "omena-query.source-syntax-index",
2126            "omena-query.style-selector-definitions",
2127        ];
2128        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(code, &mut actual);
2129
2130        assert_eq!(actual, expected);
2131    }
2132
2133    #[test]
2134    fn source_diagnostic_precision_projects_byte_identical_shape() -> Result<(), serde_json::Error>
2135    {
2136        let precision = source_diagnostic_precision(
2137            "classValueResolution",
2138            "sourceSyntaxIndex",
2139            "perSourceReference",
2140        );
2141        let serialized = serde_json::to_value(&precision)?;
2142
2143        assert_eq!(
2144            serialized,
2145            serde_json::json!({
2146                "product": "omena-query.analysis-precision",
2147                "valueDomain": "classValueResolution",
2148                "flowSensitivity": "sourceSyntaxIndex",
2149                "contextSensitivity": "perSourceReference",
2150                "revisionAxis": "OmenaQuerySourceDiagnosticsForFileV0.input"
2151            })
2152        );
2153        Ok(())
2154    }
2155}