byteor_pipeline_lower/diagnostics.rs
1#[cfg(feature = "alloc")]
2use alloc::string::String;
3#[cfg(feature = "alloc")]
4use alloc::vec::Vec;
5
6use byteor_pipeline_plan::{ExecutionTargetV1, PlanValidationDiagnosticV2};
7use byteor_pipeline_spec::{LaneKindV1, MergePolicyV1, PipelineSpecV1};
8
9/// Lowering report for the full-parity source contract.
10#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
11pub struct LowerReportV2 {
12 /// The lowered canonical spec.
13 pub spec: PipelineSpecV1,
14 /// Plan validation diagnostics gathered before lowering.
15 pub plan_diagnostics: Vec<PlanValidationDiagnosticV2>,
16 /// Lowering diagnostics describing inserted roles and other lowering actions.
17 pub lower_diagnostics: Vec<LowerDiagnosticV2>,
18}
19
20/// Structured categories for v2 lowering diagnostics.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
22#[serde(rename_all = "snake_case")]
23pub enum LowerDiagnosticCategoryV2 {
24 /// The authored source contract failed pre-lowering validation.
25 PlanValidation,
26 /// The requested lowering target did not match the authored target.
27 TargetMismatch,
28 /// The authored source payload did not match the selected target.
29 SourcePayloadMismatch,
30 /// Boundary bindings did not reference the required ingress or egress shapes.
31 BoundaryBinding,
32 /// The authored DAG or topology shape is not accepted by lowering.
33 DagShape,
34 /// The authored lane intent or option is not supported by the lowering target.
35 UnsupportedIntent,
36 /// The authored runtime policy combinations conflict.
37 PolicyConflict,
38 /// The lowered spec failed canonical validation.
39 SpecValidation,
40 /// An internal lowering invariant failed.
41 InternalInvariant,
42}
43
44/// Structured lowering diagnostics for v2 lowering.
45#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
46pub enum LowerDiagnosticV2 {
47 /// A bridge role was inserted to preserve lane-kind constraints.
48 InsertedBridge {
49 /// Bridge role name.
50 role: String,
51 /// RX lane name.
52 rx: String,
53 /// TX lane name.
54 tx: String,
55 /// Source lane kind.
56 from: LaneKindV1,
57 /// Destination lane kind.
58 to: LaneKindV1,
59 },
60
61 /// A router role was inserted for fanout.
62 InsertedRouter {
63 /// Router role name.
64 role: String,
65 /// RX lane name.
66 rx: String,
67 /// TX lane names.
68 tx: Vec<String>,
69 /// Fanout width.
70 consumers: u32,
71 },
72
73 /// A merge role was inserted for fan-in.
74 InsertedMerge {
75 /// Merge role name.
76 role: String,
77 /// RX lane names.
78 rx: Vec<String>,
79 /// TX lane name.
80 tx: String,
81 /// Merge policy.
82 policy: MergePolicyV1,
83 },
84
85 /// Lowering rejected the authored input for a structured reason.
86 Rejected {
87 /// Target being lowered.
88 target: ExecutionTargetV1,
89 /// Rejection category.
90 category: LowerDiagnosticCategoryV2,
91 /// Human-readable message.
92 message: String,
93 },
94}