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: render native.Anything inputs structureless instead of crashing the pipe-IO contract builder (#1178)

Louis Choquel68b6976ebe92
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 643d8ba47..8a9e2f1b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,7 @@
- **A dict-valued default made the generated `types.ts` unstable under prettier**: the default was rendered as a JSON object (`{"alpha": "first"}`), and prettier rewrites a TypeScript object literal at any line width — it pads the braces and drops the quotes from every key that is a plain identifier. One such default was therefore enough for a consumer's formatter run to change the artifact's bytes and have `pipelex codegen check` report an untouched file as hand-edited, which is precisely the drift the emitted formatting exists to prevent. Defaults now render as TypeScript literals, quoting only the keys prettier itself keeps quoted.
- **An unknown or ambiguous entry `pipe_code` is reported as the caller's mistake, not a server fault**: the two entry-shaped lookups — the ones a CLI argument and an API request field land in — raised the bare `PipeNotFoundError` / `PipeLibraryError`, which declare no `error_domain`, so `ErrorReport.http_status` fell through to 500. A caller typo in the `pipe_code` of a run request therefore came back as an internal error, logged with a traceback and looking retryable to every SDK, for a mistake only the caller could fix — and the same typo already answered 422 on the build routes, which catch those classes explicitly, so one input produced two verdicts depending on the route. Two dedicated classes now carry `ErrorDomain.INPUT` and a `CHANGE_INPUT` action: `EntryPipeNotFoundError` when the entry lookup resolves nothing, `EntryPipeAmbiguousError` when a bare code is declared in several domains. Both subclass the errors they replace, so every existing catcher still matches, and every presentation derives from the domain at once — 422 on the API, the classification the agent CLI reports, the hosted status. Both are caller-facing copy that survives STRICT disclosure, since the message names only the caller's own `pipe_code` and the qualified `pipe_ref`s of bundles they loaded themselves — which is the only thing that makes an ambiguity actionable. In-body resolution is deliberately untouched: `get_optional_pipe` / `get_required_pipe` keep raising the undomained classes, because a ref written inside a bundle is not a caller's input mistake. The one crossing case is translated rather than left to leak: an ambiguous `alias->bare_code` is detected one frame down, inside the alias-scoped search, and the entry lookup re-raises it as `EntryPipeAmbiguousError` keeping the original as its cause. The agent CLI's `validate` arms stopped hardcoding `PipeNotFoundError` as the reported `error_type` and now name the class that actually failed, which is where the domain and hint on that envelope come from.
- **A typo'd `--pipe` / `pipe_ref` slice selector is reported as the caller's mistake too**: bundle validation narrowed to one pipe (`pipelex-agent validate bundle --pipe`, its `validate method --pipe` twin, and the `pipe_ref` field the build routes forward) raised the undomained `PipeNotFoundError` when the selector named nothing in the bundle, so the same caller typo that answers 422 through the entry lookups came back as a 500 through this one — the divergence the entry-pipe classification above was meant to remove, left in place one module over. The selector is entry-shaped input by the same definition (a code a human typed at an entry point), so the miss now raises `EntryPipeNotFoundError` with its `INPUT` domain and `CHANGE_INPUT` action, keeping the raise site's own bundle-scoped wording, which names only the codes the caller supplied. It is a subclass of the class it replaces, so every existing catcher still matches; the hand-written 422 mapping the public runner API keeps for this case becomes redundant once a release carries the change.
+- **A `native.Anything` input no longer crashes the pipe-IO contract builder**: the builder resolved a structure class for every input, and `native.Anything` is the one concept the standard says has none — so a legal bundle declaring an `Anything` input validated cleanly and then died assembling the report, which the hosted validate route rendered as HTTP 500 with advice that could not be followed ("include the module" for a class that deliberately does not exist). The render chain now takes a structureless arm before any class lookup: on the wire, an `Anything` input publishes the permissive schema — no constraint keywords, only the identity annotations every rendered input schema carries (`title` = concept ref, `description` = the authored description) — which is semantically the empty schema "any JSON value", while sparing consumers a bare `{}` they would have to special-case; in a fill-in template it renders the empty mapping `{}`, the same value the client-side projections already chose for unknown nodes. Multiplicity wraps exactly as for class-backed concepts. The same arm heals the input shaper's expected-shape hint and `pipelex-dev trace-input-semantics`, which crashed on the same lookup. See [Pipe IO Contracts](under-the-hood/pipe-io-contracts.md).
- **A `native.JSON` input produced a fill-in template the runtime refused**: the input-form deriver grouped `native.JSON` with the three natives the standard calls structureless — `Dynamic`, `Anything` and `Composite` — so its descriptor node was `unknown`, which every inputs-template projection renders as the empty object. But `JSON` is not structureless: its pinned blueprint carries a required `json_obj`, and `JSONContent` refuses a payload without it, so the template a caller was handed for a `JSON` input could never be filled in and submitted. It now expands through the same pinned-structure arm as `Date`, `Html`, `Page`, `TextAndImages` and `SearchResult`, rendering `{"json_obj": {}}`, which the input shaper takes back. The engine's own `_pinned_structure` already drew the line in exactly this place — it returns a structure for `JSON` and `None` for the other three — so the deriver is now consistent with it, and the empty object stays the honest rendering for the natives that genuinely withhold their shape. The shared projection corpus gained a pipe covering all three of the natives it can reach at a slot position, which is where the defect had been sitting unmeasured. See [Projection Fixture Corpus](contribute/generate-projection-corpus.md).
- **A `native.Dynamic` input referenced in a `PipeLLM` prompt no longer fails dry-run validation demanding `ImageContent`**: the prompt analyzers decided whether a variable is a direct image (or document) by asking `is_compatible`, and `Dynamic`'s universal compatibility short-circuits that to `True` — so the analyzer recorded a direct image reference for a slot whose content the caller decides, and every legal bundle mentioning a `Dynamic` input in a prompt was refused at validation. A dynamic root concept now gets no static classification in either analyzer — the question is "is this definitely an X", which universal compatibility cannot answer — matching the guard shape the codebase already used in `PipeLLM.validate_output_with_library` and the input shaper. A `Dynamic` prompt variable renders as text, as it already did in `PipeCompose` templates; authors who want image or document attachment declare `Image`/`Document` (or a refining concept), and `| with_images` on a `Dynamic` variable stays refused. The document analyzer carried the identical latent bug, previously masked by the image misclassification, and gets the same guard. The same analyzer serves `PipeImgGen`'s positive and negative prompts, so the rule lands there too. One live behaviour is given up deliberately and is worth knowing: a `Dynamic` slot does not force `DynamicContent` — the input shaper hands the raw value to the bottom-up factory, so a caller passing an `ImageContent` into a `Dynamic` slot produced a `native.Image` stuff, which the direct reference then attached to the prompt. Attachment is now decided from the declared concept alone, so that image renders as text instead; declare the slot `Image` to keep it reaching the model. See [PipeLLM](building-methods/pipes/pipe-operators/PipeLLM.md).
- **A bad pipeline-input url survives STRICT disclosure as caller-facing copy**: `PipelineInputContentError` declared `caller_facing_message = True`, which is the name of the *report field*, not of the class-level flag that sets it (`_authors_caller_facing_message`). The declaration therefore did nothing, and the message a caller who simply omitted a url needs to see — the one listing the accepted schemes — was replaced by the generic internal-error placeholder on any surface serializing in STRICT mode, exactly the redaction the declaration was written to prevent. Repairing the flag also revealed why the class could not carry it as it stood: its other raise site reports an unreadable local path, and that message names the resolved path and the `OSError` subclass that rejected it, which would have made STRICT answer "does this server-side path exist, and may the runner read it?" for any authenticated caller of a deployment leaving `is_upload_local_content_enabled` on. The family is therefore split: `PipelineInputUrlMissingError` carries the blank-url message and is caller-facing, while `PipelineInputContentError` keeps the unreadable-path message and stays redacted. Both are pinned in the class-level-metadata sweep, in both directions.
diff --git a/docs/contribute/generate-projection-corpus.md b/docs/contribute/generate-projection-corpus.md
index be08d3c3d..71b613ccd 100644
--- a/docs/contribute/generate-projection-corpus.md
+++ b/docs/contribute/generate-projection-corpus.md
@@ -69,9 +69,9 @@ The entries declared today are all one descriptor gap — a nested list inside a
## The bundles
-`tests/data/input_semantics/` holds the corpus bundles. `probe_bundle.mthds` exercises every construct the language accepts and `hinted_bundle.mthds` the intent hints; `scaffold_bundle.mthds` was added for this corpus and covers what the other two do not — a text field merely named `url` beside a real file position, an optional nested structure, optional `native.Image` and `native.Document` fields inside a structure, and both a fixed `[N]` and a variable `[]` slot over a structured concept. Its `scaffold_open_natives` pipe holds the natives whose payload shape the descriptor states openly, at slot positions: `native.Dynamic` and `native.Composite`, which the standard calls structureless and whose node is therefore `unknown`, beside `native.JSON`, which is not — its pinned blueprint carries a required `json_obj`, so it expands like any other pinned native and its dict is where `unknown-empty-object` is measured.
+`tests/data/input_semantics/` holds the corpus bundles. `probe_bundle.mthds` exercises every construct the language accepts and `hinted_bundle.mthds` the intent hints; `scaffold_bundle.mthds` was added for this corpus and covers what the other two do not — a text field merely named `url` beside a real file position, an optional nested structure, optional `native.Image` and `native.Document` fields inside a structure, and both a fixed `[N]` and a variable `[]` slot over a structured concept. Its `scaffold_open_natives` pipe holds the natives whose payload shape the descriptor states openly, at slot positions: `native.Dynamic` and `native.Composite`, which declare no pinned structure and whose node is therefore `unknown`, beside `native.JSON`, which does declare one — its pinned blueprint carries a required `json_obj`, so it expands like any other pinned native and its dict is where `unknown-empty-object` is measured.
-`native.Anything` belongs in that pipe and is not there yet: an `Anything` input crashes the engine's contract builder, which resolves a structure class for every input and so asks for the one class the standard says does not exist. Its slot coverage waits on `L-260831-8f7c8c`.
+`native.Anything` belongs in that pipe and is not there yet. It no longer crashes the engine's renderer — the structureless arm renders it without resolving a class — but its template value is the empty mapping `{}`, which the input shaper refuses in both shapes, so adding it fails the round-trip gate this page describes. Its slot coverage waits on that being resolved.
## When to rerun it
diff --git a/docs/under-the-hood/pipe-io-contracts.md b/docs/under-the-hood/pipe-io-contracts.md
index 3d45050e0..d3e30175f 100644
--- a/docs/under-the-hood/pipe-io-contracts.md
+++ b/docs/under-the-hood/pipe-io-contracts.md
@@ -35,6 +35,12 @@ The JSON Schema on an input names its concept: `title` is the `concept_ref`, `de
}
```
+## The one concept with no structure class: `native.Anything`
+
+`native.Anything` is the only concept that declares no structure class, so its input schema cannot come from a pydantic render. (That is a different question from the three natives which declare no *pinned structure* — `Dynamic`, `Anything`, `Composite` — and therefore render as `unknown` in the [input-form descriptor](input-form-descriptor.md).) It publishes the **permissive schema**: no constraint keywords, only the identity annotations every rendered input schema carries — `{"title": "native.Anything", "description": "…"}`. Annotation keywords constrain nothing, so this is semantically the empty schema (any JSON value), which is what an untyped vehicle means, while consumers still see the concept's identity instead of a bare `{}` they would have to special-case. Multiplicity wraps exactly as above: `Anything[]` is an array of that schema, a fixed count adds the bounds.
+
+The schema states what the *concept* admits, not what today's input shaper accepts: an `Anything` slot currently takes a string (shaped into a `native.Text` stuff) and refuses the other JSON types. Narrowing the published schema to match would be stating a runtime limitation as a contract, so the schema stays permissive and the shaper is what has to catch up.
+
## Which surfaces carry it
The protocol `validate` operation carries `pipe_io_contracts` on its report. The [Agent CLI](../tools/cli/agent-cli.md#validate) does not: `pipelex-agent validate` emits the verdict, `pending_signatures`, `is_runnable`, and its own advisory `warnings` array, and stops there — the typed contracts are not part of its envelope.
diff --git a/pipelex/core/concepts/concept.py b/pipelex/core/concepts/concept.py
index fd78cb6d9..f6ca97eb8 100644
--- a/pipelex/core/concepts/concept.py
+++ b/pipelex/core/concepts/concept.py
@@ -194,6 +194,40 @@ class Concept(ConceptAbstract):
return result, generator.imports_needed
+ def render_structureless_representation(
+ self,
+ *,
+ output_format: ConceptRepresentationFormat,
+ multiplicity: VariableMultiplicity | None = None,
+ ) -> tuple[dict[str, Any], set[str]]:
+ """Render a representation for a concept that declares no structure class (`native.Anything`).
+
+ The SCHEMA arm publishes the permissive schema: no constraint keywords, only the concept's
+ identity annotations (`title` = concept ref, `description` = authored description) —
+ semantically the empty schema, "any JSON value", which is what an untyped vehicle means,
+ while keeping the invariant that every rendered input schema carries its concept's
+ identity. The JSON arm renders the empty mapping `{}` — the escape hatch's only honest
+ example value. Multiplicity wraps exactly as for class-backed concepts. PYTHON is refused:
+ there is no class to instantiate.
+
+ Returns:
+ Tuple of (representation dict with "concept" and "content" keys, empty imports set)
+
+ Raises:
+ ConceptValueError: When `output_format` is PYTHON.
+ """
+ match output_format:
+ case ConceptRepresentationFormat.SCHEMA:
+ json_schema: dict[str, Any] = {"title": self.concept_ref, "description": self.description}
+ content = self._wrap_schema_for_multiplicity(json_schema=json_schema, multiplicity=multiplicity)
+ return {"concept": self.concept_ref, "content": content}, set()
+ case ConceptRepresentationFormat.JSON:
+ json_content: dict[str, Any] | list[dict[str, Any]] = [{}] if is_multiple_multiplicity(multiplicity=multiplicity) else {}
+ return {"concept": self.concept_ref, "content": json_content}, set()
+ case ConceptRepresentationFormat.PYTHON:
+ msg = f"Concept '{self.concept_ref}' declares no structure class, so it has no Python representation"
+ raise ConceptValueError(msg)
+
def _render_schema_representation(
self,
*,
@@ -218,17 +252,29 @@ class Concept(ConceptAbstract):
# render: `title` is the concept ref, `description` the concept's authored description.
json_schema["title"] = self.concept_ref
json_schema["description"] = self.description
+ content = self._wrap_schema_for_multiplicity(json_schema=json_schema, multiplicity=multiplicity)
+ return {"concept": self.concept_ref, "content": content}, set()
- if is_multiple_multiplicity(multiplicity=multiplicity):
- # Wrap the schema in an array schema; the concept identity stays on `items`.
- array_schema: dict[str, Any] = {
- "type": "array",
- "items": json_schema,
- }
- item_count = fixed_item_count(multiplicity=multiplicity)
- if item_count is not None:
- array_schema["minItems"] = item_count
- array_schema["maxItems"] = item_count
- return {"concept": self.concept_ref, "content": array_schema}, set()
-
- return {"concept": self.concept_ref, "content": json_schema}, set()
+ @classmethod
+ def _wrap_schema_for_multiplicity(
+ cls,
+ *,
+ json_schema: dict[str, Any],
+ multiplicity: VariableMultiplicity | None,
+ ) -> dict[str, Any]:
+ """Wrap a rendered item schema per the declared multiplicity.
+
+ A list-shaped multiplicity wraps the schema in an array type (the concept identity stays
+ on `items`), and a fixed count adds `minItems`/`maxItems` bounds on the array.
+ """
+ if not is_multiple_multiplicity(multiplicity=multiplicity):
+ return json_schema
+ array_schema: dict[str, Any] = {
+ "type": "array",
+ "items": json_schema,
+ }
+ item_count = fixed_item_count(multiplicity=multiplicity)
+ if item_count is not None:
+ array_schema["minItems"] = item_count
+ array_schema["maxItems"] = item_count
+ return array_schema
diff --git a/pipelex/core/pipes/stuff_spec/stuff_spec.py b/pipelex/core/pipes/stuff_spec/stuff_spec.py
index db3dd3e54..32a839580 100644
--- a/pipelex/core/pipes/stuff_spec/stuff_spec.py
+++ b/pipelex/core/pipes/stuff_spec/stuff_spec.py
@@ -44,15 +44,23 @@ class StuffSpec(BaseModel):
"""Render a representation of this stuff spec.
Args:
- concept_provider: Resolves this spec's concept into its structure class. This is the one
- place in the whole render chain that resolves a class, so a caller states which
- library it means instead of every renderer reaching for one.
- output_format: The format to generate (JSON or PYTHON)
+ concept_provider: Resolves this spec's concept into its structure class, so a caller
+ states which library it means instead of every renderer reaching for one. Unused
+ on the structureless arm below, which resolves nothing.
+ output_format: The format to generate (JSON, PYTHON, or SCHEMA)
Returns:
Dictionary with concept and content structure,
wrapped in a list if multiplicity indicates multiple items.
"""
+ if not self.concept.declares_a_structure_class:
+ # `native.Anything` deliberately has no structure class: asking the provider for one
+ # is a category error, not a missing registration — render structureless instead.
+ json_value, _ = self.concept.render_structureless_representation(
+ output_format=output_format,
+ multiplicity=self.multiplicity,
+ )
+ return json_value
json_value, _ = self.concept.render_concept_representation(
structure_class=concept_provider.get_structure_class(concept=self.concept),
output_format=output_format,
diff --git a/pipelex/pipeline/input_form.py b/pipelex/pipeline/input_form.py
index b3abe4aa9..2cd4a91b0 100644
--- a/pipelex/pipeline/input_form.py
+++ b/pipelex/pipeline/input_form.py
@@ -351,9 +351,11 @@ class InputFormDeriver:
fields=[self._structure_field(name=field_name, field=field, seen=seen) for field_name, field in pinned_structure.items()],
)
case NativeConceptCode.DYNAMIC | NativeConceptCode.ANYTHING | NativeConceptCode.COMPOSITE:
- # The three the standard calls structureless: `_pinned_structure` returns None for
- # exactly these, so there is no authored shape to expand and `unknown` states that
- # honestly. Every other native belongs on an arm above — `native.JSON` sat here
+ # The three natives that declare no pinned structure: `_pinned_structure` returns
+ # None for exactly these, so there is no authored shape to expand and `unknown` states
+ # that honestly. (Distinct from `NativeConceptCode.is_structureless_concept`, which is
+ # about having no structure *class* and holds for `Anything` alone.) Every other
+ # native belongs on an arm above — `native.JSON` sat here
# until its pinned `json_obj` was noticed, and a template describing it as unknown
# rendered `{}`, which `JSONContent` then refused.
return UnknownField(name=name, concept_ref=node_ref, refines=refines, description=text, required=True)
diff --git a/tests/data/input_semantics/scaffold_bundle.mthds b/tests/data/input_semantics/scaffold_bundle.mthds
index 6a011318e..53a2ce5de 100644
--- a/tests/data/input_semantics/scaffold_bundle.mthds
+++ b/tests/data/input_semantics/scaffold_bundle.mthds
@@ -53,7 +53,7 @@ Any number of bookmarks:
"""
# The natives whose payload shape the descriptor states openly, at slot positions — the one place
-# the corpus never reached. `native.Dynamic` and `native.Composite` are structureless by design, so
+# the corpus never reached. `native.Dynamic` and `native.Composite` declare no pinned structure, so
# their node is `unknown` and every projection renders the empty object both renderers agree on.
# `native.JSON` is not: its pinned blueprint carries a required `json_obj`, so it expands like any
# other pinned native, and the dict inside it is the corpus's first REQUIRED unknown node — the
diff --git a/tests/integration/pipelex/cli/test_trace_input_semantics_cmd.py b/tests/integration/pipelex/cli/test_trace_input_semantics_cmd.py
index a559aa331..1b667a3f9 100644
--- a/tests/integration/pipelex/cli/test_trace_input_semantics_cmd.py
+++ b/tests/integration/pipelex/cli/test_trace_input_semantics_cmd.py
@@ -38,12 +38,13 @@ qty = { type = "integer", description = "SENT_field_qty", default_value = 3 }
[pipe.do_one]
type = "PipeLLM"
description = "Make text from item"
-inputs = { item = "Item", items = "Item[]", hint = "Text?" }
+inputs = { item = "Item", items = "Item[]", hint = "Text?", loose = "Anything" }
output = "Text"
prompt = '''
@item
@items
@?hint
+$loose
'''
"""
@@ -90,6 +91,12 @@ class TestTraceInputSemantics:
assert hop4_single["content"]["properties"]["label"]["description"] == "SENT_field_label"
hop4_multi = _read_json(output_dir / manifest["hop4_schema_renders"]["trace_tool_test.do_one.items"])
assert hop4_multi["content"]["type"] == "array"
+ # `native.Anything` declares no structure class: hop 3 records the skip rather than resolving
+ # one, and hop 4 still renders — through the structureless arm, as the permissive schema.
+ assert any("native.Anything" in entry for entry in manifest["hop3_skipped"])
+ hop4_loose = _read_json(output_dir / manifest["hop4_schema_renders"]["trace_tool_test.do_one.loose"])
+ assert hop4_loose["concept"] == "native.Anything"
+ assert set(hop4_loose["content"]) == {"title", "description"}
# Hop 5: the final wire contracts, keyed by namespaced pipe_ref, with presence flags.
hop5 = _read_json(output_dir / HOP5_FILE_NAME)
diff --git a/tests/integration/pipelex/pipeline/test_input_form.py b/tests/integration/pipelex/pipeline/test_input_form.py
index 69026b2f6..1d95088d4 100644
--- a/tests/integration/pipelex/pipeline/test_input_form.py
+++ b/tests/integration/pipelex/pipeline/test_input_form.py
@@ -612,8 +612,8 @@ class TestKindAssignmentTable:
assert json_field.kind == FieldKind.OBJECT, "native.JSON has a pinned structure, so it expands like the other pinned natives"
assert json_field.fields is not None
assert [field.name for field in json_field.fields] == ["json_obj"], "Its pinned blueprint's single required field"
- # The three the standard calls structureless — `_pinned_structure` returns None for exactly
- # these, so `unknown` is the honest kind and no other native may join them.
+ # The three natives that declare no pinned structure — `_pinned_structure` returns None for
+ # exactly these, so `unknown` is the honest kind and no other native may join them.
assert _field_by_name(natives, "dynamic_in").kind == FieldKind.UNKNOWN
assert _field_by_name(natives, "anything_in").kind == FieldKind.UNKNOWN
for field in natives.fields:
diff --git a/tests/integration/pipelex/pipeline/test_pipe_io_contracts.py b/tests/integration/pipelex/pipeline/test_pipe_io_contracts.py
index f05cd2d27..9c72fa597 100644
--- a/tests/integration/pipelex/pipeline/test_pipe_io_contracts.py
+++ b/tests/integration/pipelex/pipeline/test_pipe_io_contracts.py
@@ -119,6 +119,19 @@ go = "check"
"""
+_ANYTHING_MTHDS = """
+domain = "anything_contracts_test"
+description = "Bundle exercising the structureless native.Anything at input positions"
+
+[pipe.carry]
+type = "PipeCompose"
+description = "Carry an untyped payload through"
+inputs = { anything_in = "Anything", batch_in = "Anything[]", pair_in = "Anything[2]" }
+output = "Text"
+template = "$anything_in $batch_in $pair_in"
+"""
+
+
@pytest.mark.asyncio(loop_scope="class")
class TestBuildPipeIOContracts:
async def test_optional_markers_reported_on_contracts(self, load_empty_library: Callable[[], str]) -> None:
@@ -196,6 +209,39 @@ class TestBuildPipeIOContracts:
one_schema = make_from_one.inputs["docs"].json_schema
assert one_schema.get("type") != "array"
+ async def test_anything_input_publishes_permissive_schema(self, load_empty_library: Callable[[], str]) -> None:
+ """A `native.Anything` input renders instead of crashing: the contract publishes the
+ permissive schema — no constraint keywords, only the concept's identity annotations —
+ with multiplicity wrapping exactly as for class-backed concepts.
+ """
+ outer_library_id = load_empty_library()
+ try:
+ result = await validate_bundle(mthds_contents=[_ANYTHING_MTHDS])
+ io_contracts = build_pipe_io_contracts(result.pipes)
+ finally:
+ _teardown_validation_library(outer_library_id)
+
+ carry = io_contracts["anything_contracts_test.carry"]
+
+ single = carry.inputs["anything_in"]
+ assert single.concept_ref == "native.Anything"
+ assert single.multiplicity == IOMultiplicity.SINGLE
+ assert single.json_schema["title"] == "native.Anything"
+ assert single.json_schema["description"]
+ assert set(single.json_schema) == {"title", "description"}
+
+ batch = carry.inputs["batch_in"]
+ assert batch.multiplicity == IOMultiplicity.VARIABLE
+ assert batch.json_schema["type"] == "array"
+ assert batch.json_schema["items"]["title"] == "native.Anything"
+ assert "minItems" not in batch.json_schema
+
+ pair = carry.inputs["pair_in"]
+ assert pair.multiplicity == IOMultiplicity.FIXED
+ assert pair.item_count == 2
+ assert pair.json_schema["minItems"] == 2
+ assert pair.json_schema["maxItems"] == 2
+
async def test_schema_render_failure_converts_to_structured_error(
self,
load_empty_library: Callable[[], str],
diff --git a/tests/integration/pipelex/pipeline/test_protocol_validate.py b/tests/integration/pipelex/pipeline/test_protocol_validate.py
index ae5c79d40..b07573334 100644
--- a/tests/integration/pipelex/pipeline/test_protocol_validate.py
+++ b/tests/integration/pipelex/pipeline/test_protocol_validate.py
@@ -47,6 +47,18 @@ output = "Summary"
prompt = "Summarize $doc"
"""
+_ANYTHING_INPUT_MTHDS = """
+domain = "protocol_validate_anything"
+description = "Bundle with an untyped native.Anything input, for the verdict-not-500 regression"
+
+[pipe.carry]
+type = "PipeCompose"
+description = "Carry an untyped payload through"
+inputs = { anything_in = "Anything" }
+output = "Text"
+template = "$anything_in"
+"""
+
_MAIN_PIPE_MTHDS = """
domain = "protocol_validate_graph"
description = "Bundle declaring a main_pipe, for the graph arm"
@@ -133,6 +145,27 @@ class TestProtocolValidate:
finally:
clear_current_library()
+ async def test_anything_input_produces_a_verdict(self, load_empty_library: Callable[[], str]) -> None:
+ """A legal bundle with a `native.Anything` input produces a report — the IO-contract
+ assembly must not throw the verdict away after validation succeeded (the hosted route
+ rendered that as HTTP 500).
+ """
+ load_empty_library()
+ try:
+ runner = PipelexMTHDSProtocol()
+ report = await runner.validate(mthds_contents=[_ANYTHING_INPUT_MTHDS])
+
+ assert isinstance(report, PipelexValidationReport)
+ assert report.is_runnable is True
+ anything_schema = report.pipe_io_contracts["protocol_validate_anything.carry"].inputs["anything_in"].json_schema
+ # The permissive schema carries the identity annotations and nothing else: no constraint
+ # keyword may appear, and `description` must be the concept's own, not an empty string.
+ assert set(anything_schema) == {"title", "description"}
+ assert anything_schema["title"] == "native.Anything"
+ assert anything_schema["description"]
+ finally:
+ clear_current_library()
+
async def test_hint_lint_warns_without_invalidating(self, load_empty_library: Callable[[], str]) -> None:
"""A warnable hint (unknown key) rides the advisory `warnings` channel; the bundle stays
valid and runnable, and the applicable `intent` beside it warns nothing (spec: hints are
diff --git a/tests/unit/pipelex/core/memory/input_shaper/test_errors.py b/tests/unit/pipelex/core/memory/input_shaper/test_errors.py
index 5582b1351..26b59516d 100644
--- a/tests/unit/pipelex/core/memory/input_shaper/test_errors.py
+++ b/tests/unit/pipelex/core/memory/input_shaper/test_errors.py
@@ -30,6 +30,10 @@ ERROR_CASES: list[tuple[str, str, VariableMultiplicity | None, Any, type[InputSh
("wrong-bool-for-number", "shaper_test.Priority", None, True, WrongScalarKindError, "expects a number"),
# D9 a top-level null is a hard error (absence = omit the key).
("null-top-level", "native.Text", None, None, NullInputError, "null"),
+ # Same rule on the one concept that declares no structure class: `native.Anything` reaches the
+ # expected-shape render (this arm fires before the D5 `InputKind.DYNAMIC` short-circuit), so the
+ # hint has to be renderable without resolving a class — it used to raise while building the error.
+ ("null-top-level-anything", "native.Anything", None, None, NullInputError, "null"),
# D2 a list where a singular is declared is ambiguous.
("list-where-singular", "shaper_test.Question", None, ["a", "b"], ListWhereSingularError, "single"),
# `[1]` IS the singular declaration, so it refuses a list on the same grounds — including a
diff --git a/tests/unit/pipelex/core/pipes/test_stuff_spec.py b/tests/unit/pipelex/core/pipes/test_stuff_spec.py
index ab33e1a59..f8c660837 100644
--- a/tests/unit/pipelex/core/pipes/test_stuff_spec.py
+++ b/tests/unit/pipelex/core/pipes/test_stuff_spec.py
@@ -1,9 +1,15 @@
import pytest
+from typing_extensions import override
+from pipelex.core.concepts.concept import Concept
from pipelex.core.concepts.concept_factory import ConceptFactory
+from pipelex.core.concepts.concept_provider_abstract import ConceptProviderAbstract
+from pipelex.core.concepts.concept_representation_generator import ConceptRepresentationFormat
+from pipelex.core.concepts.exceptions import ConceptValueError
from pipelex.core.concepts.native.concept_native import NativeConceptCode
from pipelex.core.pipes.stuff_spec.stuff_spec import StuffSpec
from pipelex.core.pipes.variable_multiplicity import PresenceMarker, VariableMultiplicity
+from pipelex.core.stuffs.stuff_content import StuffContent
class TestStuffSpecToBundleRepresentation:
@@ -103,3 +109,98 @@ class TestStuffSpecToBundleRepresentation:
concept = ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.TEXT)
stuff_spec = StuffSpec(concept=concept, presence=presence)
assert stuff_spec.to_bundle_representation() == expected
+
+
+class _RefusingConceptProvider(ConceptProviderAbstract):
+ """A provider whose class resolution must never be reached — structureless renders resolve nothing."""
+
+ @override
+ def get_required_concept(self, concept_ref: str) -> Concept:
+ msg = "get_required_concept must not be called for a structureless render"
+ raise AssertionError(msg)
+
+ @override
+ def get_native_concept(self, native_concept: NativeConceptCode) -> Concept:
+ msg = "get_native_concept must not be called for a structureless render"
+ raise AssertionError(msg)
+
+ @override
+ def get_required_entry_concept(self, concept_ref_or_code: str, *, search_scope: str | None = None) -> Concept:
+ msg = "get_required_entry_concept must not be called for a structureless render"
+ raise AssertionError(msg)
+
+ @override
+ def is_compatible(self, *, tested_concept: Concept, wanted_concept: Concept, strict: bool = False) -> bool:
+ msg = "is_compatible must not be called for a structureless render"
+ raise AssertionError(msg)
+
+ @override
+ def get_structure_class(self, *, concept: Concept) -> type[StuffContent]:
+ msg = "get_structure_class must not be called for a structureless render"
+ raise AssertionError(msg)
+
+
+class TestStuffSpecStructurelessRender:
+ """`native.Anything` renders without resolving a structure class.
+
+ SCHEMA publishes the permissive schema — no constraint keywords, only the concept's identity
+ annotations (`title` = concept ref, `description` = authored description); JSON renders the
+ empty mapping. Multiplicity wraps exactly as for class-backed concepts.
+ """
+
+ def test_schema_single_is_annotated_permissive(self):
+ concept = ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.ANYTHING)
+ stuff_spec = StuffSpec(concept=concept)
+
+ result = stuff_spec.render_stuff_spec(concept_provider=_RefusingConceptProvider(), output_format=ConceptRepresentationFormat.SCHEMA)
+
+ assert result["concept"] == "native.Anything"
+ assert result["content"] == {"title": "native.Anything", "description": concept.description}
+
+ def test_schema_variable_list_wraps_in_unbounded_array(self):
+ concept = ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.ANYTHING)
+ stuff_spec = StuffSpec(concept=concept, multiplicity=True)
+
+ result = stuff_spec.render_stuff_spec(concept_provider=_RefusingConceptProvider(), output_format=ConceptRepresentationFormat.SCHEMA)
+
+ assert result["content"] == {
+ "type": "array",
+ "items": {"title": "native.Anything", "description": concept.description},
+ }
+
+ def test_schema_fixed_count_bounds_the_array(self):
+ concept = ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.ANYTHING)
+ stuff_spec = StuffSpec(concept=concept, multiplicity=3)
+
+ result = stuff_spec.render_stuff_spec(concept_provider=_RefusingConceptProvider(), output_format=ConceptRepresentationFormat.SCHEMA)
+
+ assert result["content"] == {
+ "type": "array",
+ "items": {"title": "native.Anything", "description": concept.description},
+ "minItems": 3,
+ "maxItems": 3,
+ }
+
+ def test_json_single_is_empty_mapping(self):
+ concept = ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.ANYTHING)
+ stuff_spec = StuffSpec(concept=concept)
+
+ result = stuff_spec.render_stuff_spec(concept_provider=_RefusingConceptProvider(), output_format=ConceptRepresentationFormat.JSON)
+
+ assert result == {"concept": "native.Anything", "content": {}}
+
+ @pytest.mark.parametrize("multiplicity", [True, 3])
+ def test_json_multiple_wraps_in_list(self, multiplicity: VariableMultiplicity):
+ concept = ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.ANYTHING)
+ stuff_spec = StuffSpec(concept=concept, multiplicity=multiplicity)
+
+ result = stuff_spec.render_stuff_spec(concept_provider=_RefusingConceptProvider(), output_format=ConceptRepresentationFormat.JSON)
+
+ assert result == {"concept": "native.Anything", "content": [{}]}
+
+ def test_python_format_is_refused(self):
+ concept = ConceptFactory.make_native_concept(native_concept_code=NativeConceptCode.ANYTHING)
+ stuff_spec = StuffSpec(concept=concept)
+
+ with pytest.raises(ConceptValueError, match="no structure class"):
+ stuff_spec.render_stuff_spec(concept_provider=_RefusingConceptProvider(), output_format=ConceptRepresentationFormat.PYTHON)
diff --git a/wip/open-native-inputs/plan.md b/wip/open-native-inputs/plan.md
index 22371dc27..fedf8058c 100644
--- a/wip/open-native-inputs/plan.md
+++ b/wip/open-native-inputs/plan.md
@@ -49,6 +49,14 @@ Branch `fix/Anything-io-contract`, PR → `dev`. Its own PR, per the item: a wir
> **Checkpoint 1 recorded (2026-09-01):** PR [#1178](https://github.com/Pipelex/pipelex/pull/1178) open against `dev` (branch `fix/Anything-io-contract`), full `agent-check` + `agent-test` green. R1 implemented as annotated-permissive and R2 as the empty mapping, both as planned; review outcome pending. The structureless arm landed in `StuffSpec.render_stuff_spec` with `Concept.render_structureless_representation` beside `_render_schema_representation`, sharing the array wrap through an extracted `_wrap_schema_for_multiplicity`; PYTHON is refused with `ConceptValueError`. The deferred `error_domain` ruling on `PipeIOContractError`'s residual causes is filed as L-260901-5bb532.
+> **Checkpoint 1 — review outcome (2026-09-02):** R1 and R2 both survived review unamended; the reviewed additions to the PR are tests and wording only, no behaviour change. Three findings were deferred to their own items rather than widening the PR, all three the same root cause — a mechanically derived `AnythingContent` that never resolves — at sites this phase did not reach:
+>
+> - **L-260902-9546ef (high)** — a `PipeLLM` with `output = "Anything"` still escapes protocol `validate` as `kajson.ClassRegistryNotFoundError`, which is not a `PipelexError` and carries no `error_domain`, so the hosted route renders the same HTTP 500 this phase set out to remove. `pipe_operators/llm/pipe_llm.py:234` reads the class registry directly, bypassing `get_structure_class` and therefore the guard. This is the input fix's mirror image and the phase's biggest blind spot: the regression test is input-only.
+> - **L-260902-db6d1e (normal)** — `pipelex build runner` on an `Anything` input still emits the unfollowable "include that module" advice verbatim (`builder/runner_code.py:102`, `:213`), and a concept declaring `refines = "Anything"` cannot be loaded at all (`core/concepts/concept_factory.py:466`) while codegen treats that declaration as legal.
+> - **R1 is wider than the runtime, and the docs now say so.** An `Anything` input accepts a string only (shaped into a `native.Text` stuff) and refuses number, bool, list and dict — see Phase 3 item 4 below for the measured evidence. R1 stays as ruled: narrowing the published schema would state a runtime limitation as a contract. `docs/under-the-hood/pipe-io-contracts.md` names the gap explicitly so a consumer reading the contract is not surprised by it, and closing it is the shaper's job.
+>
+> Also corrected in review: `docs/contribute/generate-projection-corpus.md` still asserted that an `Anything` input crashes the contract builder, which this phase made false; the word *structureless* was carrying two incompatible meanings across `NativeConceptCode.is_structureless_concept` (no structure **class**, `Anything` alone) and `input_form.py` (no **pinned structure**, three natives), and the sites now say which they mean.
+
## Phase 2 — dynamic concepts get no static prompt classification (fixes L-260831-635398)
Branch `fix/Dynamic-prompt-classification`, PR → `dev`. Independent of Phase 1 — disjoint files; no stacking needed.
@@ -74,7 +82,21 @@ This is the work L-260831-264cbd had to leave behind, and it lands as a fixture
1. Add `anything_in = "Anything"` to `scaffold_open_natives` in `tests/data/input_semantics/scaffold_bundle.mthds` (inputs and template), alongside its existing `json_in` / `dynamic_in` / `composite_in`. Add a `PipeLLM` pipe covering `native.Dynamic` referenced in a prompt — the coverage item 2's fix makes writable.
2. Regenerate: `.venv/bin/pipelex-dev generate-projection-corpus tests/data/input_semantics/*.mthds -o /tmp/projection-corpus`; update `tests/integration/pipelex/pipeline/test_input_form.py` expectations where the scaffold grew.
3. Re-commit the captures in `mthds-js` and `mthds-python`. L-260831-56a78f and L-260831-933a6c are already open for the current regeneration — if still open when Phase 3 runs, note the added coverage on them and let one re-commit carry both; otherwise file fresh items with `ledger new --owner mthds-python|mthds-js`.
-4. **Known risk**: the corpus round-trip gate feeds every projected template back through the input shaper. The `{}` example for `Anything` goes down the shaper's `InputKind.DYNAMIC` bottom-up arm; if that arm refuses an empty dict, the gate says so at generation time — resolve by either recording it as a deliberate projection difference (the corpus has a slot for those) or fixing the shaper arm, whichever the failure shows is honest. Do not pre-build a guard for a refusal that may not happen.
+4. **Known risk, now measured — the arm refuses.** The risk this item named is real, and PR 1's review probed it ahead of Phase 3 so the phase starts from a settled question. Against a live library, an `Anything` slot refuses the R2 template in both shapes:
+
+ ```
+ compact {} REFUSED StuffFactoryError: ... does not have a 'concept' key.
+ explicit {"concept": "native.Anything", "content": {}} REFUSED StuffFactoryError: ... 'native.Anything' is not compatible with a dict content
+ ```
+
+ The refusal is broader than the empty dict. Of the JSON types, an `Anything` input accepts only a string, and shapes it into a `native.Text` stuff rather than an `Anything` one:
+
+ ```
+ string OK -> concept=native.Text content=TextContent
+ number REFUSED bool REFUSED list REFUSED dict REFUSED
+ ```
+
+ So the choice this item offered — record a deliberate projection difference, or fix the shaper arm — resolves toward **fixing the shaper arm**: recording a difference would pin a template nobody can submit, which is exactly the defect the `native.JSON` entry in the same release says it removed. It also means R1's published schema ("any JSON value") is currently wider than the runtime, which `docs/under-the-hood/pipe-io-contracts.md` now says out loud rather than leaving for a consumer to discover. Adding `anything_in` to `scaffold_open_natives` before the shaper is fixed will fail the round-trip gate; `docs/contribute/generate-projection-corpus.md` records that as the reason the slot is still empty.
**Checkpoint 3** — corpus regenerated and re-committed across the three repos; both bugs closed with the merges as evidence.