Skip to main content

omena_scss_eval/control_flow/
model.rs

1use omena_abstract_value::{AbstractClassValueV0, 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 OmenaScssEvalControlFlowPropagationDepthWitnessV0 {
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#[deprecated(
150    since = "0.4.0",
151    note = "use OmenaScssEvalControlFlowPropagationDepthWitnessV0; this witness measures propagation depth, not widening"
152)]
153pub type OmenaScssEvalControlFlowWideningWitnessV0 =
154    OmenaScssEvalControlFlowPropagationDepthWitnessV0;
155
156#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
157#[serde(rename_all = "camelCase")]
158pub struct OmenaScssEvalControlFlowAscendingChainWitnessV0 {
159    pub schema_version: &'static str,
160    pub product: &'static str,
161    pub mode: &'static str,
162    pub value_type: &'static str,
163    pub policy: &'static str,
164    pub max_iterations: usize,
165    pub node_count: usize,
166    pub converged: bool,
167    pub iteration_count: usize,
168    pub solver_product: &'static str,
169    pub context_sensitivity: &'static str,
170    pub result_node_id: &'static str,
171    pub result_kind: &'static str,
172    pub result_value: AbstractClassValueV0,
173    pub output_top_count: usize,
174}
175
176#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
177#[serde(rename_all = "camelCase")]
178pub struct OmenaScssEvalTypedValueLatticeWitnessV0 {
179    pub schema_version: &'static str,
180    pub product: &'static str,
181    pub mode: &'static str,
182    pub value_type: &'static str,
183    pub payload_type: &'static str,
184    pub policy: &'static str,
185    pub sample_value_count: usize,
186    pub typed_payload_count: usize,
187    pub raw_value_count: usize,
188    pub untyped_exact_or_finite_count: usize,
189    pub typed_coverage_basis_points: usize,
190    pub typed_advisory_comparison_count: usize,
191    pub typed_advisory_true_count: usize,
192    pub divergence_count: usize,
193    pub corpus_fixture_count: usize,
194    pub typed_decided_fixture_count: usize,
195    pub typed_prune_consumer_enabled: bool,
196    pub type_kind_counts: Vec<OmenaScssEvalTypedValueKindCountV0>,
197}
198
199#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
200#[serde(rename_all = "camelCase")]
201pub struct OmenaScssEvalTypedValueKindCountV0 {
202    pub kind: &'static str,
203    pub count: usize,
204}
205
206#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
207#[serde(rename_all = "camelCase")]
208pub struct OmenaScssEvalControlFlowValueBlockV0 {
209    pub node_key: StableNodeKeyV0,
210    pub kind: &'static str,
211    pub transfer_kind: &'static str,
212    pub transfer_value: Option<AbstractCssValueV0>,
213    pub transfer_value_kind: Option<&'static str>,
214    pub transfer_truthiness: Option<&'static str>,
215    pub predecessor_node_keys: Vec<StableNodeKeyV0>,
216    pub loop_carried_bindings: Vec<String>,
217    pub loop_carried_binding_values: Vec<OmenaScssEvalControlFlowBindingValueV0>,
218    pub input_value: AbstractCssValueV0,
219    pub input_value_kind: &'static str,
220    pub output_value: AbstractCssValueV0,
221    pub output_value_kind: &'static str,
222}
223
224#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
225#[serde(rename_all = "camelCase")]
226pub struct OmenaScssEvalControlFlowBindingValueV0 {
227    pub name: String,
228    pub value: AbstractCssValueV0,
229    pub value_kind: &'static str,
230}
231
232#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
233#[serde(rename_all = "camelCase")]
234pub struct OmenaScssEvalCallReturnIrSummaryV0 {
235    pub schema_version: &'static str,
236    pub product: &'static str,
237    pub mode: &'static str,
238    pub dialect: &'static str,
239    pub node_key_type: &'static str,
240    pub recursion_cap: usize,
241    pub flat_css_cfg_built: bool,
242    pub merged_cross_file_graph: bool,
243    pub node_count: usize,
244    pub declaration_node_count: usize,
245    pub call_node_count: usize,
246    pub return_node_count: usize,
247    pub return_value_count: usize,
248    pub exact_return_value_count: usize,
249    pub finite_set_return_value_count: usize,
250    pub raw_return_value_count: usize,
251    pub top_return_value_count: usize,
252    pub bottom_return_value_count: usize,
253    pub call_resolved_return_value_count: usize,
254    pub exact_call_resolved_return_value_count: usize,
255    pub finite_set_call_resolved_return_value_count: usize,
256    pub raw_call_resolved_return_value_count: usize,
257    pub top_call_resolved_return_value_count: usize,
258    pub bottom_call_resolved_return_value_count: usize,
259    pub call_argument_value_count: usize,
260    pub exact_call_argument_value_count: usize,
261    pub finite_set_call_argument_value_count: usize,
262    pub raw_call_argument_value_count: usize,
263    pub top_call_argument_value_count: usize,
264    pub bottom_call_argument_value_count: usize,
265    pub edge_count: usize,
266    pub recursive_edge_count: usize,
267    pub capped_recursive_call_count: usize,
268    pub max_stack_depth_observed: usize,
269    pub nodes: Vec<OmenaScssEvalCallReturnNodeV0>,
270    pub edges: Vec<OmenaScssEvalCallReturnEdgeV0>,
271}
272
273#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
274#[serde(rename_all = "camelCase")]
275pub struct OmenaScssEvalCallReturnNodeV0 {
276    pub node_key: StableNodeKeyV0,
277    pub kind: &'static str,
278    pub symbol_kind: &'static str,
279    pub role: &'static str,
280    pub name: Option<String>,
281    pub namespace: Option<String>,
282    pub parameter_names: Vec<String>,
283    pub parameter_values: Vec<OmenaScssEvalCallParameterValueV0>,
284    pub local_binding_values: Vec<OmenaScssEvalCallLocalBindingV0>,
285    pub argument_values: Vec<OmenaScssEvalCallArgumentValueV0>,
286    pub return_text: Option<String>,
287    pub return_value: Option<AbstractCssValueV0>,
288    pub return_value_kind: Option<&'static str>,
289    pub call_resolved_return_value: Option<AbstractCssValueV0>,
290    pub call_resolved_return_value_kind: Option<&'static str>,
291    pub body_has_control_flow: bool,
292    pub body_has_loop_control_flow: bool,
293    pub return_inside_loop_control_flow: bool,
294    pub return_loop_header_text: Option<String>,
295    pub return_loop_header_texts: Vec<String>,
296    pub return_loop_body_texts: Vec<String>,
297    pub return_condition_text: Option<String>,
298    pub return_negated_condition_texts: Vec<String>,
299    pub source_span_start: usize,
300    pub source_span_end: usize,
301    pub containing_declaration_node_key: Option<StableNodeKeyV0>,
302}
303
304#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
305#[serde(rename_all = "camelCase")]
306pub struct OmenaScssEvalCallParameterValueV0 {
307    pub name: String,
308    pub default_value_text: Option<String>,
309    pub default_value: Option<AbstractCssValueV0>,
310    pub default_value_kind: Option<&'static str>,
311}
312
313#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
314#[serde(rename_all = "camelCase")]
315pub struct OmenaScssEvalCallArgumentValueV0 {
316    pub name: Option<String>,
317    pub text: String,
318    pub value: AbstractCssValueV0,
319    pub value_kind: &'static str,
320}
321
322#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
323#[serde(rename_all = "camelCase")]
324pub struct OmenaScssEvalCallLocalBindingV0 {
325    pub name: String,
326    pub source_span_start: usize,
327    pub source_span_end: usize,
328    pub scope_span_start: usize,
329    pub scope_span_end: usize,
330    pub value_text: String,
331    pub value: AbstractCssValueV0,
332    pub value_kind: &'static str,
333}
334
335#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
336#[serde(rename_all = "camelCase")]
337pub struct OmenaScssEvalCallReturnEdgeV0 {
338    pub source_node_key: StableNodeKeyV0,
339    pub target_node_key: StableNodeKeyV0,
340    pub kind: &'static str,
341    pub recursive: bool,
342    pub capped_by_recursion_cap: bool,
343}