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.
test(fixtures): guard the requested run mode in one shared helper
Louis Choquelea29532a5873
diff --git a/tests/integration/pipelex/fixtures/pipe_job_helpers.py b/tests/integration/pipelex/fixtures/pipe_job_helpers.pyindex eacba7fbd..643a696d1 100644--- a/tests/integration/pipelex/fixtures/pipe_job_helpers.py+++ b/tests/integration/pipelex/fixtures/pipe_job_helpers.py@@ -10,6 +10,7 @@ from pipelex.mthds_parsing.parser import MthdsParserfrom pipelex.pipe_machinery.pipe_abstract import PipeAbstractfrom pipelex.pipe_run.pipe_job import PipeJobfrom pipelex.pipe_run.pipe_job_factory import PipeJobFactory+from pipelex.pipe_run.pipe_run_params import PipeRunParamsfrom pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactoryfrom pipelex.system.job_metadata import JobMetadata, SpecialPipelineIdfrom pipelex.system.pipe_run_mode import PipeRunMode@@ -18,6 +19,25 @@ from pipelex.system.telemetry.otel_constants import OTelConstantsPIPE_JOB_HELPERS_PIPELINE_RUN_ID_PREFIX = "pipe_job_helpers_test"+def make_mode_guarded_run_params(*, pipe_run_mode: PipeRunMode = PipeRunMode.LIVE) -> PipeRunParams:+ """Run params built through the factory, with the requested run mode guarded.++ A fixture builds through the factory rather than hand-building params because the factory is the+ single writer of the three fields that carry a run-scoped invariant — `run_mode`,+ `pipe_stack_limit` and `batch_max_concurrency`. What the factory adds in exchange is the+ keyless-boot coercion: under `needs_inference=False` a requested LIVE comes back DRY. For a+ fixture whose whole point is *which controller path* runs, that would swap the path under the+ test while every assertion still passed, so assert the requested mode survived.+ """+ run_params = PipeRunParamsFactory.make_run_params(pipe_run_mode=pipe_run_mode)+ match pipe_run_mode:+ case PipeRunMode.LIVE:+ assert run_params.run_mode.is_live, "This test must run the live path — the boot coerced the run mode to DRY"+ case PipeRunMode.DRY:+ assert run_params.run_mode.is_dry, "This test must run the dry path — the boot returned a run mode other than DRY"+ return run_params++def build_pipe_job(pipe: PipeAbstract,library_crate: LibraryCrate | None,diff --git a/tests/integration/pipelex/pipeline/test_optional_method_inputs.py b/tests/integration/pipelex/pipeline/test_optional_method_inputs.pyindex 9f783387e..4892b17ab 100644--- a/tests/integration/pipelex/pipeline/test_optional_method_inputs.py+++ b/tests/integration/pipelex/pipeline/test_optional_method_inputs.py@@ -18,11 +18,11 @@ from pipelex.core.stuffs.text_content import TextContentfrom pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_operators.func.pipe_func import PipeFuncfrom pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprint-from pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactoryfrom pipelex.pipeline.execution_seams import prepare_pipe_jobfrom pipelex.system.job_metadata import JobMetadatafrom pipelex.system.pipe_run_mode import PipeRunModefrom pipelex.system.registries.func_registry import func_registry+from tests.integration.pipelex.fixtures.pipe_job_helpers import make_mode_guarded_run_paramsdef optionals_method_report(working_memory: WorkingMemory) -> TextContent:@@ -150,7 +150,7 @@ class TestOptionalMethodInputs:"""load_empty_library()pipe = _make_method_pipe()- run_params = PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.LIVE)+ run_params = make_mode_guarded_run_params(pipe_run_mode=PipeRunMode.LIVE)with pytest.raises(PipeRunInputsError) as exc_info:await pipe.run_pipe(diff --git a/tests/integration/pipelex/pipes/controller/pipe_batch/test_pipe_batch_compaction.py b/tests/integration/pipelex/pipes/controller/pipe_batch/test_pipe_batch_compaction.pyindex fd41e2d6b..722bb9ee7 100644--- a/tests/integration/pipelex/pipes/controller/pipe_batch/test_pipe_batch_compaction.py+++ b/tests/integration/pipelex/pipes/controller/pipe_batch/test_pipe_batch_compaction.py@@ -26,10 +26,11 @@ from pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_operators.func.pipe_func import PipeFuncfrom pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprintfrom pipelex.pipe_run.pipe_run_params import PipeRunParams-from pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactory, resolve_batch_max_concurrency+from pipelex.pipe_run.pipe_run_params_factory import resolve_batch_max_concurrencyfrom pipelex.system.job_metadata import JobMetadatafrom pipelex.system.pipe_run_mode import PipeRunModefrom pipelex.system.registries.func_registry import func_registry+from tests.integration.pipelex.fixtures.pipe_job_helpers import make_mode_guarded_run_params_DOMAIN_CODE = "test_optionals_batch"@@ -48,7 +49,7 @@ def _make_live_run_params() -> PipeRunParams:exercising the setting in the one test suite where the bound changes behavior. The field isrequired now, so the omission cannot recur silently — the factory is the single writer."""- return PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.LIVE)+ return make_mode_guarded_run_params(pipe_run_mode=PipeRunMode.LIVE)def _build_compacting_batch() -> PipeBatch:diff --git a/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_continue_delivery.py b/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_continue_delivery.pyindex 930bfc19a..34ff6642b 100644--- a/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_continue_delivery.py+++ b/tests/integration/pipelex/pipes/controller/pipe_condition/test_pipe_condition_continue_delivery.py@@ -24,9 +24,9 @@ from pipelex.pipe_controllers.condition.pipe_condition_blueprint import PipeCondfrom pipelex.pipe_controllers.condition.special_outcome import SpecialOutcomefrom pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_run.pipe_run_params import PipeRunParams-from pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactoryfrom pipelex.system.job_metadata import JobMetadatafrom pipelex.system.pipe_run_mode import PipeRunMode+from tests.integration.pipelex.fixtures.pipe_job_helpers import make_mode_guarded_run_paramsdef _make_continue_only_condition() -> PipeCondition:@@ -55,16 +55,7 @@ def _make_input_text_stuff():def _make_run_params(run_mode: PipeRunMode) -> PipeRunParams:- run_params = PipeRunParamsFactory.make_run_params(pipe_run_mode=run_mode)- # The factory is the single writer of the run-mode and fan-out-bound fields, so the fixture goes- # through it rather than hand-building params. Assert the mode survived: under a keyless boot the- # factory coerces LIVE to DRY, which would silently swap which controller path the test exercises.- match run_mode:- case PipeRunMode.LIVE:- assert run_params.run_mode.is_live, f"This test must run the live controller path — the boot coerced it to {run_params.run_mode}"- case PipeRunMode.DRY:- assert run_params.run_mode.is_dry, f"This test must run the dry controller path — the boot coerced it to {run_params.run_mode}"- return run_params+ return make_mode_guarded_run_params(pipe_run_mode=run_mode)@pytest.mark.asyncio(loop_scope="class")diff --git a/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_absence.py b/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_absence.pyindex 7c8d83443..1712ecf2d 100644--- a/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_absence.py+++ b/tests/integration/pipelex/pipes/controller/pipe_parallel/test_pipe_parallel_absence.py@@ -34,11 +34,11 @@ from pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_operators.func.pipe_func import PipeFuncfrom pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprintfrom pipelex.pipe_run.pipe_run_params import PipeRunParams-from pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactoryfrom pipelex.runtime_hub import get_class_registryfrom pipelex.system.job_metadata import JobMetadatafrom pipelex.system.pipe_run_mode import PipeRunModefrom pipelex.system.registries.func_registry import func_registry+from tests.integration.pipelex.fixtures.pipe_job_helpers import make_mode_guarded_run_params_DOMAIN_CODE = "test_optionals_par"@@ -69,7 +69,7 @@ _TEST_FUNCS = [optionals_par_echo_source, optionals_par_echo_topic]def _make_live_run_params() -> PipeRunParams:- return PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.LIVE)+ return make_mode_guarded_run_params(pipe_run_mode=PipeRunMode.LIVE)def _build_parallel(*, output_ref: str, structure_class_names: list[str], add_each_output: bool = False) -> PipeParallel:diff --git a/tests/integration/pipelex/pipes/optionals/test_lift_sequence.py b/tests/integration/pipelex/pipes/optionals/test_lift_sequence.pyindex 38f1e4709..4130554ce 100644--- a/tests/integration/pipelex/pipes/optionals/test_lift_sequence.py+++ b/tests/integration/pipelex/pipes/optionals/test_lift_sequence.py@@ -23,11 +23,11 @@ from pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_operators.func.pipe_func import PipeFuncfrom pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprintfrom pipelex.pipe_run.pipe_run_params import PipeRunParams-from pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactoryfrom pipelex.pipeline.execution_seams import prepare_pipe_jobfrom pipelex.system.job_metadata import JobMetadatafrom pipelex.system.pipe_run_mode import PipeRunModefrom pipelex.system.registries.func_registry import func_registry+from tests.integration.pipelex.fixtures.pipe_job_helpers import make_mode_guarded_run_params_DOMAIN_CODE = "test_optionals_seq"@@ -52,7 +52,7 @@ _TEST_FUNCS = [optionals_seq_echo_source, optionals_seq_echo_a_out, optionals_sedef _make_live_run_params() -> PipeRunParams:- return PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.LIVE)+ return make_mode_guarded_run_params(pipe_run_mode=PipeRunMode.LIVE)def _build_lift_sequence() -> PipeSequence:diff --git a/tests/integration/pipelex/pipes/optionals/test_lift_skip_trichotomy.py b/tests/integration/pipelex/pipes/optionals/test_lift_skip_trichotomy.pyindex dd51067df..ce560f272 100644--- a/tests/integration/pipelex/pipes/optionals/test_lift_skip_trichotomy.py+++ b/tests/integration/pipelex/pipes/optionals/test_lift_skip_trichotomy.py@@ -24,10 +24,10 @@ from pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_operators.func.pipe_func import PipeFuncfrom pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprintfrom pipelex.pipe_run.pipe_run_params import PipeRunParams-from pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactoryfrom pipelex.system.job_metadata import JobMetadatafrom pipelex.system.pipe_run_mode import PipeRunModefrom pipelex.system.registries.func_registry import func_registry+from tests.integration.pipelex.fixtures.pipe_job_helpers import make_mode_guarded_run_paramsfrom tests.unit.pipelex.graph.conftest import make_trace_context@@ -83,12 +83,7 @@ def _make_seeded_absence() -> AbsenceRecord:def _make_live_run_params() -> PipeRunParams:- run_params = PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.LIVE)- # The factory is the single writer of the run-mode and fan-out-bound fields, so the fixture goes- # through it rather than hand-building params. Assert the mode survived: under a keyless boot the- # factory coerces LIVE to DRY, which would silently swap which code path the test exercises.- assert run_params.run_mode.is_live, "This test must run the live controller path — the boot coerced it to DRY"- return run_params+ return make_mode_guarded_run_params(pipe_run_mode=PipeRunMode.LIVE)@pytest.mark.asyncio(loop_scope="class")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 2b9d97a92..63be0fc1c 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@@ -24,10 +24,10 @@ from pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_operators.func.pipe_func import PipeFuncfrom pipelex.pipe_operators.func.pipe_func_blueprint import PipeFuncBlueprintfrom pipelex.pipe_run.pipe_run_params import PipeRunParams-from pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactoryfrom pipelex.system.job_metadata import JobMetadatafrom pipelex.system.pipe_run_mode import PipeRunModefrom pipelex.system.registries.func_registry import func_registry+from tests.integration.pipelex.fixtures.pipe_job_helpers import make_mode_guarded_run_params_DOMAIN_CODE = "test_optionals_companion"@@ -51,7 +51,7 @@ _TEST_FUNCS = [optionals_comp_find, optionals_comp_find_many, optionals_comp_sindef _make_live_run_params() -> PipeRunParams:- return PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.LIVE)+ return make_mode_guarded_run_params(pipe_run_mode=PipeRunMode.LIVE)def _build_sequence_with_liftable_parallel() -> PipeSequence:diff --git a/tests/integration/pipelex/pipes/optionals/test_optional_gate_tolerates_missing.py b/tests/integration/pipelex/pipes/optionals/test_optional_gate_tolerates_missing.pyindex a07023a16..6b8f725eb 100644--- a/tests/integration/pipelex/pipes/optionals/test_optional_gate_tolerates_missing.py+++ b/tests/integration/pipelex/pipes/optionals/test_optional_gate_tolerates_missing.py@@ -21,15 +21,15 @@ from pipelex.pipe_machinery.pipe_factory import PipeFactoryfrom pipelex.pipe_operators.compose.pipe_compose import PipeComposefrom pipelex.pipe_operators.compose.pipe_compose_blueprint import PipeComposeBlueprintfrom pipelex.pipe_run.pipe_run_params import PipeRunParams-from pipelex.pipe_run.pipe_run_params_factory import PipeRunParamsFactoryfrom pipelex.system.job_metadata import JobMetadatafrom pipelex.system.pipe_run_mode import PipeRunMode+from tests.integration.pipelex.fixtures.pipe_job_helpers import make_mode_guarded_run_params_DOMAIN_CODE = "test_optionals_gate"def _make_live_run_params() -> PipeRunParams:- return PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.LIVE)+ return make_mode_guarded_run_params(pipe_run_mode=PipeRunMode.LIVE)def _register_guarded_compose() -> None:diff --git a/wip/pr-1093-review-notes.md b/wip/pr-1093-review-notes.mdindex b88d35d0e..836e92e37 100644--- a/wip/pr-1093-review-notes.md+++ b/wip/pr-1093-review-notes.md@@ -10,7 +10,7 @@ Both were verified against the code. **Neither is a live bug** — one is a fals> **Status (2026-08-12): done in `pipelex`, on `fix/batch-max-concurrency-required`.** The field is required, the integration fixtures route through `PipeRunParamsFactory.make_run_params`, both omission paths (constructor and `model_validate`) have `ValidationError` coverage, and the mutation check was run — restoring `default=None` turns both new tests red and nothing else. The compaction fixture builds through the factory and asserts the configured bound.>-> **Still open — the cross-repo wire test, and it *is* gated.** `pipelex-server/temporal/tests/integration/pipelex_temporal/data_converter/test_data_conv_pipe_run_params.py` round-trips `PipeRunParams` without the field, so it asserts `None == None` and would not catch the bound being dropped on the wire. It cannot be fixed ahead of the pin: `pipelex-server` pins `pipelex==0.42.0`, which predates the field entirely, and `PipeRunParams` is `extra="forbid"` — passing `batch_max_concurrency` there today fails. When the pin moves to ≥ the release carrying this change, make that test round-trip a real int bound.+> **Still open — the cross-repo wire test, and it *is* gated.** Our Temporal plugin's payload-converter test round-trips `PipeRunParams` without the field, so it asserts `None == None` and would not catch the bound being dropped on the wire. It cannot be fixed ahead of the pin: that side pins a `pipelex` version predating the field entirely, and `PipeRunParams` is `extra="forbid"` — passing `batch_max_concurrency` there today fails. When the pin moves to ≥ the release carrying this change, make that test round-trip a real int bound. Path and pin live in the workspace-level private notes.- **Origin:** surfaced while verifying Codex's second P1 on `pipelex/pipe_run/pipe_run_params.py:160`. It is *not* the defect Codex described (see "Not deferred" below for why that one is a false positive) — it is the weakness underneath it.- **Where:** `pipelex/pipe_run/pipe_run_params.py`, the `batch_max_concurrency: int | None = Field(default=None, frozen=True)` field.@@ -51,14 +51,14 @@ Keeps `int | None`, so authored `"unbounded"` still resolves to `None`; keeps `f### Why it was deferred rather than done here-The source change is one word, but the fixtures are not: ~19 direct constructions in this repo plus one in `pipelex-server` must supply the field. The integration fixtures should route through `PipeRunParamsFactory.make_run_params` instead — a net simplification, since they already hand-duplicate the factory's config read — but that is a ~20-file change with a cross-repo tail, landing on a release branch whose CI is green and which is about to merge to `main`. It belongs on `dev` immediately after the promotion.+The source change is one word, but the fixtures are not: ~19 direct constructions in this repo plus one on the plugin side must supply the field. The integration fixtures should route through `PipeRunParamsFactory.make_run_params` instead — a net simplification, since they already hand-duplicate the factory's config read — but that is a ~20-file change with a cross-repo tail, landing on a release branch whose CI is green and which is about to merge to `main`. It belongs on `dev` immediately after the promotion.### Execution notes for the follow-up- **Tests:** add `pytest.raises(ValidationError)` coverage for both the constructor and `model_validate({...})` with the key absent, mirroring the required-`run_mode` coverage already in `tests/unit/pipelex/pipe_run/test_cogt_run_params_carrier.py:72-92`.- **Mutation-check it.** Temporarily restore `default=None` and confirm the new test goes red. A test green on first run proves nothing here.- **Fix the compaction fixture** to build via the factory and assert the observed bound — that is the one place where an accidentally-unbounded fan-out actually changes behavior.-- **Cross-repo, gated on the `pipelex` pin moving:** `pipelex-server/temporal/tests/integration/pipelex_temporal/data_converter/test_data_conv_pipe_run_params.py:22` round-trips `None`, so it asserts `None == None` and would not catch the field being dropped on the wire. Make it round-trip a real int bound.+- **Cross-repo, gated on the `pipelex` pin moving:** our Temporal plugin's payload-converter test round-trips `None`, so it asserts `None == None` and would not catch the field being dropped on the wire. Make it round-trip a real int bound.- **Honest caveat to keep in view:** making the field required converts a legacy-history decode into a `ValidationError`, and a workflow-task converter exception retries forever — it hangs rather than fails. Both states are non-events while Temporal is pre-production, and neither is fixed by a field default. It reconfirms that deploy discipline, not this field, is the real control over version skew under live histories.## Not deferred — the two P1s as Codex reported them@@ -71,7 +71,7 @@ Codex argued that `Pipelex.make` given a router that satisfies `PipeRouterProtocThe language claim is correct. Everything downstream of it is not:-- **No such router exists.** Every implementer in the workspace inherits nominally — `PipeRouter` (`pipelex/pipe_run/pipe_router.py`), `TemporalPipeRouter` in `pipelex-server/temporal/`, `MistralWorkflowsPipeRouter`, and every test stub. `pipelex-api` and `pipelex-server/transport/` contain no router at all.+- **No such router exists.** Every implementer in the workspace inherits nominally — `PipeRouter` (`pipelex/pipe_run/pipe_router.py`), the routers in our Temporal and Mistral Workflows plugins, and every test stub. `pipelex-api` and the transport layer that is not open core contain no router at all.- **The failure mode is static, not runtime.** The protocol is not `@runtime_checkable`, and injection performs no isinstance check — but pyright rejects a structural non-conformer at the injection boundary with `"run_batch_branch" is not present (reportArgumentType)`. Every consumer in this workspace is type-checked.- **Structural conformance was never viable here.** `PipeRouterProtocol` declares an attribute, three concrete observer hooks, a concrete template-method `run`, and an `@abstractmethod _run_pipe_job`. Conforming without inheriting would mean reimplementing `run`'s entire error-wrapping template. Inheritance is not one supported pattern — it is the only one.- **The cited convention says the opposite.** Codex referenced `AGENTS.md:255-258`; that section actually reads *"When extending the `Protocol`, also update every implementation (including no-op / null implementations) so structural typing is satisfied"* — a rule pointing away from the claim it was cited for.@@ -86,11 +86,11 @@ No test was added either. A test injecting a non-inheriting router would assertCodex argued that a worker resuming a `PipeRunParams` serialized before `batch_max_concurrency` existed would decode it as `None`, read as unbounded, changing both concurrency and replay grouping mid-flight.-The mechanism is real: `PipeRunParams` does ride a Temporal workflow argument (`pipelex-server/temporal/pipelex_temporal/tprl_pipe/wf_pipe_router.py:204`), workflow arguments are recorded in history and re-decoded on replay, and `gather_bounded`'s chunk size does determine command grouping — which `pipelex-server/temporal/docs/temporal-replay-determinism.md` places on the replay-unsafe side of its own table.+The mechanism is real: `PipeRunParams` does ride a Temporal workflow argument in our Temporal plugin's router workflow, workflow arguments are recorded in history and re-decoded on replay, and `gather_bounded`'s chunk size does determine command grouping — which that plugin's own replay-determinism notes place on the replay-unsafe side of their table.The scenario is not:-- **The Temporal integration is not in this package.** `pipelex/temporal/**` was removed in *Refactor/plugins 5* (#1006) and lives in the private `pipelex-server/temporal/` plugin; `pyproject.toml` carries no `temporalio` dependency. No OSS consumer of `pipelex` can have an in-flight durable batch.+- **The Temporal integration is not in this package.** It lives in our Temporal plugin, and `pyproject.toml` carries no `temporalio` dependency. No OSS consumer of `pipelex` can have an in-flight durable batch.- **The only exposed party is our own hosted plane, which is pre-production.** Temporal has never shipped to prod.- **A field default cannot fix the general case.** Bumping `pipelex` on a Temporal worker is a workflow-code change, and this same release lands the kernel extraction and the plugin entry-point-group split. There is no `workflow.patched` or worker-versioning machinery. Hot-swapping any pipelex version under live histories is unsafe with or without this field; the control is deploy discipline (drain, build IDs).- **The remedy is what the workspace rules out.** "No backward compatibility… no deprecation transition period." A legacy-payload sentinel is exactly the speculative back-compat machinery that policy exists to prevent, and the change is already recorded as breaking in the changelog.