Skip to main content

omena_scss_eval/control_flow/
model.rs

1use omena_abstract_value::AbstractCssValueV0;
2use omena_transform_cst::StableNodeKeyV0;
3use serde::Serialize;
4
5/// Block summary for the per-region SCSS control-flow surface.
6#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
7#[serde(rename_all = "camelCase")]
8pub struct OmenaScssEvalControlFlowIrSummaryV0 {
9    pub schema_version: &'static str,
10    pub product: &'static str,
11    pub mode: &'static str,
12    pub dialect: &'static str,
13    pub node_key_type: &'static str,
14    pub flat_css_cfg_built: bool,
15    pub merged_cross_file_graph: bool,
16    pub block_count: usize,
17    pub branch_block_count: usize,
18    pub loop_block_count: usize,
19    pub back_edge_count: usize,
20    pub edge_count: usize,
21    pub blocks: Vec<OmenaScssEvalControlFlowBlockV0>,
22}
23
24#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
25#[serde(rename_all = "camelCase")]
26pub struct OmenaScssEvalControlFlowBlockV0 {
27    pub node_key: StableNodeKeyV0,
28    pub kind: &'static str,
29    pub at_rule_name: String,
30    pub header_text: String,
31    pub source_span_start: usize,
32    pub source_span_end: usize,
33    pub successor_count: usize,
34    pub has_back_edge: bool,
35}
36
37/// Stable integer block id for the per-region SCSS control-flow edge IR.
38#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)]
39#[serde(transparent)]
40pub struct OmenaScssEvalControlFlowBlockIdV0(pub u32);
41
42/// Explicit-edge SCSS control-flow graph for one style region.
43///
44/// `flat_css_cfg_built` means this transient per-region graph has concrete outcome
45/// edges. It does not imply a merged cross-file graph; that surface remains false.
46#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
47#[serde(rename_all = "camelCase")]
48pub struct OmenaScssEvalControlFlowGraphV0 {
49    pub schema_version: &'static str,
50    pub product: &'static str,
51    pub mode: &'static str,
52    pub dialect: &'static str,
53    pub block_id_type: &'static str,
54    pub node_key_type: &'static str,
55    pub flat_css_cfg_built: bool,
56    pub merged_cross_file_graph: bool,
57    pub block_count: usize,
58    pub edge_count: usize,
59    pub outcome_count: usize,
60    pub blocks: Vec<OmenaScssEvalControlFlowGraphBlockV0>,
61    pub edges: Vec<OmenaScssEvalControlFlowEdgeV0>,
62}
63
64/// Block payload plus the integer id used by the edge IR.
65#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
66#[serde(rename_all = "camelCase")]
67pub struct OmenaScssEvalControlFlowGraphBlockV0 {
68    pub id: OmenaScssEvalControlFlowBlockIdV0,
69    pub node_key: StableNodeKeyV0,
70    pub block: OmenaScssEvalControlFlowBlockV0,
71}
72
73/// One explicit SCSS control-flow outcome edge.
74#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
75#[serde(rename_all = "camelCase")]
76pub struct OmenaScssEvalControlFlowEdgeV0 {
77    pub source_block_id: OmenaScssEvalControlFlowBlockIdV0,
78    pub outcome: &'static str,
79    pub target_block_id: Option<OmenaScssEvalControlFlowBlockIdV0>,
80}
81
82/// Reachability recomputed after value-flow-driven control-flow pruning.
83///
84/// Unknown branch values keep their outgoing edges, so this witness is conservative
85/// unless the value fixpoint proves a branch or loop outcome.
86#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
87#[serde(rename_all = "camelCase")]
88pub struct OmenaScssEvalControlFlowPruneReachabilityV0 {
89    pub schema_version: &'static str,
90    pub product: &'static str,
91    pub mode: &'static str,
92    pub dialect: &'static str,
93    pub block_id_type: &'static str,
94    pub node_key_type: &'static str,
95    pub max_iterations: usize,
96    pub iteration_count: usize,
97    pub converged: bool,
98    pub flat_css_cfg_built: bool,
99    pub merged_cross_file_graph: bool,
100    pub block_count: usize,
101    pub original_edge_count: usize,
102    pub pruned_edge_count: usize,
103    pub reachable_block_count: usize,
104    pub unreachable_block_count: usize,
105    pub have_terminals_changed: bool,
106    pub reachable_block_ids: Vec<OmenaScssEvalControlFlowBlockIdV0>,
107    pub unreachable_block_ids: Vec<OmenaScssEvalControlFlowBlockIdV0>,
108}
109
110/// Value fixpoint over the per-region SCSS control-flow graph.
111///
112/// The graph is local to the analyzed region; `merged_cross_file_graph` remains false.
113#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
114#[serde(rename_all = "camelCase")]
115pub struct OmenaScssEvalControlFlowValueAnalysisV0 {
116    pub schema_version: &'static str,
117    pub product: &'static str,
118    pub mode: &'static str,
119    pub dialect: &'static str,
120    pub value_type: &'static str,
121    pub max_iterations: usize,
122    pub converged: bool,
123    pub iteration_count: usize,
124    pub block_count: usize,
125    pub back_edge_count: usize,
126    pub loop_carried_binding_count: usize,
127    pub widened_to_top_count: usize,
128    pub flat_css_cfg_built: bool,
129    pub merged_cross_file_graph: bool,
130    pub blocks: Vec<OmenaScssEvalControlFlowValueBlockV0>,
131}
132
133#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
134#[serde(rename_all = "camelCase")]
135pub struct OmenaScssEvalControlFlowWideningWitnessV0 {
136    pub schema_version: &'static str,
137    pub product: &'static str,
138    pub mode: &'static str,
139    pub value_type: &'static str,
140    pub policy: &'static str,
141    pub max_iterations: usize,
142    pub node_count: usize,
143    pub converged: bool,
144    pub iteration_count: usize,
145    pub widened_to_top_count: usize,
146    pub output_top_count: usize,
147}
148
149#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
150#[serde(rename_all = "camelCase")]
151pub struct OmenaScssEvalTypedValueLatticeWitnessV0 {
152    pub schema_version: &'static str,
153    pub product: &'static str,
154    pub mode: &'static str,
155    pub value_type: &'static str,
156    pub payload_type: &'static str,
157    pub policy: &'static str,
158    pub sample_value_count: usize,
159    pub typed_payload_count: usize,
160    pub raw_value_count: usize,
161    pub untyped_exact_or_finite_count: usize,
162    pub typed_coverage_basis_points: usize,
163    pub typed_advisory_comparison_count: usize,
164    pub typed_advisory_true_count: usize,
165    pub divergence_count: usize,
166    pub corpus_fixture_count: usize,
167    pub typed_decided_fixture_count: usize,
168    pub typed_prune_consumer_enabled: bool,
169    pub type_kind_counts: Vec<OmenaScssEvalTypedValueKindCountV0>,
170}
171
172#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
173#[serde(rename_all = "camelCase")]
174pub struct OmenaScssEvalTypedValueKindCountV0 {
175    pub kind: &'static str,
176    pub count: usize,
177}
178
179#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
180#[serde(rename_all = "camelCase")]
181pub struct OmenaScssEvalControlFlowValueBlockV0 {
182    pub node_key: StableNodeKeyV0,
183    pub kind: &'static str,
184    pub transfer_kind: &'static str,
185    pub transfer_value: Option<AbstractCssValueV0>,
186    pub transfer_value_kind: Option<&'static str>,
187    pub transfer_truthiness: Option<&'static str>,
188    pub predecessor_node_keys: Vec<StableNodeKeyV0>,
189    pub loop_carried_bindings: Vec<String>,
190    pub loop_carried_binding_values: Vec<OmenaScssEvalControlFlowBindingValueV0>,
191    pub input_value: AbstractCssValueV0,
192    pub input_value_kind: &'static str,
193    pub output_value: AbstractCssValueV0,
194    pub output_value_kind: &'static str,
195}
196
197#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
198#[serde(rename_all = "camelCase")]
199pub struct OmenaScssEvalControlFlowBindingValueV0 {
200    pub name: String,
201    pub value: AbstractCssValueV0,
202    pub value_kind: &'static str,
203}
204
205#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
206#[serde(rename_all = "camelCase")]
207pub struct OmenaScssEvalCallReturnIrSummaryV0 {
208    pub schema_version: &'static str,
209    pub product: &'static str,
210    pub mode: &'static str,
211    pub dialect: &'static str,
212    pub node_key_type: &'static str,
213    pub recursion_cap: usize,
214    pub flat_css_cfg_built: bool,
215    pub merged_cross_file_graph: bool,
216    pub node_count: usize,
217    pub declaration_node_count: usize,
218    pub call_node_count: usize,
219    pub return_node_count: usize,
220    pub return_value_count: usize,
221    pub exact_return_value_count: usize,
222    pub finite_set_return_value_count: usize,
223    pub raw_return_value_count: usize,
224    pub top_return_value_count: usize,
225    pub bottom_return_value_count: usize,
226    pub call_resolved_return_value_count: usize,
227    pub exact_call_resolved_return_value_count: usize,
228    pub finite_set_call_resolved_return_value_count: usize,
229    pub raw_call_resolved_return_value_count: usize,
230    pub top_call_resolved_return_value_count: usize,
231    pub bottom_call_resolved_return_value_count: usize,
232    pub call_argument_value_count: usize,
233    pub exact_call_argument_value_count: usize,
234    pub finite_set_call_argument_value_count: usize,
235    pub raw_call_argument_value_count: usize,
236    pub top_call_argument_value_count: usize,
237    pub bottom_call_argument_value_count: usize,
238    pub edge_count: usize,
239    pub recursive_edge_count: usize,
240    pub capped_recursive_call_count: usize,
241    pub max_stack_depth_observed: usize,
242    pub nodes: Vec<OmenaScssEvalCallReturnNodeV0>,
243    pub edges: Vec<OmenaScssEvalCallReturnEdgeV0>,
244}
245
246#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
247#[serde(rename_all = "camelCase")]
248pub struct OmenaScssEvalCallReturnNodeV0 {
249    pub node_key: StableNodeKeyV0,
250    pub kind: &'static str,
251    pub symbol_kind: &'static str,
252    pub role: &'static str,
253    pub name: Option<String>,
254    pub namespace: Option<String>,
255    pub parameter_names: Vec<String>,
256    pub parameter_values: Vec<OmenaScssEvalCallParameterValueV0>,
257    pub local_binding_values: Vec<OmenaScssEvalCallLocalBindingV0>,
258    pub argument_values: Vec<OmenaScssEvalCallArgumentValueV0>,
259    pub return_text: Option<String>,
260    pub return_value: Option<AbstractCssValueV0>,
261    pub return_value_kind: Option<&'static str>,
262    pub call_resolved_return_value: Option<AbstractCssValueV0>,
263    pub call_resolved_return_value_kind: Option<&'static str>,
264    pub body_has_control_flow: bool,
265    pub body_has_loop_control_flow: bool,
266    pub return_inside_loop_control_flow: bool,
267    pub return_loop_header_text: Option<String>,
268    pub return_loop_header_texts: Vec<String>,
269    pub return_loop_body_texts: Vec<String>,
270    pub return_condition_text: Option<String>,
271    pub return_negated_condition_texts: Vec<String>,
272    pub source_span_start: usize,
273    pub source_span_end: usize,
274    pub containing_declaration_node_key: Option<StableNodeKeyV0>,
275}
276
277#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
278#[serde(rename_all = "camelCase")]
279pub struct OmenaScssEvalCallParameterValueV0 {
280    pub name: String,
281    pub default_value_text: Option<String>,
282    pub default_value: Option<AbstractCssValueV0>,
283    pub default_value_kind: Option<&'static str>,
284}
285
286#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
287#[serde(rename_all = "camelCase")]
288pub struct OmenaScssEvalCallArgumentValueV0 {
289    pub name: Option<String>,
290    pub text: String,
291    pub value: AbstractCssValueV0,
292    pub value_kind: &'static str,
293}
294
295#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
296#[serde(rename_all = "camelCase")]
297pub struct OmenaScssEvalCallLocalBindingV0 {
298    pub name: String,
299    pub source_span_start: usize,
300    pub source_span_end: usize,
301    pub scope_span_start: usize,
302    pub scope_span_end: usize,
303    pub value_text: String,
304    pub value: AbstractCssValueV0,
305    pub value_kind: &'static str,
306}
307
308#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
309#[serde(rename_all = "camelCase")]
310pub struct OmenaScssEvalCallReturnEdgeV0 {
311    pub source_node_key: StableNodeKeyV0,
312    pub target_node_key: StableNodeKeyV0,
313    pub kind: &'static str,
314    pub recursive: bool,
315    pub capped_by_recursion_cap: bool,
316}