Skip to content

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 Cubic review findings on v0.38.0 release PR

Louis Choquel24053f4a5515
diff --git a/.badges/tests.json b/.badges/tests.json
index 95990360b..699a0700d 100644
--- a/.badges/tests.json
+++ b/.badges/tests.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"label": "tests",
- "message": "8214",
+ "message": "8221",
"color": "blue",
"cacheSeconds": 300
}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 158241c53..0a470bc11 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,10 @@
### Fixed
- **Template truth-tests on singular values no longer crash:** `{% if var %}` (and `@?var`, which expands to it) on a present singular value used to raise `TypeError: '…' content does not support len().` — Jinja2's truth test fell through to the artefact's list-only `__len__`. `StuffArtefact` now defines `__bool__`: a present non-list artefact is truthy, a list artefact follows list emptiness. This makes the optionals guard idiom safe on both arms.
+- **`PipeCompose` escaped-sigil literals (`$$`, `@@`) no longer double-rewrite:** `PipeCompose` alone stored its template already-preprocessed and then re-ran the sigil rewriter at guard-lint and render time. Because the escape collapse (`$$name` → `$name`) is not idempotent, the second pass resurrected escaped literals into interpolations — raising a spurious `optional_input_unguarded` on a `$$name` that only *looks* like an optional reference, and silently rendering the value of `name` instead of the literal `$name`. `PipeCompose` now stores authored source and rewrites exactly once, like every other pipe.
+- **`--inputs ~/…` now expands on `run pipe` / `run bundle`:** a quoted or `=`-form tilde path (`--inputs "~/inputs.json"`, which the shell leaves unexpanded) is now `expanduser()`-ed before loading, resolving to the home directory instead of failing on a literal `~` — matching the existing `run method` behavior, on both the human and agent CLIs.
+- **Invalid storage/secrets `method` errors stay actionable under STRICT:** `UnknownStorageMethodError` / `UnknownSecretsMethodError` are marked caller-facing, so their "registered methods: … — check `storage_config.method`" guidance survives STRICT error disclosure instead of being redacted to a generic internal-error message.
+- **Non-string JSON pipe `type` gives an actionable error:** a `type` that is a list/dict/number in a `pipelex-agent pipe` JSON spec now surfaces as an `ArgumentError` naming the valid pipe types, instead of a cryptic internal `TypeError: unhashable type`.
- **GitHub Actions:** Removed an invalid `environment` block from the `manual-trigger-tests-check.yml` workflow.
### Documentation
diff --git a/pipelex/cli/agent_cli/commands/pipe_cmd.py b/pipelex/cli/agent_cli/commands/pipe_cmd.py
index 93179bf95..2b309a6f7 100644
--- a/pipelex/cli/agent_cli/commands/pipe_cmd.py
+++ b/pipelex/cli/agent_cli/commands/pipe_cmd.py
@@ -291,6 +291,15 @@ def pipe_cmd(
"implementation is a signature (contract only).",
error_type="ArgumentError",
)
+ if not isinstance(raw_pipe_type, str):
+ # A non-string `type` (list/dict/number) is an authoring mistake — sanitize it at this
+ # untrusted-input boundary so it surfaces as an actionable ArgumentError, not a cryptic
+ # internal TypeError (an unhashable list/dict would blow up the membership test downstream).
+ agent_error(
+ f"Invalid pipe type '{raw_pipe_type}'. Must be one of: {list(pipe_type_to_spec_class)}, "
+ "or omit `type` for a signature (contract only, no type).",
+ error_type="ArgumentError",
+ )
resolved_pipe_type = raw_pipe_type
else:
resolved_pipe_type = None
diff --git a/pipelex/cli/agent_cli/commands/run/stdin_resolver.py b/pipelex/cli/agent_cli/commands/run/stdin_resolver.py
index 780655a33..3254cf892 100644
--- a/pipelex/cli/agent_cli/commands/run/stdin_resolver.py
+++ b/pipelex/cli/agent_cli/commands/run/stdin_resolver.py
@@ -182,9 +182,12 @@ def _parse_inputs_arg(inputs_arg: str) -> dict[str, Any] | None:
agent_error(f"Failed to parse inline JSON inputs: {exc}", error_type="JSONDecodeError", cause=exc)
else:
try:
- loaded = load_inputs_dict_from_path(Path(inputs_arg))
+ # expanduser so a quoted / `=`-form `~/inputs.json` resolves to the home dir, not a
+ # literal `~` component (unquoted `~` is shell-expanded, but the quoted/`=` forms are not).
+ inputs_path = Path(inputs_arg).expanduser()
+ loaded = load_inputs_dict_from_path(inputs_path)
# Resolve relative url paths against the inputs file's parent directory
- base_dir = Path(inputs_arg).parent.resolve()
+ base_dir = inputs_path.parent.resolve()
return resolve_inputs_paths(loaded, base_dir=base_dir)
except FileNotFoundError as exc:
agent_error(f"Input file not found: {inputs_arg}", error_type="FileNotFoundError", cause=exc)
diff --git a/pipelex/cli/commands/run/_run_core.py b/pipelex/cli/commands/run/_run_core.py
index d00fe945f..bd4a00a76 100644
--- a/pipelex/cli/commands/run/_run_core.py
+++ b/pipelex/cli/commands/run/_run_core.py
@@ -153,9 +153,12 @@ async def _execute_run(
raise typer.Exit(1) from json_decode_exc
else:
try:
- pipeline_inputs = load_inputs_dict_from_path(Path(inputs))
+ # expanduser so a quoted / `=`-form `~/inputs.json` resolves to the home dir, not a
+ # literal `~` component (unquoted `~` is shell-expanded, but the quoted/`=` forms are not).
+ inputs_path = Path(inputs).expanduser()
+ pipeline_inputs = load_inputs_dict_from_path(inputs_path)
# Resolve relative url paths against the inputs file's parent directory
- base_dir = Path(inputs).parent.resolve()
+ base_dir = inputs_path.parent.resolve()
pipeline_inputs = resolve_inputs_paths(pipeline_inputs, base_dir=base_dir)
typer.echo(f"Loaded inputs from: {inputs}")
except FileNotFoundError as file_not_found_exc:
diff --git a/pipelex/pipe_operators/compose/pipe_compose.py b/pipelex/pipe_operators/compose/pipe_compose.py
index c431aec58..ec2d5f565 100644
--- a/pipelex/pipe_operators/compose/pipe_compose.py
+++ b/pipelex/pipe_operators/compose/pipe_compose.py
@@ -6,6 +6,7 @@ from typing_extensions import override
from pipelex import log
from pipelex.cogt.content_generation.dry_run_factory import DryRunFactory
from pipelex.cogt.templating.template_category import TemplateCategory
+from pipelex.cogt.templating.template_preprocessor import rewrite_template_sigils
from pipelex.cogt.templating.template_rendering import render_template
from pipelex.cogt.templating.templating_style import TemplatingStyle
from pipelex.config import get_config
@@ -71,10 +72,12 @@ class PipeCompose(PipeOperator[PipeComposeOutput]):
if self.template is None:
return set()
+ # `self.template` is authored source (sigils not yet rewritten), so rewrite once before
+ # detecting Jinja2 variables — otherwise `$var` / `@var` sigils go unseen as required inputs.
try:
full_paths = detect_jinja2_required_variables(
template_category=self.category,
- template_source=self.template,
+ template_source=rewrite_template_sigils(self.template),
)
except Jinja2DetectVariablesError as exc:
msg = f"Error detecting required variables for PipeCompose: {exc}"
diff --git a/pipelex/pipe_operators/compose/pipe_compose_factory.py b/pipelex/pipe_operators/compose/pipe_compose_factory.py
index 1c5735bdd..f3ff4dec2 100644
--- a/pipelex/pipe_operators/compose/pipe_compose_factory.py
+++ b/pipelex/pipe_operators/compose/pipe_compose_factory.py
@@ -65,6 +65,11 @@ class PipeComposeFactory(PipeFactoryProtocol[PipeComposeBlueprint, PipeCompose])
msg = "Template source is required for template mode"
raise PipeComposeFactoryError(msg)
+ # Preprocess here only to validate at load time (sigil syntax + Jinja2 parseability).
+ # The PipeCompose stores the *authored* source, like every other pipe (PipeLLM,
+ # PipeImgGen, PipeSearch), so downstream sigil rewrites (guard-lint, render) run exactly
+ # once. Storing the preprocessed form instead double-rewrote escaped literals (`$$var` →
+ # `$var` → `{{ var|format() }}`), causing false OPTIONAL_INPUT_UNGUARDED and render corruption.
try:
preprocessed_template = preprocess_template(template_source, declared_inputs=set(inputs.variables))
except TemplateSigilSyntaxError as exc:
@@ -85,7 +90,7 @@ class PipeComposeFactory(PipeFactoryProtocol[PipeComposeBlueprint, PipeCompose])
description=description,
inputs=inputs,
output=output,
- template=preprocessed_template,
+ template=template_source,
templating_style=blueprint.templating_style,
category=blueprint.template_category,
extra_context=blueprint.extra_context,
diff --git a/pipelex/plugins/exceptions.py b/pipelex/plugins/exceptions.py
index 65a34fa0a..3e24fd50d 100644
--- a/pipelex/plugins/exceptions.py
+++ b/pipelex/plugins/exceptions.py
@@ -207,6 +207,10 @@ class UnknownStorageMethodError(PluginError):
starting with no storage. The message lists the registered methods so the fix is obvious.
"""
+ # The message describes the caller's own input (the configured storage method) and lists the
+ # registered methods; it is fully actionable, so keep it verbatim under STRICT disclosure.
+ _authors_caller_facing_message = True
+
def __init__(self, *, method: str, registered_methods: list[str]):
self.method = method
self.registered_methods = registered_methods
@@ -228,6 +232,10 @@ class UnknownSecretsMethodError(PluginError):
starting with no secrets provider. The message lists the registered methods so the fix is obvious.
"""
+ # The message describes the caller's own input (the configured secrets method) and lists the
+ # registered methods; it is fully actionable, so keep it verbatim under STRICT disclosure.
+ _authors_caller_facing_message = True
+
def __init__(self, *, method: str, registered_methods: list[str]):
self.method = method
self.registered_methods = registered_methods
diff --git a/tests/integration/pipelex/pipes/optionals/test_optional_guard_lint.py b/tests/integration/pipelex/pipes/optionals/test_optional_guard_lint.py
index 46c7b9885..06757f8fc 100644
--- a/tests/integration/pipelex/pipes/optionals/test_optional_guard_lint.py
+++ b/tests/integration/pipelex/pipes/optionals/test_optional_guard_lint.py
@@ -223,3 +223,27 @@ class TestOptionalGuardLint:
),
)
assert compose.code == "guard_lint_compose_ok"
+
+ def test_escaped_dollar_literal_in_compose_is_not_a_false_positive(self, load_empty_library: Callable[[], None]):
+ """Regression: `$$maybe_note` is an escaped literal `$maybe_note`, not a reference.
+
+ PipeCompose must store its template in authored form so the guard-lint rewrites sigils
+ exactly once. When PipeCompose stored the already-preprocessed template instead, the
+ lint's own `rewrite_template_sigils` ran a second time and resurrected the escaped
+ literal (`$$maybe_note` → `$maybe_note` → `{{ maybe_note|format() }}`), wrongly raising
+ OPTIONAL_INPUT_UNGUARDED on a pipe that never references the optional input.
+ """
+ load_empty_library()
+ compose = PipeFactory[PipeCompose].make_from_blueprint(
+ domain_code=_DOMAIN_CODE,
+ pipe_code="guard_lint_compose_escaped",
+ blueprint=PipeComposeBlueprint(
+ description="Compose whose template escapes a literal `$` before an optional input's name",
+ inputs={"maybe_note": "Text?"},
+ output="Text",
+ template="The literal token is $$maybe_note here.",
+ ),
+ )
+ assert compose.code == "guard_lint_compose_escaped"
+ # The stored template stays authored (escaped), so a single downstream rewrite keeps it literal.
+ assert compose.template == "The literal token is $$maybe_note here."
diff --git a/tests/integration/pipelex/pipes/test_pipe_compose.py b/tests/integration/pipelex/pipes/test_pipe_compose.py
index a8ebcf6a3..eca76bb6c 100644
--- a/tests/integration/pipelex/pipes/test_pipe_compose.py
+++ b/tests/integration/pipelex/pipes/test_pipe_compose.py
@@ -58,6 +58,47 @@ class TestPipeCompose:
rendered_text = pipe_compose_output.main_stuff_as_str
pretty_print(rendered_text)
+ async def test_escaped_dollar_renders_as_literal(
+ self,
+ job_metadata: JobMetadata,
+ load_empty_library: Callable[[], None],
+ ):
+ """Regression: `$$amount` is an escaped literal `$amount` and must never interpolate.
+
+ PipeCompose stores its template in authored form, so render rewrites sigils exactly
+ once. When PipeCompose stored the already-preprocessed template, `render_template` ran
+ `rewrite_template_sigils` a second time, resurrecting `$$amount` → `$amount` →
+ `{{ amount|format() }}` and silently rendering the value of `amount` instead of the
+ literal `$amount`.
+ """
+ load_empty_library()
+ working_memory = WorkingMemoryFactory.make_from_single_stuff(
+ stuff=StuffFactory.make_stuff(
+ concept=get_native_concept(NativeConceptCode.TEXT),
+ content=TextContent(text="999"),
+ name="amount",
+ ),
+ )
+ pipe_job = PipeJobFactory.make_pipe_job(
+ pipe=PipeFactory[PipeCompose].make_from_blueprint(
+ domain_code="generic",
+ pipe_code="adhoc_escaped_dollar_literal",
+ blueprint=PipeComposeBlueprint(
+ description="Escaped literal dollar must render literally, not interpolate",
+ template="Price token: $$amount",
+ output=NativeConceptCode.TEXT,
+ ),
+ ),
+ pipe_run_params=PipeRunParamsFactory.make_run_params(pipe_run_mode=PipeRunMode.LIVE),
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ )
+ pipe_compose_output = cast("PipeComposeOutput", await get_pipe_router().run(pipe_job=pipe_job))
+ rendered_text = pipe_compose_output.main_stuff_as_str
+ pretty_print(rendered_text)
+ assert "$amount" in rendered_text, "escaped `$$amount` must render as the literal `$amount`"
+ assert "999" not in rendered_text, "escaped `$$amount` must not interpolate the value of `amount`"
+
@pytest.mark.parametrize("template_source", JINJA2TestCases.JINJA2_FOR_STUFF)
async def test_pipe_compose_for_stuff(
self,
diff --git a/tests/unit/pipelex/cli/test_pipe_cmd.py b/tests/unit/pipelex/cli/test_pipe_cmd.py
index 7806dc66f..63467335c 100644
--- a/tests/unit/pipelex/cli/test_pipe_cmd.py
+++ b/tests/unit/pipelex/cli/test_pipe_cmd.py
@@ -74,6 +74,20 @@ class TestCliPipeCmd:
assert "ArgumentError" in combined
assert "type" in combined
+ def test_non_string_type_rejected_with_actionable_error(self, capsys: pytest.CaptureFixture[str]) -> None:
+ """A non-string JSON `type` (e.g. a list/dict — unhashable) must surface as an actionable
+ ArgumentError naming the valid types, never a cryptic internal `TypeError: unhashable type`
+ leaking from the membership test inside parse_pipe_spec.
+ """
+ spec = json.dumps({"pipe_code": "x", "description": "d", "inputs": {"doc": "Document"}, "output": "Text", "type": ["PipeCompose"]})
+ with pytest.raises(typer.Exit):
+ pipe_cmd(spec=spec)
+ captured = capsys.readouterr()
+ combined = captured.err + captured.out
+ assert "ArgumentError" in combined
+ assert "TypeError" not in combined
+ assert "Invalid pipe type" in combined
+
# -- CLI TOML serialization (uses format_toml_string) -----------------
def test_llm_model_appears_in_toml(self) -> None:
diff --git a/tests/unit/pipelex/cli/test_stdin_resolver.py b/tests/unit/pipelex/cli/test_stdin_resolver.py
index ebf856ec6..3c964b56b 100644
--- a/tests/unit/pipelex/cli/test_stdin_resolver.py
+++ b/tests/unit/pipelex/cli/test_stdin_resolver.py
@@ -211,6 +211,17 @@ class TestStdinResolver:
result = parse_cli_inputs(inputs_arg=str(json_file))
assert result == {"key": "value"}
+ def test_inputs_tilde_path_is_expanded(self, tmp_path: Any, monkeypatch: pytest.MonkeyPatch) -> None:
+ """A quoted / `=`-form `~/inputs.json` (tilde not shell-expanded) resolves to the home dir.
+
+ The loader expands `~` itself so `--inputs "~/inputs.json"` opens the real file instead of
+ failing with a not-found error on a literal `~` path — matching the `run method` path.
+ """
+ monkeypatch.setenv("HOME", str(tmp_path))
+ (tmp_path / "inputs.json").write_text('{"tilde": "expanded"}')
+ result = parse_cli_inputs(inputs_arg="~/inputs.json", stdin_fallback=False)
+ assert result == {"tilde": "expanded"}
+
def test_inputs_wins_over_stdin(self, monkeypatch: pytest.MonkeyPatch) -> None:
"""When --inputs is provided, stdin is ignored."""
monkeypatch.setattr("sys.stdin", io.StringIO('{"from_stdin": true}'))
diff --git a/tests/unit/pipelex/cogt/templating/test_template_preprocessor.py b/tests/unit/pipelex/cogt/templating/test_template_preprocessor.py
index 4c80714d6..6b381ce0e 100644
--- a/tests/unit/pipelex/cogt/templating/test_template_preprocessor.py
+++ b/tests/unit/pipelex/cogt/templating/test_template_preprocessor.py
@@ -2,7 +2,7 @@ import pytest
from pipelex import pretty_print
from pipelex.cogt.templating.exceptions import TemplateSigilSyntaxError
-from pipelex.cogt.templating.template_preprocessor import preprocess_template
+from pipelex.cogt.templating.template_preprocessor import preprocess_template, rewrite_template_sigils
class TestTemplatePreprocessor:
@@ -763,6 +763,19 @@ Line after"""
expected = "Use $var here."
assert result == expected
+ def test_rewrite_template_sigils_is_not_idempotent_for_escaped_literals(self):
+ """`rewrite_template_sigils` must be applied exactly once per authored template — it is
+ NOT idempotent for escaped literals. `$$var` collapses to a literal `$var` on the first
+ pass, which a second pass would (wrongly) interpolate. This pins the contract that makes
+ "preprocess once, store authored source" mandatory: callers must never re-feed
+ already-preprocessed output back through the rewriter (see PipeCompose template mode).
+ """
+ once = rewrite_template_sigils("Use $$var here.")
+ assert once == "Use $var here."
+ twice = rewrite_template_sigils(once)
+ assert twice == "Use {{ var|format() }} here."
+ assert once != twice, "escaped-literal rewrite is not idempotent — preprocess exactly once"
+
def test_escape_does_not_consume_legit_variable(self):
"""Escape on one token must not affect a legitimate variable later in the string."""
template = "@@media is literal, but $width is a variable."
diff --git a/tests/unit/pipelex/exceptions/test_class_level_metadata.py b/tests/unit/pipelex/exceptions/test_class_level_metadata.py
index 2172f8195..1c1dc3ae8 100644
--- a/tests/unit/pipelex/exceptions/test_class_level_metadata.py
+++ b/tests/unit/pipelex/exceptions/test_class_level_metadata.py
@@ -19,6 +19,7 @@ from pipelex.cogt.exceptions import (
from pipelex.core.interpreter.exceptions import PipelexInterpreterError
from pipelex.pipe_run.pipe_run_mode import PipeRunMode
from pipelex.pipeline.exceptions import PipeExecutionError, PipelineExecutionError, ValidateBundleError
+from pipelex.plugins.exceptions import UnknownSecretsMethodError, UnknownStorageMethodError
from pipelex.system.exceptions import EnvVarNotFoundError
from pipelex.system.pipelex_service.exceptions import (
GatewayTermsNotAcceptedError,
@@ -102,6 +103,8 @@ class TestClassLevelMetadata:
("interpreter", PipelexInterpreterError("boom"), True),
("validate_bundle", ValidateBundleError("boom"), True),
("csv", CsvError("boom"), True),
+ ("unknown_storage_method", UnknownStorageMethodError(method="bogus", registered_methods=["local", "s3"]), True),
+ ("unknown_secrets_method", UnknownSecretsMethodError(method="bogus", registered_methods=["env"]), True),
("config", PipelexConfigError("boom"), False),
("pipe_execution", PipeExecutionError("boom"), False),
("cogt", CogtError("boom"), False),
diff --git a/wip/pr-1026-review-notes.md b/wip/pr-1026-review-notes.md
new file mode 100644
index 000000000..2edbc0d9c
--- /dev/null
+++ b/wip/pr-1026-review-notes.md
@@ -0,0 +1,47 @@
+# PR #1026 (Release v0.38.0) — deferred / declined review items
+
+Cubic left 7 unresolved threads on the v0.38.0 release PR. Five were fixed in the PR (PipeCompose sigil double-rewrite, two caller-facing exception markers, `--inputs ~` expansion, non-string pipe-type guard). The two below were **not** changed — one deferred for a deliberate follow-up, one declined as a false positive. This file records the reasoning so neither gets re-litigated from scratch.
+
+## Deferred — `validate_all` (builder) drops the `warnings` payload
+
+- **Reporter:** cubic-dev-ai (confidence 9, P2)
+- **Location:** `pipelex/builder/operations/validate_ops.py` — `validate_all` (the function around L24–53)
+- **Thread:** left **open** on PR #1026 for follow-up.
+
+### The finding (confirmed, but not a bug)
+
+Builder `validate_all` returns `{success, is_valid, validated_pipes, total_pipes}` with **no `warnings` key**. Its three siblings in the same file (`validate_bundle_file`, `validate_bundle_content`, `validate_pipe_in_bundle`) all carry `warnings` via `build_optionality_warnings(collect_controller_taint_analyses(result.pipes))`, and the agent-CLI twin `validate_all_core` (`pipelex/cli/agent_cli/commands/validate/_validate_core.py`) already emits them. So the whole-library advisory lints (e.g. useless-`!` detection) are dropped **only** on the builder `validate_all` path.
+
+### Why it was deferred rather than fixed on the release branch
+
+- It is **not a correctness bug**: `is_valid` stays correct and warnings never flip the verdict.
+- The change is **purely additive** (these functions return `dict[str, Any]`; `warnings` is just a key) — no contract/type change.
+- The builder `validate_ops` dict surface has **no in-repo consumers** (only `validate_pipe` is imported, by one lifecycle test); it is a downstream-facing API for `pipelex-api` / the build assistant, and the same-shape agent-CLI `validate_all` already supplies warnings.
+- `validate_all` carries an **explicit minimal-envelope design comment** (it deliberately omits `pending_signatures`/`is_runnable`). That rationale is about `pending_signatures`, not `warnings`, but it signals the envelope shape is a deliberate design decision the author should make — not something to fold silently into a release-branch fix pass.
+
+### Fix recipe (when picked up)
+
+Mirror `validate_all_core`'s inlined lifecycle instead of the `acquire_and_validate` shortcut (which tears the library down in its `finally` before returning, so warnings can't be computed post-hoc):
+
+1. capture `prev_library_id`, `acquire_library(...)`;
+2. in a `try`, call `BundleValidator().validate_current_library()`;
+3. compute `warnings = build_optionality_warnings(collect_controller_taint_analyses(list(get_pipe_library().get_pipes_dict().values())))` **before** teardown;
+4. restore prev library + teardown in `finally`.
+
+The needed imports (`collect_controller_taint_analyses`, `build_optionality_warnings`) are already present at the top of `validate_ops.py`. **Decision for the author:** add `warnings` only (minimal), or fully align the envelope with the agent-CLI twin (also add `pending_signatures`/`is_runnable`) and update the minimal-envelope design comment accordingly. Recommend at least `warnings`.
+
+**Test:** add an integration test under `tests/integration/pipelex/builder/operations/` that loads a library with a redundant-`!` flow (reuse the pattern in `tests/integration/pipelex/pipes/optionals/test_redundant_force_warning.py`), calls `validate_all(...)`, and asserts the returned dict's `warnings` contains the `optional_force_redundant` item — the analogue of the agent-CLI's existing validate-all warnings coverage.
+
+## Declined (false positive) — `NodeSpec.skip_reason` validator
+
+- **Reporter:** cubic-dev-ai (confidence 6, P3)
+- **Location:** `pipelex/graph/graphspec.py` — `NodeSpec.skip_reason` field (around L256–260)
+- **Thread:** replied + **resolved** (no code change).
+
+Cubic proposed a `NodeSpec` model_validator enforcing `skip_reason` only when `status == NodeStatus.SKIPPED`. Declined because the invariant `skip_reason set ⟺ status == SKIPPED` is already **maintained by construction**:
+
+- `NodeSpec` is built in exactly two internal builders (`graph_tracer.py` `_NodeData.to_node_spec`, `graphspec_assembler.py`), both of which copy `skip_reason` verbatim from a `_NodeData` builder whose `skip_reason` is initialized to `None` and only ever set in the same breath as `status = NodeStatus.SKIPPED` (`graph_tracer.py:901-902`, `graphspec_assembler.py:299-300`). No transition sets `skip_reason` on a non-skipped node.
+- **No consumer reads the field on a non-skipped node** — no reactflow/mermaidflow renderer touches `skip_reason`; the one place that maps skip reasons already filters on `status == NodeStatus.SKIPPED`.
+- `validate_graphspec` (the graph-level invariant home, where the analogous `_validate_failed_nodes_have_errors` lives) is **not wired into any production path** — even the on-disk `GraphSpec.model_validate_json` load in `graph_cmd.py` does not call it. So a model_validator would guard an internally-produced, already-consistent value — exactly the "don't guard impossible cases" case.
+
+If symmetry with `_validate_failed_nodes_have_errors` is ever wanted purely for tidiness, the correct home is a `_validate_skipped_nodes_have_reasons` helper in `pipelex/graph/validation.py` (the presence direction only: `skip_reason` non-None ⇒ `SKIPPED`), **not** a pydantic `model_validator` on `NodeSpec`. Even that is optional cleanup, not a correctness fix.