Skip to content

Commit b291f93

Browse files
committed
ogar-vocab: add KausalSpec::Constrains/Onchange (SPEC-ATC2-OGAR Arm B)
`@api.constrains` is a validation trigger and `@api.onchange` is a UI-side recompute trigger — both distinct from the persisted `Depends` recompute trigger, so they get their own sum-type variants rather than being folded into `Depends`. Extends the intra-crate exhaustive `kausal_spec_match_is_exhaustive` governance test (the COUNT_FUSE substitute for `#[non_exhaustive]`) to cover both new arms — this is the loud, by-design compile break the spec calls for when a new KausalSpec variant is added. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cg8DSUz1U4AvKqXiy9Xx2f
1 parent f8420b9 commit b291f93

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

crates/ogar-vocab/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,22 @@ pub enum KausalSpec {
600600
/// Field paths that trigger this action's recomputation.
601601
paths: Vec<String>,
602602
},
603+
/// `@api.constrains('a','b')` validation trigger — the method
604+
/// re-validates when any listed field changes. Semantically a
605+
/// VALIDATION, not a recompute (SPEC-ATC2-OGAR Arm B) — kept distinct
606+
/// from `Depends` so a downstream `kausal`-variant dispatch doesn't
607+
/// mistake a validation trigger for a persisted recompute trigger.
608+
Constrains {
609+
/// Field paths that trigger this action's (re-)validation.
610+
paths: Vec<String>,
611+
},
612+
/// `@api.onchange('a')` UI form recompute — fires client-side in the
613+
/// form view when a field changes (distinct from persisted `Depends`;
614+
/// SPEC-ATC2-OGAR Arm B).
615+
Onchange {
616+
/// Field paths that trigger this action's UI-side recompute.
617+
paths: Vec<String>,
618+
},
603619
/// `@api.depends_context` env-context keys.
604620
ContextDepends {
605621
/// Context keys that trigger recomputation.
@@ -6061,6 +6077,12 @@ mod tests {
60616077
KausalSpec::Depends {
60626078
paths: vec!["a.b".into()],
60636079
},
6080+
KausalSpec::Constrains {
6081+
paths: vec!["state".into()],
6082+
},
6083+
KausalSpec::Onchange {
6084+
paths: vec!["amount".into()],
6085+
},
60646086
KausalSpec::ContextDepends {
60656087
keys: vec!["lang".into()],
60666088
},
@@ -6071,6 +6093,8 @@ mod tests {
60716093
KausalSpec::StateGuard { .. } => {}
60726094
KausalSpec::LifecycleTrigger { .. } => {}
60736095
KausalSpec::Depends { .. } => {}
6096+
KausalSpec::Constrains { .. } => {}
6097+
KausalSpec::Onchange { .. } => {}
60746098
KausalSpec::ContextDepends { .. } => {}
60756099
KausalSpec::External => {}
60766100
}

0 commit comments

Comments
 (0)