Relationships
#4765 validate: spurious ambiguous-exit warnings for evidence absent in this stage/cycle, and for complementary cel comparisons
Opened by rcrowley · 11/15/2026· Shipped 11/16/2026
Summary
validate gives ambiguous-exit warnings for sibling transitions that are exclusive. The exclusive() check in _lib/engine/graph.ts does not recognize two common gate forms:
- A CEL test that the evidence is absent in this stage and cycle, compared with an
evidence-recordedgate on the same evidence. - Complementary CEL comparisons, for example
x >= 2andx < 2.
Case 1: evidence absent in this stage and cycle
exclusive() sees that an evidence-recorded gate and a cel gate are exclusive only when absentEvidence() finds !("x" in evidence) or !has(evidence.x) at the top level of the expression.
But evidence-recorded passes only on evidence that was recorded in this stage and cycle. The evidence map in CEL holds the latest record of each name in the era, from any cycle. Thus !("x" in evidence) is not the complement of evidence-recorded. It is stricter: when one round records the evidence, the gate also fails in all of the rounds after it. The correct complement is:
- type: cel
config:
expr: >-
!("review-feedback" in evidence &&
evidence["review-feedback"].stage == stage.id &&
evidence["review-feedback"].cycle == stage.cycle)absentEvidence() does not recognize this form, because the negation wraps a conjunction. Thus the checker accepts only the incorrect gate, and it gives a warning for the correct gate.
Reproduction
Stage review has these transitions. The cel gate is on each automatic exit, and revise gates on evidence-recorded:
- id: review
transitions:
- name: accept
to: deliver
gates:
- type: cel
config:
expr: >-
!("review-feedback" in evidence &&
evidence["review-feedback"].stage == stage.id &&
evidence["review-feedback"].cycle == stage.cycle)
- type: findings-clear
config: { artifact: review, blocking: [critical, high] }
- type: cel
config:
expr: artifacts["review"].version >= 2
- name: again
to: review
gates:
- type: cel
config:
expr: >-
!("review-feedback" in evidence &&
evidence["review-feedback"].stage == stage.id &&
evidence["review-feedback"].cycle == stage.cycle)
- type: findings-clear
config: { artifact: review, blocking: [critical, high] }
- type: cel
config:
expr: artifacts["review"].version < 2
- name: revise
to: research
gates:
- type: evidence-recorded
config: { name: review-feedback }swamp behavior run <factory> validate logs:
stages.2.transitions.0 (from stage 'review'): transition 'accept' (to 'deliver') and transition 'revise' (to 'research') from stage 'review' can both pass with no person choosing between them; their cel gates could not be compared; make one manual, give it a human-approval gate without when, or make their gates exclusive
stages.2.transitions.1 (from stage 'review'): transition 'again' (to 'review') and transition 'revise' (to 'research') from stage 'review' can both pass with no person choosing between them; their cel gates could not be compared; make one manual, give it a human-approval gate without when, or make their gates exclusiveExpected
There are no warnings. When evidence-recorded on x passes, x is in evidence with stage == stage.id and cycle == stage.cycle, so the cel gate is false.
Suggested fix
In absentEvidence(), also accept !(A && ...) where one term is "x" in evidence or has(evidence.x), and all of the other terms are evidence.x.stage == stage.id or evidence.x.cycle == stage.cycle, in either operand order. Also accept the De Morgan form: !("x" in evidence) || evidence.x.stage != stage.id || evidence.x.cycle != stage.cycle.
Case 2: complementary CEL comparisons
accept and again above gate on artifacts["review"].version >= 2 and artifacts["review"].version < 2. These can never both pass, but validate logs:
stages.2.transitions.0 (from stage 'review'): transition 'accept' (to 'deliver') and transition 'again' (to 'review') from stage 'review' can both pass with no person choosing between them; their cel gates could not be compared; make one manual, give it a human-approval gate without when, or make their gates exclusiveExpected
There is no warning when two sibling cel gates compare the same operand with the same constant using complementary operators (< with >=, <= with >, == with !=), or when one expression is exactly !(<other>).
Workaround
None that keeps the same behavior. The max-cycles pair for case 2 counts stage entries, not artifact versions. Case 1 requires a manual transition or a human-approval gate, which changes the factory.
Environment
- swamp
20261114.210101.0-sha.537e03d1 @swamp/stagecraft2026.11.12.1
Related: #2655 (another false positive in the ambiguous-exit exclusivity check).
Upstream repository: https://github.com/swamp-club/swamp-extensions
Environment
- Extension:
@swamp/stagecraft@2026.11.13.1 - swamp:
20261114.210101.0-sha.537e03d1 - OS:
linux(aarch64) - Deno:
2.9.8 - Shell:
/usr/bin/zsh
Shipped
Click a lifecycle step above to view its details.
rcrowley commented 11/15/2026, 6:04:23 AM
Case 3: equality with different constants
Sibling cel gates that compare the same operand with == to different constants are also exclusive, but validate gives a warning for them. This case is not the same as the complementary comparisons in case 2 (< with >=, == with !=).
Reproduction
- id: intake
transitions:
- name: from-ticket
to: plan
gates:
- type: cel
config:
expr: artifacts["intake"].payload.origin == "ticket"
- name: from-request
to: plan
gates:
- type: cel
config:
expr: >-
artifacts["intake"].payload.origin == "request" &&
"request" in artifacts["intake"].payload
- name: from-patch
to: develop
gates:
- type: cel
config:
expr: artifacts["intake"].payload.origin == "patch"validate logs:
stages.0.transitions.0 (from stage 'intake'): transition 'from-ticket' (to 'plan') and transition 'from-patch' (to 'develop') from stage 'intake' can both pass with no person choosing between them; their cel gates could not be compared; make one manual, give it a human-approval gate without when, or make their gates exclusive
stages.0.transitions.1 (from stage 'intake'): transition 'from-request' (to 'plan') and transition 'from-patch' (to 'develop') from stage 'intake' can both pass with no person choosing between them; their cel gates could not be compared; make one manual, give it a human-approval gate without when, or make their gates exclusive(from-ticket and from-request go to the same stage, so the check skips that pair.)
Expected
There is no warning when two sibling cel gates each have a term X == c1 and X == c2, with the same operand X and different literal constants. Each term must be the whole expression or a term of its top-level &&.
Workaround
Today the checker compares field values only in evidence-recorded gates, through requireField and match. To remove these warnings, the factory must record origin a second time, as evidence, only for the gates. No gate compares the fields of an artifact.
Sign in to post a ripple.