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.

feature/Markdown-filter-corpus-entry · L-261006-d008b3 (#1356)

Louis Choquelf500c8001331
diff --git a/CHANGELOG.md b/CHANGELOG.md
index afcf2e2f2..d9e01f72a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
### Added
- **A run request carries the method packages its bundle calls (Breaking)**: a `files` or `bundle_b64` request to `/v1/execute` or `/v1/start` may ship each package its bundle calls by address under `.mthds/methods/<name>/` at its root, with its `METHODS.toml`, and the server searches them before its installed copies and fetch-on-miss, for that run alone, so a shipped package wins over an installed copy and runs with fetching off; a package fetched by `method_ref` that ships its own `.mthds/methods/` is handled the same way. Those files no longer join the bundle's own `.mthds` content or its library directory, any other `.mthds` path in a bundle is refused with a `422 InvalidBundle` naming the entry, as are two shipped packages declaring the same address and name without regard to case, and on a sandbox-hosted deployment a shipped package declaring a Python structure class is refused with `403 MethodStructuresRefusedError`. The engine takes these directories as the new keyword-only `methods_dirs` of `PipelexMTHDSProtocol`, `pipeline_run_setup`, `acquire_library` and `LibraryManagerAbstract.load_from_blueprints`, which every implementation of the abstract must accept.
+- **The MTHDS Test Corpus covers the `markdown` template filter**: the new hand-maintained `feature.markdown_filter` tag names the filter of HTML templates that turns Markdown held in a plain text field into HTML, and the offline-tier entry `feature_markdown_filter_cake_order_slip` covers it with a PipeCompose run that pins its output, raw HTML in the source shown as text and only a URL with a scheme made a link.
### Changed
diff --git a/pipelex/cli/dev_cli/commands/generate_corpus_vocabulary_cmd.py b/pipelex/cli/dev_cli/commands/generate_corpus_vocabulary_cmd.py
index 38bb4b017..7addf1fc0 100644
--- a/pipelex/cli/dev_cli/commands/generate_corpus_vocabulary_cmd.py
+++ b/pipelex/cli/dev_cli/commands/generate_corpus_vocabulary_cmd.py
@@ -121,6 +121,11 @@ _FEATURE_TAGS: dict[str, str] = {
"`bundle.mthds` entry point, so a pipe can be forward-declared as a signature in one file and "
"satisfied by a concrete definition in another."
),
+ "markdown_filter": (
+ "The `markdown` filter of an HTML template, `{{ order.notes | markdown }}`, which turns Markdown held "
+ "in a plain text field into HTML: raw HTML in the source is shown as text, and only a URL with a "
+ "scheme becomes a link."
+ ),
}
# Same contract as `_NATIVE_EXCLUSIONS`, keyed on `PipeType` for the same reason: an exclusion whose
diff --git a/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/bundle.mthds b/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/bundle.mthds
new file mode 100644
index 000000000..efc5b23f5
--- /dev/null
+++ b/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/bundle.mthds
@@ -0,0 +1,23 @@
+domain = "cake_orders"
+description = "Writing out the slip a bakery pins to a cake order, with the customer's typed wishes formatted"
+main_pipe = "write_order_slip"
+
+[concept.CakeOrder]
+description = "A cake ordered at the bakery counter"
+
+[concept.CakeOrder.structure]
+customer = { type = "text", description = "The name the order is under", required = true }
+wishes = { type = "text", description = "What the customer asked for, typed at the counter with bold, italics and a bulleted list", required = true }
+
+[pipe.write_order_slip]
+type = "PipeCompose"
+description = "Lays the order out as a slip, turning the typed wishes into formatted text"
+inputs = { order = "CakeOrder" }
+output = "Html"
+
+[pipe.write_order_slip.template]
+category = "html"
+template = """
+<h2>Order for {{ order.customer }}</h2>
+{{ order.wishes | markdown }}
+"""
diff --git a/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/entry.toml b/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/entry.toml
new file mode 100644
index 000000000..334c8c564
--- /dev/null
+++ b/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/entry.toml
@@ -0,0 +1,10 @@
+name = "feature_markdown_filter_cake_order_slip"
+description = "A bakery's cake order slip, with the wishes typed at the counter turned into formatted text"
+
+validity = "valid"
+tier = "offline"
+granularity = "focused"
+
+covers = [
+ "feature.markdown_filter",
+]
diff --git a/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/inputs.json b/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/inputs.json
new file mode 100644
index 000000000..d6a335815
--- /dev/null
+++ b/pipelex/test_extras/mthds_corpus/entries/feature_markdown_filter_cake_order_slip/inputs.json
@@ -0,0 +1,9 @@
+{
+ "order": {
+ "concept": "cake_orders.CakeOrder",
+ "content": {
+ "customer": "Maëlle Le Goff",
+ "wishes": "**Nut-free**: one of the guests is allergic.\n\n- Candles: 8\n- Writing: *Joyeux anniversaire*\n\nThe cake to copy is at https://example.com/cakes/forest, saved as forest.jpg.\n\nCollection: Saturday<br>before noon"
+ }
+ }
+}
diff --git a/pipelex/test_extras/mthds_corpus/vocabulary.toml b/pipelex/test_extras/mthds_corpus/vocabulary.toml
index dd1df746a..c8791f584 100644
--- a/pipelex/test_extras/mthds_corpus/vocabulary.toml
+++ b/pipelex/test_extras/mthds_corpus/vocabulary.toml
@@ -250,6 +250,9 @@ description = "A PipeSequence step `{ from = \"invoice.total\", result = \"total
[feature.intent_hints]
description = "An `intent` hint authored in a `hints` table — on a concept, a structure field, or an expanded input slot — carrying non-normative presentation intent (`prose`, `label`, `rating`, `quantity`) that renderers may honor and every other consumer safely ignores."
+[feature.markdown_filter]
+description = "The `markdown` filter of an HTML template, `{{ order.notes | markdown }}`, which turns Markdown held in a plain text field into HTML: raw HTML in the source is shown as text, and only a URL with a scheme becomes a link."
+
[feature.multi_file_library]
description = "A method split across several `.mthds` files in one directory and merged additively behind a `bundle.mthds` entry point, so a pipe can be forward-declared as a signature in one file and satisfied by a concrete definition in another."
diff --git a/tests/integration/pipelex/test_extras/test_data.py b/tests/integration/pipelex/test_extras/test_data.py
index a5ce97c30..b556b327d 100644
--- a/tests/integration/pipelex/test_extras/test_data.py
+++ b/tests/integration/pipelex/test_extras/test_data.py
@@ -41,6 +41,21 @@ class OfflineRunExpectations:
concept_ref="shop_notices.PrintedNotice", content={"mime_type": "application/pdf", "filename": "notice-Boulangerie-Kerlann.pdf"}
),
},
+ "feature_markdown_filter_cake_order_slip": {
+ MAIN_STUFF_NAME: Bound(
+ concept_ref="native.Html",
+ content={
+ "inner_html": (
+ "<h2>Order for Maëlle Le Goff</h2>\n"
+ "<p><strong>Nut-free</strong>: one of the guests is allergic.</p>\n"
+ "<ul>\n<li>Candles: 8</li>\n<li>Writing: <em>Joyeux anniversaire</em></li>\n</ul>\n"
+ '<p>The cake to copy is at <a href="https://example.com/cakes/forest">https://example.com/cakes/forest</a>, '
+ "saved as forest.jpg.</p>\n"
+ "<p>Collection: Saturday&lt;br&gt;before noon</p>\n"
+ )
+ },
+ ),
+ },
"feature_binding_step_invoice_fields": {
"supplier_name": Bound(concept_ref="native.Text", content={"text": "Atelier Morvan"}),
"total_amount": Bound(concept_ref="native.Number", content={"number": 1250.5}),