Skip to main content

Module conditional

Module conditional 

Source
Expand description

Deterministic realization of a conditional step’s closed-vocabulary when guard — mirrors dispatcher/claude-agent-sdk/src/conditional.ts field-for-field (see that module’s doc for the full R1 repair-fold-into-loop / R2 guarded-skip design).

This module is deliberately not wired into this back-end’s actual static-file emission (emit.rs): the Claude Code CLI target has no deterministic runtime, so its conditional/repair behavior is entirely textual — the live CLI agent judges the guard emergently from the emitted prompt text (see ir.rs‘s LlmCall::when doc comment), not from an evaluator like this one. No existing profile calls into this module; it exists solely so the two back-ends’ understanding of the SAME closed guard vocabulary can be held to a shared conformance fixture (dispatcher/conformance-fixtures/conditional.json, asserted against here and against conditional.ts) — a semantic drift between them fails whichever suite moved.

Structs§

GuardState
StepIdentity
The subset of a step’s identity this module needs: its name (an on_failure target) and the slot its output would land in (an on_failure-repair shape also requires it to be consumed).

Enums§

ConditionalDecision
StepOutcome

Constants§

DEFAULT_MAX_REPAIR_ATTEMPTS
Default bound on repair attempts. Not (yet) an IR field — max_attempts is not part of the schema either back-end reads — so this mirrors conditional.ts’s back-end-local runtime constant.

Functions§

classify_conditional_step
The single entry point a staged executor would use to decide what a conditional step does next: fold into a bounded repair turn (R1), run (R2 guard true), or skip (R2 guard false / R1 target didn’t fail).
evaluate_guard
Evaluate a guard’s truth value directly (R2 — guarded-skip). Does not special-case the R1 repair shape; callers that need to distinguish repair-fold from a plain on_failure skip should use classify_conditional_step instead.
repair_fold_target
Structural test for the R1 repair shape: an on_failure guard whose target is preceding_step, where that step’s sole produced artifact is also consumed by the conditional step. Returns the target’s identity when the shape matches, else None (falls back to R2 guarded-skip).
run_repair_loop
Drive a bounded repair loop: call attempt_failed up to max_attempts times (1-indexed), stopping at the first attempt that reports success. Mirrors conditional.ts’s runRepairLoop: returns (recovered, attempts) and never loops past max_attempts — exhaustion is reported back (recovered = false) for the caller to loud-fail, not swallowed here.