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/Console-default-refusal-never · L-261003-3b1a26 (#1321)
Louis Choquel86934aac478d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1f4275ade..c20b600fe 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,7 @@- **Markdown with unclosed emphasis is converted in memory proportional to its length**: the Markdown parser behind the `markdown` filter, the `Markdown` concept's HTML and the built-in PDF engine held memory growing with the square of the text when emphasis or strikethrough markers were left unmatched, about 1.5 GB for 64,000 characters of `**a `; it now joins the text they leave behind in one pass, and renders the same HTML.- **Routing profiles no longer rewrite their own routes**: matching a model merged the enabled `optional_routes` into the profile's declared `routes` in place, so after the first match a route declared optional had become an unconditional one in the loaded profile. Only the enablement checks each match repeats kept that from changing a routing decision.+- **The logging documentation no longer promises that a server refuses the `console` sink**: the log-sink, logging, logging-configuration and Rich-imports pages said a server installed without the `cli` extra stops at boot when it selects the `console` sink or the `rich` pretty-print mode. The core dependencies `typer` and `instructor` install Rich anyway, so such a server boots on the Rich surface; the pages now say a server selects `json` and a Rich-free mode in its own configuration, since nothing at boot makes that choice for it.### Securitydiff --git a/docs/configuration/config-practical/logging-config.md b/docs/configuration/config-practical/logging-config.mdindex 55ec89ab7..b587146a4 100644--- a/docs/configuration/config-practical/logging-config.md+++ b/docs/configuration/config-practical/logging-config.md@@ -44,7 +44,7 @@ sink = "console"```- Names the registered log sink boot installs on the root logger, the way `runtime.storage.method` names a storage backend-- `"console"`: the Rich handler, for a terminal. The default, so the CLI keeps its rendering. It needs the `cli` extra (`pipelex[cli]`), and a boot that selects it without Rich installed stops, naming the extra and the `json` alternative+- `"console"`: the Rich handler, for a terminal. The default, so the CLI keeps its rendering. It needs Rich, which the `cli` extra (`pipelex[cli]`) declares, and a boot that selects it without Rich installed stops, naming the extra and the `json` alternative. The core dependencies `typer` and `instructor` install Rich anyway, so that refusal does not fire on an ordinary install: a server that forgot to select `json` boots on this sink- `"json"`: one JSON object per line, for a server behind a log agent- `"otlp"`: the OpenTelemetry logs signal, for a collector- `"gcp"`: Google Cloud Logging through the client library, for a process that must write to it directly@@ -68,10 +68,10 @@ pretty_print_mode = "rich"```- Controls the panels that `pretty_print(...)` renders, such as the "Output of pipe" panel shown after every operator pipe-- `"rich"`: Rich tables and panels on the console print target. It needs the `cli` extra (`pipelex[cli]`), and a boot that selects it without Rich installed stops, naming the extra and the two modes below+- `"rich"`: Rich tables and panels on the console print target. It needs Rich, which the `cli` extra (`pipelex[cli]`) declares, and a boot that selects it without Rich installed stops, naming the extra and the two modes below; as with the `console` sink, the core dependencies install Rich anyway, so that refusal does not fire on an ordinary install- `"poor"`: plain text in a drawn frame on stderr, with no Rich panel and no Rich import; a pipe's output prints as its plain rendering- `"silent"`: nothing is printed and no renderable is built, for a host with no console or one that must not spend time rendering on the thread that runs pipes-- Default: `"rich"`. The agent CLI forces `"silent"`, and a server installed without the `cli` extra sets `"poor"` or `"silent"` beside `sink = "json"`+- Default: `"rich"`. The agent CLI forces `"silent"`, and a server sets `"poor"` or `"silent"` beside `sink = "json"` in its own configuration, since nothing at boot sets either for it- Boot applies the key, replacing any `PrettyPrinter.mode` assigned in code before it, and teardown returns the printer to the mode the process held before that boot### JSON Formattingdiff --git a/docs/contribute/rich-imports.md b/docs/contribute/rich-imports.mdindex cf5c93fa3..da8cdaf40 100644--- a/docs/contribute/rich-imports.md+++ b/docs/contribute/rich-imports.md@@ -81,7 +81,7 @@ Nothing a server needs. What needs Rich stops as early as it can, naming the ext| The stuff viewer page | The Pretty tab shows the JSON rendering. || The `pipelex`, `pipelex-agent` and `pipelex-dev` commands | Would fail at import with a bare `ImportError`. Not reachable on a documented install, since `typer` and `instructor` keep Rich installed; a launcher that names the extra belongs with the work that removes them from the closure. |-The boot checks the sink and the pretty-print mode together, in `runtime_boot.py`, so a server that forgot either setting fails at startup rather than at the first pipe that logs or prints its output.+The boot checks the sink and the pretty-print mode together, in `runtime_boot.py`, so a process without Rich that selected either Rich surface fails at startup rather than at the first pipe that logs or prints its output. Since every install carries Rich, as described above, a server that forgot either setting passes that check and boots on the Rich surface: its configuration is the only thing that keeps it on `json` and a Rich-free mode.## Enforcementdiff --git a/docs/tools/logging.md b/docs/tools/logging.mdindex 7501cd22c..64baa1ad2 100644--- a/docs/tools/logging.md+++ b/docs/tools/logging.md@@ -201,7 +201,7 @@ Logging is configured in two steps at boot. `log.configure` sets the levels and## Console rendering-The default sink, `console`, renders through Rich with every `[runtime.log.rich_log]` setting. Rich is the `cli` extra (`pipelex[cli]`), which the command-line tools install and a server leaves out. The sink imports Rich when it is built, so a process that selects `json` or `otlp` never loads it through the sink, and one that selects `console` without Rich installed stops at boot naming the extra to install and the `json` alternative. A server without the extra also sets `pretty_print_mode` to `"poor"` or `"silent"`, since the `"rich"` panels are refused at boot the same way (see [Pretty-Print Mode](../configuration/config-practical/logging-config.md#pretty-print-mode)).+The default sink, `console`, renders through Rich with every `[runtime.log.rich_log]` setting. Rich is the `cli` extra (`pipelex[cli]`), which the command-line tools install. The sink imports Rich when it is built, so a process that selects `json` or `otlp` never loads it through the sink, and one that selects `console` without Rich installed stops at boot naming the extra to install and the `json` alternative. That refusal is not what keeps a server off the console: `typer` and `instructor`, both core dependencies, require Rich, so it is installed even where the extra is not, and a server that forgot to select `json` boots on the `console` sink. A server therefore selects `json` in its own configuration, and sets `pretty_print_mode` to `"poor"` or `"silent"` beside it, since the boot makes neither choice for it (see [Pretty-Print Mode](../configuration/config-practical/logging-config.md#pretty-print-mode)).### Rich Formattingdiff --git a/docs/under-the-hood/log-sink-plugins.md b/docs/under-the-hood/log-sink-plugins.mdindex 9def7a71c..06d333c61 100644--- a/docs/under-the-hood/log-sink-plugins.md+++ b/docs/under-the-hood/log-sink-plugins.md@@ -130,7 +130,7 @@ The `otlp` factory imports the OpenTelemetry logs SDK when it runs, and the `gcp### Why `console` is the default-`pipelex/pipelex.toml` ships `sink = "console"`. A user who installs the CLI expects the rendering the CLI always had, the emoji, the colours, the clickable paths, and a default that changed it would be a regression for every terminal. A server is the process that must choose: it selects `json`, and the fail-loud factory is what makes the choice hard to forget. Rich is the `cli` extra, which a server installs pipelex without, so a server that forgot to select `json` refuses to boot with the extra and the `json` alternative named, rather than shipping ANSI to a log agent. How the rest of the runtime keeps Rich out of such a process, and the guard that holds it there, is in [Rich Imports](../contribute/rich-imports.md).+`pipelex/pipelex.toml` ships `sink = "console"`. A user who installs the CLI expects the rendering the CLI always had, the emoji, the colours, the clickable paths, and a default that changed it would be a regression for every terminal. A server is the process that must choose, and it chooses in its own configuration: it selects `json` in its `pipelex.toml`, as the [API server](../api-server/logging.md) does. Nothing at boot catches a server that forgot. The `console` factory checks that Rich imports, and stops the boot naming the `cli` extra and the `json` alternative when it does not, but Rich is installed with or without the extra, because `typer` and `instructor`, both core dependencies, require it unconditionally. So a server that forgot to select `json` boots on the `console` sink and ships ANSI to its log agent. A host whose log pipeline depends on JSON asserts the effective sink at boot itself, after every configuration layer is merged, as our Temporal plugin does. How the rest of the runtime keeps Rich off a server's path, and why that is not the same as keeping it out of the install, is in [Rich Imports](../contribute/rich-imports.md).---diff --git a/pipelex/cogt/usage/cost_registry.py b/pipelex/cogt/usage/cost_registry.pyindex 47a8b0a44..cbfecc118 100644--- a/pipelex/cogt/usage/cost_registry.py+++ b/pipelex/cogt/usage/cost_registry.py@@ -158,7 +158,7 @@ class CostRegistry(RootModel[CostRegistryRoot]):raise CostRegistryError(msg)# The CSV report is written first because it is the output that does not need Rich, the `cli` extra.- # Rendering the console table ahead of it would make a process without the extra lose both: the caller+ # Rendering the console table ahead of it would make a process without Rich lose both: the caller# downgrades the missing-dependency error to a warning, so the loss would be silent.if cost_report_file_path:cls.save_to_csv(records, file_path=cost_report_file_path)diff --git a/pipelex/runtime_boot.py b/pipelex/runtime_boot.pyindex 4f7d323be..b259182a9 100644--- a/pipelex/runtime_boot.py+++ b/pipelex/runtime_boot.py@@ -557,9 +557,10 @@ If you need help, drop by our Discord: we're happy to assist: {URLs.discord}.log_config = get_config().runtime.loglog_sink_registry = LogSinkRegistry(plugin_registrar.log_sinks)log.install_sink(log_sink_registry.get_required(method=log_config.sink)(log_config))- # The pretty-print mode is checked beside the sink, for the same reason: Rich is the ``cli`` extra,- # and a process asking for the ``rich`` panels without it stops here, naming the extra and the- # Rich-free modes, rather than failing at the first pipe that prints its output.+ # The pretty-print mode is checked beside the sink, for the same reason: a process asking for the+ # ``rich`` panels without Rich installed stops here, naming the ``cli`` extra and the Rich-free modes,+ # rather than failing at the first pipe that prints its output. The check asks whether Rich imports,+ # not whether the extra was named, and ``typer`` and ``instructor`` install Rich anyway.if log_config.pretty_print_mode is PrettyPrintMode.RICH:require_rich_for_rendering()diff --git a/pipelex/tools/misc/rich_extra.py b/pipelex/tools/misc/rich_extra.pyindex c21c2a058..35fc5fa24 100644--- a/pipelex/tools/misc/rich_extra.py+++ b/pipelex/tools/misc/rich_extra.py@@ -20,7 +20,7 @@ RICH_TABLE_MISSING_MESSAGE = "This listing prints its result in a Rich table."def require_rich(*, message: str) -> None:"""Import Rich, or raise ``MissingDependencyError`` naming the ``cli`` extra.- Called before a lazy ``from rich… import …``, so a process without the extra is told what to+ Called before a lazy ``from rich… import …``, so a process without Rich is told what toinstall, and what to select instead, rather than handed a bare ``ModuleNotFoundError``.Args: