Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
fix/Lifted-outcome-taint · L-261009-8c82d5 (#1404)
Louis Choquel3ee25d67d196
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7728d70cf..abd2e4e6c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,8 @@### Fixed- **A Google client's close at teardown is no longer garbage-collected**: when a Google LLM or image-generation worker was torn down inside a running event loop, nothing but the loop referenced the background task closing its async client, and a loop holds its tasks weakly, so the task could be collected before the client was closed, with the `asyncio` error `Task was destroyed but it is pending!`. Each close task is now held until it is done.+- **A condition whose outcome may be skipped declares it**: a PipeCondition routing to an outcome pipe that takes plainly an input the condition declares optional must declare its own output optional, and is refused with `optional_not_handled` otherwise, since a run without that input skips the outcome and resolves the condition's output absent; an outcome the condition's expression chooses only with that input present declares it forced (`!`) instead, since validation does not read the expression. Every name such an outcome always stores in its caller's memory counts as maybe-absent too, so a sequence binding one into a plain output is refused where it used to validate and then resolve absent; the outcome is listed in `liftable_pipes` under its condition, and a `!` input on an outcome counts in the `optional_force_redundant` lint.+- **A sequence step that may be skipped keeps what its run may store**: a step an absent input may lift, whose pipe stores a name on some runs only, now leaves that name maybe-absent when a run may store an absence there, so a sequence binding it into a plain output is refused with `optional_not_handled` rather than validating and then resolving absent.### Securitydiff --git a/docs/building-methods/pipes/pipe-controllers/PipeCondition.md b/docs/building-methods/pipes/pipe-controllers/PipeCondition.mdindex b35a5a000..3bd9a231f 100644--- a/docs/building-methods/pipes/pipe-controllers/PipeCondition.md+++ b/docs/building-methods/pipes/pipe-controllers/PipeCondition.md@@ -153,7 +153,7 @@ Beside pipe names, an outcome (or the `default_outcome`) can be one of two speci- **`fail`**: the run fails loudly with an error naming the pipe. Use it to make "this should never happen" branches explicit. The failure is a refusal written into your method, so a hosted run answers it with HTTP 422 and keeps its message, with a next step, under STRICT disclosure. The message leaves out the value the expression rendered, which the run's execution graph keeps: that value can be text of a condition a host's library declared.- **`continue`**: the condition declares that it produced **no output**. The runtime records an absence for the declared output, whose reason names the condition and its `continue` outcome, and the run continues as a success — the rest of the working memory is unchanged. The reason leaves out the value the expression rendered, which the run's execution graph keeps, for the same reason a `fail` outcome's message does: a pipe that later requires the output quotes the reason to the caller.-Because `continue` resolves the declared output as absent, a `continue`-reachable condition (any outcome mapped to `continue`, or `default_outcome = "continue"`) **must declare its output optional** — `output = "Constraint?"`. Validation enforces this statically (`optional_output_required`), so the no-output path is always visible to the type system. The same visibility rule applies at the condition's boundary: if a mapped outcome pipe declares an optional output, the condition must declare `?` too (`optional_not_handled`).+Because `continue` resolves the declared output as absent, a `continue`-reachable condition (any outcome mapped to `continue`, or `default_outcome = "continue"`) **must declare its output optional** — `output = "Constraint?"`. Validation enforces this statically (`optional_output_required`), so the no-output path is always visible to the type system. The same visibility rule applies at the condition's boundary: if a mapped outcome pipe declares an optional output, the condition must declare `?` too (`optional_not_handled`). So must a condition whose outcome pipe takes plainly an input the condition declares optional: when that input is absent, the chosen outcome is skipped and the condition's output resolves absent, along with every name the outcome would have stored in the caller's memory. A list output is the exception, since a skipped list output is an empty list. Validation does not read the expression, so a condition that chooses such an outcome only when the input is present, as `{{ 'with_flag' if flag is defined else 'no_flag' }}` does, is refused as well: declare the input forced on that outcome, `flag = "Text!"`, which says the outcome never runs without it and fails the run loudly if it ever does.### What happens downstream of `continue`diff --git a/docs/building-methods/pipes/understanding-optionality.md b/docs/building-methods/pipes/understanding-optionality.mdindex c1e26e35c..e3c53860e 100644--- a/docs/building-methods/pipes/understanding-optionality.md+++ b/docs/building-methods/pipes/understanding-optionality.md@@ -84,8 +84,8 @@ The guard-lint covers every pipe that renders authored templates over its inputsEach controller has a defined behavior when a value inside its flow resolves absent:-- **PipeSequence** — steps consuming an absent value plainly are lifted (skipped), and the absence propagates step to step. The sequence's own declared output must account for it: if the last producing step can be lifted, the sequence output must be declared `?` (otherwise `optional_not_handled`). A name a nested sequence, a condition's outcome or an `add_each_output` parallel stores in the sequence's memory carries its absence the same way, and a nested controller that is lifted records an absence for every name it always stores (an empty list for a list), so a later step reading one is lifted in turn.-- **PipeCondition** — the `continue` outcome resolves the declared output as a **declared-absent** record (memory otherwise unchanged). A condition that can reach `continue` must declare its output `?` (`optional_output_required`). See [PipeCondition](pipe-controllers/PipeCondition.md).+- **PipeSequence** — steps consuming an absent value plainly are lifted (skipped), and the absence propagates step to step. The sequence's own declared output must account for it: if the last producing step can be lifted, the sequence output must be declared `?` (otherwise `optional_not_handled`). A name a nested sequence, a condition's outcome or an `add_each_output` parallel stores in the sequence's memory carries its absence the same way, and a nested controller that is lifted records an absence for every name it always stores (an empty list for a list), so a later step reading one is lifted in turn. A step that may be lifted may also run, so a name it stores on some runs only may hold either what it held before or the absence a run leaves there.+- **PipeCondition** — the `continue` outcome resolves the declared output as a **declared-absent** record (memory otherwise unchanged). A condition that can reach `continue` must declare its output `?` (`optional_output_required`). An outcome that takes plainly an input the condition declares `?` is lifted when it is chosen with that input absent: the condition's output then resolves absent, so the condition must declare it `?` (`optional_not_handled`), and every name the outcome always stores in the caller's memory may hold an absence too. An outcome the expression chooses only when the input is present declares it forced (`!`) instead, since validation does not read the expression. See [PipeCondition](pipe-controllers/PipeCondition.md).- **PipeParallel** — combining under absence: a `Composite` output omits the absent component (with a ledger note); a structured output absorbs an absent branch into a non-required field as that field's declared default; a **required** field fed by a maybe-absent branch is rejected statically (`optional_branch_required_field`). See [PipeParallel](pipe-controllers/PipeParallel.md).- **PipeBatch** — absent branch results are **compacted** out of the aggregated list (a list cannot hold a hole). See [PipeBatch](pipe-controllers/PipeBatch.md).diff --git a/pipelex/pipe_controllers/absence_taint.py b/pipelex/pipe_controllers/absence_taint.pyindex 184e1a2b4..5efe3b75a 100644--- a/pipelex/pipe_controllers/absence_taint.py+++ b/pipelex/pipe_controllers/absence_taint.py@@ -12,9 +12,9 @@ Plural slots are never tainted (D4): a skipped plural output normalizes to an embatched step compacts absent branch results, so a list slot is always guaranteed (possibly empty).The walk logic itself lives on the controllers (`PipeSequence.analyze_taint`,-`PipeParallel.analyze_branch_taint`); this module holds the shared value objects and the-presence-resolution helper so the pipeline layer (liftable-pipe inventory) can consume the-same shapes without importing controller internals. `SlotTaint` itself lives in+`PipeParallel.analyze_branch_taint`, `PipeCondition.analyze_outcome_taint`); this module holds+the shared value objects and the presence-resolution helpers so the pipeline layer+(liftable-pipe inventory) can consume the same shapes without importing controller internals. `SlotTaint` itself lives in`pipelex.pipe_machinery.memory_writes`, beside the model of what a nested controller stores inits caller's memory, which carries it."""@@ -77,6 +77,14 @@ class ParallelTaintAnalysis:force_consumptions: tuple[ForceConsumptionInfo, ...] = ()+@dataclass(frozen=True)+class ConditionTaintAnalysis:+ """Result of the taint walk over a PipeCondition's outcomes: which outcome its own `?` inputs may lift."""++ liftable_steps: tuple[LiftableStepInfo, ...]+ force_consumptions: tuple[ForceConsumptionInfo, ...] = ()++class TaintTriggerScan(NamedTuple):"""How a pipe consumes the currently tainted slots: the plain-consumed (lift-trigger)variable names, the first trigger's taint (for provenance chaining), and the `!`@@ -90,6 +98,19 @@ class TaintTriggerScan(NamedTuple):redundant_force_names: tuple[str, ...] = ()+def optional_input_taints(*, pipe: PipeAbstract) -> dict[str, SlotTaint]:+ """The slots a controller's own frame may find absent: each single input it declares optional (`?`).++ An input it declares plain or `!` is present inside it, since an absence there lifts the controller or fails it at its+ boundary, and a list input is never absent (D4).+ """+ return {+ input_name: SlotTaint(source=f"optional input '{input_name}' of pipe '{pipe.code}'", origin_slot_name=input_name)+ for input_name, stuff_spec in pipe.inputs.root.items()+ if stuff_spec.presence.is_optional and not stuff_spec.is_multiple()+ }++def scan_taint_triggers(pipe: PipeAbstract, *, slot_taints: dict[str, SlotTaint], visited_pipes: set[str] | None = None) -> TaintTriggerScan:"""Apply the D3 trichotomy to a pipe's needed inputs against the given taint map.diff --git a/pipelex/pipe_controllers/condition/pipe_condition.py b/pipelex/pipe_controllers/condition/pipe_condition.pyindex b5f4e1718..d35d3016f 100644--- a/pipelex/pipe_controllers/condition/pipe_condition.py+++ b/pipelex/pipe_controllers/condition/pipe_condition.py@@ -16,10 +16,20 @@ from pipelex.core.stuffs.stuff import Stufffrom pipelex.graph.condition_output_merge import ConditionOutputMerge, ConditionOutputTypingfrom pipelex.graph.graph_tracer_manager import GraphTracerManagerfrom pipelex.interpreter_hub import get_optional_pipe, get_pipe_router, get_required_pipe+from pipelex.pipe_controllers.absence_taint import (+ ConditionTaintAnalysis,+ ForceConsumptionInfo,+ LiftableStepInfo,+ TaintTriggerScan,+ is_plural_step_result,+ optional_input_taints,+ scan_taint_triggers,+)from pipelex.pipe_controllers.condition.pipe_condition_blueprint import describe_expression_parse_failurefrom pipelex.pipe_controllers.condition.special_outcome import SpecialOutcomefrom pipelex.pipe_controllers.pipe_controller import PipeController-from pipelex.pipe_machinery.memory_writes import AlternativeWrites, MemoryWrite, merge_alternative_writes+from pipelex.pipe_machinery.memory_writes import AlternativeWrites, MemoryWrite, SlotTaint, merge_alternative_writes, write_after_lift+from pipelex.pipe_machinery.pipe_abstract import PipeAbstractfrom pipelex.pipe_machinery.template_guard_lint import lint_authored_templatefrom pipelex.pipe_run.pipe_job_factory import PipeJobFactoryfrom pipelex.pipe_run.pipe_run_params import PipeRunParams, output_multiplicity_to_apply@@ -101,30 +111,103 @@ class PipeCondition(PipeController):The outcomes are merged as alternatives (`merge_alternative_writes`): a name is always written only if every outcomethat can run stores it, may hold an absence if any outcome may leave one, and keeps a spec only if every outcomestoring it stores the same one, recording otherwise which outcome stores which spec, so that a binding reading the name- is refused before the run. A `continue` outcome stores nothing, a `fail` outcome stops the run, and an outcome- pipe that does not resolve is left out, as a sequence assumes an unresolved pipe delivers. The alias the condition- may add is left out too: the working memory refuses an alias over a name it already holds, so it never replaces a- value the flow types.+ is refused before the run. An outcome that the condition's own `?` inputs may lift (`analyze_outcome_taint`) may leave+ an absence under every single name it always stores, since its lift resolves them so (`write_after_lift`). A `continue`+ outcome stores nothing, a `fail` outcome stops the run, and an outcome pipe that does not resolve is left out, as a+ sequence assumes an unresolved pipe delivers. The alias the condition may add is left out too: the working memory+ refuses an alias over a name it already holds, so it never replaces a value the flow types."""if visited_pipes is None:visited_pipes = set()if self.visit_key in visited_pipes:return {}visited_pipes_with_current = visited_pipes | {self.visit_key}+ input_taints = optional_input_taints(pipe=self)outcome_writes: list[AlternativeWrites] = []for outcome_pipe_code in sorted(self.pipe_dependencies()):outcome_pipe = get_optional_pipe(pipe_code=outcome_pipe_code)- if outcome_pipe is not None:- outcome_writes.append(- AlternativeWrites(- label=f"outcome '{outcome_pipe.code}' of pipe '{self.code}'",- writes=outcome_pipe.memory_writes(visited_pipes=visited_pipes_with_current),- )- )+ if outcome_pipe is None:+ continue+ writes = outcome_pipe.memory_writes(visited_pipes=visited_pipes_with_current)+ if writes and input_taints:+ trigger_scan = scan_taint_triggers(outcome_pipe, slot_taints=input_taints, visited_pipes=visited_pipes_with_current)+ writes = self._writes_after_outcome_lift(outcome_pipe=outcome_pipe, writes=writes, trigger_scan=trigger_scan)+ outcome_writes.append(AlternativeWrites(label=f"outcome '{outcome_pipe.code}' of pipe '{self.code}'", writes=writes))if self._continue_reachable:outcome_writes.append(AlternativeWrites(label=f"the `continue` outcome of pipe '{self.code}'", writes={}))return merge_alternative_writes(alternatives=outcome_writes)+ @classmethod+ def _writes_after_outcome_lift(+ cls, *, outcome_pipe: PipeAbstract, writes: dict[str, MemoryWrite], trigger_scan: TaintTriggerScan+ ) -> dict[str, MemoryWrite]:+ """What an outcome stores, joined with its lift when it consumes plain one of the condition's `?` inputs."""+ trigger_taint = trigger_scan.trigger_taint+ if trigger_taint is None:+ return writes+ return {+ written_name: write_after_lift(+ memory_write=memory_write,+ lift_taint=SlotTaint(+ source=trigger_taint.source,+ origin_slot_name=trigger_taint.origin_slot_name,+ chain=(+ *trigger_taint.chain,+ f"pipe '{outcome_pipe.code}' may be skipped when '{trigger_scan.trigger_names[0]}' is absent → slot '{written_name}'",+ ),+ ),+ )+ for written_name, memory_write in writes.items()+ }++ def analyze_outcome_taint(self, *, visited_pipes: set[str] | None = None) -> ConditionTaintAnalysis:+ """Static taint over the outcomes (D6): which outcome the condition's own `?` inputs may lift.++ Within the condition's frame the maybe-absent slots are exactly its own `?`-declared inputs, as in a parallel's: a+ maybe-absent slot it declares plain lifts the whole condition, which is its caller's concern. An outcome consuming one+ of them plain is lifted when it is chosen with that input absent, which resolves the condition's result, and every+ name the outcome always stores, to an absence, or to an empty list for a list (D4).++ Args:+ visited_pipes: The recursion guard of the walk this one runs inside, handed to each outcome's needed inputs;+ `None` for a walk of its own.+ """+ liftable_steps: list[LiftableStepInfo] = []+ force_consumptions: list[ForceConsumptionInfo] = []+ for outcome_pipe, trigger_scan in self._outcome_trigger_scans(visited_pipes=visited_pipes):+ for asserting_name in trigger_scan.asserting_force_names:+ force_consumptions.append(+ ForceConsumptionInfo(+ within_pipe_ref=self.pipe_ref, pipe_ref=outcome_pipe.pipe_ref, variable_name=asserting_name, is_asserting=True+ )+ )+ for redundant_name in trigger_scan.redundant_force_names:+ force_consumptions.append(+ ForceConsumptionInfo(+ within_pipe_ref=self.pipe_ref, pipe_ref=outcome_pipe.pipe_ref, variable_name=redundant_name, is_asserting=False+ )+ )+ if trigger_scan.trigger_taint is not None:+ liftable_steps.append(+ LiftableStepInfo(+ within_pipe_ref=self.pipe_ref,+ pipe_ref=outcome_pipe.pipe_ref,+ trigger_variable_names=trigger_scan.trigger_names,+ absence_source=trigger_scan.trigger_taint.source,+ )+ )+ return ConditionTaintAnalysis(liftable_steps=tuple(liftable_steps), force_consumptions=tuple(force_consumptions))++ def _outcome_trigger_scans(self, *, visited_pipes: set[str] | None) -> list[tuple[PipeAbstract, TaintTriggerScan]]:+ """How each outcome pipe that resolves consumes the condition's `?` inputs, in the order of the outcome pipe codes."""+ input_taints = optional_input_taints(pipe=self)+ trigger_scans: list[tuple[PipeAbstract, TaintTriggerScan]] = []+ for outcome_pipe_code in sorted(self.pipe_dependencies()):+ outcome_pipe = get_optional_pipe(pipe_code=outcome_pipe_code)+ if outcome_pipe is not None:+ trigger_scans.append((outcome_pipe, scan_taint_triggers(outcome_pipe, slot_taints=input_taints, visited_pipes=visited_pipes)))+ return trigger_scans+@overridedef needed_inputs(self, *, visited_pipes: set[str] | None = None) -> InputStuffSpecs:if visited_pipes is None:@@ -246,6 +329,33 @@ class PipeCondition(PipeController):pipe_code=self.code,provided_concept_code=self.output.concept.concept_ref,)+ # An outcome that the condition's own `?` inputs may lift resolves the condition's result absent, unless the+ # result is a list, which the lift leaves empty (D4). The expression is not read, so an outcome it chooses only+ # when the input is present is refused too, and forcing the input on that outcome (`!`) is the guarded remedy.+ for outcome_pipe, trigger_scan in self._outcome_trigger_scans(visited_pipes=None):+ if trigger_scan.trigger_taint is None:+ continue+ if is_plural_step_result(outcome_pipe, step_output_multiplicity=None, has_batch_params=False):+ continue+ trigger_name = trigger_scan.trigger_names[0]+ msg = (+ f"PipeCondition '{self.code}' maps outcome pipe '{outcome_pipe.code}', which is skipped when its input "+ f"'{trigger_name}' is absent, and the condition declares '{trigger_name}' optional, so a run without it "+ f"resolves the condition's output absent, but that output '{self.output.concept.concept_ref}' is not declared "+ f"optional. Declare the condition's output optional ('{self.output.concept.concept_ref}?') so the maybe-absent "+ f"result stays visible downstream, or declare '{trigger_name}' optional on '{outcome_pipe.code}' and handle "+ f"its absence there. When the condition's expression chooses '{outcome_pipe.code}' only with '{trigger_name}' "+ f"present, which validation does not read, declare '{trigger_name}' forced on '{outcome_pipe.code}' with '!', "+ "so that a run reaching it without the input fails instead of resolving the output absent."+ )+ raise PipeValidationError(+ message=msg,+ error_type=PipeValidationErrorType.OPTIONAL_NOT_HANDLED,+ domain_code=self.domain_code,+ pipe_code=self.code,+ provided_concept_code=self.output.concept.concept_ref,+ variable_names=[trigger_name],+ )# Collect all unique output concept refs from mapped pipesmapped_output_refs: set[str] = set()diff --git a/pipelex/pipe_controllers/parallel/pipe_parallel.py b/pipelex/pipe_controllers/parallel/pipe_parallel.pyindex 833684a0a..d44e217d5 100644--- a/pipelex/pipe_controllers/parallel/pipe_parallel.py+++ b/pipelex/pipe_controllers/parallel/pipe_parallel.py@@ -33,6 +33,7 @@ from pipelex.pipe_controllers.absence_taint import (LiftableStepInfo,ParallelTaintAnalysis,is_plural_step_result,+ optional_input_taints,scan_taint_triggers,)from pipelex.pipe_controllers.pipe_controller import PipeController@@ -293,14 +294,7 @@ class PipeParallel(PipeController):visited_pipes: The recursion guard of the walk this one runs inside, `memory_writes`'s, handed to each branch'sneeded inputs; `None` for a walk of its own."""- optional_input_taints: dict[str, SlotTaint] = {}- for input_name, stuff_spec in self.inputs.root.items():- if stuff_spec.presence.is_optional and not stuff_spec.is_multiple():- optional_input_taints[input_name] = SlotTaint(- source=f"optional input '{input_name}' of pipe '{self.code}'",- origin_slot_name=input_name,- )-+ input_taints = optional_input_taints(pipe=self)branch_taints: dict[str, SlotTaint] = {}liftable_steps: list[LiftableStepInfo] = []force_consumptions: list[ForceConsumptionInfo] = []@@ -308,7 +302,7 @@ class PipeParallel(PipeController):branch_pipe = get_optional_pipe(pipe_code=sub_pipe.pipe_code)if branch_pipe is None:continue- trigger_scan = scan_taint_triggers(branch_pipe, slot_taints=optional_input_taints, visited_pipes=visited_pipes)+ trigger_scan = scan_taint_triggers(branch_pipe, slot_taints=input_taints, visited_pipes=visited_pipes)for asserting_name in trigger_scan.asserting_force_names:force_consumptions.append(ForceConsumptionInfo(@@ -361,32 +355,21 @@ class PipeParallel(PipeController):@overridedef lifted_companion_slots(self) -> list[CompanionSlot]:- """When an `add_each_output` parallel is lifted, every branch result slot it would have- written must be resolved too: a recorded absence for singular results, an empty list for- plural ones (D4).+ """The slots the base class derives from `memory_writes`, each credited to the branch pipe producing it.++ When an `add_each_output` parallel is lifted, every branch result slot it would have written is resolved, a recorded+ absence for a single result and an empty list for a plural one (D4), exactly the names its caller's analyses count as+ stored, a branch whose pipe does not resolve included, which is credited to the pipe its branch names."""- if not self.add_each_output:- return []- companion_slots: list[CompanionSlot] = []- for sub_pipe in self.parallel_sub_pipes:- if not sub_pipe.output_name:- continue- branch_pipe = get_optional_pipe(pipe_code=sub_pipe.pipe_code)- if branch_pipe is None:- continue- companion_slots.append(- CompanionSlot(- slot_name=sub_pipe.output_name,- concept=branch_pipe.output.concept,- is_plural=is_plural_step_result(- branch_pipe,- step_output_multiplicity=sub_pipe.output_multiplicity,- has_batch_params=sub_pipe.batch_params is not None,- ),- producing_pipe_code=branch_pipe.code,- ),- )- return companion_slots+ producing_pipe_codes: dict[str, str] = {}+ for branch in self.parallel_sub_pipes:+ if branch.output_name:+ branch_pipe = get_optional_pipe(pipe_code=branch.pipe_code)+ producing_pipe_codes[branch.output_name] = branch_pipe.code if branch_pipe is not None else branch.pipe_code+ return [+ companion_slot._replace(producing_pipe_code=producing_pipe_codes.get(companion_slot.slot_name, companion_slot.producing_pipe_code))+ for companion_slot in super().lifted_companion_slots()+ ]# Note: builtins.type because the `type: Literal["PipeParallel"]` field shadows the# builtin in this class body, where signature annotations are evaluated.diff --git a/pipelex/pipe_controllers/sequence/pipe_sequence.py b/pipelex/pipe_controllers/sequence/pipe_sequence.pyindex 06a23bb81..4990fbc13 100644--- a/pipelex/pipe_controllers/sequence/pipe_sequence.py+++ b/pipelex/pipe_controllers/sequence/pipe_sequence.py@@ -23,6 +23,7 @@ from pipelex.pipe_controllers.absence_taint import (SequenceTaintAnalysis,TaintTriggerScan,is_plural_step_result,+ optional_input_taints,scan_taint_triggers,)from pipelex.pipe_controllers.binding.binding_derivation import BindingDerivation@@ -42,7 +43,7 @@ from pipelex.pipe_controllers.sequence.sequence_typed_flow import (step_memory_writes,)from pipelex.pipe_controllers.sub_pipe import SubPipe-from pipelex.pipe_machinery.memory_writes import MemoryWrite, SlotTaint, is_same_value_spec, taint_after_write+from pipelex.pipe_machinery.memory_writes import MemoryWrite, SlotTaint, is_same_value_spec, taint_after_write, write_after_liftfrom pipelex.pipe_machinery.validation import is_valid_input_name, suggest_plain_namefrom pipelex.pipe_run.pipe_run_params import BatchParams, PipeRunParams, output_multiplicity_to_applyfrom pipelex.system.job_metadata import JobMetadata@@ -814,13 +815,7 @@ class PipeSequence(PipeController):it lifts on nothing, and only the `!` lint reads what it consumes. That keeps a caller's needed inputs, which read`memory_writes` for every nested controller, from walking each nested controller's needs a second time."""- slot_taints: dict[str, SlotTaint] = {}- for input_name, stuff_spec in self.inputs.root.items():- if stuff_spec.presence.is_optional and not stuff_spec.is_multiple():- slot_taints[input_name] = SlotTaint(- source=f"optional input '{input_name}' of pipe '{self.code}'",- origin_slot_name=input_name,- )+ slot_taints = optional_input_taints(pipe=self)liftable_steps: list[LiftableStepInfo] = []force_consumptions: list[ForceConsumptionInfo] = []@@ -908,26 +903,23 @@ class PipeSequence(PipeController):step_writes = typed_flow.memory_writes_by_pipe_step[step_index]else:step_writes = step_memory_writes(step=sequential_sub_pipe, step_pipe=sub_pipe, visited_pipes=writes_visited_pipes)- for written_name, memory_write in step_writes.items():+ for written_name, step_write in step_writes.items():+ memory_write = step_writeif step_lifted and trigger_taint is not None:- # The whole step lifts: what it always stores resolves exactly like the runtime- # `_make_lifted_output` resolves its companion slots — a singular slot goes absent,- # a plural slot becomes a guaranteed empty list (D4) — and a name only some runs- # store is left as it was.- if not memory_write.is_always_written:- continue- if memory_write.stuff_spec is not None and memory_write.stuff_spec.is_multiple():- slot_taints.pop(written_name, None)- else:- slot_taints[written_name] = SlotTaint(+ # The step may be lifted, and may also run: what it always stores resolves exactly like the runtime+ # `_make_lifted_output` resolves its companion slots, a singular slot going absent and a plural slot+ # becoming a guaranteed empty list (D4), while a name only some runs store keeps what a run leaves.+ memory_write = write_after_lift(+ memory_write=step_write,+ lift_taint=SlotTaint(source=trigger_taint.source,origin_slot_name=trigger_taint.origin_slot_name,chain=(*trigger_taint.chain,f"pipe '{sub_pipe.code}' may be skipped when '{trigger_scan.trigger_names[0]}' is absent → slot '{written_name}'",),- )- continue+ ),+ )written_taint = taint_after_write(prior_taint=slot_taints.get(written_name), memory_write=memory_write)if written_taint is None:slot_taints.pop(written_name, None)diff --git a/pipelex/pipe_machinery/memory_writes.py b/pipelex/pipe_machinery/memory_writes.pyindex 6c53483b7..ab67e711d 100644--- a/pipelex/pipe_machinery/memory_writes.py+++ b/pipelex/pipe_machinery/memory_writes.py@@ -174,3 +174,17 @@ def taint_after_write(*, prior_taint: SlotTaint | None, memory_write: MemoryWritif memory_write.is_always_written:return Nonereturn prior_taint+++def write_after_lift(*, memory_write: MemoryWrite, lift_taint: SlotTaint) -> MemoryWrite:+ """What a pipe that may be lifted stores under one name, joining the lift with a run, since the pipe may also run.++ The lift resolves a name the pipe always stores to an absence, which `lift_taint` describes, or to an empty list for a+ list (`PipeAbstract.lifted_companion_slots`), so such a single name may hold an absence, and a list never does. The lift+ leaves a name only some runs store as it was, as a run that does not store it does, so that write stands as runs make it.+ """+ if not memory_write.is_always_written:+ return memory_write+ if memory_write.stuff_spec is not None and memory_write.stuff_spec.is_multiple():+ return memory_write+ return memory_write.model_copy(update={"absence": lift_taint})diff --git a/pipelex/pipeline/controller_taint.py b/pipelex/pipeline/controller_taint.pyindex 0e59ec75b..5dd60cfe9 100644--- a/pipelex/pipeline/controller_taint.py+++ b/pipelex/pipeline/controller_taint.py@@ -1,7 +1,7 @@"""Single-pass controller taint collection shared by the validate-report projections.-The absence-taint walk (`PipeSequence.analyze_taint`, `PipeParallel.analyze_branch_taint`)-hub-resolves every sub-pipe and recurses through nested controllers, so it must run exactly+The absence-taint walk (`PipeSequence.analyze_taint`, `PipeParallel.analyze_branch_taint`,+`PipeCondition.analyze_outcome_taint`) hub-resolves every sub-pipe and recurses through nested controllers, so it must run exactlyonce per validate pass. Both report projections — the `liftable_pipes` inventory and the`warnings` optionality lints — consume the same analyses; callers collect them here and feedthe list to both builders instead of each builder re-walking the pipes.@@ -13,12 +13,13 @@ the hub.from collections.abc import Sequencefrom typing import TypeAlias-from pipelex.pipe_controllers.absence_taint import ParallelTaintAnalysis, SequenceTaintAnalysis+from pipelex.pipe_controllers.absence_taint import ConditionTaintAnalysis, ParallelTaintAnalysis, SequenceTaintAnalysis+from pipelex.pipe_controllers.condition.pipe_condition import PipeConditionfrom pipelex.pipe_controllers.parallel.pipe_parallel import PipeParallelfrom pipelex.pipe_controllers.sequence.pipe_sequence import PipeSequencefrom pipelex.pipe_machinery.pipe_abstract import PipeAbstract-ControllerTaintAnalysis: TypeAlias = SequenceTaintAnalysis | ParallelTaintAnalysis+ControllerTaintAnalysis: TypeAlias = SequenceTaintAnalysis | ParallelTaintAnalysis | ConditionTaintAnalysisdef collect_controller_taint_analyses(pipes: Sequence[PipeAbstract]) -> list[ControllerTaintAnalysis]:@@ -36,4 +37,6 @@ def collect_controller_taint_analyses(pipes: Sequence[PipeAbstract]) -> list[Conanalyses.append(pipe.analyze_taint())elif isinstance(pipe, PipeParallel):analyses.append(pipe.analyze_branch_taint())+ elif isinstance(pipe, PipeCondition):+ analyses.append(pipe.analyze_outcome_taint())return analysesdiff --git a/pipelex/pipeline/liftable_pipes.py b/pipelex/pipeline/liftable_pipes.pyindex bed70fccd..e9d6bb28c 100644--- a/pipelex/pipeline/liftable_pipes.py+++ b/pipelex/pipeline/liftable_pipes.py@@ -33,9 +33,9 @@ class LiftablePipeEntry(BaseModel):def build_liftable_pipes(taint_analyses: Sequence[ControllerTaintAnalysis]) -> list[LiftablePipeEntry]:"""Project the controllers' taint analyses into `liftable_pipes` entries.- Sequences contribute their lifted steps; parallels contribute their liftable branches- (a parallel nested in a sequence reports its branches under itself, so there is no- double-reporting).+ Sequences contribute their lifted steps; parallels contribute their liftable branches and+ conditions the outcomes their own `?` inputs may lift (a parallel or a condition nested in a+ sequence reports its branches or outcomes under itself, so there is no double-reporting).Args:taint_analyses: The controllers' analyses from `collect_controller_taint_analyses`diff --git a/pipelex/pipeline/optionality_warnings.py b/pipelex/pipeline/optionality_warnings.pyindex 0617dbf14..12d76d515 100644--- a/pipelex/pipeline/optionality_warnings.py+++ b/pipelex/pipeline/optionality_warnings.py@@ -7,7 +7,8 @@ is present — but when every analyzed flow guarantees the slot, the assertion cthe marker is dead weight.The presence data comes from the same controller taint analyses that feed the liftable-pipe-inventory (`PipeSequence.analyze_taint`, `PipeParallel.analyze_branch_taint`). Observations are+inventory (`PipeSequence.analyze_taint`, `PipeParallel.analyze_branch_taint`,+`PipeCondition.analyze_outcome_taint`). Observations areaggregated per (pipe, variable) ACROSS flows before warning: a pipe whose `!` is meaningful inone flow is never told to remove it just because another flow guarantees the slot. A `!` inputon a pipe that appears in no analyzed flow yields no observation and no warning (conservative —diff --git a/tests/integration/pipelex/pipes/optionals/test_lifted_parallel_companion_slots.py b/tests/integration/pipelex/pipes/optionals/test_lifted_parallel_companion_slots.pyindex f9c14989a..f6b831855 100644--- a/tests/integration/pipelex/pipes/optionals/test_lifted_parallel_companion_slots.py+++ b/tests/integration/pipelex/pipes/optionals/test_lifted_parallel_companion_slots.py@@ -7,6 +7,7 @@ static taint pass blessed meets a neither-value-nor-record hard miss at its gatefrom typing import Callable, castimport pytest+from pytest_mock import MockerFixturefrom pipelex.core.memory.absence import AbsenceKind, AbsenceRecordfrom pipelex.core.memory.working_memory import WorkingMemory@@ -14,12 +15,14 @@ from pipelex.core.memory.working_memory_factory import WorkingMemoryFactoryfrom pipelex.core.stuffs.list_content import ListContentfrom pipelex.core.stuffs.stuff_factory import StuffFactoryfrom pipelex.core.stuffs.text_content import TextContent-from pipelex.interpreter_hub import get_pipe_library+from pipelex.interpreter_hub import get_optional_pipe, get_pipe_library+from pipelex.pipe_controllers.parallel import pipe_parallel as parallel_modulefrom pipelex.pipe_controllers.parallel.pipe_parallel import PipeParallelfrom pipelex.pipe_controllers.parallel.pipe_parallel_blueprint import PipeParallelBlueprintfrom pipelex.pipe_controllers.sequence.pipe_sequence import PipeSequencefrom pipelex.pipe_controllers.sequence.pipe_sequence_blueprint import PipeSequenceBlueprintfrom pipelex.pipe_controllers.sub_pipe_blueprint import SubPipeBlueprint+from pipelex.pipe_machinery.pipe_abstract import CompanionSlot, PipeAbstractfrom pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_operators.func.pipe_func import PipeFuncfrom pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprint@@ -123,7 +126,6 @@ def _build_sequence_with_liftable_parallel() -> PipeSequence:return sequence[email protected](loop_scope="class")class TestLiftedParallelCompanionSlots:@classmethoddef setup_class(cls):@@ -136,6 +138,7 @@ class TestLiftedParallelCompanionSlots:if func_registry.has_function(func.__name__):func_registry.unregister_function_by_name(func.__name__)+ @pytest.mark.asyncio(loop_scope="class")async def test_lifted_parallel_resolves_branch_slots(self, job_metadata: JobMetadata, load_empty_library: Callable[[], str]):"""Static validation blesses the flow AND the runtime resolves every branch slot on lift:singular → SKIPPED record with provenance; plural → empty list. The absorbing sink runs.@@ -175,3 +178,34 @@ class TestLiftedParallelCompanionSlots:many_out_content = many_out_stuff.contentassert isinstance(many_out_content, ListContent)assert cast("ListContent[TextContent]", many_out_content).items == []++ def test_companion_slots_are_what_the_parallel_always_stores(self, load_empty_library: Callable[[], str], mocker: MockerFixture):+ """Regression: the slots a lifted parallel resolves are the names its `memory_writes` always stores, which the caller's+ analyses read, a branch whose pipe does not resolve included: its slot is resolved absent, being of no known spec.+ """+ load_empty_library()+ sequence = _build_sequence_with_liftable_parallel()+ sequence.validate_with_libraries()+ parallel = get_pipe_library().get_required_pipe(pipe_code="test_optionals_companion.comp_parallel")+ assert isinstance(parallel, PipeParallel)++ def get_optional_pipe_but_comp_find(*, pipe_code: str) -> PipeAbstract | None:+ if pipe_code.endswith("comp_find"):+ return None+ return get_optional_pipe(pipe_code=pipe_code)++ mocker.patch.object(parallel_module, "get_optional_pipe", side_effect=get_optional_pipe_but_comp_find)++ companion_slots = parallel.lifted_companion_slots()++ always_written_names = {name for name, memory_write in parallel.memory_writes().items() if memory_write.is_always_written}+ assert {companion_slot.slot_name for companion_slot in companion_slots} == always_written_names == {"a_out", "many_out"}+ assert sorted(companion_slots) == [+ CompanionSlot(slot_name="a_out", concept=None, is_plural=False, producing_pipe_code="test_optionals_companion.comp_find"),+ CompanionSlot(+ slot_name="many_out",+ concept=get_pipe_library().get_required_pipe(pipe_code="test_optionals_companion.comp_find_many").output.concept,+ is_plural=True,+ producing_pipe_code="comp_find_many",+ ),+ ]diff --git a/tests/integration/pipelex/pipes/optionals/test_lifted_writes_taint.py b/tests/integration/pipelex/pipes/optionals/test_lifted_writes_taint.pynew file mode 100644index 000000000..4cf2c50dc--- /dev/null+++ b/tests/integration/pipelex/pipes/optionals/test_lifted_writes_taint.py@@ -0,0 +1,282 @@+"""A pipe that may be lifted still stores what its runs store, and the absence analyses must join both.++A condition's chosen outcome runs on its caller's memory, and an outcome may be lifted for an optional input of the condition+it takes plain: the lift then resolves the condition's result, and every name the outcome always stores, to an absence. A+sequence step that may be lifted may also run, and a run that stores a name may leave it absent. Each bundle here validated+once while its run resolved an output declared plain to an absence; each must now be refused, or, declared optional, run as+the analysis says.+"""++from collections.abc import Callable+from typing import TYPE_CHECKING, Any++import pytest++from pipelex.core.memory.absence import AbsenceKind, AbsenceRecord+from pipelex.core.pipes.exceptions import PipeValidationError+from pipelex.interpreter_hub import get_library_manager+from pipelex.mthds_parsing.parser import MthdsParser+from pipelex.pipe_controllers.condition.pipe_condition import PipeCondition+from pipelex.pipe_machinery.pipe_abstract import PipeAbstract+from pipelex.pipeline.controller_taint import collect_controller_taint_analyses+from pipelex.pipeline.liftable_pipes import build_liftable_pipes+from pipelex.pipeline.runner import PipelexMTHDSProtocol+from pipelex.system.pipe_run_mode import PipeRunMode+from pipelex.validation_error_types import PipeValidationErrorType++if TYPE_CHECKING:+ from mthds.protocol.pipeline_inputs import PipelineInputs++_LIFTED_OUTCOME_DOMAIN = "probe_cond_lift"+++def _lifted_outcome_bundle(*, pick_output: str, outer_output: str) -> str:+ """A condition taking `doc` optional routes to `inner`, which takes it plain, and the caller binds what `inner` stores."""+ return f"""domain = "{_LIFTED_OUTCOME_DOMAIN}"+description = "A condition outcome skipped for an absent input"+main_pipe = "outer"++[concept.Doc]+description = "A document"++[concept.Doc.structure]+label = {{ type = "text", description = "Its label", required = true }}++[pipe.outer]+type = "PipeSequence"+description = "Route, then bind what the outcome stored"+inputs = {{ doc = "Doc?", mode = "Text" }}+output = "{outer_output}"+steps = [+ {{ pipe = "pick", result = "picked" }},+ {{ from = "label", result = "final" }},+]++[pipe.pick]+type = "PipeCondition"+description = "Route by mode"+inputs = {{ mode = "Text", doc = "Doc?" }}+output = "{pick_output}"+expression = "mode"+default_outcome = "inner"++[pipe.pick.outcomes]+other = "inner"++[pipe.inner]+type = "PipeSequence"+description = "Bind the label"+inputs = {{ doc = "Doc" }}+output = "Text"+steps = [+ {{ from = "doc.label", result = "label" }},+]+"""+++_SOMETIMES_WRITTEN_DOMAIN = "probe_sometimes"+++def _sometimes_written_bundle(*, outer_output: str) -> str:+ """A step that may be lifted for an absent `doc` runs a condition that, on some runs, stores `x` from a path that may find nothing."""+ return f"""domain = "{_SOMETIMES_WRITTEN_DOMAIN}"+description = "A liftable step that stores a name on some runs only"+main_pipe = "outer"++[concept.Doc]+description = "A document"++[concept.Doc.structure]+label = {{ type = "text", description = "Its label", required = true }}+note = {{ type = "text", description = "Its note" }}++[pipe.outer]+type = "PipeSequence"+description = "Seed x, maybe overwrite it, then bind it"+inputs = {{ doc = "Doc?", mode = "Text", seed = "Text" }}+output = "{outer_output}"+steps = [+ {{ from = "seed", result = "x" }},+ {{ pipe = "pick", result = "picked" }},+ {{ from = "x", result = "final" }},+]++[pipe.pick]+type = "PipeCondition"+description = "Route by mode"+inputs = {{ mode = "Text", doc = "Doc" }}+output = "Text?"+expression = "mode"+default_outcome = "continue"++[pipe.pick.outcomes]+a = "store_note"++[pipe.store_note]+type = "PipeSequence"+description = "Bind the note as x"+inputs = {{ doc = "Doc" }}+output = "Text?"+steps = [+ {{ from = "doc.note", result = "x" }},+]+"""+++_GUARDED_DOMAIN = "probe_guarded"+++def _guarded_bundle(*, flag_spec: str) -> str:+ """A condition chooses `flagged_note`, which takes `flag` as `flag_spec`, only when its optional `flag` is present."""+ return f"""domain = "{_GUARDED_DOMAIN}"+description = "A condition whose expression guards an optional input"+main_pipe = "route"++[pipe.route]+type = "PipeCondition"+description = "Route on the presence of the flag"+inputs = {{ flag = "Text?" }}+output = "Text"+expression_template = "{{{{ 'with_flag' if flag is defined else 'no_flag' }}}}"+default_outcome = "plain_note"++[pipe.route.outcomes]+with_flag = "flagged_note"+no_flag = "plain_note"++[pipe.flagged_note]+type = "PipeCompose"+description = "Note the flag"+inputs = {{ flag = "{flag_spec}" }}+output = "Text"+template = "Flagged: {{{{ flag }}}}"++[pipe.plain_note]+type = "PipeCompose"+description = "Note that there is no flag"+output = "Text"+template = "Plain"+"""+++def _text_input(text: str) -> dict[str, Any]:+ return {"concept": "native.Text", "content": {"text": text}}+++def _doc_input(*, domain: str, content: dict[str, str]) -> dict[str, Any]:+ return {"concept": f"{domain}.Doc", "content": content}+++def _load_pipes(*, mthds_content: str, library_id: str) -> dict[str, PipeAbstract]:+ blueprint = MthdsParser.make_pipelex_bundle_blueprint(mthds_content=mthds_content, mthds_source="probe.mthds")+ pipes = get_library_manager().load_from_blueprints(library_id=library_id, blueprints=[blueprint])+ return {pipe.code: pipe for pipe in pipes}+++async def _run(*, mthds_content: str, inputs: "PipelineInputs") -> AbsenceRecord | str:+ """Run the bundle live, and return the text it output, or the absence its output holds."""+ response = await PipelexMTHDSProtocol(pipe_run_mode=PipeRunMode.LIVE).execute(mthds_contents=[mthds_content], inputs=inputs)+ main_resolved = response.pipe_output.working_memory.resolve_main_stuff()+ if isinstance(main_resolved, AbsenceRecord):+ return main_resolved+ return response.pipe_output.main_stuff_as_str+++class TestLiftedWritesTaint:+ def test_a_condition_that_may_lift_its_outcome_declares_its_output_optional(self, load_empty_library: Callable[[], str]) -> None:+ """Regression: `pick` takes `doc` optional and routes to `inner`, which takes it plain, so a run without `doc` lifts+ `inner` and resolves the condition's result to an absence: a plain output would hide it.+ """+ with pytest.raises(PipeValidationError) as exc_info:+ _load_pipes(mthds_content=_lifted_outcome_bundle(pick_output="Text", outer_output="Text?"), library_id=load_empty_library())++ assert exc_info.value.error_type == PipeValidationErrorType.OPTIONAL_NOT_HANDLED+ assert exc_info.value.pipe_code == "pick"+ assert "'inner'" in str(exc_info.value)+ assert "'doc'" in str(exc_info.value)++ def test_a_name_a_liftable_outcome_always_stores_may_be_absent(self, load_empty_library: Callable[[], str]) -> None:+ """Regression: the lift of `inner` resolves `label`, which it always stores, to an absence, so `final`, bound from it,+ may be absent, and `outer` must declare its output optional.+ """+ with pytest.raises(PipeValidationError) as exc_info:+ _load_pipes(mthds_content=_lifted_outcome_bundle(pick_output="Text?", outer_output="Text"), library_id=load_empty_library())++ assert exc_info.value.error_type == PipeValidationErrorType.OPTIONAL_NOT_HANDLED+ assert exc_info.value.pipe_code == "outer"+ assert "pipe 'inner' may be skipped when 'doc' is absent → slot 'label'" in str(exc_info.value)++ @pytest.mark.asyncio(loop_scope="class")+ async def test_a_lifted_outcome_resolves_what_the_analysis_says(self, load_empty_library: Callable[[], str]) -> None:+ mthds_content = _lifted_outcome_bundle(pick_output="Text?", outer_output="Text?")+ pipes = _load_pipes(mthds_content=mthds_content, library_id=load_empty_library())++ pick = pipes["pick"]+ assert isinstance(pick, PipeCondition)+ label_write = pick.memory_writes()["label"]+ assert label_write.is_always_written+ assert label_write.absence is not None+ assert label_write.absence.origin_slot_name == "doc"+ inventory = build_liftable_pipes(collect_controller_taint_analyses(list(pipes.values())))+ assert [(entry.within_pipe_ref, entry.pipe_ref, entry.skipped_when_absent) for entry in inventory] == [+ (f"{_LIFTED_OUTCOME_DOMAIN}.pick", f"{_LIFTED_OUTCOME_DOMAIN}.inner", ["doc"])+ ]++ outcome = await _run(mthds_content=mthds_content, inputs={"mode": _text_input("x")})+ assert isinstance(outcome, AbsenceRecord)+ assert outcome.kind == AbsenceKind.SKIPPED+ assert outcome.upstream is not None+ assert outcome.upstream.variable_name == "label"+ outcome = await _run(+ mthds_content=mthds_content,+ inputs={"mode": _text_input("x"), "doc": _doc_input(domain=_LIFTED_OUTCOME_DOMAIN, content={"label": "L"})},+ )+ assert outcome == "L"++ def test_a_liftable_step_keeps_the_taint_of_what_its_run_may_store(self, load_empty_library: Callable[[], str]) -> None:+ """Regression: `pick` may be lifted for an absent `doc`, which leaves `x` as seeded, but it may also run, and its+ outcome may store `x` as an absence, so `final`, bound from `x`, may be absent.+ """+ with pytest.raises(PipeValidationError) as exc_info:+ _load_pipes(mthds_content=_sometimes_written_bundle(outer_output="Text"), library_id=load_empty_library())++ assert exc_info.value.error_type == PipeValidationErrorType.OPTIONAL_NOT_HANDLED+ assert exc_info.value.pipe_code == "outer"+ assert "'doc.note'" in str(exc_info.value)++ @pytest.mark.asyncio(loop_scope="class")+ async def test_a_liftable_step_resolves_what_the_analysis_says(self, load_empty_library: Callable[[], str]) -> None:+ mthds_content = _sometimes_written_bundle(outer_output="Text?")+ _load_pipes(mthds_content=mthds_content, library_id=load_empty_library())++ def inputs(*, mode: str, doc: dict[str, str] | None) -> "PipelineInputs":+ run_inputs: dict[str, Any] = {"mode": _text_input(mode), "seed": _text_input("s")}+ if doc is not None:+ run_inputs["doc"] = _doc_input(domain=_SOMETIMES_WRITTEN_DOMAIN, content=doc)+ return run_inputs++ outcome = await _run(mthds_content=mthds_content, inputs=inputs(mode="a", doc={"label": "L"}))+ assert isinstance(outcome, AbsenceRecord)+ assert await _run(mthds_content=mthds_content, inputs=inputs(mode="a", doc={"label": "L", "note": "N"})) == "N"+ assert await _run(mthds_content=mthds_content, inputs=inputs(mode="a", doc=None)) == "s"+ assert await _run(mthds_content=mthds_content, inputs=inputs(mode="b", doc={"label": "L"})) == "s"++ def test_a_guarded_outcome_taking_the_input_plain_is_refused(self, load_empty_library: Callable[[], str]) -> None:+ """Validation does not read the expression, so an outcome the guard chooses only with `flag` present, taking it plain,+ may be lifted as far as it can tell, and the refusal names the remedy that keeps the output plain.+ """+ with pytest.raises(PipeValidationError) as exc_info:+ _load_pipes(mthds_content=_guarded_bundle(flag_spec="Text"), library_id=load_empty_library())++ assert exc_info.value.error_type == PipeValidationErrorType.OPTIONAL_NOT_HANDLED+ assert exc_info.value.pipe_code == "route"+ assert "declare 'flag' forced on 'flagged_note' with '!'" in str(exc_info.value)++ @pytest.mark.asyncio(loop_scope="class")+ async def test_a_guarded_outcome_forcing_the_input_keeps_the_output_plain(self, load_empty_library: Callable[[], str]) -> None:+ mthds_content = _guarded_bundle(flag_spec="Text!")+ pipes = _load_pipes(mthds_content=mthds_content, library_id=load_empty_library())++ assert build_liftable_pipes(collect_controller_taint_analyses(list(pipes.values()))) == []+ assert await _run(mthds_content=mthds_content, inputs={"flag": _text_input("urgent")}) == "Flagged: urgent"+ assert await _run(mthds_content=mthds_content, inputs={}) == "Plain"