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/Drop-remote-config · L-261004-75f0ec (#1334)
Louis Choquele39288f3eff5
diff --git a/.claude/skills/add-migration/SKILL.md b/.claude/skills/add-migration/SKILL.mdindex ddaeff6b2..6d89016ca 100644--- a/.claude/skills/add-migration/SKILL.md+++ b/.claude/skills/add-migration/SKILL.md@@ -15,7 +15,7 @@ description: ># Add a Migration EntryA configuration **surface** — `pipelex.toml` and its tiers, `telemetry.toml`,-`pipelex_service.toml`, the inference backend definitions in+the inference backend definitions in`inference/backends/` — ships a checked-in ledger at`pipelex/migration/ledgers/<surface-id>.toml` recording, as data, every shapechange it has ever undergone. A user's existing file is repaired by replaying thatdiff --git a/.claude/skills/add-model/SKILL.md b/.claude/skills/add-model/SKILL.mdindex 30823d9d1..0492d8805 100644--- a/.claude/skills/add-model/SKILL.md+++ b/.claude/skills/add-model/SKILL.md@@ -16,7 +16,7 @@ description: >A model is added once per backend that serves it. Each backend TOML under `.pipelex/inference/backends/` declares the models that backend can call, the kit copy under `pipelex/kit/configs/` is what ships in the package, and `.pipelex-dev/test_profiles.toml` decides which models the parametrized inference tests can select. Those are the files that declare a model; the steps below also write the changelog, and regenerate the goldens and references that follow from them.-One backend is different: `pipelex_manifold` takes its model catalog from the **remote config**, a versioned artifact the runtime fetches at boot from the URL in `pipelex/system/pipelex_service/pipelex_details.py` (overridable with `PIPELEX_REMOTE_CONFIG_URL`). Its local TOML only lets a user override `sdk` and `structure_method` per model, so a model cannot be added to it from here. See step 8.+The Pipelex Manifold catalog is not in this repository: the hosted plane carries it. See step 8.## 1. Establish the facts, from the provider@@ -71,15 +71,13 @@ For an LLM, go past `TestLLMInference` and exercise what the entry declares: `Te## 7. Deck, changelog, checks-- **Deck.** Adding a model does not change the deck. Promoting it to an alias or preset in `.pipelex/inference/deck/` (`best-gpt`, `default-premium`, a preset's `model`) changes what existing methods run on, so it is a separate decision: ask, and if the answer is yes, edit the deck, then run `make ukc` again. Promote only once a shipped backend serves the model: under the default `all_enabled_backends` routing, a preset or choice default reaching a handle no enabled backend serves is dropped from the deck with a warning, and under `all_pipelex_manifold` a handle the manifold catalog lacks raises `GatewayUnknownModelError` at boot, so `make tb` turns red. An alias no preset or choice default reaches is not checked at all, so a dangling one ships silently: read the deck yourself rather than trusting the boot. Then grep `docs/` for the alias you moved: `docs/configuration/config-technical/inference-backend-config.md` mirrors the deck's aliases, and other pages quote single ones.+- **Deck.** Adding a model does not change the deck. Promoting it to an alias or preset in `.pipelex/inference/deck/` (`best-gpt`, `default-premium`, a preset's `model`) changes what existing methods run on, so it is a separate decision: ask, and if the answer is yes, edit the deck, then run `make ukc` again. Promote only once a shipped backend serves the model: under the default `all_enabled_backends` routing, a preset or choice default reaching a handle no enabled backend serves is dropped from the deck with a warning. An alias no preset or choice default reaches is not checked at all, so a dangling one ships silently: read the deck yourself rather than trusting the boot. Then grep `docs/` for the alias you moved: `docs/configuration/config-technical/inference-backend-config.md` mirrors the deck's aliases, and other pages quote single ones.- **Changelog.** One bullet under `## [Unreleased]` → `### Added` in `CHANGELOG.md`: the handle, the backends, what it takes and produces, and anything unusual such as a refused parameter.- **Checks.** `make tb` boots the config, which parses and validates the backends `backends.toml` enables — and only those, so an entry added to a disabled backend such as `vertexai` is never read. To validate one, enable that backend in the gitignored `.pipelex/inference/backends_override.toml` for the run, and delete the file afterwards. Then stage your changes (the drift digest reads the git index) and run `make agent-check`.## 8. The manifold catalog-This repository cannot add the model to `pipelex_manifold`: its catalog is published by the Pipelex team in the remote config. Tell the user so, and say which handle, model ids and capabilities the catalogs need. **In the Pipelex workspace, the workspace-level `/add-model` does that part**, and runs this skill as its pipelex leg.--Once a remote config carrying the model is published at the version this repository pins, `/test-model` on `pipelex_manifold` proves the model end to end through the service.+This repository cannot add the model to Pipelex Manifold: its catalog lives with the hosted plane. Tell the user so, and say which handle, model ids and capabilities the catalog needs. **In the Pipelex workspace, the workspace-level `/add-model` does that part**, and runs this skill as its pipelex leg.## Checklist@@ -94,4 +92,4 @@ Show this to the user at the end, each box ticked or explained:- [ ] Deck left alone, or the promotion decided by the user, made after a shipped backend serves the model, and mirrored in `docs/`- [ ] Changelog entry under `[Unreleased]`- [ ] `make tb` and `make agent-check` green-- [ ] Manifold catalog handed off, and `/test-model` on `pipelex_manifold` run once it is published+- [ ] Manifold catalog handed off to the hosted planediff --git a/.claude/skills/test-model/SKILL.md b/.claude/skills/test-model/SKILL.mdindex b1fc4e440..78a41281a 100644--- a/.claude/skills/test-model/SKILL.md+++ b/.claude/skills/test-model/SKILL.md@@ -5,7 +5,7 @@ description: >infrastructure. Handles test profile creation, fixture regeneration, andrunning the right test class for the model type (LLM, image gen, extract,search). Use when the user says "test model X", "test gpt-5.4 on openai",- "test model on manifold", "run inference test for model", "try model X on+ "test model on anthropic", "run inference test for model", "try model X onbackend Y", "verify model X works", or any variation of running inferencetests against a specific model on a specific backend. Also use when the usermentions testing a model after adding it, or wants to verify a model works@@ -25,7 +25,7 @@ Gather from the user (or infer from context):| Field | Description | Example ||-------|-------------|---------|| **Model name** | The model handle as it appears in backend TOMLs | `gpt-5.6-sol` |-| **Backend** | Which backend to test on | `pipelex_manifold` |+| **Backend** | Which backend to test on | `openai` || **Model type** | `llm`, `img_gen`, `extract`, or `search` | `llm` |### How to determine the model type@@ -44,7 +44,6 @@ If the user says a backend name, use it directly. Common shorthand mappings:| User says | Backend name ||-----------|-------------|-| "manifold" | `pipelex_manifold` || "openai" | `openai` || "azure" | `azure_openai` || "anthropic" | `anthropic` |@@ -57,16 +56,12 @@ If the user says a backend name, use it directly. Common shorthand mappings:### Verify the model exists on the target backendBefore creating a test profile, confirm the model is actually configured on the-target backend. For most backends, check the TOML file:+target backend by checking its TOML file:```.pipelex/inference/backends/<backend_name>.toml```-For **manifold** (`pipelex_manifold`), the model list is fetched remotely — you-cannot verify locally. Proceed and let the test tell you if the model isn't-available.-## Step 2: Create a temporary test profileEdit `.pipelex-dev/test_profiles_override.toml` (this file is gitignored) to adddiff --git a/.dockerignore b/.dockerignoreindex 93ab690dd..4ce3362f5 100644--- a/.dockerignore+++ b/.dockerignore@@ -39,10 +39,9 @@# The runtime layers more than the `_override` tier over a base file: `_local`, `_{environment}`# selected by PIPELEX_ENV, and `_temporary_override`, for every configuration family in the# directory rather than for `pipelex` alone. Environment names are open-ended, so the exclusion is-# by shape — any suffixed variant of a base file — and the one tracked variant is named back in.+# by shape — any suffixed variant of a base file.# The nested inference overrides need their own line because a pattern's `*` does not cross a `/`.api/.pipelex/*_*.toml-!api/.pipelex/pipelex_service.tomlapi/.pipelex/inference/*_override.tomlapi/.pipelex/storageapi/.pipelex/tracesdiff --git a/.drift/acks/cli-docs.toml b/.drift/acks/cli-docs.tomlindex 18ed09c28..a22ff21e0 100644--- a/.drift/acks/cli-docs.toml+++ b/.drift/acks/cli-docs.toml@@ -1,8 +1,8 @@contract = "cli-docs"-digest = "sha256:0c6ad1ab6e3210129c0a0b7ea1fabcc73e4b883ff8e6f8680750b50713c8a3ab"-reviewed_by = "Claude (Opus 5.5)"-reviewed_at = "2026-10-04T16:59:46Z"-rationale = "real-catch: the comment on the init backend recommendation now scopes OpenAI's one key to the language-model and image-generation tiers, since extraction and search default to their own backends; init.md said every default tier at both its backend-selection step and its global-init example, both corrected. Swept docs/tools/cli/ and pipelex/cli/agent_cli/CLAUDE.md for tier and extraction-default claims: update.md's account of managed deck files and x_custom_ overrides still holds."+digest = "sha256:2de1c86f2f5885be4f34f5552593d5eb842879d96efd6673aaf979ed0ca5f028"+reviewed_by = "Louis Choquel"+reviewed_at = "2026-10-04T21:23:47Z"+rationale = "clean-pass: only a code comment in doctor_cmd.py changed, no CLI surface or behaviour change; docs need no update"[trigger_files]"pipelex/cli/__init__.py" = "blob:8b137891791fe96927ad78e64b0aad7bded08bdc"@@ -10,58 +10,58 @@ rationale = "real-catch: the comment on the init backend recommendation now scop"pipelex/cli/agent_cli/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/agent_cli/_agent_cli.py" = "blob:9241b520ba209867c37330551101bdd5d262ac88""pipelex/cli/agent_cli/commands/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"-"pipelex/cli/agent_cli/commands/agent_cli_factory.py" = "blob:c557214028805cd8204ee76c118fe3e4479db2ce"-"pipelex/cli/agent_cli/commands/agent_output.py" = "blob:c78a85513a6f5ce230f19f20844c6e1f1f74a107"+"pipelex/cli/agent_cli/commands/agent_cli_factory.py" = "blob:3a70f3a7fe2670510c0ca7748a4fdba6f33db318"+"pipelex/cli/agent_cli/commands/agent_output.py" = "blob:506eabec37ab3b06644b6ae4c321a91780241161""pipelex/cli/agent_cli/commands/bundle_path_resolver.py" = "blob:a1904517c731afb72af7d49adf6d217dc50b2660"-"pipelex/cli/agent_cli/commands/check_model_cmd.py" = "blob:c0ba11631c3904b9c4b4529d48d5954494cc1153"+"pipelex/cli/agent_cli/commands/check_model_cmd.py" = "blob:42a6b8c02a1d103394e12243181af8ea1c16f31d""pipelex/cli/agent_cli/commands/codegen/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/agent_cli/commands/codegen/app.py" = "blob:56130b89fe9efec5ad3d014ed6bc16bef1bd1645""pipelex/cli/agent_cli/commands/codegen/check_cmd.py" = "blob:9e8beb084a9f04f39e8acca9e6ae2554d40cb667"-"pipelex/cli/agent_cli/commands/codegen/types_cmd.py" = "blob:dea775a8a469816f2c84ea4f6a5c9234c4af6705"+"pipelex/cli/agent_cli/commands/codegen/types_cmd.py" = "blob:5da4131cb459383ab4007c2cdb15f3cfde74510f""pipelex/cli/agent_cli/commands/doctor_cmd.py" = "blob:9bfdb8c24a39a859665d2a9ff6b57883da0bd666""pipelex/cli/agent_cli/commands/fix/__init__.py" = "blob:65662c86f17f610ad55ecfc3e27a022b9aa26e8b""pipelex/cli/agent_cli/commands/fix/app.py" = "blob:e6190d9bde6a05755c04bd21806f699461038ac0"-"pipelex/cli/agent_cli/commands/fix/bundle_cmd.py" = "blob:37b13a1ead7b55d601f53b23647c285fc85418cd"+"pipelex/cli/agent_cli/commands/fix/bundle_cmd.py" = "blob:cfd9e645986636c44c02a6a04a0fc67ed60d444b""pipelex/cli/agent_cli/commands/fmt_cmd.py" = "blob:97d6fb6c328e0b718b1293bd6b73cba03edcb7dc"-"pipelex/cli/agent_cli/commands/init_cmd.py" = "blob:152be3b800cd1412e2a2257d0e8d35030cdcabba"+"pipelex/cli/agent_cli/commands/init_cmd.py" = "blob:9d574ad51d472b265875136c195b6457ea9d794b""pipelex/cli/agent_cli/commands/inputs/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/agent_cli/commands/inputs/_inputs_core.py" = "blob:4161029643f3a302de54fa637d2676521e10d873""pipelex/cli/agent_cli/commands/inputs/app.py" = "blob:7e19284687b334c684fb03381a8d9d20af1aa152"-"pipelex/cli/agent_cli/commands/inputs/bundle_cmd.py" = "blob:e42c08315b879df91ba4a22074ba697311830ae2"-"pipelex/cli/agent_cli/commands/inputs/method_cmd.py" = "blob:56fc7edc47ec9513d4e289010c42405df351544e"-"pipelex/cli/agent_cli/commands/inputs/pipe_cmd.py" = "blob:bdddcc8f1bf6e5437ab4375b1c601ee66bee994f"+"pipelex/cli/agent_cli/commands/inputs/bundle_cmd.py" = "blob:30efc54a0501015527a4a03b72ba49b2e97385de"+"pipelex/cli/agent_cli/commands/inputs/method_cmd.py" = "blob:604e91b2e65d951fd9a6eeed924a01f04fe2096f"+"pipelex/cli/agent_cli/commands/inputs/pipe_cmd.py" = "blob:5c9c233b00d626599dea4907b148b4f08cdd58a0""pipelex/cli/agent_cli/commands/lint_cmd.py" = "blob:91ad9cb4d618ba4c0b7da366cde2f74f38d350df""pipelex/cli/agent_cli/commands/migrate_cmd.py" = "blob:ce733b78df03e65c3c8a10d46b27b57c05ec054c"-"pipelex/cli/agent_cli/commands/models_cmd.py" = "blob:e1e17e86d1f1b1f1fae167fcaa87a0618ba25681"+"pipelex/cli/agent_cli/commands/models_cmd.py" = "blob:f48a921fa89d8275c585b3e15f135f5585ac01aa""pipelex/cli/agent_cli/commands/plxt_passthrough.py" = "blob:a1c530d110482485ce462f199b9e79fac29f8896""pipelex/cli/agent_cli/commands/run/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/agent_cli/commands/run/_output_helpers.py" = "blob:40ed1700e0d5e86d7696eadd7f9887baeb8059f6""pipelex/cli/agent_cli/commands/run/_run_core.py" = "blob:32f973c5c754b23016f3e708ab3235856e8bc5f4""pipelex/cli/agent_cli/commands/run/_run_core_api.py" = "blob:ac949cc4c93ca8e0f18b93a68f59584a7cf1a75e""pipelex/cli/agent_cli/commands/run/app.py" = "blob:64b2ecc02007cda11b526d8d3fc139593875dd9d"-"pipelex/cli/agent_cli/commands/run/bundle_cmd.py" = "blob:b1c01b3ad4aeffe806c5c44a886a64f5324c8afc"-"pipelex/cli/agent_cli/commands/run/method_cmd.py" = "blob:75a67ad84ea53e793d2aec415b045e84abd7464c"-"pipelex/cli/agent_cli/commands/run/pipe_cmd.py" = "blob:0985c360de8fddc3f282b41a530792e3cf1fd254"+"pipelex/cli/agent_cli/commands/run/bundle_cmd.py" = "blob:583624d5ec02cd7d87e7f9fbd41bedb82681afcd"+"pipelex/cli/agent_cli/commands/run/method_cmd.py" = "blob:ab844621c41f49f9d7aa6860b852586dce6eb784"+"pipelex/cli/agent_cli/commands/run/pipe_cmd.py" = "blob:54e09713855c1b0639883da7096ed58ebe7dbfe8""pipelex/cli/agent_cli/commands/run/stdin_resolver.py" = "blob:c7c7d7495508f1c4e5a46eba336a4ab1694ebcf7""pipelex/cli/agent_cli/commands/validate/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/agent_cli/commands/validate/_validate_core.py" = "blob:2a04aeff94db4afc56ac0c033a9d4add54d85c88""pipelex/cli/agent_cli/commands/validate/app.py" = "blob:d2d0ed19288c2d1c25be1650dd962189fcdb3b86"-"pipelex/cli/agent_cli/commands/validate/bundle_cmd.py" = "blob:b3f17f88fc74d02abf8a167af69f4275a8e8c6c8"-"pipelex/cli/agent_cli/commands/validate/method_cmd.py" = "blob:cf841e73d6af1a7e90d5ddfadaad012928f1a3ba"-"pipelex/cli/agent_cli/commands/validate/pipe_cmd.py" = "blob:b5aae81bc47ed8de23a13755b2c8c2418b4b8b9a"+"pipelex/cli/agent_cli/commands/validate/bundle_cmd.py" = "blob:6b02bb77dadf0ecd1814176580920962fcda2a42"+"pipelex/cli/agent_cli/commands/validate/method_cmd.py" = "blob:0f4cf76d99b39422610c5daf6b5a0500de234818"+"pipelex/cli/agent_cli/commands/validate/pipe_cmd.py" = "blob:9a315ab32c89430c8ea111a0a50e629ed1acd6bf""pipelex/cli/bundle_target_resolution.py" = "blob:460aa997ea0886c6faee0f3a42bd55231c480240"-"pipelex/cli/cli_factory.py" = "blob:0e7e35cbf795c285a80fba6a1bbd91a183f775b6"+"pipelex/cli/cli_factory.py" = "blob:27167bc7ee2b8543a87323d2caf4196efd3e7573""pipelex/cli/commands/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/commands/build/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/commands/build/app.py" = "blob:d3205e1dc0268a9d32a517e4f9a9a3b4647e8889""pipelex/cli/commands/build/inputs/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"-"pipelex/cli/commands/build/inputs/_inputs_core.py" = "blob:6f3f7a5417f72eabef33c39d95157a89c8c22e88"+"pipelex/cli/commands/build/inputs/_inputs_core.py" = "blob:7706dfd81d078e81af876516e459594f9e727dfa""pipelex/cli/commands/build/inputs/app.py" = "blob:2a7770c8294b8c2c1b4420ac00d6ffdfa50609bf""pipelex/cli/commands/build/inputs/bundle_cmd.py" = "blob:699980753d79480387ef1edc7f94b00325827e63""pipelex/cli/commands/build/inputs/method_cmd.py" = "blob:2fcaea4f05df4947d6ec1a49b2fa23b52c23ca3c""pipelex/cli/commands/build/inputs/pipe_cmd.py" = "blob:00625740fd29837e3165d31be692e40e96065fc8""pipelex/cli/commands/build/output/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"-"pipelex/cli/commands/build/output/_output_core.py" = "blob:9ba47b88a3c0b6cbf3f8de5f9a4939373f64ceb8"+"pipelex/cli/commands/build/output/_output_core.py" = "blob:3b7462ccb49c18522c5453fe3ae482586bcebf05""pipelex/cli/commands/build/output/app.py" = "blob:67996650b99551fbd58be30e692688204d16935a""pipelex/cli/commands/build/output/bundle_cmd.py" = "blob:7cafc55438704ecc6e86d1182069e4b1f73f9794""pipelex/cli/commands/build/output/method_cmd.py" = "blob:242434d518aff0b9706b910e7f937b53a601fde1"@@ -71,19 +71,19 @@ rationale = "real-catch: the comment on the init backend recommendation now scop"pipelex/cli/commands/codegen/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/commands/codegen/app.py" = "blob:9158084a89da23654e122e9df3a0a9c726401642""pipelex/cli/commands/codegen/check_cmd.py" = "blob:329f410bca90eb022fad2abc729e8b5203138c02"-"pipelex/cli/commands/codegen/inputs_cmd.py" = "blob:9957ee119b5d839aaa56f98444a1be3789c68f7c"-"pipelex/cli/commands/codegen/types_cmd.py" = "blob:b7c9c7a3664c9fbe66f9b4c3c5ebf9ea1322445c"+"pipelex/cli/commands/codegen/inputs_cmd.py" = "blob:28b22cfbca717d3f5ee75162b68e132439655deb"+"pipelex/cli/commands/codegen/types_cmd.py" = "blob:27d7a06d571ad832b449d21b6f9eb66c017fb197""pipelex/cli/commands/crate_loading.py" = "blob:3d7d651931ecf1a15a3e2d72411b3212b55d74ef"-"pipelex/cli/commands/doctor_cmd.py" = "blob:ad083e66e12b0a7940fd525b6a456f246ffe2ec7"+"pipelex/cli/commands/doctor_cmd.py" = "blob:aba718233ff3a55bf152b24984a8f79be381f17e""pipelex/cli/commands/fix/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/commands/fix/_diff_sandbox.py" = "blob:d39c0df92b95567f74881deb01f8c1b3119fc8ef"-"pipelex/cli/commands/fix/_fix_core.py" = "blob:dac7056fcaf50210c910e4cad1ba14328b7f8adc"+"pipelex/cli/commands/fix/_fix_core.py" = "blob:aa698305e6b60dfb7caf133698dc1d5c1f5f68f1""pipelex/cli/commands/fix/app.py" = "blob:6f019930e8e3e0043ee46d87493ba4602eb33a76""pipelex/cli/commands/fix/bundle_cmd.py" = "blob:427364cc453957dfe0cec879f019050329c13b3c""pipelex/cli/commands/graph_cmd.py" = "blob:d54737af7efc9ab9bbf3f978050d017af0e27a41""pipelex/cli/commands/init/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/commands/init/backends.py" = "blob:04a1a06f1003ed0c7157ec4ca6c8659e4e09fe6b"-"pipelex/cli/commands/init/command.py" = "blob:2aedf2b8f5b7fccf767d113650bcfba1c1a376e9"+"pipelex/cli/commands/init/command.py" = "blob:d6810258bdbdf912af026f667f4f013d06ec8ade""pipelex/cli/commands/init/config_files.py" = "blob:c13be6b8d2a8b211ce9ef0f4889ee131ffc3d2d8""pipelex/cli/commands/init/credentials.py" = "blob:36dcc33599a2749b7d63bf214363a4b6fd6698e8""pipelex/cli/commands/init/ide_extension.py" = "blob:9f0ec1494c07062246ecc906bc55b7f2cf95c715"@@ -96,28 +96,28 @@ rationale = "real-catch: the comment on the init backend recommendation now scop"pipelex/cli/commands/init/ui/types.py" = "blob:e263802d8e9c9f9687435de1eb992afa5336544f""pipelex/cli/commands/migrate_cmd.py" = "blob:897f9cbf93acace8f61091a9924895f0fda76443""pipelex/cli/commands/plugins_cmd.py" = "blob:9657b713c3650ff4a929e92ae68af453d896393e"-"pipelex/cli/commands/resolve_cmd.py" = "blob:2928a0e26eab7983367a59a78533f6618817feba"+"pipelex/cli/commands/resolve_cmd.py" = "blob:88237df0f048bbf5a02e585baef932bfc355e1ee""pipelex/cli/commands/run/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391""pipelex/cli/commands/run/_inputs_file_loader.py" = "blob:957e6eb00531d168b3b1e179a517717d069cb7fc""pipelex/cli/commands/run/_inputs_path_resolver.py" = "blob:c8ec89d98718e18af7aaaded44c9f545be60adab""pipelex/cli/commands/run/_main_stuff_file.py" = "blob:ca806e55085aa2e5748492751521296ce1f42960"-"pipelex/cli/commands/run/_run_core.py" = "blob:12958ebb9bc89fec6f0e6faf0b79d031091f02b3"+"pipelex/cli/commands/run/_run_core.py" = "blob:bf092cc1bfeb5e6c091aedf0e2f1c34efee83b02""pipelex/cli/commands/run/app.py" = "blob:a7090b0ff6bf2f1d47827fa27d2a138096a2e148""pipelex/cli/commands/run/bundle_cmd.py" = "blob:13d68d533986c3938b1b2ee808819d8daf6f91db""pipelex/cli/commands/run/exceptions.py" = "blob:e9552226e597922b6ac0757f7b52eb880a2e1472""pipelex/cli/commands/run/method_cmd.py" = "blob:9f5c7b6ad8f7fc7d086a9e6253049c6e2ec3e7d8""pipelex/cli/commands/run/pipe_cmd.py" = "blob:f92fcb94e3ad55cf5aeec366a59fa7a74bcc9667"-"pipelex/cli/commands/show_cmd.py" = "blob:9492c9af966877f694ca61f7b1db3d151a1ddf56"+"pipelex/cli/commands/show_cmd.py" = "blob:ffddb6bd91ab503d691ff41a5ae7d1f745786f36""pipelex/cli/commands/update_cmd.py" = "blob:b2db6170ddd9c67f17d88096ba1f1796a897557d""pipelex/cli/commands/validate/__init__.py" = "blob:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"-"pipelex/cli/commands/validate/_validate_core.py" = "blob:237c57bd815b6fa75e1fee28069f75ec6c5b7726"+"pipelex/cli/commands/validate/_validate_core.py" = "blob:27c343323180c73280f4ad5f29336811d06cf635""pipelex/cli/commands/validate/app.py" = "blob:309061423af13f2f6c496a024306ad696af567ab""pipelex/cli/commands/validate/bundle_cmd.py" = "blob:1fbf3e0cf695db39101c83160a724df6468988e9""pipelex/cli/commands/validate/method_cmd.py" = "blob:f12ee233fc985d04a4512f1fef6b9ea02a1b9644"-"pipelex/cli/commands/validate/pipe_cmd.py" = "blob:d67267571559006459628180f2c8b216ba7fee31"-"pipelex/cli/commands/which_cmd.py" = "blob:68661d4bab22e2c4dab183d59bd9f2c6dd573472"+"pipelex/cli/commands/validate/pipe_cmd.py" = "blob:791b9a693f4ec52f727b42dab4b102af46a4ee22"+"pipelex/cli/commands/which_cmd.py" = "blob:ed45019f8acd3678340fe395c49d065d6fc6c04d""pipelex/cli/deck_notice.py" = "blob:542877125e89e35b02bc969cfee952155b0d7c2c"-"pipelex/cli/error_handlers.py" = "blob:bef9c6c10c157eef0beaa069add4560aba49c499"+"pipelex/cli/error_handlers.py" = "blob:dd01a16295c17cc06378d3290ad5e60c27de986f""pipelex/cli/exceptions.py" = "blob:1d51c3a53ddd3f6cf8de566fa2ade3fa75ab7a3a""pipelex/cli/installed_methods.py" = "blob:09197f47baf8d7251d28d148a0544b4a23ee7365""pipelex/cli/method_resolver.py" = "blob:afaf77b2d8b6a3467d6ab1f355b1ee78a71eafa7"diff --git a/.drift/acks/config-docs.toml b/.drift/acks/config-docs.tomlindex 502520901..fa48d2a7a 100644--- a/.drift/acks/config-docs.toml+++ b/.drift/acks/config-docs.toml@@ -1,8 +1,8 @@contract = "config-docs"-digest = "sha256:70f9df825a1d92ab7415fd91a975870de55ca44afd9ba13de4f728d701d88e9c"-reviewed_by = "Claude (Opus 5.5)"-reviewed_at = "2026-10-04T20:43:40Z"-rationale = "clean-pass: the only trigger change is the comment above the deferred engine import in config_surface.py (the engine and its applier are now kernel-layer, so the deferral only keeps the healthy path untouched); grep of docs/configuration for applier, pipeline.fixes and kernel finds nothing it affects, and configs.py, config_cogt.py and the ledgers are untouched."+digest = "sha256:308ed837087ad1f5a71409cc3c53f78681fb8a5bb009e57fe0b8877999460add"+reviewed_by = "Louis Choquel"+reviewed_at = "2026-10-04T21:04:16Z"+rationale = "clean-pass: merging dev into this branch combines dev's comment change on the deferred engine import in config_surface.py with this branch's removal of the pipelex-service-config surface id; docs/configuration, configs.py and config_cogt.py carry no pipelex_service or remote-config mention, and the ledgers directory holds no service ledger"[trigger_files]"pipelex/cogt/config_cogt.py" = "blob:02f71cb4a6b01aebda59c2e31f262ef9c865e17b"@@ -16,7 +16,7 @@ rationale = "clean-pass: the only trigger change is the comment above the deferr"pipelex/system/configuration/config_loader.py" = "blob:b1940ff11d9be7f9b8e113ec564d041ec53bb0ce""pipelex/system/configuration/config_model.py" = "blob:83b29dc6e93393c9b98c4353636caf0135c80339""pipelex/system/configuration/config_root.py" = "blob:c7d43851270912d17413cfc6a511247d3c7cc160"-"pipelex/system/configuration/config_surface.py" = "blob:67e6e2be84c2f064cacf833ee8ba22184144dc96"+"pipelex/system/configuration/config_surface.py" = "blob:dc6c877564254aa97ce0b20fd29118def31c957c""pipelex/system/configuration/configs.py" = "blob:3cb65cf9c3d34aef0baf92b62d8bd63e5c69d4eb""pipelex/system/configuration/pipe_func_config.py" = "blob:dc8890e914fbcdb611147e42eaa0cd87b32288a5""pipelex/system/telemetry/telemetry_config.py" = "blob:068a785d97a2d52ee43e82e723cd944b8b6601bc"diff --git a/.env.example b/.env.exampleindex e4ddcfafb..3973dd0a7 100644--- a/.env.example+++ b/.env.example@@ -1,10 +1,3 @@-# [OPTIONAL] Pipelex Manifold — the Pipelex-operated inference service, currently in private beta.-# The endpoint is the service ORIGIN: scheme, host and port, with no "/v1" and no trailing path.-# Leave both blank unless you are in the beta: the backend ships disabled in backends.toml, and-# filling these in without enabling it there does nothing.-PIPELEX_MANIFOLD_ENDPOINT=-PIPELEX_MANIFOLD_API_KEY=-# OpenAI: to use models like GPT-4o and GPT-5OPENAI_API_KEY=diff --git a/.pipelex-dev/test_profiles.toml b/.pipelex-dev/test_profiles.tomlindex 8a79ec6fb..c967f0b4d 100644--- a/.pipelex-dev/test_profiles.toml+++ b/.pipelex-dev/test_profiles.toml@@ -256,7 +256,6 @@ from_pdf = ["mistral-ocr-2505","mistral-ocr-2512","mistral-document-ai-2505",- "azure-document-intelligence",]# --- Image Extraction Models ---@@ -267,7 +266,6 @@ from_image = ["mistral-ocr-2505","mistral-ocr-2512","deepseek-ocr",- "azure-document-intelligence",]################################################################################@@ -303,32 +301,6 @@ extract_models = ["@from_pdf", "linkup-fetch"]search_models = ["linkup-standard"]judgment_models = []-################################################################################-# Manifold Profile-################################################################################-# The `dev` profile's shape, served by Pipelex Manifold instead of the BYOK-# backends. Deliberately not a copy of `dev`: the two catalogs are allowed to-# diverge, so this names what the manifold section actually serves. `linkup` is-# absent from it, and `@from_pdf` is not used because most of that collection is-# other backends' — the manifold text extractors are named directly.-#-# The three LLMs are chosen to cover all three of the dialect's completion SDKs-# in one run: `claude-4.5-haiku` on `anthropic` (POST /v1/messages),-# `gpt-4o-mini` on `manifold_responses`, `gemini-2.5-flash-lite` on-# `manifold_completions`.-[profiles.manifold]-description = "The dev model set, served by Pipelex Manifold (private beta)"-backends = ["pipelex_manifold", "internal"]-llm_models = [- "claude-4.5-haiku",- "gpt-4o-mini",- "gemini-2.5-flash-lite",-]-img_gen_models = ["gpt-image-1-mini"]-extract_models = ["azure-document-intelligence", "linkup-fetch"]-search_models = ["linkup-standard"]-judgment_models = []-################################################################################# TypeSafe Profile################################################################################diff --git a/.pipelex/inference/backends.toml b/.pipelex/inference/backends.tomlindex 340269560..3c271f595 100644--- a/.pipelex/inference/backends.toml+++ b/.pipelex/inference/backends.toml@@ -10,15 +10,6 @@#####################################################################################################-# Pipelex Manifold is a closed private beta: leave it off unless you have been invited.-[pipelex_manifold]-display_name = "Pipelex Manifold (private beta)"-enabled = false-endpoint = "${PIPELEX_MANIFOLD_ENDPOINT}"-api_key = "${PIPELEX_MANIFOLD_API_KEY}"-model_specs_section = "manifold_model_specs"-auth_header = "x-pipelex-api-key"-[anthropic]enabled = trueapi_key = "${ANTHROPIC_API_KEY}"diff --git a/.pipelex/inference/deck/3_extract_deck.toml b/.pipelex/inference/deck/3_extract_deck.tomlindex c5e474a91..daf2de5e4 100644--- a/.pipelex/inference/deck/3_extract_deck.toml+++ b/.pipelex/inference/deck/3_extract_deck.toml@@ -42,17 +42,13 @@ default-extract-web-page = "linkup-fetch"# Waterfalls#####################################################################################################-# Each default resolves to the first entry an enabled backend serves: Azure Document Intelligence-# through Pipelex Manifold, then Mistral OCR with your own Mistral key. Documents fall back last to-# reading a PDF's text layer locally, which needs no key but recovers no text from a scanned page.+# Each default resolves to the first entry an enabled backend serves: Mistral OCR with your own+# Mistral key. Documents fall back to reading a PDF's text layer locally, which needs no key but+# recovers no text from a scanned page.[extract.waterfalls]-document-extractor = [- "azure-document-intelligence",- "mistral-ocr",- "pypdfium2-extract-pdf",-]-ocr-extractor = ["azure-document-intelligence", "mistral-ocr"]+document-extractor = ["mistral-ocr", "pypdfium2-extract-pdf"]+ocr-extractor = ["mistral-ocr"]##################################################################################################### Extract Presetsdiff --git a/.pipelex/inference/deck/x_custom_extract_deck.toml b/.pipelex/inference/deck/x_custom_extract_deck.tomlindex dab86f45c..779c934af 100644--- a/.pipelex/inference/deck/x_custom_extract_deck.toml+++ b/.pipelex/inference/deck/x_custom_extract_deck.toml@@ -26,14 +26,10 @@## Example (uncomment to use):# [extract.waterfalls]-# document_extractor = ["azure-document-intelligence", "mistral-document-ai-2505"]+# document_extractor = ["mistral-document-ai-2505", "pypdfium2-extract-pdf"]# pdf_text_extractor = [-# "azure-document-intelligence",# "mistral-document-ai-2505",# "pypdfium2-extract-pdf",# ]-# image_text_extractor = [-# "azure-document-intelligence",-# "mistral-document-ai-2505",-# ]+# image_text_extractor = ["mistral-document-ai-2505"]####################################################################################################diff --git a/.pipelex/inference/routing_profiles.toml b/.pipelex/inference/routing_profiles.tomlindex c11082327..00272c799 100644--- a/.pipelex/inference/routing_profiles.toml+++ b/.pipelex/inference/routing_profiles.toml@@ -45,7 +45,6 @@ fallback_order = ["scaleway","ollama","vertexai",- "pipelex_manifold",]# Judgment models are served by their own backend alone, so they go to it whenever it is enabled.@@ -53,17 +52,6 @@ fallback_order = [[profiles.all_enabled_backends.optional_routes]"jev-*" = "typesafe"-# The Pipelex-operated inference service (private beta). A model's wire id and sdk are per-backend,-# so decks, aliases and presets keep naming the same handles whichever profile is active.-[profiles.all_pipelex_manifold]-description = "Use Pipelex Manifold (private beta) for all its supported models"-default = "pipelex_manifold"--# Judgment models are brought by you rather than served by Pipelex, so they go to their own backend-# whenever it is enabled. An optional route is inert while its backend is disabled.-[profiles.all_pipelex_manifold.optional_routes]-"jev-*" = "typesafe"-[profiles.all_anthropic]description = "Use Anthropic backend for all its supported models"default = "anthropic"diff --git a/.test_durations b/.test_durationsindex d95a2c5e8..1d394b23d 100644--- a/.test_durations+++ b/.test_durations@@ -189,14 +189,6 @@"tests/integration/pipelex/cli/agent_cli/test_run_cost_report.py::TestAgentRunCostReport::test_no_cost_report_for_dry_run": 0.1196,"tests/integration/pipelex/cli/agent_cli/test_run_error_chain.py::TestRunErrorChain::test_run_error_chain_json": 2.2508,"tests/integration/pipelex/cli/agent_cli/test_run_error_chain.py::TestRunErrorChain::test_run_error_chain_markdown": 1.5323,- "tests/integration/pipelex/cli/commands/init/test_cache_priming.py::TestCachePriming::test_init_does_not_double_prime": 0.1256,- "tests/integration/pipelex/cli/commands/init/test_cache_priming.py::TestCachePriming::test_init_primes_cache_when_online": 1.0514,- "tests/integration/pipelex/cli/commands/init/test_cache_priming.py::TestCachePriming::test_init_warns_when_cache_write_fails": 0.0186,- "tests/integration/pipelex/cli/commands/init/test_cache_priming.py::TestCachePriming::test_init_warns_when_offline": 0.0218,- "tests/integration/pipelex/cli/commands/init/test_cache_priming.py::TestCachePriming::test_init_warns_when_offline_with_stale_cache_present": 0.028,- "tests/integration/pipelex/cli/commands/init/test_cache_priming.py::TestCachePriming::test_init_warns_when_the_written_cache_does_not_read_back": 0.0211,- "tests/integration/pipelex/cli/commands/init/test_cache_priming.py::TestCachePriming::test_priming_reads_backends_toml_from_target_dir": 0.1575,- "tests/integration/pipelex/cli/commands/init/test_cache_priming.py::TestCachePriming::test_priming_runs_for_a_manifold_only_installation": 0.5568,"tests/integration/pipelex/cli/test_advisory_warning_channels.py::TestAdvisoryWarningChannels::test_agent_cli_bundle_envelope_carries_all_three_families": 0.6051,"tests/integration/pipelex/cli/test_advisory_warning_channels.py::TestAdvisoryWarningChannels::test_agent_cli_markdown_lists_all_three_families_in_the_same_order": 1.949,"tests/integration/pipelex/cli/test_advisory_warning_channels.py::TestAdvisoryWarningChannels::test_agent_cli_markdown_renders_the_warning_under_its_heading": 1.5342,@@ -1336,24 +1328,6 @@"tests/integration/pipelex/plugins/test_secrets_external_plugin.py::TestSecretsExternalPlugin::test_external_secrets_method_is_discovered_and_selected_onto_the_hub": 0.8547,"tests/integration/pipelex/plugins/test_storage_external_plugin.py::TestStorageExternalPlugin::test_explicit_storage_provider_wins_over_config_selection": 0.9394,"tests/integration/pipelex/plugins/test_storage_external_plugin.py::TestStorageExternalPlugin::test_external_storage_method_is_discovered_and_selected_onto_the_hub": 0.7849,- "tests/integration/pipelex/system/pipelex_service/test_offline_baseline.py::TestOfflineBaseline::test_byok_offline_setup_succeeds_without_fetching_remote_config": 0.9307,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_cache_store_oserror_does_not_abort_fresh_fetch": 0.0029,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_codex_cloud_short_circuit_still_works": 0.0043,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_falls_back_to_cache_after_5_transient_failures": 0.0028,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_fresh_path_validates_payload_only_once": 0.1428,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_http_error_with_cache_returns_cached": 0.0035,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_http_error_without_cache_raises_unavailable": 0.0038,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_inner_retry_layer_still_raises_remote_config_fetch_error": 0.0035,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_network_failure_with_cache_returns_cached": 0.0037,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_network_failure_without_cache_raises_unavailable": 0.0022,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_require_fresh_refuses_cache": 0.0046,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_succeeds_after_4_transient_failures_no_cache_fallback": 0.0061,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_success_returns_fresh_and_writes_cache": 1.046,- "tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py::TestRemoteConfigFetcher::test_validation_error_does_not_fall_back": 0.0022,- "tests/integration/pipelex/system/pipelex_service/test_setup_with_cache.py::TestSetupWithCache::test_byok_offline_regression_guard": 0.8641,- "tests/integration/pipelex/system/pipelex_service/test_setup_with_cache.py::TestSetupWithCache::test_setup_fails_without_cache_dry_run": 0.2463,- "tests/integration/pipelex/system/pipelex_service/test_setup_with_cache.py::TestSetupWithCache::test_setup_succeeds_with_stale_cache_dry_run": 0.9718,- "tests/integration/pipelex/system/pipelex_service/test_setup_with_cache.py::TestSetupWithCache::test_telemetry_disabled_when_source_cached": 0.8672,"tests/integration/pipelex/system/telemetry/test_pipe_span_carries_run_identity.py::TestPipeSpanIdentity::test_a_run_with_no_groups_writes_no_groups_attribute": 0.061,"tests/integration/pipelex/system/telemetry/test_pipe_span_carries_run_identity.py::TestPipeSpanIdentity::test_langfuse_gets_the_user_id_when_it_is_enabled": 0.094,"tests/integration/pipelex/system/telemetry/test_pipe_span_carries_run_identity.py::TestPipeSpanIdentity::test_the_groups_the_caller_supplied_reach_the_span": 1.7447,@@ -4090,11 +4064,6 @@"tests/unit/pipelex/cogt/model_backends/test_backend_library_overrides.py::TestBackendLibraryOverrides::test_the_last_override_wins": 0.035,"tests/unit/pipelex/cogt/model_backends/test_backend_toml_path.py::TestBackendTomlPath::test_an_absolute_backend_name_stays_under_the_backends_directory": 0.1031,"tests/unit/pipelex/cogt/model_backends/test_backend_toml_path.py::TestBackendTomlPath::test_an_ordinary_backend_name_lands_beside_its_siblings": 0.7344,- "tests/unit/pipelex/cogt/model_backends/test_gateway_unknown_defaults.py::TestGatewayUnknownDefaults::test_pruning_emits_no_record": 0.0653,- "tests/unit/pipelex/cogt/model_backends/test_managed_backend_missing_variable.py::TestAManagedBackendMissingItsVariables::test_a_byok_backend_missing_its_variables_still_stops_the_boot": 0.001,- "tests/unit/pipelex/cogt/model_backends/test_managed_backend_missing_variable.py::TestAManagedBackendMissingItsVariables::test_it_is_disabled_with_a_warning_naming_the_backend_and_the_variable": 0.5832,- "tests/unit/pipelex/cogt/model_backends/test_managed_backend_missing_variable.py::TestAManagedBackendWithNoPublishedSection::test_it_is_disabled_rather_than_refused": 0.0367,- "tests/unit/pipelex/cogt/model_backends/test_managed_backend_missing_variable.py::TestAManagedBackendWithNoPublishedSection::test_no_managed_configs_at_all_is_the_callers_error": 0.0519,"tests/unit/pipelex/cogt/model_backends/test_model_lister_dispatch.py::TestModelListerDispatch::test_any_listed_progresses_across_sdks": 0.0039,"tests/unit/pipelex/cogt/model_backends/test_model_lister_dispatch.py::TestModelListerDispatch::test_lister_failure_is_wrapped_in_cli_error": 0.0862,"tests/unit/pipelex/cogt/model_backends/test_model_lister_dispatch.py::TestModelListerDispatch::test_lister_unsupported_signal_is_reported_unsupported": 0.0018,@@ -4194,15 +4163,6 @@"tests/unit/pipelex/cogt/model_routing/test_routing_profile_overrides.py::TestRoutingProfileOverrides::test_lenient_tolerates_a_disabled_backend": 0.071,"tests/unit/pipelex/cogt/model_routing/test_routing_profile_overrides.py::TestRoutingProfileOverrides::test_the_base_alone_is_what_it_was": 0.5345,"tests/unit/pipelex/cogt/model_routing/test_routing_profile_overrides.py::TestRoutingProfileOverrides::test_the_last_override_wins": 0.0263,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_aliases_and_waterfalls_are_not_enumerated_directly": 0.1047,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_collects_presets_and_choice_defaults_for_all_types": 0.0033,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_extract_choice_handle[None-None]": 0.7444,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_extract_choice_handle[choice2-ref-handle]": 0.0005,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_extract_choice_handle[choice3-llm-model]": 0.0004,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_extract_choice_handle[choice4-extract-model]": 0.0004,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_extract_choice_handle[choice5-img-gen-model]": 0.0019,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_extract_choice_handle[choice6-search-model]": 0.0008,- "tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py::TestCollectDeckReferencedHandles::test_extract_choice_handle[raw-handle-raw-handle]": 0.0004,"tests/unit/pipelex/cogt/models/test_deck_manifest.py::TestDeckManifest::test_compute_file_sha256_is_deterministic": 0.0024,"tests/unit/pipelex/cogt/models/test_deck_manifest.py::TestDeckManifest::test_compute_kit_manifest_stamps_version": 0.0027,"tests/unit/pipelex/cogt/models/test_deck_manifest.py::TestDeckManifest::test_is_deck_stale_fast[1.0.0+ci.42-1.0.0-False]": 0.0036,@@ -4237,7 +4197,6 @@"tests/unit/pipelex/cogt/models/test_deck_manifest.py::TestDeckManifest::test_sync_report_no_manifest_marks_drift_as_locally_modified": 0.0036,"tests/unit/pipelex/cogt/models/test_deck_manifest.py::TestDeckManifest::test_sync_report_no_manifest_treats_matching_files_as_up_to_date": 0.0028,"tests/unit/pipelex/cogt/models/test_deck_manifest.py::TestDeckManifest::test_sync_report_up_to_date": 0.0041,- "tests/unit/pipelex/cogt/models/test_enforce_gateway_model_membership.py::TestDocumentEnginesAreNotGatewayModels::test_a_doc_gen_default_whose_engine_is_undeclared_does_not_fail_the_boot": 0.0716,"tests/unit/pipelex/cogt/models/test_inference_config_overrides_end_to_end.py::TestInferenceConfigOverridesEndToEnd::test_a_project_override_wins_over_the_global_one": 0.1637,"tests/unit/pipelex/cogt/models/test_model_deck.py::TestModelDeckGetLLMSettingWithPresets::test_get_llm_setting_with_bare_preset_name_fails": 0.124,"tests/unit/pipelex/cogt/models/test_model_deck.py::TestModelDeckGetLLMSettingWithPresets::test_get_llm_setting_with_prefixed_preset": 0.0009,@@ -4398,23 +4357,6 @@"tests/unit/pipelex/cogt/models/test_plugin_model_merge.py::TestPluginModelMerge::test_a_plugin_table_takes_no_file_defaults": 0.0667,"tests/unit/pipelex/cogt/models/test_plugin_model_merge.py::TestPluginModelMerge::test_an_invalid_plugin_table_fails_the_boot_naming_the_plugin": 0.0361,"tests/unit/pipelex/cogt/models/test_plugin_model_merge.py::TestPluginModelMerge::test_without_an_internal_backend_the_plugin_adds_nothing": 0.034,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_alias_cycle_returns_empty": 0.0013,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_alias_resolves_to_handle": 0.001,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_cross_kind_cycle_still_returns_empty": 0.0003,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_dangling_alias_returns_alias_name": 0.0007,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_handle_returns_self": 0.7574,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_preset_returns_empty": 0.0003,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_self_referential_waterfall_returns_empty": 0.0007,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_shared_name_alias_and_waterfall_is_not_a_cycle[@shared-aliases0-waterfalls0-expected0]": 0.0014,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_shared_name_alias_and_waterfall_is_not_a_cycle[~shared-aliases1-waterfalls1-expected1]": 0.0006,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_waterfall_entries_respect_fallback_flag[waterfall_entries0-True-expected0]": 0.001,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_waterfall_entries_respect_fallback_flag[waterfall_entries1-False-expected1]": 0.0005,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_waterfall_entries_respect_fallback_flag[waterfall_entries2-True-expected2]": 0.0006,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_waterfall_entries_respect_fallback_flag[waterfall_entries3-False-expected3]": 0.1469,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_waterfall_returns_every_fallback": 0.0006,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_waterfall_through_alias_unrolls_both": 0.0021,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_waterfall_when_fallback_disabled_returns_only_first": 0.0004,- "tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py::TestResolveTerminalCandidates::test_waterfall_with_invalid_entry_skips_only_that_branch": 0.0006,"tests/unit/pipelex/cogt/templating/test_template_blueprint_strictness.py::TestTemplateBlueprintStrictness::test_kajson_round_trip_survives_strictness": 0.0959,"tests/unit/pipelex/cogt/templating/test_template_blueprint_strictness.py::TestTemplateBlueprintStrictness::test_misspelled_extra_context_is_rejected": 0.0009,"tests/unit/pipelex/cogt/templating/test_template_blueprint_strictness.py::TestTemplateBlueprintStrictness::test_misspelled_key_is_rejected_through_pipe_compose_blueprint": 0.0007,@@ -10395,19 +10337,6 @@"tests/unit/pipelex/system/configuration/test_config_surface.py::TestStripReservedMeta::test_a_meta_table_with_other_keys_keeps_them": 0.0006,"tests/unit/pipelex/system/configuration/test_config_surface.py::TestStripReservedMeta::test_a_non_table_meta_is_left_for_validation_to_reject": 0.08,"tests/unit/pipelex/system/configuration/test_config_surface.py::TestStripReservedMeta::test_the_reserved_key_is_removed_with_its_now_empty_table": 0.8598,- "tests/unit/pipelex/system/pipelex_service/test_pipelex_service_config.py::TestPipelexServiceConfig::test_load_pipelex_service_config_if_exists_returns_config": 0.0018,- "tests/unit/pipelex/system/pipelex_service/test_pipelex_service_config.py::TestPipelexServiceConfig::test_load_pipelex_service_config_if_exists_returns_none": 0.0013,- "tests/unit/pipelex/system/pipelex_service/test_remote_config.py::TestRemoteConfig::test_remote_config_empty_backend": 0.0008,- "tests/unit/pipelex/system/pipelex_service/test_remote_config.py::TestRemoteConfig::test_remote_config_missing_backend_fails": 0.0005,- "tests/unit/pipelex/system/pipelex_service/test_remote_config.py::TestRemoteConfig::test_remote_config_valid": 0.0005,- "tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py::TestRemoteConfigCache::test_cache_path_uses_global_config_dir": 0.001,- "tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py::TestRemoteConfigCache::test_raw_payload_extras_preserved": 0.0025,- "tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py::TestRemoteConfigCache::test_read_corrupted_json_returns_none_and_logs": 0.0024,- "tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py::TestRemoteConfigCache::test_read_missing_returns_none": 0.0013,- "tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py::TestRemoteConfigCache::test_read_wrong_schema_version_returns_none": 0.0026,- "tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py::TestRemoteConfigCache::test_write_creates_parent_dir": 0.0022,- "tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py::TestRemoteConfigCache::test_write_is_atomic": 0.0025,- "tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py::TestRemoteConfigCache::test_write_then_read_roundtrip": 0.0029,"tests/unit/pipelex/system/telemetry/test_current_span.py::TestPipelexSpanActive::test_a_line_joins_the_pipelex_span_inside_the_block_and_the_previous_one_after": 0.0767,"tests/unit/pipelex/system/telemetry/test_current_span.py::TestPipelexSpanActive::test_a_none_span_holds_nothing": 0.0154,"tests/unit/pipelex/system/telemetry/test_current_span.py::TestPipelexSpanActive::test_a_span_naming_no_trace_does_not_hide_the_enclosing_pipelex_span": 0.0013,diff --git a/.worktreeinclude b/.worktreeincludeindex c5fb6283b..b8a2aa224 100644--- a/.worktreeinclude+++ b/.worktreeinclude@@ -5,7 +5,6 @@.pipelex/telemetry_override.toml.pipelex/inference/backends_override.toml.pipelex/inference/routing_profiles_override.toml-.pipelex/pipelex_service.toml.pipelex-dev/test_profiles_override.toml# The api/ server (a workspace member) keeps its own .env and Pipelex overrides.api/.envdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2799203a6..04a13e3d0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,7 +13,7 @@- **The Inference SPI table lists every symbol a provider plugin builds on**: `docs/under-the-hood/inference-backend-plugins.md` now publishes, one module per row, the worker contracts with their jobs and outputs, the OpenAI- and Anthropic-protocol factories and workers, the image-generation and prompt-preparation helpers, the error pipeline and the runtime accessors, and `parse_retry_after_seconds` and `error_code_from_body_code_first` become public in `pipelex.cogt.inference.error_classification` for a plugin that distils a plain-HTTP failure itself.- **The Anthropic worker no longer adds a backend's headers by backend name (Breaking)**: a worker built without an `extras_factory` sends nothing extra, whatever its backend, so a backend that relied on the worker adding its request headers must register its own sdk token with an extras factory and name that token in the `sdk` of its model specs, local overrides included; a model left on `anthropic` keeps answering, without those headers.- **The gateway refusal families leave the core classifier (Breaking)**: `GatewayRequestLimit`, `GatewayUnresolvedReference` and `GatewayRoutingRefusal`, the matching properties of `ProviderErrorMetadata` and fields of `ClassificationResult`, and `MANAGED_GATEWAY_BACKEND_NAMES` are removed; a gateway's own codes now reach `ClassificationResult.service_error_code` through the plugin that contributes them, and Portkey's `model_not_allowed_error` is read by `ProviderErrorMetadata.is_model_not_allowed` and `ClassificationResult.is_model_not_allowed`. Errors raised by the hosted-only provider plugin now report the `type` and `title` of their generic family, such as `extract-job-failure-error`, rather than pages and titles of their own.-- **The default extractors are waterfalls**: `@default-extract-document` takes the first of Azure Document Intelligence, Mistral OCR and `pypdfium2-extract-pdf` that an enabled backend serves, and `@default-extract-image` and `@default-premium` the first of the two OCR models, where all three named Azure Document Intelligence, which only the Pipelex Gateway and Pipelex Manifold serve. A `PipeExtract` step naming no model therefore runs on Manifold, on Mistral OCR with your own key, or, for a PDF, on its text layer read locally, which recovers no text from a scanned page; a project's managed `3_extract_deck.toml` takes the new aliases with `pipelex update`.+- **The default extractors run on your own keys (Breaking)**: `@default-extract-document` takes the first of Mistral OCR and `pypdfium2-extract-pdf` that an enabled backend serves, and `@default-extract-image` and `@default-premium` take Mistral OCR, where all three named Azure Document Intelligence, which no shipped backend serves any more. A `PipeExtract` step naming no model therefore runs on Mistral OCR with your own key or, for a PDF, on its text layer read locally, which recovers no text from a scanned page; a project's managed `3_extract_deck.toml` takes the new aliases with `pipelex update`.### Fixed@@ -22,13 +22,13 @@### Removed- **The builder: `pipelex-agent concept`, `pipelex-agent pipe`, `pipelex build runner` and `pipelex.builder` (Breaking)**: the two agent commands that converted a JSON concept or pipe spec into MTHDS TOML, and `pipelex build runner bundle` and `pipelex build runner method`, which wrote a Python script running a pipe, are gone with the spec layer behind them, `ConceptSpec`, `PipeSpec`, `PipelexBundleSpec` and the `ConceptSpecError`, `PipeSpecError` and `PipelexBundleSpecBlueprintError` classes; write a method in MTHDS directly and check it with `pipelex validate`, and take a runner's typed structures from `pipelex build structures` or `pipelex codegen types --target python-structures`. The `pipelex.builder` package no longer exists: the modules the runtime still uses moved, `pipelex.builder.conventions` to `pipelex.pipeline.default_file_names`, `pipelex.builder.operations.models_ops` to `pipelex.cogt.models.model_listing` and `pipelex.builder.operations.inputs_ops` to `pipelex.pipeline.inputs_template`, and the others are deleted with the helpers only they used, `force_include_dirs` on `pipelex.tools.misc.file_utils.find_files_in_dir` among them, which only forced the builder package into library loading. The `circular_dependency_error` validation error type, which only the spec layer's pipe sorter raised, leaves the `error_type` registry and the API server's OpenAPI schema.-- **The Pipelex Gateway backend is gone from the runtime (Breaking)**: `pipelex_gateway` leaves the shipped `backends.toml`, its `backends/pipelex_gateway.toml` override file and the generated `pipelex_gateway_models*.md` references leave the kit, the `all_pipelex_gateway` routing profile is gone, and the `pipelex-gateway` provider plugin is deleted along with its `gateway_*` SDKs, its error classes and their docs pages. A `backends.toml` that still carries a `[pipelex_gateway]` table loads it as an unknown backend with no plugin behind it, so remove the table; a routing profile naming it must move to another backend. The shipped default routing profile is now `all_enabled_backends`, which needs no Pipelex account: it sends each model to the first enabled backend that serves it, in the order its `fallback_order` lists. `pipelex init` pre-selects OpenAI, whose one key serves every default language-model and image-generation tier of the shipped model deck, and no longer sets `all_pipelex_gateway` when several backends are chosen; `pipelex-agent init` given no backend list keeps the template's routing profile rather than demanding a `primary_backend`. The `pipelex/pipelex-api` image enables `openai` in its place and boots on `OPENAI_API_KEY`, which serves every default language-model and image-generation tier of its deck. `pipelex_manifold` and every bring-your-own-keys backend are untouched.-- **The Gateway terms of service and the first-run check are gone (Breaking)**: `GatewayTermsNotAcceptedError`, the `[agreement]` section of `pipelex_service.toml`, `pipelex init agreement` and the `pipelex-agent accept-gateway-terms` command are removed, and `pipelex-agent init` no longer reads `accept_gateway_terms` from its config. The check that stopped a live run on a Pipelex-managed backend until inference setup had been recorded is removed as well, with `InferenceSetupRequiredError`, its CLI handling and `IntegrationMode.requires_terms_acceptance`, so a server, a container or a test suite boots with no `pipelex_service.toml` at all; `pipelex-agent init` still records `[onboarding] inference_setup_completed`, which nothing reads any more. A `pipelex_service.toml` written by an earlier release keeps booting: the migration ledger carries an entry that drops the retired section, and `pipelex migrate` rewrites the file.+- **The Pipelex Gateway backend is gone from the runtime (Breaking)**: `pipelex_gateway` leaves the shipped `backends.toml`, its `backends/pipelex_gateway.toml` override file and the generated `pipelex_gateway_models*.md` references leave the kit, the `all_pipelex_gateway` routing profile is gone, and the `pipelex-gateway` provider plugin is deleted along with its `gateway_*` SDKs, its error classes and their docs pages. A `backends.toml` that still enables a `[pipelex_gateway]` table, as the previous release's kit did, is refused at boot, because an enabled backend whose file declares no model is now an error rather than a backend every routed model silently goes missing from: disable or remove the table, and move a routing profile naming it, the previous default `all_pipelex_gateway` included, to another backend. The shipped default routing profile is now `all_enabled_backends`, which needs no Pipelex account: it sends each model to the first enabled backend that serves it, in the order its `fallback_order` lists. `pipelex init` pre-selects OpenAI, whose one key serves every default language-model and image-generation tier of the shipped model deck, and no longer sets `all_pipelex_gateway` when several backends are chosen; `pipelex-agent init` given no backend list keeps the template's routing profile rather than demanding a `primary_backend`. The `pipelex/pipelex-api` image enables `openai` in its place and boots on `OPENAI_API_KEY`, which serves every default language-model and image-generation tier of its deck. Every bring-your-own-keys backend is untouched.+- **The Gateway terms of service and the first-run check are gone (Breaking)**: `GatewayTermsNotAcceptedError`, the `[agreement]` section of `pipelex_service.toml`, `pipelex init agreement` and the `pipelex-agent accept-gateway-terms` command are removed, and `pipelex-agent init` no longer reads `accept_gateway_terms` from its config. The check that stopped a live run on a Pipelex-managed backend until inference setup had been recorded is removed as well, with `InferenceSetupRequiredError`, its CLI handling and `IntegrationMode.requires_terms_acceptance`, so a server, a container or a test suite boots with no setup recorded at all.- **The run-scoped telemetry identity applies to the one remaining stream**: `dev` grew `TelemetryIdentity` and `RunIdentityPolicy`, which resolve who a capture is attributed to from the run in flight, and wired them through both the operator's stream and the Pipelex one. With the Pipelex stream gone, the resolution stays and the second destination does not: the exception autocapture is one client again rather than two, `_track_to_pipelex` and the Pipelex span exporter are removed, and `_forget_posthog_capture_marks` — which existed only so the second stream could capture an error the first had already stamped — goes with them.- **The Pipelex-owned telemetry stream is gone (Breaking)**: the runtime no longer reports to Pipelex's PostHog on the Gateway's behalf, so `GatewayApiKeyMissingError`, `GatewayDoNotTrackConflictError`, `GatewayTelemetryManagerInjectedError`, `TelemetryManagerAbstract.is_pipelex_telemetry_enabled`, `IntegrationMode.is_test_harness` and the maintainer-only `[pipelex_gateway]` section of `telemetry.toml` (with its `is_pipelex_gateway_portkey_*` knobs) are removed; `TelemetryFactory.make_telemetry_manager` and `TelemetryManager` take only the user's `telemetry_config`. The user's own opt-in telemetry under `[custom_posthog]`, `[langfuse]` and `[[otlp]]` is untouched, and the telemetry ledger carries the entry that drops the retired section.- **`pipelex login` is gone (Breaking)**: it wrote a `PIPELEX_GATEWAY_API_KEY` that nothing reads any more, and it also leaves `_CORE_COMMAND_ORDER` and the setup-command set that skips the readiness check — an order list naming a command the CLI does not register makes `pipelex --help` itself exit non-zero. The credential flow for the hosted service is rebuilt separately.- **The `check-gateway-models` and `update-gateway-models` dev commands are gone**, with their `make ugm` / `make cgm` aliases and the `ticc` config-coverage target that ran the Gateway's Portkey configs.-- **`RemoteConfig` declares no fields of its own**: `posthog`, `backend_model_specs` and `aws_region` are no longer read, so the artifact's sections all arrive through `extra="allow"` and `GatewayConfig` drops its `aws_region`. `PipelexRoutingProfile` and `PipelexBackend.GATEWAY` are removed, `resolve_model_specs_section` no longer hands any backend a section it did not declare, and `is_pipelex_gateway_enabled` is gone — `enabled_managed_gateway_sections` is the one question the boot asks.+- **The runtime no longer downloads a remote config, and the hosted-only inference backend is no longer shipped (Breaking)**: the boot fetches nothing, so `PIPELEX_REMOTE_CONFIG_URL`, the `~/.pipelex/cache/remote_config.json` cache, the cache priming in `pipelex init` and `pipelex-agent init`, the remote fetch in `pipelex doctor` and `make regenerate-test-models`, and the `RemoteConfigFetchError`, `RemoteConfigValidationError`, `RemoteConfigUnavailableError`, `GatewayUnknownModelError` and `GatewayConfigMergeError` classes are gone, with the `warnings` array the agent CLI added to a success envelope for a stale cache. Every backend now reads its model specs from its own file under `inference/backends/`, so `model_specs_section` is no longer a backend setting, and the kit no longer ships the hosted-only backend's `backends.toml` table, its file under `inference/backends/` or the routing profile that sent every model to it; a project config that still declares them keeps booting while that backend is disabled, since a disabled backend is skipped and only the active routing profile loads. An enabled backend whose `backends.toml` table still carries `model_specs_section` is refused at boot, naming the key: list its models in its `backends/<name>.toml` and remove the key, or disable it. `pipelex_service.toml` is retired with its `PipelexServiceConfig` and `PipelexServiceError` classes: `pipelex-agent init` no longer writes it or reports `inference_setup_completed`, `cache_primed` or `cache_priming_error`, and a copy an earlier release left behind is ignored, by `pipelex migrate` too. The `needs_model_specs` argument of `Pipelex.make`, which only chose whether to fetch, is removed.## [v0.72.0] - 2026-10-04diff --git a/api/.pipelex/inference/backends.toml b/api/.pipelex/inference/backends.tomlindex 696711e7b..ba9c09007 100644--- a/api/.pipelex/inference/backends.toml+++ b/api/.pipelex/inference/backends.toml@@ -14,15 +14,6 @@#####################################################################################################-# Pipelex Manifold is a closed private beta: leave it off unless you have been invited.-[pipelex_manifold]-display_name = "Pipelex Manifold (private beta)"-enabled = false-endpoint = "${PIPELEX_MANIFOLD_ENDPOINT}"-api_key = "${PIPELEX_MANIFOLD_API_KEY}"-model_specs_section = "manifold_model_specs"-auth_header = "x-pipelex-api-key"-[anthropic]enabled = falseapi_key = "${ANTHROPIC_API_KEY}"diff --git a/api/.pipelex/inference/backends/pipelex_manifold.toml b/api/.pipelex/inference/backends/pipelex_manifold.tomldeleted file mode 100644index d2130ec85..000000000--- a/api/.pipelex/inference/backends/pipelex_manifold.toml+++ /dev/null@@ -1,51 +0,0 @@-################################################################################-# Pipelex Manifold Local Overrides-################################################################################-#-# PRIVATE BETA:-#-# Pipelex Manifold is the Pipelex-operated inference service. It is in private-# beta, it ships disabled in backends.toml, and this file does nothing until you-# enable it there and set PIPELEX_MANIFOLD_ENDPOINT and PIPELEX_MANIFOLD_API_KEY.-#-################################################################################-#-# TELEMETRY NOTICE:-#-# This backend sends no telemetry from your machine: the runtime's only-# telemetry stream is the one you configure yourself in telemetry.toml.-# Manifold is a Pipelex-operated service, though, so your usage of it is-# recorded server-side the way any hosted platform records the calls it serves.-#-# We collect only technical data (model names, token counts, latency, error-# rates). We do NOT collect prompts, completions, pipe codes, or business data.-#-# This allows us to monitor service quality, enforce fair usage, and support you.-#-################################################################################-#-# WARNING: USE AT YOUR OWN RISK!-#-# The actual model configuration is fetched remotely from Pipelex servers.-# Any override in this file may cause unexpected behavior or failures,-# as the remote configuration may change at any time.-#-# If you must override, you may ONLY use these keys per model:-# - sdk-# - structure_method-#-# All other keys will be ignored.-#-# If you need custom configurations, consider using your own API keys-# with direct provider backends (openai, anthropic, etc.) instead.-#-# Documentation:-# https://docs.pipelex.com/latest/configuration/config-technical/inference-backend-config/-# Support: https://go.pipelex.com/discord-#-################################################################################--# Per-model overrides example:-# [gpt-4o]-# sdk = "manifold_completions"-# structure_method = "instructor/openai_tools"diff --git a/api/.pipelex/inference/deck/3_extract_deck.toml b/api/.pipelex/inference/deck/3_extract_deck.tomlindex c5e474a91..daf2de5e4 100644--- a/api/.pipelex/inference/deck/3_extract_deck.toml+++ b/api/.pipelex/inference/deck/3_extract_deck.toml@@ -42,17 +42,13 @@ default-extract-web-page = "linkup-fetch"# Waterfalls#####################################################################################################-# Each default resolves to the first entry an enabled backend serves: Azure Document Intelligence-# through Pipelex Manifold, then Mistral OCR with your own Mistral key. Documents fall back last to-# reading a PDF's text layer locally, which needs no key but recovers no text from a scanned page.+# Each default resolves to the first entry an enabled backend serves: Mistral OCR with your own+# Mistral key. Documents fall back to reading a PDF's text layer locally, which needs no key but+# recovers no text from a scanned page.[extract.waterfalls]-document-extractor = [- "azure-document-intelligence",- "mistral-ocr",- "pypdfium2-extract-pdf",-]-ocr-extractor = ["azure-document-intelligence", "mistral-ocr"]+document-extractor = ["mistral-ocr", "pypdfium2-extract-pdf"]+ocr-extractor = ["mistral-ocr"]##################################################################################################### Extract Presetsdiff --git a/api/.pipelex/inference/deck/x_custom_extract_deck.toml b/api/.pipelex/inference/deck/x_custom_extract_deck.tomlindex 5d4c46442..53304842c 100644--- a/api/.pipelex/inference/deck/x_custom_extract_deck.toml+++ b/api/.pipelex/inference/deck/x_custom_extract_deck.toml@@ -27,14 +27,10 @@# Example (uncomment to use):# [extract.waterfalls]-# document_extractor = ["azure-document-intelligence", "mistral-document-ai-2505"]+# document_extractor = ["mistral-document-ai-2505", "pypdfium2-extract-pdf"]# pdf_text_extractor = [-# "azure-document-intelligence",# "mistral-document-ai-2505",# "pypdfium2-extract-pdf",# ]-# image_text_extractor = [-# "azure-document-intelligence",-# "mistral-document-ai-2505",-# ]+# image_text_extractor = ["mistral-document-ai-2505"]####################################################################################################diff --git a/api/.pipelex/inference/routing_profiles.toml b/api/.pipelex/inference/routing_profiles.tomlindex c11082327..00272c799 100644--- a/api/.pipelex/inference/routing_profiles.toml+++ b/api/.pipelex/inference/routing_profiles.toml@@ -45,7 +45,6 @@ fallback_order = ["scaleway","ollama","vertexai",- "pipelex_manifold",]# Judgment models are served by their own backend alone, so they go to it whenever it is enabled.@@ -53,17 +52,6 @@ fallback_order = [[profiles.all_enabled_backends.optional_routes]"jev-*" = "typesafe"-# The Pipelex-operated inference service (private beta). A model's wire id and sdk are per-backend,-# so decks, aliases and presets keep naming the same handles whichever profile is active.-[profiles.all_pipelex_manifold]-description = "Use Pipelex Manifold (private beta) for all its supported models"-default = "pipelex_manifold"--# Judgment models are brought by you rather than served by Pipelex, so they go to their own backend-# whenever it is enabled. An optional route is inert while its backend is disabled.-[profiles.all_pipelex_manifold.optional_routes]-"jev-*" = "typesafe"-[profiles.all_anthropic]description = "Use Anthropic backend for all its supported models"default = "anthropic"diff --git a/docs/configuration/config-technical/inference-backend-config.md b/docs/configuration/config-technical/inference-backend-config.mdindex f0110a263..2fadeb3fa 100644--- a/docs/configuration/config-technical/inference-backend-config.md+++ b/docs/configuration/config-technical/inference-backend-config.md@@ -1,5 +1,5 @@----description: "Set up AI model providers, routing profiles, and inference backends — use Pipelex Gateway, direct API keys, or custom configurations."+description: "Set up AI model providers, routing profiles, and inference backends with your own API keys and custom routing."---# Inference Backend Configuration@@ -8,23 +8,11 @@ The Inference Backend Configuration System manages how Pipelex handles AI model## Configuration Approaches-Pipelex supports three flexible approaches for accessing AI models:+Pipelex calls AI models through backends you configure with your own provider API keys.-### Option A: Pipelex Gateway (Optional & Free)+### Bring Your Own Keys-Get a single API key that works with all major providers (OpenAI, Anthropic, Google, Mistral, FAL, and more). This is the **recommended approach for getting started quickly**.--- ✅ Single API key for all providers-- ✅ Simplified configuration-- ✅ Automatic model routing-- ✅ Free on Discord (limited time offer)--!!! note "Terms of Service"- Using Pipelex Gateway requires accepting our terms of service. When you run `pipelex init`, you'll be prompted to review and accept the terms. Gateway usage enables identified telemetry (tied to your hashed API key) for service monitoring. See our [Privacy Policy](https://go.pipelex.com/privacy-policy) for details.--### Option B: Bring Your Own Keys--Use your own API keys from individual providers for full control and direct billing. Ideal for production deployments with existing provider relationships.+Use your own API keys from individual providers for full control and direct billing.- ✅ Direct provider relationships- ✅ Full control over billing@@ -33,14 +21,13 @@ Use your own API keys from individual providers for full control and direct billSee [Inference Backends](#inference-backends) section below for configuration.-### Option C: Mix & Match (Custom Routing)+### Mix & Match (Custom Routing)-Configure custom routing profiles to use your own keys for some models and Pipelex Gateway for others. This gives you full flexibility to optimize for cost, performance, or rate limits.+Configure custom routing profiles to send some models to one provider and others to another. This gives you full flexibility to optimize for cost, performance, or rate limits.-- ✅ Hybrid approach- ✅ Cost optimization- ✅ Performance tuning-- ✅ Gradual migration between approaches+- ✅ Gradual migration between providersSee [Routing Profiles](#routing-profiles) section below for setup.@@ -93,125 +80,6 @@ Deck files are loaded in order by their numeric prefix (`1_`, `2_`, `3_`), withTo customize aliases, presets, or default choices without conflict, edit (or create) any file in this directory whose name starts with `x_custom_` — Pipelex never tracks or overwrites those. See [`pipelex update`](../../tools/cli/update.md) for the full workflow.-## Pipelex Gateway (Optional & Free)--Pipelex Gateway is a unified inference backend that provides access to all major AI providers through a single API key. This is the **recommended approach for getting started quickly** with Pipelex and **unlocking its full power**—with many models already available and new ones being added constantly. Using Pipelex Gateway is **completely optional**.--### Benefits--- **Single API Key**: Access OpenAI, Anthropic, Google, Mistral, FAL, and more with one key-- **Free to Get Started**: Available free on [app.pipelex.com](https://app.pipelex.com/) (no credit card required, limited time offer)-- **Simplified Configuration**: No need to manage multiple provider credentials-- **Automatic Routing**: All AI models (LLMs, OCR, image generation) are automatically routed to their respective providers-- **Unified Interface**: Same configuration system for text generation, OCR, and image generation--### Terms of Service & Telemetry--Using Pipelex Gateway requires accepting our terms of service. When you enable Gateway and run `pipelex init`, you'll be prompted with a terms panel explaining:--- **What we collect**: Model names, token counts, latency, error rates (technical data only)-- **What we do NOT collect**: Your prompts, completions, pipe codes, or business data-- **Why**: To monitor service quality, enforce fair usage, and provide better support-- **Your choice**: If you decline, Gateway is disabled and you can use direct provider backends instead--Your API key is hashed for security. Gateway telemetry operates independently from your `telemetry.toml` settings. See our [Privacy Policy](https://go.pipelex.com/privacy-policy) for details.--### Setup--1. **Get your API key:**-- - Visit [https://go.pipelex.com/discord](https://go.pipelex.com/discord) to join our Discord- - Request your free API key in the appropriate channel- - No credit card required (limited time offer)--2. **Configure environment variables:**-- ```bash- # Copy the example environment file- cp .env.example .env-- # Edit .env and add your Pipelex Gateway API key- PIPELEX_GATEWAY_API_KEY="your-api-key"- ```--3. **Accept terms and verify configuration:**-- ```bash- pipelex init- ```-- When prompted, review and accept the Gateway terms of service.--4. **Verify backend configuration:**-- The `pipelex_gateway` backend should be enabled in `.pipelex/inference/backends.toml`:-- ```toml- [pipelex_gateway]- display_name = "⭐ Pipelex Gateway"- enabled = true- api_key = "${PIPELEX_GATEWAY_API_KEY}"- ```-- The environment variable `${PIPELEX_GATEWAY_API_KEY}` will be automatically loaded from your environment.--4. **Verify routing configuration:**-- The default routing profile in `.pipelex/inference/routing_profiles.toml` should be set to `all_pipelex_gateway`:-- ```toml- active = "all_pipelex_gateway"-- [profiles.all_pipelex_gateway]- description = "Use Pipelex Gateway for all its supported models"- default = "pipelex_gateway"- ```--### Usage--Once configured, all models are available through the unified backend. Use standard model names in your pipelines:--```toml-[pipe.example]-type = "PipeLLM"-model = { model = "claude-4.5-sonnet", temperature = 0.7 }-# Model automatically routed through Pipelex Gateway-```--### Gateway Model Overrides--!!! warning "Advanced Feature - Use at Your Own Risk"- The Pipelex Gateway model configuration is fetched remotely from Pipelex servers. Any local override may cause unexpected behavior or failures, as the remote configuration may change at any time.--If you need to customize how a specific model behaves through the Gateway, you can add per-model overrides in `.pipelex/inference/backends/pipelex_gateway.toml`. However, only two keys are supported:--- `sdk`: The SDK to use for the model (e.g., `gateway_completions`)-- `structure_method`: The method for structured output (e.g., `instructor/openai_tools`)--All other keys will be ignored. What each structure method sends is described under [Structure methods](#structure-methods).--```toml-# .pipelex/inference/backends/pipelex_gateway.toml--# Per-model overrides example:-[gpt-4o]-sdk = "gateway_completions"-structure_method = "instructor/openai_tools"-```--!!! tip "Prefer Direct Backends for Custom Configurations"- If you need custom configurations beyond `sdk` and `structure_method`, consider using your own API keys with direct provider backends (openai, anthropic, etc.) instead of Gateway overrides.--### Model Availability Note--While Pipelex Gateway provides access to most AI models through a unified API, certain specialized models require their native backend to be enabled directly:--- **FAL image generation models** (e.g., Flux models) - Enable the FAL backend-- **OpenAI image generation** (`gpt-image-1`) - Enable the OpenAI backend (should also work via Azure OpenAI, but we haven't been able to test this - if you've successfully used it on Azure, please let us know on [Discord](https://go.pipelex.com/discord) so we can validate this configuration)-- **Mistral OCR models** - Enable the Mistral backend--These models are not proxied through Pipelex Gateway and require direct configuration of their respective backends with appropriate API keys.-## Inference BackendsBackends represent AI service providers that can offer LLMs, OCR models, or image generation models. Each backend is configured with its endpoint and authentication details.@@ -234,9 +102,6 @@ cp .env.example .envThe `.env.example` file contains all available providers with helpful comments:```bash-# [OPTIONAL] Free Pipelex Gateway API key - Get yours on Discord: https://go.pipelex.com/discord-PIPELEX_GATEWAY_API_KEY=-OPENAI_API_KEY=# Amazon Bedrock - For accessing models via Amazon Bedrock@@ -300,7 +165,9 @@ enabled = trueThe `${VARIABLE_NAME}` syntax automatically loads values from your `.env` file. Set `enabled = true` to activate a backend, or `false` to disable it.-Judgment models are never served by the Pipelex Gateway, so the default routing profile sends them to their own backend through an optional route (`"jev-*" = "typesafe"`), which applies only while that backend is enabled. With a `TYPESAFE_API_KEY` set, `@default-judgment` works under the default profile with no routing edit.+An enabled backend must declare at least one model in its file under `backends/` (see [Model Specifications](#model-specifications)). Pipelex refuses to boot when one declares none, because routing would send models to a backend that cannot serve them: disable the backend, or list the models it serves. The `internal` backend is exempt, since plugins add its models at boot. A backend table also no longer accepts a `model_specs_section` key; an enabled backend that still carries one is refused, and the fix is to list its models in `backends/<name>.toml` and remove the key, or to disable the backend.++Judgment models are served by their own backend alone, so the default routing profile sends them to their own backend through an optional route (`"jev-*" = "typesafe"`), which applies only while that backend is enabled. With a `TYPESAFE_API_KEY` set, `@default-judgment` works under the default profile with no routing edit.### Model Specifications@@ -358,7 +225,7 @@ A file whose format the consuming model does not declare is refused with an inpu#### Structure methods-`structure_method` says how a model is asked for structured output. A structure method names a provider, but the SDK decides how the request is sent. Each method stands for one of `instructor`'s core modes: every `*_tools` method is tool calling, and so is `instructor/openai_structured_outputs`, which sends OpenAI a non-strict tool schema; `instructor/mistral_structured_outputs` or `instructor/openrouter_structured_outputs` is a JSON-schema response format. So a method named after another provider still works through the Gateway's OpenAI-compatible SDKs.+`structure_method` says how a model is asked for structured output. A structure method names a provider, but the SDK decides how the request is sent. Each method stands for one of `instructor`'s core modes: every `*_tools` method is tool calling, and so is `instructor/openai_structured_outputs`, which sends OpenAI a non-strict tool schema; `instructor/mistral_structured_outputs` or `instructor/openrouter_structured_outputs` is a JSON-schema response format. So a method named after another provider still works through an OpenAI-compatible SDK.One method keeps a behaviour of its own on the `anthropic` and `bedrock_anthropic` SDKs: tool calling forces the model to call the response tool, and `instructor/anthropic_reasoning_tools` leaves that choice to the model instead, steering it to the tool with a system line, for a model that refuses a forced tool choice.@@ -394,35 +261,15 @@ Unknown key on model 'gpt-4o' for backend 'openai' from file '.pipelex/inferenceletters, digits and the characters !#$%&'*+-.^_`|~.```-The Pipelex Gateway's model specs are fetched from Pipelex servers rather than read from a local file, and there the same rule is applied leniently: a header-shaped key whose name and value the wire can carry becomes a header, and any other unknown key — including a header-shaped one whose value is not a string, or whose name or value HTTP would refuse — is dropped instead of failing the boot, since a served config can legitimately be newer or older than the client reading it.--`endpoint_path` is a declared model-spec field, not a header: it names the provider-side route for models that are called by raw path (the Gateway's image models), and is never sent on the wire.+`endpoint_path` is a declared model-spec field, not a header: it names the provider-side route for models that are called by raw path (some gateways' image models), and is never sent on the wire.## Routing Profiles-Routing profiles determine which backend handles specific models. This is where you configure the **Mix & Match approach** (Option C) to optimize your setup. Configure them in `.pipelex/inference/routing_profiles.toml`:+Routing profiles determine which backend handles specific models. This is where you configure the **Mix & Match approach** to optimize your setup. Configure them in `.pipelex/inference/routing_profiles.toml`:### Profile Examples-**All Pipelex Gateway (Option A):**--Setup:-```bash-# In .env-PIPELEX_GATEWAY_API_KEY="your-pipelex-key"-```--In `.pipelex/inference/routing_profiles.toml`:-```toml-# Which profile to use-active = "all_pipelex_gateway"--[profiles.all_pipelex_gateway]-description = "Use Pipelex Gateway for all its supported models"-default = "pipelex_gateway"-```--**Native Providers Only (Option B):**+**Native Providers Only:**Setup:```bash@@ -450,12 +297,12 @@ default = "openai""flux-*" = "fal"```-**Mix & Match (Option C):**+**Mix & Match:**Setup:```bash-# In .env - combine Pipelex with specific provider keys-PIPELEX_GATEWAY_API_KEY="your-pipelex-key"+# In .env - combine the provider keys you need+ANTHROPIC_API_KEY="your-anthropic-key"OPENAI_API_KEY="your-openai-key" # For GPT modelsFAL_API_KEY="your-fal-key" # For image generation```@@ -465,17 +312,18 @@ In `.pipelex/inference/routing_profiles.toml`:active = "hybrid"[profiles.hybrid]-description = "Use Pipelex Gateway for most models, native providers for specific ones"-default = "pipelex_gateway"+description = "Claude on Anthropic, GPT on OpenAI, FLUX on fal"+default = "anthropic"[profiles.hybrid.routes]-# Use your own OpenAI key for GPT models (better rate limits)+# Use your own OpenAI key for GPT models and OpenAI image generation"gpt-*" = "openai"# Use your own FAL key for image generation (direct billing)"flux-*" = "fal"-# All other models use Pipelex Gateway (claude, gemini, mistral, etc.)```+The `default` backend only serves the models it declares: Anthropic serves Claude models and nothing else, so a model with no route here that Anthropic does not serve, such as a Gemini or Mistral model, is left out of the deck. Give every model family you use a route, or list your backends in a `fallback_order` as the shipped `all_enabled_backends` profile does, so each model goes to the first enabled backend that serves it.+### Routing System FeaturesThe routing system supports:@@ -485,22 +333,22 @@ The routing system supports:- Prefix: `"gpt-*" = "openai"`- Suffix: `"*-turbo" = "openai"`- Contains: `"*-vision-*" = "openai"`-- **Default fallback**: `default = "pipelex_gateway"`+- **Default fallback**: `default = "anthropic"`### Use Cases for Mix & MatchCommon scenarios for hybrid routing:-1. **Cost Optimization**: Use Pipelex Gateway for expensive models, your own keys for cheaper ones-2. **Rate Limits**: Use your own keys for high-volume models to avoid shared rate limits-3. **Gradual Migration**: Start with Pipelex Gateway, gradually move to your own keys as usage grows-4. **Provider Features**: Use native providers for models requiring specific features not proxied through Pipelex Gateway+1. **Cost Optimization**: Send expensive models to the provider that prices them best+2. **Rate Limits**: Spread high-volume models across providers to avoid rate limits+3. **Gradual Migration**: Move models from one provider to another one route at a time+4. **Provider Features**: Use a model's native provider when you need features an aggregator does not proxy### Internal Backend (Always Available)The **internal backend** is a special backend containing software-only models that run locally without requiring AI services. These include models for PDF text extraction, local document parsing, and other processing tasks that don't need external API calls.-Unlike other backends, internal backend models are **always available** regardless of which routing profile you select. This means you can use these models even when your routing profile is focused on a specific AI provider (e.g., `all_pipelex_gateway` or `all_openai`).+Unlike other backends, internal backend models are **always available** regardless of which routing profile you select. This means you can use these models even when your routing profile is focused on a specific AI provider (e.g., `all_anthropic` or `all_openai`).This behavior is automatic and requires no additional configuration. To see which models are available from the internal backend, check `.pipelex/inference/backends/internal.toml`.@@ -681,12 +529,12 @@ Where a file lives decides its reach. The base file resolves as before — the pThe global override reaches a project that carries its own tracked base, which is the point: one edit under `~/.pipelex/inference/` and every project follows. Deleting the override files restores the shipped default.-A developer who wants a whole machine off the gateway and on Anthropic writes two files once:+A developer who wants a whole machine on Anthropic alone writes two files once:```toml# ~/.pipelex/inference/backends_override.toml-[pipelex_gateway]-enabled = false+[anthropic]+enabled = true``````toml@@ -696,7 +544,7 @@ active = "all_anthropic"Enabling a backend and activating a profile that needs it go together: a profile whose default or routes name a backend that is not enabled is refused at boot, and the error names the backend to enable. `pipelex show backends` and `pipelex doctor` report the merged view, so what they print is what runs.-An override leaves a trace. When one was merged, the boot logs which files each document was read from, so a run on an unexpected backend says why in its own log. A file that does not parse is refused the way an invalid document is — as a setup error naming the file, in the boot, in `pipelex init` and in the doctor's Models row — and so is a value where a table was meant, such as `anthropic = false` where `[anthropic]` with `enabled = false` was intended. `pipelex init` keeps writing the base file, but it decides whether a Pipelex-managed gateway backend is enabled on the merged document, so one switched on only by an override still gets the terms prompt; and when declining the terms disables those backends in the base while an override still pins one on, the command says so and names both the backend and the file to edit.+An override leaves a trace. When one was merged, the boot logs which files each document was read from, so a run on an unexpected backend says why in its own log. A file that does not parse is refused the way an invalid document is — as a setup error naming the file, in the boot, in `pipelex init` and in the doctor's Models row — and so is a value where a table was meant, such as `anthropic = false` where `[anthropic]` with `enabled = false` was intended. `pipelex init` keeps writing the base file.### Custom deck files@@ -720,7 +568,7 @@ small-llm = ["gemini-2.5-flash-lite", "gpt-4o-mini", "claude-3-haiku"]```toml[extract.waterfalls]-document_extractor = ["azure-document-intelligence", "mistral-document-ai-2505"]+document_extractor = ["mistral-document-ai-2505", "pypdfium2-extract-pdf"]```When using waterfalls in `.mthds` files, prefix them with `~`:@@ -783,7 +631,7 @@ pipelex migrate # ask, then rewrite in placeWhat it touches and what it leaves alone:- **Every `*.toml` directly in `inference/backends/`** — the files this page describes, in both the global `~/.pipelex/` and a project's `.pipelex/`.-- **Not** `inference/backends.toml`, which sits beside that directory rather than in it, and **not** the model deck under `inference/deck/`. The deck has its own `pipelex update`, which also refreshes `internal.toml` from the kit.+- **Not** `inference/backends.toml`, which sits beside that directory rather than in it, and **not** the model deck under `inference/deck/`. The deck has its own `pipelex update`, which also refreshes `internal.toml` from the kit. A `backends.toml` left by an older release that still enables a backend with no model file, such as `[pipelex_gateway]`, is refused at boot and has to be edited by hand: set that backend's `enabled = false`, and point the active routing profile in `routing_profiles.toml` at a backend you have enabled.- **Not a key you added yourself.** The history only describes keys *we* removed or renamed. An unknown key of your own — a misspelled `maxx_tokens`, an extra header that is not header-shaped — is still an error, and it names the file, the key and what to do. That is deliberate: silently dropping a key you meant to set would change which model you get.- **Every file it rewrites is copied first**, beside itself, as `<file>.bak.<UTC timestamp>`. Running the command twice is the same as running it once — a file already up to date comes back byte for byte identical.@@ -794,9 +642,8 @@ See [The Migration Ledger](../../migration-ledger.md) for what the history may c## Best Practices1. **Choosing Your Configuration Approach**:- - **Starting out?** Use Pipelex Gateway (Option A) to get running quickly- - **Production deployment?** Consider bringing your own keys (Option B) for direct billing control- - **Optimizing costs/performance?** Use Mix & Match (Option C) for maximum flexibility+ - **Starting out?** Enable the one provider you already have a key for, and route everything to it+ - **Optimizing costs/performance?** Use Mix & Match for maximum flexibility- You can switch between approaches at any time by changing your routing profile2. **Backend Management**:diff --git a/docs/contribute/inference-family-surface.md b/docs/contribute/inference-family-surface.mdindex dc6edad98..c57fa4fcc 100644--- a/docs/contribute/inference-family-surface.md+++ b/docs/contribute/inference-family-surface.md@@ -46,7 +46,7 @@ Most of the list is enforced by the type checker: the matches over the family en4. **Configuration.** The backend's table in the kit's `backends.toml`, its model file under `backends/`, and an `all_<vendor>` routing profile — which is also what the integration combo fixtures route to — all mirrored into `.pipelex/inference/`. Its API key variable goes in `.env.example`.-5. **Silent: the routing profiles.** The default `all_enabled_backends` profile tries the backends its `fallback_order` lists first and any other enabled backend after them, so list the vendor there when it should be tried before the end. Under the managed `all_pipelex_manifold` profile every handle routes to the manifold by default, and a handle the manifold does not serve is silently dropped from the deck — so a user who has the vendor's key still cannot use its models. Give the managed profile an `optional_routes` entry sending the vendor's models to its backend; an optional route applies only while that backend is enabled.+5. **Silent: the routing profiles.** The default `all_enabled_backends` profile tries the backends its `fallback_order` lists first and any other enabled backend after them, so list the vendor there when it should be tried before the end. A profile whose `default` is a single backend sends every handle there, and a handle that backend does not serve is silently dropped from the deck — so a user who has the vendor's key still cannot use its models. Give such a profile an `optional_routes` entry sending the vendor's models to its backend; an optional route applies only while that backend is enabled.6. **Silent: the CI placeholder list.** CI runners hold no provider keys, and every test module boots live, so each variable an enabled kit backend references must be in `ENV_VAR_KEYS_WHICH_MAY_NEED_PLACEHOLDERS_IN_CI` in `pipelex/test_extras/shared_pytest_plugins.py`. `tests/unit/pipelex/test_extras/test_ci_placeholder_keys.py` fails when one is missing. The agent CLI's end-to-end tests build their own hermetic environment, with a dummy value per variable, in the `offline_subprocess_env` fixture of `tests/e2e/agent_cli/conftest.py`, and nothing checks that list: a variable missing there only makes a dry run skip the backend.diff --git a/docs/contribute/rich-imports.md b/docs/contribute/rich-imports.mdindex 093be6115..1d0e0d6f7 100644--- a/docs/contribute/rich-imports.md+++ b/docs/contribute/rich-imports.md@@ -107,7 +107,7 @@ The test runs, in a subprocess, what a server does. A meta-path finder installedA subprocess is required rather than preferred: the test process has Rich loaded, since the suite installs every extra, and evicting it from `sys.modules` would leave duplicate classes behind for every later test.-Every one of those boots asks for no model specs (`needs_model_specs=False`), which is what lets the test run where inference was never set up — a CI runner — because that branch of the boot does not reach the network. `needs_inference` stays true on purpose: a keyless boot forces every run this process starts to DRY, and the dry path never prints the "Output of pipe" panel, which is the Rich reach the test is here for.+None of those boots reaches the network, which is what lets the test run where inference was never set up — a CI runner. `needs_inference` stays true on purpose: a keyless boot forces every run this process starts to DRY, and the dry path never prints the "Output of pipe" panel, which is the Rich reach the test is here for.The test blocks Rich rather than checking that it is absent from an ordinary environment, because an environment is not the measure. Whether Rich is installed also depends on what the other dependencies of `pipelex` require, and some third-party packages import Rich whenever it is installed. What the runtime owns is that it never needs Rich on a server's path, and that is what the blocked run measures.diff --git a/docs/errors/gateway-config-merge-error.md b/docs/errors/gateway-config-merge-error.mddeleted file mode 100644index 59407789f..000000000--- a/docs/errors/gateway-config-merge-error.md+++ /dev/null@@ -1,21 +0,0 @@-----title: "Gateway config merge"-description: "Reference for the `GatewayConfigMergeError` Pipelex error class."------<!-- pipelex:generated -->--# Gateway config merge--Raised when merging a managed gateway's served model specs with local overrides meets invalid data.--| Field | Value |-|---|---|-| `error_type` | `GatewayConfigMergeError` |-| `title` | Gateway config merge |-| `type_uri` | `https://docs.pipelex.com/latest/errors/gateway-config-merge-error/` |-| `error_domain` | _(inherited from parent)_ |-| Defined in | `pipelex.system.pipelex_service.exceptions` |-| Parent class | [`PipelexServiceError`](pipelex-service-error.md) |--[Back to Error Reference](index.md)diff --git a/docs/errors/gateway-unknown-model-error.md b/docs/errors/gateway-unknown-model-error.mddeleted file mode 100644index e19f8023b..000000000--- a/docs/errors/gateway-unknown-model-error.md+++ /dev/null@@ -1,21 +0,0 @@-----title: "Gateway unknown model"-description: "Reference for the `GatewayUnknownModelError` Pipelex error class."------<!-- pipelex:generated -->--# Gateway unknown model--A model handle the active routing profile sends to a managed gateway is absent from its specs.--| Field | Value |-|---|---|-| `error_type` | `GatewayUnknownModelError` |-| `title` | Gateway unknown model |-| `type_uri` | `https://docs.pipelex.com/latest/errors/gateway-unknown-model-error/` |-| `error_domain` | _(inherited from parent)_ |-| Defined in | `pipelex.cogt.exceptions` |-| Parent class | [`CogtError`](cogt-error.md) |--[Back to Error Reference](index.md)diff --git a/docs/errors/inference-and-providers.md b/docs/errors/inference-and-providers.mdindex e79343532..d265d98a8 100644--- a/docs/errors/inference-and-providers.md+++ b/docs/errors/inference-and-providers.md@@ -28,7 +28,6 @@ own page. Classes are grouped by subsystem.- [`ExtractModelNotFoundError`](extract-model-not-found-error.md) — Extract model not found- [`ExtractOutputError`](extract-output-error.md) — Extract output- [`FalCredentialsError`](fal-credentials-error.md) — Fal credentials-- [`GatewayUnknownModelError`](gateway-unknown-model-error.md) — Gateway unknown model- [`GeneratedImageError`](generated-image-error.md) — Generated image- [`ImageContentError`](image-content-error.md) — Image content- [`ImgGenGeneratedTypeError`](img-gen-generated-type-error.md) — Img gen generated typediff --git a/docs/errors/pipelex-service-config-validation-error.md b/docs/errors/pipelex-service-config-validation-error.mddeleted file mode 100644index 003b9dd20..000000000--- a/docs/errors/pipelex-service-config-validation-error.md+++ /dev/null@@ -1,21 +0,0 @@-----title: "Pipelex service config validation"-description: "Reference for the `PipelexServiceConfigValidationError` Pipelex error class."------<!-- pipelex:generated -->--# Pipelex service config validation--Raised when pipelex_service.toml validation fails.--| Field | Value |-|---|---|-| `error_type` | `PipelexServiceConfigValidationError` |-| `title` | Pipelex service config validation |-| `type_uri` | `https://docs.pipelex.com/latest/errors/pipelex-service-config-validation-error/` |-| `error_domain` | `config` |-| Defined in | `pipelex.system.pipelex_service.exceptions` |-| Parent class | [`PipelexError`](pipelex-error.md) |--[Back to Error Reference](index.md)diff --git a/docs/errors/pipelex-service-error.md b/docs/errors/pipelex-service-error.mddeleted file mode 100644index b24a52771..000000000--- a/docs/errors/pipelex-service-error.md+++ /dev/null@@ -1,21 +0,0 @@-----title: "Pipelex service"-description: "Reference for the `PipelexServiceError` Pipelex error class."------<!-- pipelex:generated -->--# Pipelex service--Base exception for Pipelex service errors.--| Field | Value |-|---|---|-| `error_type` | `PipelexServiceError` |-| `title` | Pipelex service |-| `type_uri` | `https://docs.pipelex.com/latest/errors/pipelex-service-error/` |-| `error_domain` | `config` |-| Defined in | `pipelex.system.pipelex_service.exceptions` |-| Parent class | [`PipelexError`](pipelex-error.md) |--[Back to Error Reference](index.md)diff --git a/docs/errors/platform-and-tooling.md b/docs/errors/platform-and-tooling.mdindex 385530a29..a7ce3f0c3 100644--- a/docs/errors/platform-and-tooling.md+++ b/docs/errors/platform-and-tooling.md@@ -73,16 +73,10 @@ own page. Classes are grouped by subsystem.- [`EnvVarNotFoundError`](env-var-not-found-error.md) — Environment variable not set- [`FatalError`](fatal-error.md) — Fatal error- [`FuncRegistryError`](func-registry-error.md) — Func registry-- [`GatewayConfigMergeError`](gateway-config-merge-error.md) — Gateway config merge- [`JobMetadataError`](job-metadata-error.md) — Job metadata- [`LangfuseCredentialsError`](langfuse-credentials-error.md) — Langfuse credentials- [`MissingDependencyError`](missing-dependency-error.md) — Missing dependency- [`NestedKeyConflictError`](nested-key-conflict-error.md) — Nested key conflict-- [`PipelexServiceConfigValidationError`](pipelex-service-config-validation-error.md) — Pipelex service config validation-- [`PipelexServiceError`](pipelex-service-error.md) — Pipelex service-- [`RemoteConfigFetchError`](remote-config-fetch-error.md) — Remote config fetch-- [`RemoteConfigUnavailableError`](remote-config-unavailable-error.md) — Remote config unavailable-- [`RemoteConfigValidationError`](remote-config-validation-error.md) — Remote config validation- [`TelemetryConfigError`](telemetry-config-error.md) — Telemetry config- [`TelemetryConfigValidationError`](telemetry-config-validation-error.md) — Telemetry config validation- [`ToolError`](tool-error.md) — Tool errordiff --git a/docs/errors/remote-config-fetch-error.md b/docs/errors/remote-config-fetch-error.mddeleted file mode 100644index 94c2cbfda..000000000--- a/docs/errors/remote-config-fetch-error.md+++ /dev/null@@ -1,21 +0,0 @@-----title: "Remote config fetch"-description: "Reference for the `RemoteConfigFetchError` Pipelex error class."------<!-- pipelex:generated -->--# Remote config fetch--Raised when fetching the Pipelex remote configuration fails.--| Field | Value |-|---|---|-| `error_type` | `RemoteConfigFetchError` |-| `title` | Remote config fetch |-| `type_uri` | `https://docs.pipelex.com/latest/errors/remote-config-fetch-error/` |-| `error_domain` | _(inherited from parent)_ |-| Defined in | `pipelex.system.pipelex_service.exceptions` |-| Parent class | [`PipelexServiceError`](pipelex-service-error.md) |--[Back to Error Reference](index.md)diff --git a/docs/errors/remote-config-unavailable-error.md b/docs/errors/remote-config-unavailable-error.mddeleted file mode 100644index e63f0b846..000000000--- a/docs/errors/remote-config-unavailable-error.md+++ /dev/null@@ -1,21 +0,0 @@-----title: "Remote config unavailable"-description: "Reference for the `RemoteConfigUnavailableError` Pipelex error class."------<!-- pipelex:generated -->--# Remote config unavailable--Raised when a fresh fetch failed AND no usable cached fallback exists.--| Field | Value |-|---|---|-| `error_type` | `RemoteConfigUnavailableError` |-| `title` | Remote config unavailable |-| `type_uri` | `https://docs.pipelex.com/latest/errors/remote-config-unavailable-error/` |-| `error_domain` | _(inherited from parent)_ |-| Defined in | `pipelex.system.pipelex_service.exceptions` |-| Parent class | [`PipelexServiceError`](pipelex-service-error.md) |--[Back to Error Reference](index.md)diff --git a/docs/errors/remote-config-validation-error.md b/docs/errors/remote-config-validation-error.mddeleted file mode 100644index 3e57b7aea..000000000--- a/docs/errors/remote-config-validation-error.md+++ /dev/null@@ -1,21 +0,0 @@-----title: "Remote config validation"-description: "Reference for the `RemoteConfigValidationError` Pipelex error class."------<!-- pipelex:generated -->--# Remote config validation--Raised when remote configuration payload validation fails.--| Field | Value |-|---|---|-| `error_type` | `RemoteConfigValidationError` |-| `title` | Remote config validation |-| `type_uri` | `https://docs.pipelex.com/latest/errors/remote-config-validation-error/` |-| `error_domain` | _(inherited from parent)_ |-| Defined in | `pipelex.system.pipelex_service.exceptions` |-| Parent class | [`PipelexServiceError`](pipelex-service-error.md) |--[Back to Error Reference](index.md)diff --git a/docs/features/document-extraction.md b/docs/features/document-extraction.mdindex f620af740..8aea9ad9e 100644--- a/docs/features/document-extraction.md+++ b/docs/features/document-extraction.md@@ -20,12 +20,11 @@ Unlike LLM APIs (partly standardized around OpenAI's completions API), the OCR l| **pypdfium2** | Built-in | Basic PDF text and image extraction without AI inference — works out of the box with no API keys || **Mistral OCR** | Cloud API | Industry-leading document understanding for media, text, tables, and equations || **docling** | Local SDK | IBM's open-source extraction library with local CPU processing and optional GPU acceleration |-| **Azure Document Intelligence** | Pipelex Manifold | Enterprise-grade OCR with high accuracy for complex layouts, tables, and handwriting || **Linkup Fetch** | Cloud API | Web page content extraction — fetches and extracts text from web URLs |## The Default Extractor-A `PipeExtract` step that names no model uses `@default-extract-document`, which tries Azure Document Intelligence, then Mistral OCR, then `pypdfium2-extract-pdf`, and takes the first one an enabled backend serves. Azure Document Intelligence is served through Pipelex Manifold and Mistral OCR by the `mistral` backend with your own `MISTRAL_API_KEY`; with neither, a PDF is read locally from its text layer, which needs no key but recovers no text from a scanned page, and the run logs that it fell back. `@default-extract-image` and `@default-premium` try the two OCR models only, so they need one of those backends. Name a model in the step, or point the aliases elsewhere in `x_custom_extract_deck.toml`, to choose differently.+A `PipeExtract` step that names no model uses `@default-extract-document`, which tries Mistral OCR, then `pypdfium2-extract-pdf`, and takes the first one an enabled backend serves. Mistral OCR is served by the `mistral` backend with your own `MISTRAL_API_KEY`; without it, a PDF is read locally from its text layer, which needs no key but recovers no text from a scanned page, and the run logs that it fell back. `@default-extract-image` and `@default-premium` try Mistral OCR only, so they need the `mistral` backend. Name a model in the step, or point the aliases elsewhere in `x_custom_extract_deck.toml`, to choose differently.## Formats Each Extractor Reads@@ -36,7 +35,6 @@ Each extract model declares the file formats it reads, and a `PipeExtract` step| `pypdfium2-extract-pdf` | PDF || `docling-extract-text` | PDF, Word (`.docx`), PowerPoint (`.pptx`), Excel (`.xlsx`), HTML, Markdown (`.md`), CSV, plain text (`.txt`), WebVTT captions (`.vtt`), email messages (`.eml`) and images || Mistral OCR (`mistral-ocr` and its versions) | PDF and images |-| `azure-document-intelligence` (Pipelex Manifold) | PDF and images || `linkup-fetch` (Linkup) | Web pages, fetched from their URL |A file in a format the step's model does not read is refused before the run starts, with an input error that names the input, its format, the step, the model and the formats that model reads. Give the file in a format the model reads, or choose a model that reads it. When the step can only be reached through a condition, the run starts, and the step refuses the file the same way when it gets to it. See [File formats are checked before the run](../building-methods/concepts/native-concepts.md#file-formats-are-checked-before-the-run).diff --git a/docs/migration-ledger.md b/docs/migration-ledger.mdindex da0b6afd0..c84f589c8 100644--- a/docs/migration-ledger.md+++ b/docs/migration-ledger.md@@ -22,7 +22,6 @@ A **surface** is one artifact family with one schema version and one ledger. The|---|---|---|---|---|---|| `pipelex-config` | — | `pipelex.toml` | `pipelex_*.toml` | `PipelexConfig` | Packaged document (`pipelex/pipelex.toml`) || `telemetry-config` | — | `telemetry.toml` | `telemetry_*.toml` | `TelemetryConfig` | Model defaults |-| `pipelex-service-config` | — | `pipelex_service.toml` | — | `PipelexServiceConfig` | Model defaults || `inference-backend` | `inference/backends/` | — | `*.toml` | `InferenceModelSpecFileNode`, one root table at a time | Copied document (the kit's `inference/backends/portkey.toml`) |Paths are relative to a configuration directory, and every surface spans exactly two of them: the global `~/.pipelex/` and the project's `.pipelex/`. `pipelex migrate` walks both, and only those. Two paths that look like configuration are outside the walk by design: the unit-testing tier `./tests/pipelex_{run_mode}.toml`, and a directory an embedder hands `Pipelex.make(config_dir=…)` that is neither of the two. Boot tolerance and the error-path diagnosis still read such a directory (see [Boot tolerance](#boot-tolerance)), but its files are the embedder's to bring up to date: `pipelex migrate` has no way to be pointed at them, and does not pretend otherwise.@@ -31,9 +30,9 @@ A surface's **directory** is where its files sit *within* a configuration directThe tier set is **open**. Environment and run-mode names are dynamic, so the tier filenames of `pipelex-config` cannot be enumerated in advance — `pipelex_local.toml`, `pipelex_{environment}.toml`, `pipelex_{run_mode}.toml`, `pipelex_override.toml` and `pipelex_temporary_override.toml` are a description of today, not a closed list. That is why the registry matches tiers with a glob, and the glob is what makes the resolution rule necessary:-> **A file is claimed by the pair (directory, name).** Only the surfaces that own the directory a file sits in may claim it; among those, exact filenames claim before globs, and a file matched by any of their exact patterns is excluded from all of their globs. A file claimed by two globs, or by two exact names, in the same directory, is a registry error.+> **A file is claimed by the pair (directory, name).** Only the surfaces that own the directory a file sits in may claim it; among those, exact filenames claim before globs, and a file matched by any of their exact patterns is excluded from all of their globs. A file claimed by two globs, or by two exact names, in the same directory, is a registry error. A retired file name directly in a configuration directory is claimed by no surface.-Both halves earn their place on a real file. Without the name half, `pipelex_service.toml` is both the base file of one surface and a match for another's `pipelex_*.toml`. Without the directory half, `inference/backends/pipelex_manifold.toml` is a `pipelex_*.toml` match as well — and it is an inference backend definition, so the main configuration's ledger would be replayed over it and rewrite it. Either way, which ledger runs over a file would become an accident of iteration order.+Each rule earns its place on a real file. Without the retired rule, `pipelex_service.toml` — which earlier releases wrote and nothing reads any more — is a match for `pipelex-config`'s `pipelex_*.toml`, and that ledger would be replayed over a document it never described. Without the directory rule, a backend file named `inference/backends/pipelex_<name>.toml` is a `pipelex_*.toml` match as well — and it is an inference backend definition, so the main configuration's ledger would be replayed over it and rewrite it. Either way, which ledger runs over a file would become an accident of iteration order.The same scoping applies to what the registry refuses. A base file and a glob are claims over one directory's listing, so two surfaces collide on a spelling only when they own the same directory — `*.toml` is the natural glob for any surface that owns a directory of its own, and the second such surface must not have to narrow it for the registry's bookkeeping.@@ -575,7 +574,7 @@ A validation error cannot answer that by itself. It is raised against the merged> **An inference backend file used to be on that list, and moving it off was a code change rather than a wording one.** The boot builds its own message for the two libraries that refuse after the main configuration is already up — the backend library and the model deck — and it named no surface for either, which was right while neither had a ledger. Now one of them does, and the two are told apart by the component itself rather than at the `except` clause: the pairing of a component with its surface is stated once, so a call site cannot quietly drop it. The case this reaches is narrow and real — a backend file that is *both* behind and carrying something we cannot explain never gets as far as boot tolerance's warning, and before this it was told only the second half. The scan is only reachable if the boot catches what the loader really raises, so the classes that mean *this library's files are not loadable* are named once, beside the component — a backend definition file refuses in two shapes, and only one of them carries a pydantic error; the library index file `backends.toml` refuses in a third, on a backend table's own fields, and each has to be a class the boot names.-> **Scoping narrows the answer, never the registry.** Which surface owns a file is decided across *all* of them, because an exact base file claims before any glob. A registry built to hold only the surface being asked about removes the other claimants from that arbitration, and `pipelex_service.toml` — another surface's base file, and a match for `pipelex-config`'s `pipelex_*.toml` — is then replayed under the wrong ledger and diagnosed against the wrong model, so its ordinary settings come back reported as paths this build knows nothing about.+> **Scoping narrows the answer, never the registry.** Which surface owns a file is decided across *all* of them, because an exact base file claims before any glob. A registry built to hold only the surface being asked about removes the other claimants from that arbitration, and another surface's base file that also matches the asked surface's glob is then replayed under the wrong ledger and diagnosed against the wrong model, so its ordinary settings come back reported as paths this build knows nothing about.The answer rides the error twice, and the two halves are not interchangeable:diff --git a/docs/tools/cli/agent-cli.md b/docs/tools/cli/agent-cli.mdindex 9a2bfb855..eaf299861 100644--- a/docs/tools/cli/agent-cli.md+++ b/docs/tools/cli/agent-cli.md@@ -174,22 +174,6 @@ Commands use different stdout formats depending on their purpose:JSON commands return the result object directly. They are not wrapped in a `status` or `data` envelope.-**Warnings** — non-fatal setup conditions are surfaced on a top-level `warnings` array of the success envelope, so consumers don't have to parse stderr. The field is absent when there is nothing to report. Each entry is an object with a `type` and a `message`:--```json-{- "success": true,- "target_dir": "/path/to/.pipelex",- "warnings": [- { "type": "RemoteConfigStale", "message": "The Pipelex-managed gateway backends are running off a cached remote config (snapshot: 2026-10-01T09:30:00+00:00). Run `pipelex init` while online to refresh." }- ]-}-```--`RemoteConfigStale` is emitted when a Pipelex-managed gateway backend is enabled but the remote config service is unreachable and Pipelex falls back to its on-disk cache (offline mode).--Do not confuse this setup-warning shape with the `warnings` array on the `validate` envelope — validate warnings are advisory lint items that reuse the validation-error item shape (see "Advisory warnings on validate" above).-**Error** — written to stderr:```jsondiff --git a/docs/tools/cli/init.md b/docs/tools/cli/init.mdindex 40b985577..3b856e1ae 100644--- a/docs/tools/cli/init.md+++ b/docs/tools/cli/init.md@@ -66,9 +66,6 @@ This command creates or resets a Pipelex config directory with:!!! warning "Init writes a fresh file — it does not update one"Every `init` target replaces the file with the template, so whatever was in it is gone. If a configuration file has simply fallen behind the current schema, [`pipelex migrate`](migrate.md) is the command: it rewrites the file in place and keeps every setting — your PostHog key, your Langfuse credentials, your exporters. `pipelex doctor` tells you which of the two you have.-!!! note "Offline cache priming"- When any Pipelex-managed gateway backend is enabled, `pipelex init` also primes an on-disk copy of the published remote config at `~/.pipelex/cache/remote_config.json`. This lets later setup, validation, and dry-runs work even when the remote config service is briefly unreachable. If you run `pipelex init` while offline, it prints a yellow warning and skips priming — re-run it online to enable offline dry-runs.-## Interactive Setup FlowWhen you run `pipelex init`, Pipelex can guide you through:@@ -105,7 +102,7 @@ All fields are optional:| Field | Type | Description ||-------|------|-------------|-| `backends` | `list[str]` | Backend keys to enable (e.g. `openai`, `anthropic`, `openrouter`, `pipelex_manifold`). Omit to keep the template's enabled backends and its routing profile, which sends each model to the first of them that serves it. |+| `backends` | `list[str]` | Backend keys to enable (e.g. `openai`, `anthropic`, `openrouter`). Omit to keep the template's enabled backends and its routing profile, which sends each model to the first of them that serves it. || `primary_backend` | `str` | Required when 2+ backends are named. Named without `backends`, it routes the template's backends to it first. |Telemetry is not configured via `--config`: init seeds a `telemetry.toml` from a template (a global init writes an active one; a project init drops a commented-out one).diff --git a/docs/tools/cli/migrate.md b/docs/tools/cli/migrate.mdindex f462e1f22..bdfb2e48b 100644--- a/docs/tools/cli/migrate.md+++ b/docs/tools/cli/migrate.md@@ -22,7 +22,7 @@ Two directories, and only those:- the global `~/.pipelex/`- the project `.pipelex/`, when the current directory is inside a project that has one-Within each, it looks at the configuration files themselves — `pipelex.toml` and its `pipelex_*.toml` tiers, `telemetry.toml` and its tiers, `pipelex_service.toml` — and at the inference backend definitions in `inference/backends/`.+Within each, it looks at the configuration files themselves — `pipelex.toml` and its `pipelex_*.toml` tiers, `telemetry.toml` and its tiers — and at the inference backend definitions in `inference/backends/`.It goes one level deep, and only into a directory some configuration family owns. `inference/backends/` is such a directory, so every `*.toml` in it is repaired the same way a `pipelex.toml` is. `inference/deck/` is not one, and neither is `inference/backends.toml`, which sits beside the backends directory rather than in it — neither is ever entered or rewritten by this command, and the model deck has its own `pipelex update`.diff --git a/docs/under-the-hood/init-cli-flows.md b/docs/under-the-hood/init-cli-flows.mdindex 3000ac931..27375d90a 100644--- a/docs/under-the-hood/init-cli-flows.md+++ b/docs/under-the-hood/init-cli-flows.md@@ -16,7 +16,7 @@ The `.pipelex/` directory contains two categories of files with different lifecy1. **Config files** (`pipelex.toml`, `plxt.toml`) — static templates copied verbatim from the kit (no interactive customization); re-running init overwrites them (full reset).2. **Inference files** (`inference/backends.toml`, `inference/routing_profiles.toml`, `inference/backends/*.toml`, `inference/deck/*.toml`) — interactive setup, customized per-project based on which AI backends the user selects.-These two categories are managed by separate steps. `init_config()` copies only config files (skipping the `inference/` directory entirely). The inference step handles its own template copying and then runs interactive backend selection and routing customization. Each file is owned by exactly one step — `init_config()` explicitly skips the `inference/` directory via `INIT_SKIP_DIRS`, and skips `telemetry.toml` and `pipelex_service.toml` via `INIT_SKIP_FILES`. This separation ensures that re-running `pipelex init config` never overwrites a user's carefully tuned inference setup.+These two categories are managed by separate steps. `init_config()` copies only config files (skipping the `inference/` directory entirely). The inference step handles its own template copying and then runs interactive backend selection and routing customization. Each file is owned by exactly one step — `init_config()` explicitly skips the `inference/` directory via `INIT_SKIP_DIRS`, and skips `telemetry.toml` via `INIT_SKIP_FILES`. This separation ensures that re-running `pipelex init config` never overwrites a user's carefully tuned inference setup.---@@ -253,7 +253,6 @@ Copies a telemetry template and prints instructions. No interactive prompts. Whi| `inference/deck/*.toml` | Inference step | Model deck definitions || `inference/routing_profiles.toml` | Inference step | Routing profile definitions || `telemetry.toml` | Telemetry step | Telemetry export configuration |-| `pipelex_service.toml` | `pipelex-agent init` | The inference setup state that `pipelex-agent init` records |### Skip Lists@@ -320,7 +319,7 @@ This means a project-level file **wins** over the global one, but only if it act### Global Config Bootstrap-`ensure_global_config_exists()` creates `~/.pipelex/` with kit template files on first use (called automatically during `load_config()`). It skips all `GIT_IGNORED_CONFIG_FILES` (files like `pipelex_service.toml`) and `.DS_Store` — these are never part of the bootstrap copy.+`ensure_global_config_exists()` creates `~/.pipelex/` with kit template files on first use (called automatically during `load_config()`). It skips all `GIT_IGNORED_CONFIG_FILES` (files like `pipelex_override.toml`) and `.DS_Store` — these are never part of the bootstrap copy.### Config Loading Chain@@ -370,9 +369,7 @@ flowchart TDSTEP15 --> STEP16["Step 1.6: Copy telemetry template<br/>(global: active defaults; project: commented-out)"]STEP16 --> STEP2["Step 2: Configure backends<br/>Enable requested backends in backends.toml"]STEP2 --> STEP3["Step 3: Configure routing<br/>Auto-derive routing profile<br/>(the template's, when the config names neither field)"]- STEP3 --> STEP4["Step 4: Mark inference setup completed<br/>(written to ~/.pipelex/)"]- STEP4 --> STEP5["Step 5: Prime remote-config cache<br/>(no-op when no managed gateway is enabled)"]- STEP5 --> OUTPUT["Output result<br/>(Markdown, or JSON via --format json)"]+ STEP3 --> OUTPUT["Output result<br/>(Markdown, or JSON via --format json)"]```!!! note "No credentials step"diff --git a/docs/under-the-hood/log-sink-plugins.md b/docs/under-the-hood/log-sink-plugins.mdindex 1bf119210..12c74cc41 100644--- a/docs/under-the-hood/log-sink-plugins.md+++ b/docs/under-the-hood/log-sink-plugins.md@@ -47,7 +47,7 @@ teardownLogging is configured as soon as the configuration is read, in `RuntimeBoot.__init__`, so that everything the boot says afterwards is a record on a module-named logger at the configured level. The sink, though, is a plugin capability, and plugin discovery runs a little later, in `setup()`, once the boot knows which built-ins and which entry-point groups it reads. Rather than choose a default renderer for that window, `configure` installs a **holding handler** that keeps every record, and `install_sink` replays them through the selected sink's handler the moment it is installed, in the order they were emitted. A boot's own lines are therefore rendered by the sink the configuration chose, never dropped and never written in a shape nothing chose.-The sink is the second capability resolved out of the registrar, right after the secrets provider and ahead of telemetry and storage, so that every later line of the boot goes through it while its own settings can still name a secret: an OTLP collector's bearer token, the path of the service-account key the `gcp` sink reads. Building the provider first costs nothing in kind, because the holding handler already covers the window: what the provider logs is held like every line before it, and the remote-config fetch and plugin discovery were in that window already. A boot that dies before the sink is installed, on a failed remote-config fetch or on a secrets provider that cannot be built for instance, releases its process globals through `log.reset()`, which closes the holding handler: what it still holds gets the stdlib's last-resort treatment: every held record reaches stderr, since each passed the level the configuration set, and the redaction processor runs over each one first, behind the guard a sink's handler would have put it behind. The only built-in secrets provider, `env`, does no I/O and logs nothing, so in practice only an external secrets plugin can fail there.+The sink is the second capability resolved out of the registrar, right after the secrets provider and ahead of telemetry and storage, so that every later line of the boot goes through it while its own settings can still name a secret: an OTLP collector's bearer token, the path of the service-account key the `gcp` sink reads. Building the provider first costs nothing in kind, because the holding handler already covers the window: what the provider logs is held like every line before it, and plugin discovery was in that window already. A boot that dies before the sink is installed, on a secrets provider that cannot be built for instance, releases its process globals through `log.reset()`, which closes the holding handler: what it still holds gets the stdlib's last-resort treatment: every held record reaches stderr, since each passed the level the configuration set, and the redaction processor runs over each one first, behind the guard a sink's handler would have put it behind. The only built-in secrets provider, `env`, does no I/O and logs nothing, so in practice only an external secrets plugin can fail there.This is the usual order elsewhere. Spring Boot resolves its configuration, vault-backed properties included, before it initialises logging and replays what was logged meanwhile; ASP.NET Core reads Key Vault as a configuration source before logging is configured, with a bootstrap logger covering the gap.diff --git a/docs/under-the-hood/test-profile-configuration.md b/docs/under-the-hood/test-profile-configuration.mdindex cdad2d391..8e2c90fbc 100644--- a/docs/under-the-hood/test-profile-configuration.md+++ b/docs/under-the-hood/test-profile-configuration.md@@ -179,10 +179,7 @@ extract_models = ["@from_pdf"]### 1. Model Discovery-The preprocessing command discovers available models from:--- **Backend TOML files** in `inference/backends/*.toml`, resolved from the project `.pipelex/` directory if present there, otherwise from the global `~/.pipelex/` directory-- **Pipelex Gateway** remote configuration+The preprocessing command discovers available models from the backend TOML files in `inference/backends/*.toml`, resolved from the project `.pipelex/` directory if present there, otherwise from the global `~/.pipelex/` directory.### 2. Profile Resolution@@ -300,7 +297,7 @@ This is useful for:# Add a personal profile[profiles.my_local]description = "My local testing profile"-backends = ["pipelex_manifold"]+backends = ["anthropic", "openai"]llm_models = ["claude-4.5-sonnet", "gpt-4o"]img_gen_models = []extract_models = []diff --git a/pipelex/cli/agent_cli/commands/agent_cli_factory.py b/pipelex/cli/agent_cli/commands/agent_cli_factory.pyindex c55721402..3a70f3a7f 100644--- a/pipelex/cli/agent_cli/commands/agent_cli_factory.py+++ b/pipelex/cli/agent_cli/commands/agent_cli_factory.py@@ -2,22 +2,16 @@import loggingimport sys-import warningsfrom collections.abc import Mappingfrom pathlib import Pathfrom types import MappingProxyTypefrom typing import Any-from pipelex.cli.agent_cli.commands.agent_output import agent_error, record_setup_warning-from pipelex.cogt.exceptions import GatewayUnknownModelError, ModelDeckPresetValidatonError+from pipelex.cli.agent_cli.commands.agent_output import agent_error+from pipelex.cogt.exceptions import ModelDeckPresetValidatonErrorfrom pipelex.pipelex import Pipelexfrom pipelex.runtime_hub import RuntimeHubfrom pipelex.system.console_target import ConsoleTarget-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigStaleWarning,- RemoteConfigUnavailableError,- RemoteConfigValidationError,-)from pipelex.system.runtime import IntegrationModefrom pipelex.system.telemetry.exceptions import TelemetryConfigValidationErrorfrom pipelex.tools.log.log import log@@ -159,9 +153,7 @@ def apply_agent_cli_output_discipline() -> None:hub.set_console_print_target(target=ConsoleTarget.STDERR)-def make_pipelex_for_agent_cli(- *, library_dirs: list[str] | list[Path] | None = None, needs_inference: bool = True, needs_model_specs: bool | None = None-) -> Pipelex:+def make_pipelex_for_agent_cli(*, library_dirs: list[str] | list[Path] | None = None, needs_inference: bool = True) -> Pipelex:"""Initialize Pipelex for agent CLI commands with JSON error output.This is the agent CLI counterpart of ``make_pipelex_for_cli`` in@@ -189,8 +181,7 @@ def make_pipelex_for_agent_cli(Args:library_dirs: Optional library directories to use for the Pipelex instance.- needs_inference: When False, skip inference setup (credentials, managed gateways, telemetry).- needs_model_specs: When True, load real model specs even without inference.+ needs_inference: When False, skip inference setup (credentials, telemetry).Returns:Initialized Pipelex instance.@@ -202,34 +193,14 @@ def make_pipelex_for_agent_cli(# log line (anthropic/httpx/botocore credential probes, telemetry setup, etc.).silence_logging_for_agent_cli()try:- with warnings.catch_warnings(record=True) as caught:- warnings.simplefilter("always", RemoteConfigStaleWarning)- pipelex_instance = Pipelex.make(- integration_mode=IntegrationMode.CLI,- library_dirs=library_dirs,- needs_inference=needs_inference,- needs_model_specs=needs_model_specs,- config_overrides=dict(AGENT_CLI_CONFIG_OVERRIDES),- )- # Surface a structured ``RemoteConfigStale`` entry so JSON consumers can react to- # stale-cache operation without parsing stderr.- for item in caught:- if issubclass(item.category, RemoteConfigStaleWarning):- record_setup_warning({"type": "RemoteConfigStale", "message": str(item.message)})+ pipelex_instance = Pipelex.make(+ integration_mode=IntegrationMode.CLI,+ library_dirs=library_dirs,+ needs_inference=needs_inference,+ config_overrides=dict(AGENT_CLI_CONFIG_OVERRIDES),+ )except TelemetryConfigValidationError as exc:agent_error(exc.message, error_type="TelemetryConfigValidationError", cause=exc)- except RemoteConfigUnavailableError as exc:- agent_error(exc.message, error_type="RemoteConfigUnavailableError", cause=exc)- except RemoteConfigValidationError as exc:- agent_error(exc.message, error_type="RemoteConfigValidationError", cause=exc)- except GatewayUnknownModelError as exc:- agent_error(- exc.message,- error_type="GatewayUnknownModelError",- cause=exc,- model_name=exc.model_name,- source=exc.source,- )except ModelDeckPresetValidatonError as exc:agent_error(exc.message,diff --git a/pipelex/cli/agent_cli/commands/agent_output.py b/pipelex/cli/agent_cli/commands/agent_output.pyindex c78a85513..506eabec3 100644--- a/pipelex/cli/agent_cli/commands/agent_output.py+++ b/pipelex/cli/agent_cli/commands/agent_output.py@@ -35,32 +35,6 @@ from pipelex.pipeline.exceptions import PipelineExecutionError, ValidateBundleErfrom pipelex.pipeline.validation_render import build_fix_command, count_applicable_fixes, format_validation_error_items_markdownfrom pipelex.tools.misc.json_utils import clean_json_dumps-# Module-level capture for setup-time warnings (currently used by RemoteConfigStaleWarning).-# The agent CLI factory writes here when it catches a stale-cache warning during ``Pipelex.make``-# and ``agent_success`` reads back here to attach the ``warnings`` field to the envelope so-# machine consumers see the provenance.-_CAPTURED_WARNINGS: list[dict[str, Any]] = []---def record_setup_warning(warning_payload: dict[str, Any]) -> None:- """Stash a structured warning for inclusion in the next ``agent_success`` envelope.-- Callers pass a dict shaped like ``{"type": "RemoteConfigStale", "message": "..."}``;- the contents are surfaced verbatim by ``agent_success``.- """- _CAPTURED_WARNINGS.append(warning_payload)---def consume_setup_warnings() -> list[dict[str, Any]]:- """Drain the captured warnings buffer. Returns whatever was recorded and clears state.-- Called once per envelope so successive commands within a single Python process don't- re-emit yesterday's warnings.- """- drained = list(_CAPTURED_WARNINGS)- _CAPTURED_WARNINGS.clear()- return drained-class CliOutputFormat(StrEnum):JSON = "json"@@ -187,17 +161,6 @@ AGENT_ERROR_HINTS: dict[str, str] = {"Without a 'migration' field, correct the telemetry.toml settings named in the message."),"BinaryNotFoundError": "Install pipelex-tools: uv tool install pipelex-tools",- "RemoteConfigUnavailableError": (- "Run `pipelex init` while online to prime the cache, or disable the Pipelex-managed gateway backends in backends.toml "- "to operate offline (BYOK)"- ),- "RemoteConfigValidationError": (- "This is a server-side issue; report it on Discord/GitHub. Disable the Pipelex-managed gateway backends in backends.toml as a workaround"- ),- "GatewayUnknownModelError": (- "The deck references a model the gateway doesn't expose. If the source is `cached`, run `pipelex init` while online to refresh; "- "otherwise update the deck or check the model name."- ),# API runner errors"ClientAuthenticationError": _API_CREDENTIALS_HINT,"PipelineRequestError": "Check that pipe_code or mthds_contents is provided",@@ -488,22 +451,10 @@ def agent_error(message: str, *, error_type: str, cause: BaseException | None =def agent_success(result: dict[str, Any]) -> None:"""Print a structured JSON success result to stdout.- Any pending setup warnings (e.g. a stale remote-config cache) recorded via ``record_setup_warning``- are drained into a top-level ``warnings`` array on the envelope so machine consumers can- surface them without parsing stderr. Callers may pre-populate ``result["warnings"]`` (must- be a list) — the captured ones are appended. The caller's ``result`` dict is NOT mutated;- a copy is taken before merging.-Args:result: Dictionary to serialize as JSON."""- captured = consume_setup_warnings()- envelope: dict[str, Any] = result- if captured:- existing_raw = result.get("warnings")- existing_warnings: list[Any] = cast("list[Any]", existing_raw) if isinstance(existing_raw, list) else []- envelope = {**result, "warnings": [*existing_warnings, *captured]}- print(clean_json_dumps(envelope, indent=2))+ print(clean_json_dumps(result, indent=2))def agent_success_formatted(diff --git a/pipelex/cli/agent_cli/commands/check_model_cmd.py b/pipelex/cli/agent_cli/commands/check_model_cmd.pyindex c0ba11631..42a6b8c02 100644--- a/pipelex/cli/agent_cli/commands/check_model_cmd.py+++ b/pipelex/cli/agent_cli/commands/check_model_cmd.py@@ -76,7 +76,7 @@ def agent_check_model_cmd("""set_agent_cli_error_format(error_format or output_format)try:- make_pipelex_for_agent_cli(needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(needs_inference=False)model_deck = get_model_deck()ref = ModelReference.parse(name)diff --git a/pipelex/cli/agent_cli/commands/codegen/types_cmd.py b/pipelex/cli/agent_cli/commands/codegen/types_cmd.pyindex dea775a8a..5da4131cb 100644--- a/pipelex/cli/agent_cli/commands/codegen/types_cmd.py+++ b/pipelex/cli/agent_cli/commands/codegen/types_cmd.py@@ -72,9 +72,7 @@ def agent_codegen_types_cmd("""set_agent_cli_error_format(error_format or output_format)output_root = Path(output_dir).expanduser()- # needs_model_specs=True (like `validate`): library validation checks pipe model pins- # against the deck, so the specs must be loaded even though codegen needs no inference.- make_pipelex_for_agent_cli(needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(needs_inference=False)try:combined_dirs: list[Path] = [*(paths or []), *(Path(lib_dir) for lib_dir in library_dir or [])]diff --git a/pipelex/cli/agent_cli/commands/fix/bundle_cmd.py b/pipelex/cli/agent_cli/commands/fix/bundle_cmd.pyindex 37b13a1ea..cfd9e6459 100644--- a/pipelex/cli/agent_cli/commands/fix/bundle_cmd.py+++ b/pipelex/cli/agent_cli/commands/fix/bundle_cmd.py@@ -122,7 +122,7 @@ def fix_bundle_cmd(library_dirs = [Path(lib_dir) for lib_dir in library_dir] if library_dir else Nonetry:- make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False)result = asyncio.run(fix_bundle_file(Path(bundle_path),diff --git a/pipelex/cli/agent_cli/commands/init_cmd.py b/pipelex/cli/agent_cli/commands/init_cmd.pyindex 152be3b80..9d574ad51 100644--- a/pipelex/cli/agent_cli/commands/init_cmd.py+++ b/pipelex/cli/agent_cli/commands/init_cmd.py@@ -15,13 +15,11 @@ from pipelex.cli.agent_cli.commands.agent_output import (set_agent_cli_error_format,)from pipelex.cli.commands.init.backends import get_selected_backend_keys, update_backends_in_toml-from pipelex.cli.commands.init.command import attempt_prime_remote_config_cachefrom pipelex.cli.commands.init.config_files import init_configfrom pipelex.cli.commands.init.ui.backends_ui import get_backend_options_from_tomlfrom pipelex.cogt.models.deck_manifest import stamp_kit_manifestsfrom pipelex.kit.paths import get_kit_configs_dirfrom pipelex.system.configuration.config_loader import config_manager-from pipelex.system.pipelex_service.pipelex_service_onboarding import update_inference_setup_completedfrom pipelex.system.telemetry.telemetry_config import TELEMETRY_CONFIG_FILE_NAME, TELEMETRY_PROJECT_TEMPLATE_FILE_NAMEfrom pipelex.tools.misc.toml_utils import load_toml_with_tomlkit, save_toml_to_path@@ -70,13 +68,7 @@ def _format_init_markdown(result: dict[str, Any]) -> str:f"**Backends enabled:** {', '.join(backends_enabled) or 'none'}","",f"**Routing profile:** `{result['routing_profile']}`",- "",- f"**Inference setup completed:** {result.get('inference_setup_completed', False)}",- "",- f"**Remote config cache primed:** {result.get('cache_primed', False)}",]- if result.get("cache_priming_error"):- lines.extend(["", f"> ⚠ Cache priming error: {result['cache_priming_error']}"])return "\n".join(lines)@@ -388,26 +380,13 @@ def agent_init_cmd(# Step 3: Configure routingrouting_profile = _configure_routing(backends_enabled, config=parsed_config, target_dir=target_dir)- # Step 4: Mark inference setup as completed- update_inference_setup_completed(completed=True, config_dir=config_manager.global_config_dir)-- # Step 5: Prime the remote-config cache so subsequent offline dry-runs can fall back.- # No-op when no managed gateway backend is enabled; surfaces failure as structured- # fields on the success envelope rather than crashing init. We forward the init target- # directory so the managed-gateway check inspects the backends.toml we just wrote, not a- # sibling layered config.- priming_result = attempt_prime_remote_config_cache(target_config_dir=target_dir)result_payload: dict[str, Any] = {"success": True,"target_dir": str(target_dir),"config_files_copied": config_files_copied,"backends_enabled": backends_enabled,"routing_profile": routing_profile,- "inference_setup_completed": True,- "cache_primed": priming_result.primed,}- if priming_result.error_message is not None:- result_payload["cache_priming_error"] = priming_result.error_message# Output resultagent_success_formatted(result_payload, markdown_renderer=_format_init_markdown, output_format=output_format)diff --git a/pipelex/cli/agent_cli/commands/inputs/bundle_cmd.py b/pipelex/cli/agent_cli/commands/inputs/bundle_cmd.pyindex e42c08315..30efc54a0 100644--- a/pipelex/cli/agent_cli/commands/inputs/bundle_cmd.py+++ b/pipelex/cli/agent_cli/commands/inputs/bundle_cmd.py@@ -93,7 +93,7 @@ def inputs_bundle_cmd()library_dirs = [Path(lib_dir) for lib_dir in library_dir] if library_dir else None- make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False)try:result = asyncio.run(inputs_core(pipe_code=pipe, bundle_path=Path(bundle_path), library_dirs=library_dirs, explicit=explicit)) # type: ignore[arg-type]diff --git a/pipelex/cli/agent_cli/commands/inputs/method_cmd.py b/pipelex/cli/agent_cli/commands/inputs/method_cmd.pyindex 56fc7edc4..604e91b2e 100644--- a/pipelex/cli/agent_cli/commands/inputs/method_cmd.py+++ b/pipelex/cli/agent_cli/commands/inputs/method_cmd.py@@ -75,7 +75,7 @@ def inputs_method_cmd(if library_dir:library_dirs_paths.extend(Path(lib_dir) for lib_dir in library_dir)- make_pipelex_for_agent_cli(library_dirs=library_dirs_paths, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(library_dirs=library_dirs_paths, needs_inference=False)try:result = asyncio.run(inputs_core(pipe_code=pipe_code, bundle_path=bundle_path, library_dirs=library_dirs_paths, explicit=explicit))diff --git a/pipelex/cli/agent_cli/commands/inputs/pipe_cmd.py b/pipelex/cli/agent_cli/commands/inputs/pipe_cmd.pyindex bdddcc8f1..5c9c233b0 100644--- a/pipelex/cli/agent_cli/commands/inputs/pipe_cmd.py+++ b/pipelex/cli/agent_cli/commands/inputs/pipe_cmd.py@@ -74,7 +74,7 @@ def inputs_pipe_cmd(library_dir = [*export_dirs, *library_dir]library_dirs = [Path(lib_dir) for lib_dir in library_dir] if library_dir else None- make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False)try:result = asyncio.run(inputs_core(pipe_code=pipe_code, bundle_path=None, library_dirs=library_dirs, explicit=explicit))diff --git a/pipelex/cli/agent_cli/commands/models_cmd.py b/pipelex/cli/agent_cli/commands/models_cmd.pyindex e1e17e86d..f48a921fa 100644--- a/pipelex/cli/agent_cli/commands/models_cmd.py+++ b/pipelex/cli/agent_cli/commands/models_cmd.py@@ -35,7 +35,7 @@ def agent_models_cmd("""set_agent_cli_error_format(error_format or output_format)try:- make_pipelex_for_agent_cli(needs_inference=False, needs_model_specs=backend is not None)+ make_pipelex_for_agent_cli(needs_inference=False)result = list_models(categories=model_type, backend=backend)diff --git a/pipelex/cli/agent_cli/commands/run/bundle_cmd.py b/pipelex/cli/agent_cli/commands/run/bundle_cmd.pyindex b1c01b3ad..583624d5e 100644--- a/pipelex/cli/agent_cli/commands/run/bundle_cmd.py+++ b/pipelex/cli/agent_cli/commands/run/bundle_cmd.py@@ -208,7 +208,7 @@ def run_bundle_cmd(agent_error(str(exc), error_type=type(exc).__name__, cause=exc)case RunnerType.PIPELEX:- make_pipelex_for_agent_cli(needs_inference=not dry_run, needs_model_specs=True)+ make_pipelex_for_agent_cli(needs_inference=not dry_run)try:result = asyncio.run(diff --git a/pipelex/cli/agent_cli/commands/run/method_cmd.py b/pipelex/cli/agent_cli/commands/run/method_cmd.pyindex 75a67ad84..ab844621c 100644--- a/pipelex/cli/agent_cli/commands/run/method_cmd.py+++ b/pipelex/cli/agent_cli/commands/run/method_cmd.py@@ -179,7 +179,7 @@ def run_method_cmd(agent_error(str(exc), error_type=type(exc).__name__, cause=exc)case RunnerType.PIPELEX:- make_pipelex_for_agent_cli(needs_inference=not dry_run, needs_model_specs=True)+ make_pipelex_for_agent_cli(needs_inference=not dry_run)try:result = asyncio.run(diff --git a/pipelex/cli/agent_cli/commands/run/pipe_cmd.py b/pipelex/cli/agent_cli/commands/run/pipe_cmd.pyindex 0985c360d..54e097138 100644--- a/pipelex/cli/agent_cli/commands/run/pipe_cmd.py+++ b/pipelex/cli/agent_cli/commands/run/pipe_cmd.py@@ -158,7 +158,7 @@ def run_pipe_cmd(agent_error(str(exc), error_type=type(exc).__name__, cause=exc)case RunnerType.PIPELEX:- make_pipelex_for_agent_cli(needs_inference=not dry_run, needs_model_specs=True)+ make_pipelex_for_agent_cli(needs_inference=not dry_run)try:result = asyncio.run(diff --git a/pipelex/cli/agent_cli/commands/validate/bundle_cmd.py b/pipelex/cli/agent_cli/commands/validate/bundle_cmd.pyindex b3f17f88f..6b02bb77d 100644--- a/pipelex/cli/agent_cli/commands/validate/bundle_cmd.py+++ b/pipelex/cli/agent_cli/commands/validate/bundle_cmd.py@@ -98,7 +98,7 @@ def validate_bundle_cmd(# Convert library_dirs to list[str] for graph helperlibrary_dir_strings = [str(lib_dir) for lib_dir in library_dirs] if library_dirs else None- make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False)try:if pipe:diff --git a/pipelex/cli/agent_cli/commands/validate/method_cmd.py b/pipelex/cli/agent_cli/commands/validate/method_cmd.pyindex cf841e73d..0f4cf76d9 100644--- a/pipelex/cli/agent_cli/commands/validate/method_cmd.py+++ b/pipelex/cli/agent_cli/commands/validate/method_cmd.py@@ -92,7 +92,7 @@ def validate_method_cmd(if library_dir:library_dirs_paths.extend(Path(lib_dir) for lib_dir in library_dir)- make_pipelex_for_agent_cli(library_dirs=library_dirs_paths, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(library_dirs=library_dirs_paths, needs_inference=False)try:if pipe:diff --git a/pipelex/cli/agent_cli/commands/validate/pipe_cmd.py b/pipelex/cli/agent_cli/commands/validate/pipe_cmd.pyindex b5aae81bc..9a315ab32 100644--- a/pipelex/cli/agent_cli/commands/validate/pipe_cmd.py+++ b/pipelex/cli/agent_cli/commands/validate/pipe_cmd.py@@ -76,7 +76,7 @@ def validate_pipe_cmd(if pipe_code:agent_error("--all cannot be used with a pipe code", error_type="ArgumentError", exit_code=2)- make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False)try:result = asyncio.run(validate_all_core(library_dirs=library_dirs, allow_signatures=allow_signatures))@@ -159,7 +159,7 @@ def validate_pipe_cmd(else:library_dirs = [*export_paths, *library_dirs]- make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_agent_cli(library_dirs=library_dirs, needs_inference=False)try:result = asyncio.run(validate_pipe_core(pipe_code=pipe_code, library_dirs=library_dirs, allow_signatures=allow_signatures))diff --git a/pipelex/cli/cli_factory.py b/pipelex/cli/cli_factory.pyindex 0e7e35cbf..27167bc7e 100644--- a/pipelex/cli/cli_factory.py+++ b/pipelex/cli/cli_factory.py@@ -4,18 +4,11 @@ from pathlib import Pathfrom pipelex.cli.error_handlers import (ErrorContext,- handle_gateway_unknown_model_error,handle_model_deck_preset_error,- handle_remote_config_unavailable_error,- handle_remote_config_validation_error,handle_telemetry_config_validation_error,)-from pipelex.cogt.exceptions import GatewayUnknownModelError, ModelDeckPresetValidatonError+from pipelex.cogt.exceptions import ModelDeckPresetValidatonErrorfrom pipelex.pipelex import Pipelex-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigUnavailableError,- RemoteConfigValidationError,-)from pipelex.system.runtime import IntegrationModefrom pipelex.system.telemetry.exceptions import TelemetryConfigValidationError@@ -26,7 +19,6 @@ def make_pipelex_for_cli(library_dirs: list[str] | list[Path] | None = None,needs_inference: bool = True,boot_orchestrator: str | None = None,- needs_model_specs: bool | None = None,) -> Pipelex:"""Initialize Pipelex for CLI commands with proper error handling.@@ -36,9 +28,8 @@ def make_pipelex_for_cli(Args:context: The CLI context for error messages.library_dirs: The library directories to use for the Pipelex instance.- needs_inference: When False, skip inference setup (credentials, managed gateways, telemetry).+ needs_inference: When False, skip inference setup (credentials, telemetry).boot_orchestrator: When provided, boots this process under the orchestrator plugin of this name.- needs_model_specs: When True, load real model specs even without inference.Returns:Initialized Pipelex instance.@@ -52,15 +43,8 @@ def make_pipelex_for_cli(library_dirs=library_dirs,needs_inference=needs_inference,boot_orchestrator=boot_orchestrator,- needs_model_specs=needs_model_specs,)except TelemetryConfigValidationError as exc:handle_telemetry_config_validation_error(exc)- except RemoteConfigUnavailableError as exc:- handle_remote_config_unavailable_error(exc)- except RemoteConfigValidationError as exc:- handle_remote_config_validation_error(exc)- except GatewayUnknownModelError as exc:- handle_gateway_unknown_model_error(exc)except ModelDeckPresetValidatonError as exc:handle_model_deck_preset_error(exc, context=context)diff --git a/pipelex/cli/commands/build/inputs/_inputs_core.py b/pipelex/cli/commands/build/inputs/_inputs_core.pyindex 6f3f7a541..7706dfd81 100644--- a/pipelex/cli/commands/build/inputs/_inputs_core.py+++ b/pipelex/cli/commands/build/inputs/_inputs_core.py@@ -135,9 +135,7 @@ def execute_generate_inputs(telemetry_command_label: str = f"{COMMAND} {SUB_COMMAND_INPUTS}",) -> None:"""Synchronous entry point wrapping the async inputs generation with Pipelex setup/teardown."""- pipelex_instance = make_pipelex_for_cli(- context=ErrorContext.VALIDATION_BEFORE_BUILD_INPUTS, library_dirs=library_dir, needs_inference=False, needs_model_specs=True- )+ pipelex_instance = make_pipelex_for_cli(context=ErrorContext.VALIDATION_BEFORE_BUILD_INPUTS, library_dirs=library_dir, needs_inference=False)try:with get_telemetry_manager().telemetry_context():diff --git a/pipelex/cli/commands/build/output/_output_core.py b/pipelex/cli/commands/build/output/_output_core.pyindex 9ba47b88a..3b7462ccb 100644--- a/pipelex/cli/commands/build/output/_output_core.py+++ b/pipelex/cli/commands/build/output/_output_core.py@@ -138,9 +138,7 @@ def execute_generate_output(telemetry_command_label: str = f"{COMMAND} {SUB_COMMAND_OUTPUT}",) -> None:"""Synchronous entry point wrapping the async output generation with Pipelex setup/teardown."""- pipelex_instance = make_pipelex_for_cli(- context=ErrorContext.VALIDATION_BEFORE_BUILD_OUTPUT, library_dirs=library_dir, needs_inference=False, needs_model_specs=True- )+ pipelex_instance = make_pipelex_for_cli(context=ErrorContext.VALIDATION_BEFORE_BUILD_OUTPUT, library_dirs=library_dir, needs_inference=False)try:with get_telemetry_manager().telemetry_context():diff --git a/pipelex/cli/commands/codegen/inputs_cmd.py b/pipelex/cli/commands/codegen/inputs_cmd.pyindex 9957ee119..28b22cfbc 100644--- a/pipelex/cli/commands/codegen/inputs_cmd.py+++ b/pipelex/cli/commands/codegen/inputs_cmd.py@@ -61,9 +61,7 @@ def codegen_inputs_cmd(] = None,) -> None:"""Project a runnable inputs template for the selected (or main) pipe of the closure."""- # needs_model_specs=True (like `validate`): library validation checks pipe model pins- # against the deck, so the specs must be loaded even though codegen needs no inference.- make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False)try:with get_telemetry_manager().telemetry_context():diff --git a/pipelex/cli/commands/codegen/types_cmd.py b/pipelex/cli/commands/codegen/types_cmd.pyindex b7c9c7a36..27d7a06d5 100644--- a/pipelex/cli/commands/codegen/types_cmd.py+++ b/pipelex/cli/commands/codegen/types_cmd.py@@ -49,9 +49,7 @@ def codegen_types_cmd(] = None,) -> None:"""Project the crate's concept set into typed artifacts for the chosen target."""- # needs_model_specs=True (like `validate`): library validation checks pipe model pins- # against the deck, so the specs must be loaded even though codegen needs no inference.- make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False)output_root = Path(output_dir).expanduser()try:diff --git a/pipelex/cli/commands/doctor_cmd.py b/pipelex/cli/commands/doctor_cmd.pyindex ad083e66e..aba718233 100644--- a/pipelex/cli/commands/doctor_cmd.py+++ b/pipelex/cli/commands/doctor_cmd.py@@ -25,7 +25,6 @@ from pipelex.cli.commands.update_cmd import update_cmdfrom pipelex.cli.exceptions import PipelexCLIErrorfrom pipelex.cogt.exceptions import (CogtError,- GatewayUnknownModelError,InferenceBackendCredentialsError,InferenceBackendLibraryError,InferenceBackendLibraryNotFoundError,@@ -64,15 +63,6 @@ from pipelex.system.configuration.config_surface import PIPELEX_CONFIG_SURFACE_Ifrom pipelex.system.configuration.configs import PipelexConfigfrom pipelex.system.console_target import ConsoleTargetfrom pipelex.system.environment import get_optional_env-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigUnavailableError,- RemoteConfigValidationError,-)-from pipelex.system.pipelex_service.managed_gateway_configs import build_managed_gateway_configs-from pipelex.system.pipelex_service.pipelex_service_config import (- enabled_managed_gateway_sections,-)-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcherfrom pipelex.system.telemetry.telemetry_config import TELEMETRY_CONFIG_FILE_NAME, TelemetryConfigfrom pipelex.tools.log.console_log_sink import ConsoleLogSinkfrom pipelex.tools.log.log_config import LogConfig@@ -87,9 +77,7 @@ from pipelex.tools.misc.toml_utils import load_toml_from_base_and_overrides, loaif TYPE_CHECKING:from collections.abc import Mapping- from pipelex.cogt.model_backends.gateway_config import GatewayConfigfrom pipelex.plugins.registrar import PluginRegistrar- from pipelex.system.pipelex_service.types import RemoteConfigSourcefrom pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract@@ -631,11 +619,11 @@ def check_backend_files(# Create a temporary backend library and try to load this backendtemp_library = InferenceBackendLibrary.make_empty()- # This row reports on file shape, so the load is lenient: a backend whose gateway- # model specs were not handed to the loader (no fetch happens here) or whose- # credentials do not resolve is skipped rather than reported — those are the- # Models row's and the Credentials row's findings. A malformed file stays fatal- # in lenient mode, which is what this probe exists to catch.+ # This row reports on file shape, so the load is lenient: a backend whose+ # credentials do not resolve is skipped rather than reported — that is the+ # Credentials row's finding. A malformed file stays fatal in lenient mode, which+ # is what this probe exists to catch, and so do the library's refusals of an+ # enabled backend that declares no model or still carries `model_specs_section`.temp_library.load(secrets_provider=secrets_provider,backends_library_paths=backends_file_paths,@@ -1468,29 +1456,6 @@ def check_models(msg = f"Backend configuration error: {first_error}"return False, msg, backend_file_reports- # Fetch the managed gateways' model specs if any managed gateway backend is enabled.- # Probe the same backends document the doctor is reporting on (project-vs-global) instead- # of always defaulting to the global path — otherwise --global on a machine with a- # project-local backends.toml would mis-report the managed-gateway state because the- # layered `config_manager.backends_file_paths()` would still resolve its base to the- # project file.- managed_gateway_configs: dict[str, GatewayConfig] | None = None- gateway_config_source: RemoteConfigSource | None = None- try:- managed_gateway_sections = enabled_managed_gateway_sections(config_dir=config_dir)- except InferenceBackendLibraryValidationError as exc:- return False, f"Error checking models: {exc}", backend_file_reports- if managed_gateway_sections:- try:- result = RemoteConfigFetcher.fetch_remote_config()- gateway_config_source = result.source- managed_gateway_configs = build_managed_gateway_configs(- remote_config=result.config,- managed_gateway_sections=managed_gateway_sections,- )- except (RemoteConfigUnavailableError, RemoteConfigValidationError) as exc:- return False, f"Failed to fetch the Pipelex remote configuration: {exc}", backend_file_reports-# When --global (config_dir set), pin every path so layered config_manager.X# resolution doesn't silently fall back to the project-local files. The two documents# are pinned as sequences: that directory's base file and its own override.@@ -1517,8 +1482,6 @@ def check_models(try:models_manager.setup(secrets_provider=secrets_provider,- managed_gateway_configs=managed_gateway_configs,- gateway_config_source=gateway_config_source,plugin_model_declarations=plugin_model_declarations,backends_library_paths=backends_library_override,backends_dir_path=backends_dir_override,@@ -1545,7 +1508,6 @@ def check_models(InferenceBackendLibraryValidationError,ModelDeckValidationError,InferenceBackendCredentialsError,- GatewayUnknownModelError,PluginModelDeclarationError,) as exc:return False, f"Error checking models: {redacted_failure(exc=exc, log_config=log_config)}", backend_file_reportsdiff --git a/pipelex/cli/commands/fix/_fix_core.py b/pipelex/cli/commands/fix/_fix_core.pyindex dac7056fc..aa698305e 100644--- a/pipelex/cli/commands/fix/_fix_core.py+++ b/pipelex/cli/commands/fix/_fix_core.py@@ -261,7 +261,7 @@ def execute_fix(verdict semantics."""try:- make_pipelex_for_cli(context=ErrorContext.FIX, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_cli(context=ErrorContext.FIX, needs_inference=False)with get_telemetry_manager().telemetry_context():tag(name=EventProperty.INTEGRATION, value=IntegrationMode.CLI)tag(name=EventProperty.PIPELEX_VERSION, value=get_package_version())diff --git a/pipelex/cli/commands/init/command.py b/pipelex/cli/commands/init/command.pyindex 2aedf2b8f..d6810258b 100644--- a/pipelex/cli/commands/init/command.py+++ b/pipelex/cli/commands/init/command.py@@ -4,7 +4,6 @@ import shutilfrom pathlib import Pathimport typer-from pydantic import BaseModel, ConfigDictfrom rich.console import Consolefrom rich.markup import escapefrom rich.prompt import Confirm@@ -23,99 +22,9 @@ from pipelex.cogt.models.deck_manifest import stamp_kit_manifestsfrom pipelex.kit.paths import get_kit_configs_dirfrom pipelex.runtime_hub import get_consolefrom pipelex.system.configuration.config_loader import config_manager-from pipelex.system.pipelex_service.exceptions import RemoteConfigUnavailableError-from pipelex.system.pipelex_service.pipelex_service_config import enabled_managed_gateway_sections-from pipelex.system.pipelex_service.remote_config_cache import RemoteConfigCache-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcherfrom pipelex.system.telemetry.telemetry_config import TELEMETRY_CONFIG_FILE_NAME-class CachePrimingResult(BaseModel):- """Outcome of an attempt to prime the on-disk remote-config cache.-- ``primed`` is ``True`` only when a fresh fetch succeeded *and* a usable cache exists on disk- afterwards. ``error_message`` is populated when the fetch was attempted but failed (offline at- init time) *or* when the fetch succeeded but the cache could not be persisted, read back, or- validated as a usable ``RemoteConfig`` (e.g. a read-only or full cache directory). ``None``- means priming was skipped (no managed gateway backend enabled) or that it succeeded.- """-- model_config = ConfigDict(extra="forbid", strict=True)-- primed: bool- error_message: str | None = None---def attempt_prime_remote_config_cache(*, target_config_dir: Path | None = None) -> CachePrimingResult:- """Prime the on-disk remote-config cache so later offline runs can fall back to it.-- Pure-logic variant: no I/O on the way out, so both the interactive (`pipelex init`) and- machine (`pipelex-agent init`) surfaces can decide how to surface failure (Rich warning vs- structured JSON field).-- Skipped (``primed=False, error_message=None``) when no managed gateway backend is enabled in- ``backends.toml``: BYOK has nothing to cache.-- The question is the boot's — *any* managed gateway backend — because what gets cached is the- single published configuration carrying every managed backend's section.-- Always passes ``require_fresh=True`` to the fetcher: priming's only job is to write a fresh- cache, so silently accepting an existing cached fallback would be a misleading success. When- the network is unreachable and only a stale cache exists, the fetcher raises- ``RemoteConfigUnavailableError`` and we surface that as ``error_message`` — the stale cache- on disk is left intact so subsequent offline dry-runs can still fall back to it.-- ``RemoteConfigValidationError`` is intentionally NOT caught: a server-side schema break is a- real bug (we control the back-office) and should surface loudly rather than be hidden by the- priming step.-- Args:- target_config_dir: When set, read the backends document *at that directory* (its- ``backends.toml`` and its own ``backends_override.toml``) to decide whether a managed- gateway backend is enabled. ``pipelex init`` and ``pipelex init --local`` target- different ``.pipelex/`` directories — using the layered/project-preferred config here- would let priming branch on the wrong file. ``None`` (default) falls back to the layered- document.- """- if not enabled_managed_gateway_sections(config_dir=target_config_dir):- return CachePrimingResult(primed=False)-- try:- RemoteConfigFetcher.fetch_remote_config(require_fresh=True)- except RemoteConfigUnavailableError as exc:- return CachePrimingResult(primed=False, error_message=str(exc))-- # A successful fetch does NOT guarantee a usable cache. ``RemoteConfigFetcher`` treats the- # cache write as opportunistic and swallows OSErrors (read-only / full cache dir) with only a- # stderr warning, so read the cache back: a wrapper that loads holds the payload as a JSON- # object, which is all a ``RemoteConfig`` needs. Otherwise priming would misreport success and- # later offline runs would hit ``RemoteConfigUnavailableError``.- cached = RemoteConfigCache.load()- if cached is None:- msg = (- f"Remote config was fetched but the cache at {RemoteConfigCache.cache_path()} "- "could not be written, read back, or validated; offline dry-runs will not have a "- "fallback. Check that the directory is writable."- )- return CachePrimingResult(primed=False, error_message=msg)- return CachePrimingResult(primed=True)---def prime_remote_config_cache(*, console: Console, target_config_dir: Path | None = None) -> None:- """Interactive-surface wrapper around :func:`attempt_prime_remote_config_cache`.-- Prints a yellow warning to the console when a fetch was attempted and failed; otherwise- silent. Used by ``pipelex init`` so the user knows priming didn't happen and how to retry.-- ``target_config_dir`` is forwarded so the managed-gateway check inspects the directory- being initialized rather than the layered config (see ``attempt_prime_remote_config_cache``).- """- result = attempt_prime_remote_config_cache(target_config_dir=target_config_dir)- if result.error_message is not None:- console.print(f"[yellow]⚠ Could not prime remote config cache: {escape(result.error_message)}[/yellow]")- console.print("[dim]Re-run 'pipelex init' while online to prime the cache for offline dry-runs.[/dim]")--def determine_needs(*,reset: bool,@@ -345,12 +254,6 @@ def execute_initialization(if needs_telemetry:setup_telemetry(console=console, telemetry_config_path=telemetry_config_path, for_project=for_project)- # Step 5: Prime the remote-config cache so dry-runs and validate can fall back offline.- # No-op when no managed gateway backend is enabled. We forward ``target_config_dir`` so the- # managed-gateway check inspects the directory we just initialized (matters for ``--local``- # vs default init).- prime_remote_config_cache(console=console, target_config_dir=target_config_dir)-console.print()diff --git a/pipelex/cli/commands/resolve_cmd.py b/pipelex/cli/commands/resolve_cmd.pyindex 2928a0e26..88237df0f 100644--- a/pipelex/cli/commands/resolve_cmd.py+++ b/pipelex/cli/commands/resolve_cmd.py@@ -43,9 +43,7 @@ def resolve_cmd(] = None,) -> None:"""Emit the normalized library crate for a bundle closure to stdout."""- # needs_model_specs=True (like `validate`): library validation checks pipe model pins- # against the deck, so the specs must be loaded even though resolving needs no inference.- make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False)try:with get_telemetry_manager().telemetry_context():diff --git a/pipelex/cli/commands/run/_run_core.py b/pipelex/cli/commands/run/_run_core.pyindex 12958ebb9..bf092cc1b 100644--- a/pipelex/cli/commands/run/_run_core.py+++ b/pipelex/cli/commands/run/_run_core.py@@ -496,9 +496,8 @@ def execute_run("""# A dry run makes no inference call, so it must not demand credentials: `needs_inference=False`# forces every run to DRY and skips a backend whose key is missing instead of failing the boot.- # `needs_model_specs=True` keeps the real gateway model specs (not the dummy ones), so wherever- # credentials ARE present a dry run resolves model handles exactly as a live run would. It does not- # help on a machine with no key at all: a skipped backend contributes no models, so a pipe pinning a+ # Wherever credentials ARE present a dry run resolves model handles exactly as a live run would. On+ # a machine with no key at all, a skipped backend contributes no models, so a pipe pinning a# bare handle served only by that backend reports it as not found (see docs/features/validation-dry-run.md).# This is the same boot `pipelex-agent run --dry-run` uses, so the two CLIs agree either way.make_pipelex_for_cli(@@ -506,7 +505,6 @@ def execute_run(library_dirs=library_dir,needs_inference=not dry_run,boot_orchestrator=orchestrator,- needs_model_specs=True,)try:diff --git a/pipelex/cli/commands/show_cmd.py b/pipelex/cli/commands/show_cmd.pyindex 9492c9af9..ffddb6bd9 100644--- a/pipelex/cli/commands/show_cmd.py+++ b/pipelex/cli/commands/show_cmd.py@@ -228,7 +228,7 @@ def show_pipe_cmd(raise typer.Exit(1)library_dirs = [Path(lib_dir) for lib_dir in library_dir] if library_dir else None- make_pipelex_for_cli(context=ErrorContext.VALIDATION_BEFORE_SHOW_PIPE, library_dirs=library_dirs, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_cli(context=ErrorContext.VALIDATION_BEFORE_SHOW_PIPE, library_dirs=library_dirs, needs_inference=False)try:library_manager = get_library_manager()diff --git a/pipelex/cli/commands/validate/_validate_core.py b/pipelex/cli/commands/validate/_validate_core.pyindex 237c57bd8..27c343323 100644--- a/pipelex/cli/commands/validate/_validate_core.py+++ b/pipelex/cli/commands/validate/_validate_core.py@@ -236,7 +236,7 @@ def execute_validate(runtime — so this flag does not change *what* validation does; it controls how Pipelex boots,which is the lever for exercising the "validation stays in-process on an orchestrator backend" contract."""- make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False, needs_model_specs=True, boot_orchestrator=orchestrator)+ make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False, boot_orchestrator=orchestrator)try:with get_telemetry_manager().telemetry_context():diff --git a/pipelex/cli/commands/validate/pipe_cmd.py b/pipelex/cli/commands/validate/pipe_cmd.pyindex d67267571..791b9a693 100644--- a/pipelex/cli/commands/validate/pipe_cmd.py+++ b/pipelex/cli/commands/validate/pipe_cmd.py@@ -72,7 +72,6 @@ def validate_pipe_cmd(context=ErrorContext.VALIDATION,library_dirs=library_dirs_paths,needs_inference=False,- needs_model_specs=True,boot_orchestrator=orchestrator,)do_validate_all_libraries_and_dry_run(diff --git a/pipelex/cli/commands/which_cmd.py b/pipelex/cli/commands/which_cmd.pyindex 68661d4ba..ed45019f8 100644--- a/pipelex/cli/commands/which_cmd.py+++ b/pipelex/cli/commands/which_cmd.py@@ -86,7 +86,7 @@ def which_cmd(pipelex which my_domain.my_pipe -L ./my_pipesPIPELEXPATH=/path/to/pipes pipelex which some_pipe"""- make_pipelex_for_cli(context=ErrorContext.VALIDATION_BEFORE_SHOW_PIPE, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_cli(context=ErrorContext.VALIDATION_BEFORE_SHOW_PIPE, needs_inference=False)try:library_manager = get_library_manager()diff --git a/pipelex/cli/dev_cli/commands/generate_projection_corpus_cmd.py b/pipelex/cli/dev_cli/commands/generate_projection_corpus_cmd.pyindex 4c2f7e714..644b5b51d 100644--- a/pipelex/cli/dev_cli/commands/generate_projection_corpus_cmd.py+++ b/pipelex/cli/dev_cli/commands/generate_projection_corpus_cmd.py@@ -684,7 +684,7 @@ def generate_projection_corpus_cmd(*, bundle_paths: list[Path], output_dir: Pathconsole.print(f"[red]Bundle file not found: {bundle_path}[/red]")sys.exit(2)- make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False)try:manifest = asyncio.run(generate_projection_corpus(bundle_paths=bundle_paths, output_dir=output_dir))except ValidateBundleError as exc:diff --git a/pipelex/cli/dev_cli/commands/preprocess_test_models_cmd.py b/pipelex/cli/dev_cli/commands/preprocess_test_models_cmd.pyindex 9c5121ddf..f9988c71e 100644--- a/pipelex/cli/dev_cli/commands/preprocess_test_models_cmd.py+++ b/pipelex/cli/dev_cli/commands/preprocess_test_models_cmd.py@@ -16,9 +16,6 @@ from rich.table import Tablefrom pipelex.runtime_hub import get_consolefrom pipelex.system.configuration.config_loader import config_managerfrom pipelex.system.configuration.configs import ConfigPaths-from pipelex.system.pipelex_service.exceptions import RemoteConfigUnavailableError, RemoteConfigValidationError-from pipelex.system.pipelex_service.pipelex_service_config import enabled_managed_gateway_sections-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcherfrom pipelex.tools.misc.exceptions import TomlErrorfrom pipelex.tools.misc.json_utils import deep_updatefrom pipelex.tools.misc.toml_utils import load_toml_from_path@@ -43,9 +40,8 @@ DEFAULT_MODEL_TYPE = "llm"def _group_handles_by_model_type(*, specs: dict[str, Any]) -> dict[str, list[str]]:"""Group a table of model specs by model type.- One function for both sources on purpose: a local backend TOML and a remote-config model-specs- section carry the same shape — one table per model handle, an optional `defaults` table naming- the model type the rest inherit — so reading them differently is how the two drift.+ A backend TOML holds one table per model handle and an optional `defaults` table naming the+ model type the rest inherit.Args:specs: The specs table, keyed by model handle.@@ -105,46 +101,6 @@ def _extract_models_from_backend_toml(backend_path: Path) -> dict[str, list[str]return _group_handles_by_model_type(specs=config)-def _fetch_managed_gateway_models() -> dict[str, dict[str, list[str]]]:- """Fetch model handles for every enabled managed gateway backend, grouped by model type.-- A *managed gateway backend* is one that declares a `model_specs_section`, and there can be more- than one of them — `pipelex_manifold` today. Which section a backend reads is its own- declaration, so this asks `enabled_managed_gateway_sections` rather than naming any backend- here: hardcoding one name is exactly what would keep this command blind to the next one.-- Returns:- Dictionary mapping backend name to its {model_type: [model handles]}. Empty when no managed- gateway backend is enabled, in which case the remote config is never fetched at all.-- Raises:- RemoteConfigUnavailableError: The remote config is unreachable and no usable cache- exists — ``require_fresh=True`` refuses any cached fallback.- RemoteConfigValidationError: The service responded with a payload that does not match- the expected schema.- """- sections = enabled_managed_gateway_sections()- if not sections:- return {}-- # ``require_fresh=True`` guarantees we never bake stale or missing model specs into committed- # files. Any ``RemoteConfigUnavailableError`` / ``RemoteConfigValidationError`` propagates so- # the command refuses to proceed rather than writing fixtures silently missing every managed- # gateway model.- result = RemoteConfigFetcher.fetch_remote_config(require_fresh=True)-- models_by_backend: dict[str, dict[str, list[str]]] = {}- for backend_name, section_name in sorted(sections.items()):- section = result.config.get_model_specs_section(section_name)- if section is None:- # The artifact carries no such section: a real answer, and the same posture the runtime- # takes — that backend simply serves nothing here, rather than failing the whole run.- continue- models_by_backend[backend_name] = _group_handles_by_model_type(specs=dict(section))-- return models_by_backend--def _collect_all_model_availability() -> dict[str, Any]:"""Collect model availability from all backends.@@ -168,29 +124,16 @@ def _collect_all_model_availability() -> dict[str, Any]:backends_dir = config_manager.backends_dir_path- # Managed gateway backends are handled separately below: their models come from the published- # artifact, so a local TOML of the same name holds overrides and never the model list.- managed_backends = _fetch_managed_gateway_models()-# Process each backend TOML filefor backend_file in sorted(backends_dir.glob("*.toml")):backend_name = backend_file.stem- if backend_name in managed_backends:- continue-models_by_type = _extract_models_from_backend_toml(backend_file)for model_type in MODEL_TYPES:if models_by_type.get(model_type):result[model_type][backend_name] = models_by_type[model_type]- # Add each managed gateway backend's models- for backend_name, models_by_type in managed_backends.items():- for model_type in MODEL_TYPES:- if models_by_type.get(model_type):- result[model_type][backend_name] = models_by_type[model_type]-return result@@ -630,8 +573,7 @@ def preprocess_test_models_cmd() -> None:"""Preprocess test models from backend TOMLs and generate fixture files.- This command reads all backend TOML configurations and, for every enabled managed gateway- backend, its own section of the published remote config, to build a complete mapping of+ This command reads all backend TOML configurations to build a complete mapping ofavailable models. It can optionally generate a Python fixture file with pre-computed(model, backend) pairs.@@ -691,26 +633,6 @@ def preprocess_test_models_cmd(console.print(" • Verify disk space and filesystem health")console.print()sys.exit(1)- except (RemoteConfigUnavailableError, RemoteConfigValidationError) as exc:- # The remote config is unavailable or stale. This command regenerates committed files- # (model_availability.json, _generated_model_sets.py), so it must refuse rather than write- # fixtures missing every managed gateway backend's models.- if quiet:- console.print(f"[red]✗ Preprocessing failed:[/red] Remote config unavailable - {escape(str(exc))}")- else:- error_panel = Panel(- f"[red]✗[/red] The Pipelex service's remote configuration is unavailable\n\n[dim]{escape(str(exc))}[/dim]",- title="[bold red]Remote Config Unavailable[/bold red]",- border_style="red",- padding=(1, 2),- )- console.print(error_panel)- console.print()- console.print("[bold yellow]Recommended Actions:[/bold yellow]")- console.print(" • Run [cyan]pipelex init[/cyan] while online to prime the remote config cache")- console.print(" • Fixture generation must not proceed without fresh managed gateway model specs")- console.print()- sys.exit(1)except Exception as exc: # ruff: ignore[blind-except]# Dev CLI command root: any unexpected preprocessing failure is reported as a FAILED status line; exit non-zero.if quiet:diff --git a/pipelex/cli/dev_cli/commands/trace_input_semantics_cmd.py b/pipelex/cli/dev_cli/commands/trace_input_semantics_cmd.pyindex 71cedebbb..c2eb7494a 100644--- a/pipelex/cli/dev_cli/commands/trace_input_semantics_cmd.py+++ b/pipelex/cli/dev_cli/commands/trace_input_semantics_cmd.py@@ -352,7 +352,7 @@ def trace_input_semantics_cmd(*, bundle_paths: list[Path], output_dir: Path, allconsole.print(f"[red]Bundle file not found: {bundle_path}[/red]")sys.exit(2)- make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False, needs_model_specs=True)+ make_pipelex_for_cli(context=ErrorContext.VALIDATION, needs_inference=False)try:manifest = asyncio.run(trace_input_semantics(diff --git a/pipelex/cli/error_handlers.py b/pipelex/cli/error_handlers.pyindex bef9c6c10..dd01a1629 100644--- a/pipelex/cli/error_handlers.py+++ b/pipelex/cli/error_handlers.py@@ -10,17 +10,12 @@ from rich.markup import escapefrom rich.traceback import Tracebackfrom pipelex.base_exceptions import ValidationErrorCategory, ValidationErrorItem, error_domain_is_input, iter_cause_chain-from pipelex.cogt.exceptions import GatewayUnknownModelError, ModelDeckPresetValidatonError+from pipelex.cogt.exceptions import ModelDeckPresetValidatonErrorfrom pipelex.core.pipes.exceptions import PipeOperatorModelChoiceErrorfrom pipelex.pipe_operators.exceptions import PipeOperatorModelAvailabilityErrorfrom pipelex.pipeline.exceptions import ValidateBundleErrorfrom pipelex.pipeline.validation_render import build_fix_command, count_applicable_fixes, suggested_fix_label, validation_item_titlefrom pipelex.runtime_hub import get_console-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigUnavailableError,- RemoteConfigValidationError,-)-from pipelex.system.pipelex_service.types import RemoteConfigSourcefrom pipelex.system.telemetry.exceptions import TelemetryConfigValidationErrorfrom pipelex.urls import URLs@@ -438,113 +433,3 @@ def handle_telemetry_config_validation_error(exc: TelemetryConfigValidationErrorconsole.print(f"[dim]Join our Discord for help: {URLs.discord}[/dim]\n")raise typer.Exit(1) from exc---def handle_remote_config_validation_error(exc: RemoteConfigValidationError) -> NoReturn:- """Handle and display RemoteConfigValidationError with user-friendly guidance.-- This error occurs when the Pipelex remote configuration was fetched but- the data is malformed or doesn't match the expected schema.-- Args:- exc: The remote config validation error exception- """- console = get_console()- print_traceback_if_requested(console=console)- console.print("\n[bold red]❌ The Pipelex remote configuration is invalid[/bold red]\n")-- console.print(- "[bold yellow]⚠ Server Issue:[/bold yellow] The Pipelex remote configuration was received but\n"- "couldn't be validated. This is a server-side issue that we need to fix.\n"- )-- console.print("[bold cyan]Error details:[/bold cyan]")- console.print(f" {escape(str(exc))}\n")-- console.print("[bold red]🚨 Please report this![/bold red]")- console.print(" This error shouldn't happen and we want to fix it ASAP.")- console.print(" Please copy-paste this error to:")- console.print(f" • Discord: [cyan]{URLs.discord}[/cyan]")- console.print(f" • GitHub Issues: [cyan]{URLs.repository}/issues[/cyan]")- console.print()-- console.print("[dim]In the meantime, you can:[/dim]")- console.print("[dim] • Disable the Pipelex-managed gateway backends in .pipelex/inference/backends.toml[/dim]")- console.print("[dim] • Use your own API keys with direct provider backends[/dim]")- console.print()-- console.print(f"[dim]For more information: {URLs.backend_provider_docs}[/dim]\n")- raise typer.Exit(1) from exc---def handle_remote_config_unavailable_error(exc: RemoteConfigUnavailableError) -> NoReturn:- """Handle and display RemoteConfigUnavailableError with user-friendly guidance.-- Raised when a fresh fetch failed AND no usable cached fallback exists. A Pipelex-managed- gateway backend is enabled but we have neither network nor a primed local cache.-- Args:- exc: The remote config unavailable error exception- """- console = get_console()- print_traceback_if_requested(console=console)- console.print("\n[bold red]❌ The Pipelex remote configuration is unreachable and no cached config is available[/bold red]\n")-- console.print(- "[bold yellow]⚠ Offline + Cold Cache:[/bold yellow] A Pipelex-managed gateway backend requires a config\n"- "either fetched fresh or restored from a local cache, but neither is available.\n"- )-- console.print("[bold cyan]Error details:[/bold cyan]")- console.print(f" {escape(str(exc))}\n")-- console.print("[bold green]💡 To fix:[/bold green]")- console.print(" • Reconnect to the network and run [cyan]pipelex init[/cyan] to prime the cache")- console.print(- " • Or disable the Pipelex-managed gateway backends in [cyan].pipelex/inference/backends.toml[/cyan] for permanent offline (BYOK) operation"- )- console.print()-- console.print(f"[dim]For more information: {URLs.backend_provider_docs}[/dim]")- console.print(f"[dim]Join our Discord for help: {URLs.discord}[/dim]\n")- raise typer.Exit(1) from exc---def handle_gateway_unknown_model_error(exc: GatewayUnknownModelError) -> NoReturn:- """Handle and display GatewayUnknownModelError with user-friendly guidance.-- Raised when the active model deck references a gateway model handle that doesn't exist- in the gateway specs (either freshly fetched or loaded from cache). Branches the- remediation on the provenance of the gateway config.-- **The backend is named rather than assumed.** More than one managed gateway can be live at- once, so telling the user to disable one when it was another service that could not serve the- handle would send them to fix the wrong line of their configuration.-- Args:- exc: The gateway unknown model error exception- """- console = get_console()- print_traceback_if_requested(console=console)- console.print("\n[bold red]❌ Unknown gateway model handle[/bold red]\n")-- backend_name = escape(exc.backend_name or "")- console.print(f"[bold cyan]Model handle:[/bold cyan] [yellow]'{escape(exc.model_name)}'[/yellow]")- console.print(f"[bold cyan]Backend:[/bold cyan] [yellow]{backend_name}[/yellow]")- console.print(f"[bold cyan]Config source:[/bold cyan] [yellow]{escape(exc.source)}[/yellow]")- console.print(f"\n[bold red]Error:[/bold red] {escape(str(exc))}\n")-- console.print("[bold green]💡 To fix:[/bold green]")- match exc.source:- case RemoteConfigSource.FRESH:- console.print(" • Check the model handle for typos against [cyan]pipelex doctor[/cyan]")- console.print(" • Update the deck to reference a model the gateway currently exposes")- console.print(f" • Or disable [cyan]{backend_name}[/cyan] in [cyan].pipelex/inference/backends.toml[/cyan] to fall back to BYOK")- case RemoteConfigSource.CACHED:- console.print(" • The on-disk cache may be stale — run [cyan]pipelex init[/cyan] while online to refresh it")- console.print(f" • Or disable [cyan]{backend_name}[/cyan] in [cyan].pipelex/inference/backends.toml[/cyan] to operate offline (BYOK)")- console.print()-- console.print(f"[dim]For more information: {URLs.backend_provider_docs}[/dim]")- console.print(f"[dim]Join our Discord for help: {URLs.discord}[/dim]\n")- raise typer.Exit(1) from excdiff --git a/pipelex/cogt/exceptions.py b/pipelex/cogt/exceptions.pyindex 8ba107f60..77eee85ae 100644--- a/pipelex/cogt/exceptions.py+++ b/pipelex/cogt/exceptions.py@@ -7,7 +7,6 @@ from typing_extensions import overridefrom pipelex.base_exceptions import ErrorDomain, ErrorReport, PipelexError, iter_cause_chainfrom pipelex.cogt.inference.error_classification import ProviderErrorMetadata, UserAction, UserActionKind-from pipelex.system.pipelex_service.types import RemoteConfigSourceif TYPE_CHECKING:from pipelex.cogt.model_backends.model_type import ModelType@@ -624,43 +623,3 @@ class ModelDeckNotFoundError(CogtError):class ModelDeckValidationError(CogtError):pass---class GatewayUnknownModelError(CogtError):- """A model handle the active routing profile sends to a managed gateway is absent from its specs.-- Carries the provenance of the gateway config (``FRESH`` vs ``CACHED``) so the message can- branch: a cached-source failure suggests stale gateway specs and points the user at- ``pipelex init`` to refresh while online; a fresh-source failure is a genuine- misconfiguration.-- **And it carries the backend name**, because more than one managed gateway can be live at once- and "which one" is then a question the message has to answer — the handle may be perfectly- present in the other service's section, which is a legitimate configuration rather than a- contradiction.- """-- error_category = InferenceErrorCategory.CONFIGURATION-- def __init__(self, model_name: str, backend_name: str, source: RemoteConfigSource) -> None:- self.model_name = model_name- self.backend_name = backend_name- self.source = source- match source:- case RemoteConfigSource.FRESH:- msg = (- f"Model handle '{model_name}' is routed to backend '{backend_name}' by the active routing profile, "- f"but is not present in the model specs we just fetched for it. Either the model name is wrong, that "- f"gateway no longer offers it, or your deck overrides need updating.\n"- f" - Run `pipelex doctor` to inspect the active gateway models.\n"- f" - Route this model to another backend in .pipelex/inference/routing_profiles.toml.\n"- f" - Or disable {backend_name} in .pipelex/inference/backends.toml to fall back to BYOK."- )- case RemoteConfigSource.CACHED:- msg = (- f"Model handle '{model_name}' is routed to backend '{backend_name}' by the active routing profile, "- f"but is not present in the model specs loaded for it from the on-disk cache. The cache may be stale.\n"- f" - Run `pipelex init` while online to refresh the cached gateway config.\n"- f" - Or disable {backend_name} in .pipelex/inference/backends.toml to operate offline (BYOK)."- )- super().__init__(msg)diff --git a/pipelex/cogt/model_backends/backend.py b/pipelex/cogt/model_backends/backend.pyindex 4ecb2cf16..95cbcc183 100644--- a/pipelex/cogt/model_backends/backend.py+++ b/pipelex/cogt/model_backends/backend.py@@ -8,11 +8,6 @@ from pipelex.cogt.model_backends.model_spec import InferenceModelSpecfrom pipelex.system.configuration.config_model import ConfigModelfrom pipelex.tools.typing.pydantic_utils import empty_dict_factory_of, empty_list_factory_of-# The section the manifold dialect's catalog is published under in the Pipelex service's artifact.-# Named here so the kit config, the fetcher's dummy and the tests cannot drift apart on a string-# literal.-MANIFOLD_MODEL_SPECS_SECTION = "manifold_model_specs"-class PipelexBackend(StrEnum):"""Special Pipelex-managed inference backends."""@@ -29,18 +24,6 @@ class PipelexBackend(StrEnum):return "Internal (software-only)"-def resolve_model_specs_section(*, backend_name: str, declared_section: str | None) -> str | None:- """The remote-config section this backend's model specs come from, or `None` when it has none.-- **Declaring a section is what makes a backend a managed gateway backend**: its model specs- arrive from the Pipelex service's published artifact rather than from a local per-backend TOML.- A backend with no section resolves to `None` and loads its specs from its own file, which is- every BYOK backend and the internal one. No name resolves to a section it did not declare.- """- del backend_name # every managed backend declares its section; the name carries no default- return declared_section--class InferenceBackend(ConfigModel):name: strdisplay_name: str | None = Nonediff --git a/pipelex/cogt/model_backends/backend_factory.py b/pipelex/cogt/model_backends/backend_factory.pyindex 820251ab9..061ba0c8d 100644--- a/pipelex/cogt/model_backends/backend_factory.py+++ b/pipelex/cogt/model_backends/backend_factory.py@@ -13,10 +13,6 @@ class InferenceBackendBlueprint(ConfigModel):enabled: bool = Trueendpoint: str | None = Noneapi_key: str | None = None- # Naming a remote-config section is what declares this backend a *managed gateway* backend: its- # model specs arrive from the Pipelex service's published artifact rather than from a local- # per-backend TOML. See `resolve_model_specs_section`, which is the only reader.- model_specs_section: str | None = Nonelisted_constraints: list[ListedConstraint] = Field(default_factory=empty_list_factory_of(ListedConstraint))valued_constraints: dict[ValuedConstraint, Any] = Field(default_factory=empty_dict_factory_of(ValuedConstraint))extra_config: dict[str, Any] = Field(default_factory=dict)diff --git a/pipelex/cogt/model_backends/backend_library.py b/pipelex/cogt/model_backends/backend_library.pyindex 29f6cccdf..bf10e593f 100644--- a/pipelex/cogt/model_backends/backend_library.py+++ b/pipelex/cogt/model_backends/backend_library.py@@ -15,20 +15,19 @@ from pipelex.cogt.exceptions import (InferenceModelSpecError,PluginModelDeclarationError,)-from pipelex.cogt.model_backends.backend import InferenceBackend, PipelexBackend, resolve_model_specs_section+from pipelex.cogt.model_backends.backend import InferenceBackend, PipelexBackendfrom pipelex.cogt.model_backends.backend_factory import (InferenceBackendBlueprint,InferenceBackendFactory,)from pipelex.cogt.model_backends.constraints import ListedConstraint, ValuedConstraint-from pipelex.cogt.model_backends.gateway_config import GatewayConfig, drop_unknown_gateway_defaultsfrom pipelex.cogt.model_backends.model_spec_document import MODEL_SPEC_DEFAULTS_TABLEfrom pipelex.cogt.model_backends.model_spec_factory import (BackendModelSpecs,InferenceModelSpecBlueprint,InferenceModelSpecFactory,)-from pipelex.cogt.model_backends.model_spec_keys import ModelSpecSource, describe_rejected_keys, split_model_spec_keys+from pipelex.cogt.model_backends.model_spec_keys import describe_rejected_keys, split_model_spec_keysfrom pipelex.migration.plan import MigrationPlanfrom pipelex.plugins.plugin_model_declarations import PluginModelDeclarationsfrom pipelex.system.configuration.config_loader import config_manager@@ -37,7 +36,6 @@ from pipelex.system.configuration.config_surface import (replay_surface_files_in_memory,stale_configuration_warning,)-from pipelex.system.pipelex_service.gateway_config_merger import GatewayConfigMergerfrom pipelex.system.runtime import runtime_managerfrom pipelex.tools.misc.dict_utils import (apply_to_strings_recursive,@@ -47,7 +45,6 @@ from pipelex.tools.misc.toml_utils import (describe_toml_base_and_overrides,load_toml_from_base_and_overrides,load_toml_from_path,- load_toml_from_path_if_exists,present_toml_override_paths,)from pipelex.tools.secrets.exceptions import UnknownVarPrefixError, VarFallbackPatternError, VarNotFoundError@@ -60,6 +57,9 @@ if TYPE_CHECKING:InferenceBackendLibraryRoot = dict[str, InferenceBackend]+# A `backends.toml` key that named the remote-config section holding a backend's model specs.+RETIRED_MODEL_SPECS_SECTION_KEY = "model_specs_section"+class RecoveredModelSpecs(NamedTuple):"""One backend's model specs rebuilt from a migrated file, and what the ledger did to get there."""@@ -113,14 +113,10 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):backends_library_paths: Sequence[Path],backends_dir_path: str,include_disabled: bool = False,- managed_gateway_configs: dict[str, GatewayConfig] | None = None,lenient: bool = False,):"""Load backend configurations from TOML files.- For a managed gateway backend, uses that backend's slice of the fetched remote config and- merges with local overrides from a file named after the backend.-**A file left behind by a schema change is carried forward rather than fatal.** When a localper-backend TOML is refused, the `inference-backend` ledger is replayed over that one file**in memory** and the loader's own steps re-run over what comes back; a load that then@@ -143,11 +139,7 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):backends_library_paths: The base `backends.toml` first, then the override files in merge order.backends_dir_path: Path to directory containing per-backend TOML files.include_disabled: Whether to include disabled backends.- managed_gateway_configs: One gateway configuration per managed backend, keyed by backend- name. A managed backend absent from this mapping has no live specs — see the- per-backend branch below for what that means in each mode.- lenient: When True, skip a backend whose *credentials* cannot be resolved, or a managed- gateway backend when no `managed_gateway_configs` were handed in, instead of+ lenient: When True, skip a backend whose *credentials* cannot be resolved instead ofraising — that is the whole of the tolerance. A malformed configuration (an unknownor invalid key, a model spec that is not a table, a missing per-backend TOML) staysfatal in both modes: a config typo must never silently delete a backend, because the@@ -194,20 +186,20 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):enabled = inference_backend_blueprint_dict_raw.get("enabled", True)if not enabled and not include_disabled:continue+ if enabled and RETIRED_MODEL_SPECS_SECTION_KEY in backend_table:+ # The key once pointed at specs the remote config served. Read as an extra key, it would+ # boot the backend with whatever its own file lists — for a backend whose file was a+ # comment-only template, nothing — and every model routed to it would go missing with no+ # word on why. Fatal in both modes, like any document that is wrong.+ msg = (+ f"Invalid inference backend '{backend_name}' in {library_paths_description}: "+ f"'{RETIRED_MODEL_SPECS_SECTION_KEY}' is no longer supported, because model specs are no longer "+ f"downloaded. List the backend's models in 'backends/{backend_name}.toml' and remove the key, "+ f"or disable the backend."+ )+ raise InferenceBackendLibraryValidationError(msg, backend_name=backend_name)if runtime_manager.is_ci_testing and backend_name == "vertexai":continue- # Read before substitution, deliberately: the section is a plain literal with no `${…}`- # in it, and whether this backend is *managed* decides how the substitution below is- # allowed to fail. Reading it off the validated blueprint would be too late.- declared_model_specs_section = self._declared_model_specs_section(backend_dict=inference_backend_blueprint_dict_raw)- model_specs_section = resolve_model_specs_section(- backend_name=backend_name,- declared_section=declared_model_specs_section,- )- # **The tolerance below keys on the DECLARATION.** A declaration is something only the- # kit writes, and only for a backend it also ships disabled, so it is the one signal that- # an installation may legitimately carry a managed backend without its variables.- tolerates_missing_variables = declared_model_specs_section is not Nonetry:inference_backend_blueprint_dict = apply_to_strings_recursive(inference_backend_blueprint_dict_raw, transform_func=substitute_vars_with_provider@@ -228,27 +220,6 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):if lenient:log.verbose(f"Skipping backend '{backend_name}': missing credential variable '{var_not_found_exc.var_name}'")continue- if tolerates_missing_variables:- # **Scoped to backends that DECLARE a model specs section, and the scoping is- # the whole point.** Such a backend is one the kit can ship *declared* —- # `pipelex_manifold` ships declared and disabled, and joining the beta is- # enabling it and setting two variables — so an installation that has enabled- # one and not yet filled in its variables must not fail to boot over them.- # Disabled with a named warning is exactly the posture the gateway itself takes- # toward an integration missing its variables. (An installation that has not- # joined never reaches here at all: a disabled backend is skipped above, and the- # one loader that asks for disabled backends asks leniently.)- #- # Every other backend keeps today's fatal boot, because widening this would mean- # a user who typos ANTHROPIC_API_KEY stops getting a boot failure and starts- # getting a silently missing backend that resurfaces much later as a- # model-resolution error.- log.warning(- f"Backend '{backend_name}' is disabled: it is a Pipelex-managed gateway backend and the variable "- f"'{var_not_found_exc.var_name}' it needs is not set. Set it to enable this backend, or set "- f"`enabled = false` on it in {library_paths_description} to silence this warning."- )- continuemsg = (f"Variable substitution failed due to a 'variable not found' error in {library_paths_description}:\n"f"Backend name: '{backend_name}', Variable name: '{var_not_found_exc.var_name}'\n"@@ -288,54 +259,17 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):msg = f"Invalid inference backend '{backend_name}' in {library_paths_description}: {validation_error_msg}"raise InferenceBackendLibraryValidationError(msg, backend_name=backend_name) from validation_error- # A managed gateway backend takes its specs from the fetched artifact; everything- # else reads its own local file.- backend_config_source: str- model_spec_source: ModelSpecSource- if model_specs_section is not None:- if managed_gateway_configs is None:- if lenient:- log.verbose(f"Skipping backend '{backend_name}': gateway model specs not available")- continue- # A caller's omission rather than a user's, and the two are told apart by- # *which* input is missing. `None` means the caller supplied no managed- # configs at all while this document declares one enabled — reachable only by- # loading the library directly without them.- msg = (- f"Backend '{backend_name}' is enabled in {library_paths_description} and declares model specs section "- f"'{model_specs_section}', but no model specs were given to the loader for it: pass it in "- "`managed_gateway_configs`, or disable the backend"- )- raise InferenceBackendLibraryError(msg, backend_name=backend_name)- gateway_config = managed_gateway_configs.get(backend_name)- if gateway_config is None:- # A mapping that was supplied and simply has no entry for this backend is the- # user's situation, not the caller's: the config builder walked this same file- # and found the published artifact carried no such section, warning by name as- # it skipped. Disabled here, quietly, because that warning was already said.- log.verbose(f"Skipping backend '{backend_name}': the Pipelex configuration carries no '{model_specs_section}' section")- continue- model_spec_source = ModelSpecSource.REMOTE_GATEWAY- model_specs_dict, backend_config_source = self._load_gateway_model_specs(- gateway_config=gateway_config,- backend_name=backend_name,- backends_dir_path=backends_dir_path,- substitute_vars_with_provider=substitute_vars_with_provider,- )- else:- model_spec_source = ModelSpecSource.LOCAL_FILE- model_specs_dict, backend_config_source = self._load_local_model_specs(- backend_name=backend_name,- backends_dir_path=backends_dir_path,- substitute_vars_with_provider=substitute_vars_with_provider,- )+ model_specs_dict, backend_config_source = self._load_local_model_specs(+ backend_name=backend_name,+ backends_dir_path=backends_dir_path,+ substitute_vars_with_provider=substitute_vars_with_provider,+ )try:backend_model_specs = self._build_backend_model_specs(model_specs_dict=model_specs_dict,backend_name=backend_name,backend_config_source=backend_config_source,- model_spec_source=model_spec_source,backend_listed_constraints=backend_blueprint.listed_constraints,backend_valued_constraints=backend_blueprint.valued_constraints,)@@ -343,7 +277,6 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):recovered = self._local_model_specs_the_ledger_can_explain(backend_name=backend_name,backends_dir_path=backends_dir_path,- model_spec_source=model_spec_source,backend_blueprint=backend_blueprint,substitute_vars_with_provider=substitute_vars_with_provider,)@@ -351,6 +284,18 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):raisebackend_model_specs = recovered.model_specsstale_plans.extend(recovered.plans)+ if enabled and not backend_model_specs and backend_name != PipelexBackend.INTERNAL:+ # An enabled backend serving nothing is never what a user meant: it is a table an+ # earlier release left enabled over a comment-only file, the Pipelex Gateway's above all.+ # Booting it would only drop every model routed to it from the deck, which says+ # "handle not found" and nothing about why. The internal backend is exempt: plugins+ # add its models after this load.+ msg = (+ f"Inference backend '{backend_name}' is enabled in {library_paths_description} but "+ f"{backend_config_source} declares no model. Disable it, or list the models it serves; "+ f"if a routing profile sends models to it, point that profile at a backend that serves them."+ )+ raise InferenceBackendLibraryValidationError(msg, backend_name=backend_name)backend = InferenceBackendFactory.make_inference_backend(name=backend_name,blueprint=backend_blueprint,@@ -369,18 +314,6 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):# first did not already say.self._stale_warning = stale_configuration_warning(plans=stale_plans, walked_dirs=config_manager.existing_config_dirs) if stale_plans else None- @classmethod- def _declared_model_specs_section(cls, *, backend_dict: dict[str, Any]) -> str | None:- """The `model_specs_section` this declaration states, read straight off the raw table.-- Non-string values return `None` rather than raising: the blueprint validation a few lines- later is what reports a malformed declaration, and it says so with the backend and the file- in front of the analysis. Answering "not managed" here just means that report happens on the- normal path instead of from inside a pre-check.- """- declared = backend_dict.get("model_specs_section")- return declared if isinstance(declared, str) else None-@classmethoddef _build_backend_model_specs(cls,@@ -388,7 +321,6 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):model_specs_dict: BackendModelSpecs,backend_name: str,backend_config_source: str,- model_spec_source: ModelSpecSource,backend_listed_constraints: list[ListedConstraint],backend_valued_constraints: dict[ValuedConstraint, Any],) -> "dict[str, InferenceModelSpec]":@@ -409,25 +341,18 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):model_spec_dict: dict[str, Any] = cast("dict[str, Any]", value)try:# A per-model key the blueprint does not know is a request header only if it is shaped- # like one; anything else is a typo or a dead field, and what happens to it depends on- # where the table came from.+ # like one; anything else is a typo or a dead field, and is refused.key_split = split_model_spec_keys(model_spec_dict=model_spec_dict)if key_split.rejected:- match model_spec_source:- case ModelSpecSource.LOCAL_FILE | ModelSpecSource.PLUGIN:- # Fatal in lenient mode too: leniency covers credentials only (see the docstring),- # and this is not a credentials error, so the lenient `except` in `load` lets it- # through. What may still catch it is the ledger, one level up.- plural = "s" if len(key_split.rejected) > 1 else ""- msg = (- f"Unknown key{plural} on model '{model_spec_name}' for backend '{backend_name}' "- f"from {backend_config_source}: {describe_rejected_keys(rejected=key_split.rejected)}"- )- raise InferenceBackendLibraryError(msg, backend_name=backend_name)- case ModelSpecSource.REMOTE_GATEWAY:- # Version skew, the same judgement `drop_unknown_gateway_defaults` makes for the- # `defaults` block: pruned, and silently — this can run before the log hub is set.- pass+ # Fatal in lenient mode too: leniency covers credentials only (see the docstring),+ # and this is not a credentials error, so the lenient `except` in `load` lets it+ # through. What may still catch it is the ledger, one level up.+ plural = "s" if len(key_split.rejected) > 1 else ""+ msg = (+ f"Unknown key{plural} on model '{model_spec_name}' for backend '{backend_name}' "+ f"from {backend_config_source}: {describe_rejected_keys(rejected=key_split.rejected)}"+ )+ raise InferenceBackendLibraryError(msg, backend_name=backend_name)# Start from the defaults, then override with the model's own fieldsmodel_spec_blueprint_dict = defaults_dict.copy()model_spec_blueprint_dict.update(key_split.fields)@@ -458,7 +383,6 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):*,backend_name: str,backends_dir_path: str,- model_spec_source: ModelSpecSource,backend_blueprint: InferenceBackendBlueprint,substitute_vars_with_provider: Any,) -> RecoveredModelSpecs | None:@@ -469,21 +393,10 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):re-raises the error the file actually produced, which names the key the user can act on,where "migration did not help" would name nothing.- **One file, and only a local one.** The helper deep-merges the paths it is given, which is+ **One file at a time.** The helper deep-merges the paths it is given, which isright for a tier stack and wrong here — backend files are independent documents that share no- keys, so they are replayed one at a time. And a managed gateway backend is left out on purpose:- `GatewayConfigMerger` ignores a local `[defaults]` outright and keeps only `sdk` and- `structure_method` from a per-model override, so a stale key in `pipelex_manifold.toml` is- filtered out before any spec is built and can never be what refused the load. `pipelex- migrate` still repairs that file on disk — the surface claims every `*.toml` in the directory- — but at boot there is nothing there to carry forward.+ keys, so they are replayed one at a time."""- match model_spec_source:- case ModelSpecSource.REMOTE_GATEWAY | ModelSpecSource.PLUGIN:- # A plugin's table is never read from a file, and never retried here: it is built after the load.- return None- case ModelSpecSource.LOCAL_FILE:- passpath_to_model_specs_toml = backend_toml_path(backends_dir_path=backends_dir_path, backend_name=backend_name)replayed = replay_surface_files_in_memory(surface_id=INFERENCE_BACKEND_CONFIG_SURFACE_ID, paths=[path_to_model_specs_toml])if replayed is None:@@ -500,7 +413,6 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):model_specs_dict=migrated_specs_dict,backend_name=backend_name,backend_config_source=backend_config_source,- model_spec_source=model_spec_source,backend_listed_constraints=backend_blueprint.listed_constraints,backend_valued_constraints=backend_blueprint.valued_constraints,)@@ -508,53 +420,6 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):return Nonereturn RecoveredModelSpecs(model_specs=model_specs, plans=replayed.plans)- def _load_gateway_model_specs(- self,- gateway_config: GatewayConfig,- *,- backend_name: str,- backends_dir_path: str,- substitute_vars_with_provider: Any,- ) -> tuple[BackendModelSpecs, str]:- """Load a managed gateway backend's model specs from the remote config.-- Args:- gateway_config: The backend's slice of the fetched artifact.- backend_name: Name the backend library gives this gateway backend.- backends_dir_path: Path to directory containing local override file.- substitute_vars_with_provider: Function to substitute variables.-- Returns:- Model specs dictionary merged from remote and local overrides.-- Raises:- InferenceBackendCredentialsError: If variable substitution fails.- """- # Load local overrides if they exist. The path follows the *backend's own name*, so- # `backends/pipelex_manifold.toml` overrides the manifold backend and no other managed- # backend's models. Built through the shared helper for the reason its docstring gives: a- # backend name is an unvalidated top-level TOML key, and a quoted absolute-path key would- # otherwise escape the backends directory.- path_to_local_overrides = str(backend_toml_path(backends_dir_path=backends_dir_path, backend_name=backend_name))- local_overrides = load_toml_from_path_if_exists(path=path_to_local_overrides) or {}-- # Merge remote config with local overrides- model_specs_dict = GatewayConfigMerger.merge(- gateway_model_specs=drop_unknown_gateway_defaults(gateway_model_specs=gateway_config.model_specs),- local_overrides=local_overrides,- )-- backend_config_source = f"remote config with local overrides from '{path_to_local_overrides}'"- # Apply variable substitution (in case remote config has any variables)- model_specs_dict = self._substitute_model_spec_vars(- model_specs_dict=model_specs_dict,- backend_name=backend_name,- source=backend_config_source,- substitute_vars_with_provider=substitute_vars_with_provider,- )-- return model_specs_dict, backend_config_source-def _load_local_model_specs(self,backend_name: str,@@ -641,7 +506,7 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):def merge_plugin_internal_models(self, *, plugin_model_declarations: PluginModelDeclarations, backends_dir_path: str) -> bool:"""Merge the internal models the plugins declared into the internal backend, or report there is none to merge into.- Each table is built by the path a backend file's tables take, as a `PLUGIN` source: a key the model spec+ Each table is built by the path a backend file's tables take: a key the model specdoes not know is the plugin author's mistake and fatal, as it is in a local file. The table is complete onits own, so the `[defaults]` of `internal.toml` is not applied to it.@@ -684,7 +549,6 @@ class InferenceBackendLibrary(RootModel[InferenceBackendLibraryRoot]):model_specs_dict={model_name: plugin_model.spec},backend_name=PipelexBackend.INTERNAL,backend_config_source=f"plugin '{plugin_model.plugin}'",- model_spec_source=ModelSpecSource.PLUGIN,backend_listed_constraints=internal_backend.listed_constraints,backend_valued_constraints=internal_backend.valued_constraints,)diff --git a/pipelex/cogt/model_backends/gateway_config.py b/pipelex/cogt/model_backends/gateway_config.pydeleted file mode 100644index d31a7b3c8..000000000--- a/pipelex/cogt/model_backends/gateway_config.py+++ /dev/null@@ -1,56 +0,0 @@-import copy-from typing import Any, cast--from pydantic import BaseModel, ConfigDict, Field--from pipelex.cogt.model_backends.model_spec_factory import BackendModelSpecs, InferenceModelSpecBlueprint---class GatewayConfig(BaseModel):- """One managed gateway backend's slice of the fetched artifact.-- There is one of these per declared managed backend, built from that backend's named section of- the single fetched artifact. They are held in a `dict[backend_name, GatewayConfig]` rather than- merged, because two managed services are two services: a handle that one serves and another does- not is a legitimate configuration, not a conflict to resolve.- """-- model_config = ConfigDict(extra="forbid")-- model_specs: BackendModelSpecs = Field(description="Model specifications for this managed gateway (model_name -> spec dict)")---def drop_unknown_gateway_defaults(*, gateway_model_specs: BackendModelSpecs) -> BackendModelSpecs:- """Drop keys the model-spec blueprint no longer knows from the remote config's `defaults` block.-- The gateway config is served by a component that deploys on its own schedule, so a client can- legitimately read a config written by a newer or older release than itself. An unknown key there- is version skew, and dropping it keeps a boot working across that skew; a *local* backend file- stays strict, because there an unknown key really is the author's typo.-- Scoped to `defaults` on purpose. A per-model key gets its own rule in `InferenceBackendLibrary.load`,- via `split_model_spec_keys`: header-shaped keys are outbound request headers, and the rest is pruned- from a remote payload (the same skew judgement as here) or fatal in a local file.-- Deliberately pure, and deliberately silent: it runs on the success path of every gateway-backend- load, including loads that happen before `runtime_hub.set_config()` has configured the log- dispatch. A `log` call here would turn a plain data transform into a boot-order dependency: a line- emitted before the dispatch is configured goes to the stdlib's default handling, where an `info`- is dropped and a warning lands on stderr unformatted, ahead of the console the boot is about to- configure, so a warning about the served payload would read differently depending on when the- load happened to run.- """- known_fields = InferenceModelSpecBlueprint.model_fields.keys()- defaults = gateway_model_specs.get("defaults")- if not isinstance(defaults, dict):- return gateway_model_specs-- unknown_keys = [key for key in cast("dict[str, Any]", defaults) if key not in known_fields]- if not unknown_keys:- return gateway_model_specs-- pruned: BackendModelSpecs = copy.deepcopy(gateway_model_specs)- pruned_defaults = cast("dict[str, Any]", pruned["defaults"])- for unknown_key in unknown_keys:- del pruned_defaults[unknown_key]- return pruneddiff --git a/pipelex/cogt/model_backends/model_spec_keys.py b/pipelex/cogt/model_backends/model_spec_keys.pyindex 31acbf35e..4fe9db97a 100644--- a/pipelex/cogt/model_backends/model_spec_keys.py+++ b/pipelex/cogt/model_backends/model_spec_keys.py@@ -5,8 +5,8 @@ away. Historically every such key was moved to `extra_headers` and sent to the pheader — which is right for `x-portkey-config` and wrong for a typo or a field deleted from the blueprint,both of which then went out on the wire while the real setting stayed unset.-The rule here is a shape rule, not a name allowlist, so the served gateway config can start carrying a-new `x-portkey-*` header without waiting for a client release: **an unknown key is a header only if it+The rule here is a shape rule, not a name allowlist, so a backend file can carry a new provider+header without waiting for a client release: **an unknown key is a header only if itcontains a hyphen and its value is a string.** Header names conventionally do; blueprint field namesnever do, because they are Python identifiers. A hyphenated spelling of a known field (`max-tokens`) isthe one hole that leaves, and it is closed by name. The value half is not coercion: `x-foo = 3` is an@@ -25,9 +25,8 @@ not become "whatever this version of h11 does".This module is deliberately pure and deliberately silent. It runs on the success path of every backendload, including loads that precede `runtime_hub.set_config()`, so a `log` call here would turn a data-transform into a boot-order dependency. It also does not decide what a rejected key *means*: only the-caller knows whether the table came from a local file or a plugin (where a rejected key is the author's-typo, and fatal) or from the served gateway config (where it is version skew, and pruned).+transform into a boot-order dependency. It also does not report a rejected key: the caller does, naming+the file or the plugin the table came from."""import re@@ -44,15 +43,6 @@ _HEADER_NAME_PATTERN = re.compile(r"[!#$%&'*+\-.^_`|~0-9A-Za-z]+")_HEADER_VALUE_PATTERN = re.compile(r"([\x21-\x7e]([ \t\x21-\x7e]*[\x21-\x7e])?)?")-class ModelSpecSource(StrEnum):- """Where a per-model table was read from — the only thing that decides what a rejected key means."""-- LOCAL_FILE = "local_file"- REMOTE_GATEWAY = "remote_gateway"- PLUGIN = "plugin"- """A table a plugin declared with `add_internal_model`, merged into the internal backend at boot."""--class ModelSpecKeyRejection(StrEnum):"""Why an unknown per-model key was not accepted as a request header."""diff --git a/pipelex/cogt/models/model_manager.py b/pipelex/cogt/models/model_manager.pyindex 83f246adc..b772b1702 100644--- a/pipelex/cogt/models/model_manager.py+++ b/pipelex/cogt/models/model_manager.py@@ -6,29 +6,20 @@ from typing_extensions import overridefrom pipelex import logfrom pipelex.cogt.doc_gen.doc_gen_format import parse_doc_gen_choice_key-from pipelex.cogt.exceptions import GatewayUnknownModelError, ModelManagerError, PluginModelDeclarationError-from pipelex.cogt.extract.extract_setting import ExtractSetting-from pipelex.cogt.img_gen.img_gen_setting import ImgGenSetting-from pipelex.cogt.judgment.judgment_setting import JudgmentSetting-from pipelex.cogt.llm.llm_setting import LLMSetting+from pipelex.cogt.exceptions import ModelManagerError, PluginModelDeclarationErrorfrom pipelex.cogt.model_backends.backend import InferenceBackend, PipelexBackendfrom pipelex.cogt.model_backends.backend_library import InferenceBackendLibrary-from pipelex.cogt.model_backends.gateway_config import GatewayConfigfrom pipelex.cogt.model_backends.model_spec import InferenceModelSpecfrom pipelex.cogt.model_backends.model_type import ModelTypefrom pipelex.cogt.model_routing.routing_models import BackendMatchingMethodfrom pipelex.cogt.model_routing.routing_profile import RoutingProfilefrom pipelex.cogt.model_routing.routing_profile_loader import load_active_routing_profile-from pipelex.cogt.models.exceptions import ModelReferenceParseErrorfrom pipelex.cogt.models.model_deck import ModelDeck, ModelDeckBlueprintfrom pipelex.cogt.models.model_deck_loader import load_model_deck_blueprintfrom pipelex.cogt.models.model_manager_abstract import ModelManagerAbstract-from pipelex.cogt.models.model_reference import ModelReference, ModelReferenceKind-from pipelex.cogt.search.search_setting import SearchSettingfrom pipelex.config import get_configfrom pipelex.plugins.plugin_model_declarations import PluginModelDeclarationsfrom pipelex.system.configuration.config_loader import config_manager-from pipelex.system.pipelex_service.types import RemoteConfigSourcefrom pipelex.tools.misc.file_utils import find_files_in_dirfrom pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract@@ -71,8 +62,6 @@ class ModelManager(ModelManagerAbstract):self,*,secrets_provider: SecretsProviderAbstract,- managed_gateway_configs: dict[str, GatewayConfig] | None,- gateway_config_source: RemoteConfigSource | None,plugin_model_declarations: PluginModelDeclarations,needs_inference: bool = True,backends_library_paths: Sequence[Path] | None = None,@@ -89,7 +78,6 @@ class ModelManager(ModelManagerAbstract):secrets_provider=secrets_provider,backends_library_paths=backends_library_paths or config_manager.backends_file_paths(),backends_dir_path=resolved_backends_dir_path,- managed_gateway_configs=managed_gateway_configs,lenient=not needs_inference,)# The loader parks its stale-configuration warning rather than logging it, so that the@@ -98,8 +86,8 @@ class ModelManager(ModelManagerAbstract):# single copy, and by here logging is configured.if (stale_warning := self.inference_backend_library.take_stale_configuration_warning()) is not None:log.warning(stale_warning)- # The plugins' internal models join the internal backend before anything reads the library, so routing, the- # deck and the gateway check below see them exactly as they see a model `internal.toml` declares.+ # The plugins' internal models join the internal backend before anything reads the library, so routing+ # and the deck see them exactly as they see a model `internal.toml` declares.has_internal_backend = self.inference_backend_library.merge_plugin_internal_models(plugin_model_declarations=plugin_model_declarations,backends_dir_path=resolved_backends_dir_path,@@ -119,18 +107,12 @@ class ModelManager(ModelManagerAbstract):)self.model_deck = self.build_deck(enabled_backends=enabled_backends, model_deck_blueprint=deck_blueprint)- self._enforce_gateway_model_membership(- managed_gateway_configs=managed_gateway_configs,- gateway_config_source=gateway_config_source,- enabled_backends=enabled_backends,- )-@classmethoddef _make_plugin_deck_base(cls, *, plugin_model_declarations: PluginModelDeclarations, has_internal_backend: bool) -> dict[str, Any]:"""The model deck document the plugins' defaults make, for the deck files to be merged over.Left out entirely without an internal backend, as the plugins' models are: a default pointing at a model this- boot does not serve is exactly what a live gateway's membership check refuses, and a plugin must not make a+ boot does not serve would fail the deck's validation, and a plugin must not make aboot fail that would succeed without it. The kit's own internal models set the precedent: with the backenddisabled their files' models are not loaded, and nothing a plugin adds changes that.@@ -147,246 +129,6 @@ class ModelManager(ModelManagerAbstract):raise PluginModelDeclarationError(msg, plugin=doc_gen_default.plugin) from excreturn plugin_model_declarations.make_deck_base()- def _enforce_gateway_model_membership(- self,- managed_gateway_configs: dict[str, GatewayConfig] | None,- *,- gateway_config_source: RemoteConfigSource | None,- enabled_backends: list[str],- ) -> None:- """Fail loudly when a handle routed to a managed gateway is absent from that gateway's specs.-- Runs even when ``missing_presets_reaction = "log"`` (the default), because a missing- gateway model is a distinct failure mode from a generic preset mismatch: it means the- active gateway specs (fresh or cached) are out of sync with what the deck author- declared. Surfacing this as ``GatewayUnknownModelError`` lets the agent CLI hint at- cache-refresh remediation when the config was sourced from the on-disk fallback.-- We only fire the check when both the configs and ``gateway_config_source`` are set — that- is, when a managed gateway is actually live in this setup pass.-- **One check per live managed service, run separately — not a union across them.** With two- services the old shape breaks in two directions at once. It was a union membership test- ("is this handle in the deck *or* in the one gateway's specs?"), which with two sections- would pass a handle that neither service can actually serve as long as the *other* one can.- And ``_collect_deck_referenced_handles`` walks the whole deck, so running the old check- separately against both would demand every deck handle appear in *both* sections — which- the mixed profile cannot satisfy and the parked families contradict.-- **The resolution is the routing profile.** Each per-service check validates only the deck- handles the active profile actually routes to that service. A handle legitimately absent- from one section is then not an error, the mixed profile stays expressible, and the case- that matters — the profile routes a handle to a service whose section does not carry it —- still fails loudly at boot.-- Waterfall semantics: a waterfall reference is "known" if AT LEAST ONE of its- fallbacks resolves to a known handle. At runtime the deck walks the list and uses- the first available model (when ``is_model_fallback_enabled`` is true, the default),- so a deck like ``["future-model", "current-model"]`` is perfectly valid as long as- ``current-model`` is in the gateway specs.- """- if not managed_gateway_configs or gateway_config_source is None:- return- deck = self.get_model_deck()- referenced_handles = self._collect_deck_referenced_handles(deck)-- for backend_name, gateway_config in managed_gateway_configs.items():- gateway_spec_names = {name for name in gateway_config.model_specs if name != "defaults"}- for handle, model_type in referenced_handles:- try:- ref = ModelReference.parse(handle)- except ModelReferenceParseError:- continue- candidates = self._resolve_terminal_candidates(deck=deck, ref=ref, model_type=model_type)- # Only the candidates this service is responsible for. A candidate the profile sends- # to a BYOK backend, to the internal one, or to the *other* managed service is not- # this check's business; the generic missing-handle path covers those.- routed_here = [- candidate- for candidate in candidates- if self._routes_to_backend(candidate=candidate, backend_name=backend_name, enabled_backends=enabled_backends)- ]- if not routed_here:- continue- # ``deck.inference_models`` is consulted over the WHOLE candidate list, not just the- # part routed here, and the difference is load-bearing. That map is built by routing- # every handle through the active profile and keeping the ones whose matched backend- # has a spec, so membership in it already means "resolvable under this profile",- # whichever backend serves it — which is exactly what ``_resolve_waterfall`` walks at- # runtime. Narrowing this half to ``routed_here`` would refuse a waterfall whose- # working fallback lives on another backend, and the runtime would have served it.- if any(candidate in deck.inference_models for candidate in candidates):- continue- # The section lookup, by contrast, is only about what THIS service carries.- if any(candidate in gateway_spec_names for candidate in routed_here):- continue- # No candidate resolves to a known handle. Report the first one — it's the- # primary the user is asking for; subsequent entries are fallbacks.- raise GatewayUnknownModelError(model_name=routed_here[0], backend_name=backend_name, source=gateway_config_source)-- def _routes_to_backend(self, *, candidate: str, backend_name: str, enabled_backends: list[str]) -> bool:- """Whether the active routing profile sends this handle to this backend."""- backend_match = self.routing_profile.get_backend_match_for_model(- enabled_backends=enabled_backends,- model_name=candidate,- )- return backend_match is not None and backend_match.backend_name == backend_name-- @classmethod- def _collect_deck_referenced_handles(cls, deck: ModelDeck) -> list[tuple[str, ModelType]]:- """Gather the (handle, model_type) pairs that the deck advertises as usable.-- Covers presets and choice defaults across every model type a managed gateway can serve.- Aliases and waterfalls are intentionally NOT enumerated directly — they are reachable via- preset/choice references, and the resolver walks through them. Including them here would- force the check on dangling helpers the user has not actively wired into a preset.-- Document engines (``doc_gen``) are left out: they are software on the host, which no- gateway serves, and a step whose engine is undeclared is refused at load naming the engine- and the fix, where a gateway error at boot would stop every method and blame the gateway.- """- references: list[tuple[str, ModelType]] = []- for llm_setting in deck.llm_presets.values():- references.append((llm_setting.model, ModelType.LLM))- llm_text_handle = cls._extract_choice_handle(deck.llm_choice_defaults.for_text)- if llm_text_handle is not None:- references.append((llm_text_handle, ModelType.LLM))- llm_object_handle = cls._extract_choice_handle(deck.llm_choice_defaults.for_object)- if llm_object_handle is not None:- references.append((llm_object_handle, ModelType.LLM))- for extract_setting in deck.extract_presets.values():- references.append((extract_setting.model, ModelType.TEXT_EXTRACTOR))- extract_default_handle = cls._extract_choice_handle(deck.extract_choice_default)- if extract_default_handle is not None:- references.append((extract_default_handle, ModelType.TEXT_EXTRACTOR))- for img_gen_setting in deck.img_gen_presets.values():- references.append((img_gen_setting.model, ModelType.IMG_GEN))- img_gen_default_handle = cls._extract_choice_handle(deck.img_gen_choice_default)- if img_gen_default_handle is not None:- references.append((img_gen_default_handle, ModelType.IMG_GEN))- for search_setting in deck.search_presets.values():- references.append((search_setting.model, ModelType.SEARCH))- search_default_handle = cls._extract_choice_handle(deck.search_choice_default)- if search_default_handle is not None:- references.append((search_default_handle, ModelType.SEARCH))- for judgment_setting in deck.judgment_presets.values():- references.append((judgment_setting.model, ModelType.JUDGMENT))- judgment_default_handle = cls._extract_choice_handle(deck.judgment_choice_default)- if judgment_default_handle is not None:- references.append((judgment_default_handle, ModelType.JUDGMENT))- return references-- @classmethod- def _extract_choice_handle(- cls,- choice: LLMSetting | ExtractSetting | ImgGenSetting | SearchSetting | JudgmentSetting | ModelReference | str | None,- ) -> str | None:- """Normalise a ``*ModelChoice`` union (LLMModelChoice etc.) to a raw handle string.-- Choice defaults can be a typed setting object, a parsed ``ModelReference``, or a raw- string — all three paths point at a handle we need to validate.- """- if choice is None:- return None- if isinstance(choice, str):- return choice- if isinstance(choice, ModelReference):- return choice.raw- return choice.model-- @classmethod- def _resolve_terminal_candidates(cls, *, deck: ModelDeck, ref: ModelReference, model_type: ModelType) -> list[str]:- """Return every terminal handle reachable from ``ref`` via aliases/waterfalls.-- For ``HANDLE`` references: returns ``[name]`` (bare strings are HANDLEs by design —- see ``ModelReference.parse`` for the BREAKING CHANGE note).-- For ``ALIAS`` references: follows the alias target. Cycles return ``[]``.-- For ``WATERFALL`` references: follows EVERY fallback in order (or only the first- when ``model_deck_config.is_model_fallback_enabled`` is false, matching runtime- behaviour at ``model_deck._get_optional_inference_model_with_fallback``). Cycles- across either alias or waterfall keys return ``[]`` for the cycling branch but do- not poison the rest of the candidate list.-- For ``PRESET`` references: returns ``[]`` (presets are not handles).- """- aliases, waterfalls = deck.get_aliases_and_waterfalls_for_type(model_type)- is_fallback_enabled = deck.model_deck_config.is_model_fallback_enabled- return cls._collect_candidates(- ref=ref,- aliases=aliases,- waterfalls=waterfalls,- is_fallback_enabled=is_fallback_enabled,- visited=set(),- )-- @classmethod- def _collect_candidates(- cls,- ref: ModelReference,- *,- aliases: dict[str, str],- waterfalls: dict[str, list[str]],- is_fallback_enabled: bool,- visited: set[tuple[ModelReferenceKind, str]],- ) -> list[str]:- # Cycle key is (kind, name): an alias and a waterfall can share a name yet be distinct nodes.- visit_key: tuple[ModelReferenceKind, str]- match ref.kind:- case ModelReferenceKind.HANDLE:- return [ref.name]- case ModelReferenceKind.ALIAS:- visit_key = (ref.kind, ref.name)- if visit_key in visited:- return []- visited.add(visit_key)- target = aliases.get(ref.name)- if target is None:- return [ref.name]- try:- next_ref = ModelReference.parse(target)- except ModelReferenceParseError:- return []- return cls._collect_candidates(- ref=next_ref,- aliases=aliases,- waterfalls=waterfalls,- is_fallback_enabled=is_fallback_enabled,- visited=visited,- )- case ModelReferenceKind.WATERFALL:- visit_key = (ref.kind, ref.name)- if visit_key in visited:- return []- visited.add(visit_key)- fallback_list = waterfalls.get(ref.name)- if not fallback_list:- return [ref.name]- # Runtime only tries the first fallback when fallback is disabled; mirror- # that here so the membership check stays consistent with what actually runs.- entries = fallback_list if is_fallback_enabled else fallback_list[:1]- candidates: list[str] = []- for entry in entries:- try:- next_ref = ModelReference.parse(entry)- except ModelReferenceParseError:- continue- # Fresh visited set per branch so two waterfall entries that legitimately- # share an alias don't kill the second one.- candidates.extend(- cls._collect_candidates(- ref=next_ref,- aliases=aliases,- waterfalls=waterfalls,- is_fallback_enabled=is_fallback_enabled,- visited=set(visited),- )- )- return candidates- case ModelReferenceKind.PRESET:- return []-@overridedef validate_model_deck(self):self.get_model_deck().validate_registered_models()diff --git a/pipelex/cogt/models/model_manager_abstract.py b/pipelex/cogt/models/model_manager_abstract.pyindex abd392cb6..7db74b1b0 100644--- a/pipelex/cogt/models/model_manager_abstract.py+++ b/pipelex/cogt/models/model_manager_abstract.py@@ -1,12 +1,10 @@from abc import ABC, abstractmethodfrom pipelex.cogt.model_backends.backend import InferenceBackend-from pipelex.cogt.model_backends.gateway_config import GatewayConfigfrom pipelex.cogt.model_backends.model_spec import InferenceModelSpecfrom pipelex.cogt.model_backends.model_type import ModelTypefrom pipelex.cogt.models.model_deck import ModelDeckfrom pipelex.plugins.plugin_model_declarations import PluginModelDeclarations-from pipelex.system.pipelex_service.types import RemoteConfigSourcefrom pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract@@ -24,8 +22,6 @@ class ModelManagerAbstract(ABC):self,*,secrets_provider: SecretsProviderAbstract,- managed_gateway_configs: dict[str, GatewayConfig] | None,- gateway_config_source: RemoteConfigSource | None,plugin_model_declarations: PluginModelDeclarations,needs_inference: bool = True,) -> None:diff --git a/pipelex/kit/configs/inference/backends.toml b/pipelex/kit/configs/inference/backends.tomlindex 340269560..3c271f595 100644--- a/pipelex/kit/configs/inference/backends.toml+++ b/pipelex/kit/configs/inference/backends.toml@@ -10,15 +10,6 @@#####################################################################################################-# Pipelex Manifold is a closed private beta: leave it off unless you have been invited.-[pipelex_manifold]-display_name = "Pipelex Manifold (private beta)"-enabled = false-endpoint = "${PIPELEX_MANIFOLD_ENDPOINT}"-api_key = "${PIPELEX_MANIFOLD_API_KEY}"-model_specs_section = "manifold_model_specs"-auth_header = "x-pipelex-api-key"-[anthropic]enabled = trueapi_key = "${ANTHROPIC_API_KEY}"diff --git a/pipelex/kit/configs/inference/backends/pipelex_manifold.toml b/pipelex/kit/configs/inference/backends/pipelex_manifold.tomldeleted file mode 100644index d2130ec85..000000000--- a/pipelex/kit/configs/inference/backends/pipelex_manifold.toml+++ /dev/null@@ -1,51 +0,0 @@-################################################################################-# Pipelex Manifold Local Overrides-################################################################################-#-# PRIVATE BETA:-#-# Pipelex Manifold is the Pipelex-operated inference service. It is in private-# beta, it ships disabled in backends.toml, and this file does nothing until you-# enable it there and set PIPELEX_MANIFOLD_ENDPOINT and PIPELEX_MANIFOLD_API_KEY.-#-################################################################################-#-# TELEMETRY NOTICE:-#-# This backend sends no telemetry from your machine: the runtime's only-# telemetry stream is the one you configure yourself in telemetry.toml.-# Manifold is a Pipelex-operated service, though, so your usage of it is-# recorded server-side the way any hosted platform records the calls it serves.-#-# We collect only technical data (model names, token counts, latency, error-# rates). We do NOT collect prompts, completions, pipe codes, or business data.-#-# This allows us to monitor service quality, enforce fair usage, and support you.-#-################################################################################-#-# WARNING: USE AT YOUR OWN RISK!-#-# The actual model configuration is fetched remotely from Pipelex servers.-# Any override in this file may cause unexpected behavior or failures,-# as the remote configuration may change at any time.-#-# If you must override, you may ONLY use these keys per model:-# - sdk-# - structure_method-#-# All other keys will be ignored.-#-# If you need custom configurations, consider using your own API keys-# with direct provider backends (openai, anthropic, etc.) instead.-#-# Documentation:-# https://docs.pipelex.com/latest/configuration/config-technical/inference-backend-config/-# Support: https://go.pipelex.com/discord-#-################################################################################--# Per-model overrides example:-# [gpt-4o]-# sdk = "manifold_completions"-# structure_method = "instructor/openai_tools"diff --git a/pipelex/kit/configs/inference/deck/3_extract_deck.toml b/pipelex/kit/configs/inference/deck/3_extract_deck.tomlindex c5e474a91..daf2de5e4 100644--- a/pipelex/kit/configs/inference/deck/3_extract_deck.toml+++ b/pipelex/kit/configs/inference/deck/3_extract_deck.toml@@ -42,17 +42,13 @@ default-extract-web-page = "linkup-fetch"# Waterfalls#####################################################################################################-# Each default resolves to the first entry an enabled backend serves: Azure Document Intelligence-# through Pipelex Manifold, then Mistral OCR with your own Mistral key. Documents fall back last to-# reading a PDF's text layer locally, which needs no key but recovers no text from a scanned page.+# Each default resolves to the first entry an enabled backend serves: Mistral OCR with your own+# Mistral key. Documents fall back to reading a PDF's text layer locally, which needs no key but+# recovers no text from a scanned page.[extract.waterfalls]-document-extractor = [- "azure-document-intelligence",- "mistral-ocr",- "pypdfium2-extract-pdf",-]-ocr-extractor = ["azure-document-intelligence", "mistral-ocr"]+document-extractor = ["mistral-ocr", "pypdfium2-extract-pdf"]+ocr-extractor = ["mistral-ocr"]##################################################################################################### Extract Presetsdiff --git a/pipelex/kit/configs/inference/deck/x_custom_extract_deck.toml b/pipelex/kit/configs/inference/deck/x_custom_extract_deck.tomlindex 5d4c46442..53304842c 100644--- a/pipelex/kit/configs/inference/deck/x_custom_extract_deck.toml+++ b/pipelex/kit/configs/inference/deck/x_custom_extract_deck.toml@@ -27,14 +27,10 @@# Example (uncomment to use):# [extract.waterfalls]-# document_extractor = ["azure-document-intelligence", "mistral-document-ai-2505"]+# document_extractor = ["mistral-document-ai-2505", "pypdfium2-extract-pdf"]# pdf_text_extractor = [-# "azure-document-intelligence",# "mistral-document-ai-2505",# "pypdfium2-extract-pdf",# ]-# image_text_extractor = [-# "azure-document-intelligence",-# "mistral-document-ai-2505",-# ]+# image_text_extractor = ["mistral-document-ai-2505"]####################################################################################################diff --git a/pipelex/kit/configs/inference/routing_profiles.toml b/pipelex/kit/configs/inference/routing_profiles.tomlindex c11082327..00272c799 100644--- a/pipelex/kit/configs/inference/routing_profiles.toml+++ b/pipelex/kit/configs/inference/routing_profiles.toml@@ -45,7 +45,6 @@ fallback_order = ["scaleway","ollama","vertexai",- "pipelex_manifold",]# Judgment models are served by their own backend alone, so they go to it whenever it is enabled.@@ -53,17 +52,6 @@ fallback_order = [[profiles.all_enabled_backends.optional_routes]"jev-*" = "typesafe"-# The Pipelex-operated inference service (private beta). A model's wire id and sdk are per-backend,-# so decks, aliases and presets keep naming the same handles whichever profile is active.-[profiles.all_pipelex_manifold]-description = "Use Pipelex Manifold (private beta) for all its supported models"-default = "pipelex_manifold"--# Judgment models are brought by you rather than served by Pipelex, so they go to their own backend-# whenever it is enabled. An optional route is inert while its backend is disabled.-[profiles.all_pipelex_manifold.optional_routes]-"jev-*" = "typesafe"-[profiles.all_anthropic]description = "Use Anthropic backend for all its supported models"default = "anthropic"diff --git a/pipelex/kit/configs/pipelex_service.toml b/pipelex/kit/configs/pipelex_service.tomldeleted file mode 100644index e08cfd6fb..000000000--- a/pipelex/kit/configs/pipelex_service.toml+++ /dev/null@@ -1,14 +0,0 @@-####################################################################################################-# Pipelex Service Configuration-####################################################################################################-#-# This file records the state of your Pipelex setup on this machine.-#-# Documentation: https://docs.pipelex.com-# Support: https://go.pipelex.com/discord-#-####################################################################################################--[onboarding]-# Set to true after completing inference setup.-inference_setup_completed = falsediff --git a/pipelex/kit/deck_variants/multi_provider/3_extract_deck.toml b/pipelex/kit/deck_variants/multi_provider/3_extract_deck.tomlindex c5e474a91..daf2de5e4 100644--- a/pipelex/kit/deck_variants/multi_provider/3_extract_deck.toml+++ b/pipelex/kit/deck_variants/multi_provider/3_extract_deck.toml@@ -42,17 +42,13 @@ default-extract-web-page = "linkup-fetch"# Waterfalls#####################################################################################################-# Each default resolves to the first entry an enabled backend serves: Azure Document Intelligence-# through Pipelex Manifold, then Mistral OCR with your own Mistral key. Documents fall back last to-# reading a PDF's text layer locally, which needs no key but recovers no text from a scanned page.+# Each default resolves to the first entry an enabled backend serves: Mistral OCR with your own+# Mistral key. Documents fall back to reading a PDF's text layer locally, which needs no key but+# recovers no text from a scanned page.[extract.waterfalls]-document-extractor = [- "azure-document-intelligence",- "mistral-ocr",- "pypdfium2-extract-pdf",-]-ocr-extractor = ["azure-document-intelligence", "mistral-ocr"]+document-extractor = ["mistral-ocr", "pypdfium2-extract-pdf"]+ocr-extractor = ["mistral-ocr"]##################################################################################################### Extract Presetsdiff --git a/pipelex/kit/paths.py b/pipelex/kit/paths.pyindex 9588dbe12..efba84380 100644--- a/pipelex/kit/paths.py+++ b/pipelex/kit/paths.py@@ -3,7 +3,7 @@ from importlib.resources.abc import Traversable# Git-ignored config files that should not be synced between .pipelex and kit/configs.# These are personal override files that differ per developer/environment:-# - pipelex_service.toml: Contains the onboarding state of this machine (False for new users, True for devs)+# - pipelex_service.toml: retired, written by earlier releases; a developer's checkout may still hold one# - pipelex_override.toml: Personal config overrides# - telemetry_override.toml: Personal telemetry settings# - inference/backends_override.toml, inference/routing_profiles_override.toml: personaldiff --git a/pipelex/migration/gitignore.py b/pipelex/migration/gitignore.pyindex 9ee5247d8..b5be30aa8 100644--- a/pipelex/migration/gitignore.py+++ b/pipelex/migration/gitignore.py@@ -75,7 +75,7 @@ of it: a developer's own choices (their observability, the backend they run on)project's defaults ship as the project wrote them. The two inference overrides are named with theirsubdirectory, because a rule with a slash in it is anchored to this directory rather than matched atany depth. What is *not* here: `pipelex_local.toml` and the `pipelex_{{environment}}.toml` tier, which-are part of a project's tracked configuration, and `pipelex_service.toml`, which is not an override.+are part of a project's tracked configuration."""_GITIGNORE_CONTENT = f"""\diff --git a/pipelex/migration/goldens/pipelex-service-config/[email protected] b/pipelex/migration/goldens/pipelex-service-config/[email protected]deleted file mode 100644index 6d05c4fd3..000000000--- a/pipelex/migration/goldens/pipelex-service-config/[email protected]+++ /dev/null@@ -1,5 +0,0 @@-[agreement]-terms_accepted = false--[onboarding]-inference_setup_completed = falsediff --git a/pipelex/migration/goldens/pipelex-service-config/[email protected] b/pipelex/migration/goldens/pipelex-service-config/[email protected]deleted file mode 100644index 5a65cc004..000000000--- a/pipelex/migration/goldens/pipelex-service-config/[email protected]+++ /dev/null@@ -1,2 +0,0 @@-[onboarding]-inference_setup_completed = falsediff --git a/pipelex/migration/goldens/pipelex-service-config/[email protected] b/pipelex/migration/goldens/pipelex-service-config/[email protected]deleted file mode 100644index d5305e923..000000000--- a/pipelex/migration/goldens/pipelex-service-config/[email protected]+++ /dev/null@@ -1,29 +0,0 @@-{- "surface_id": "pipelex-service-config",- "schema_version": 1,- "document_root_is_open": false,- "paths": {- "agreement": {- "value_type": "table",- "required": false,- "open_node": false- },- "agreement.terms_accepted": {- "value_type": "bool",- "required": false,- "default": false,- "open_node": false- },- "onboarding": {- "value_type": "table",- "required": false,- "open_node": false- },- "onboarding.inference_setup_completed": {- "value_type": "bool",- "required": false,- "default": false,- "open_node": false- }- }-}diff --git a/pipelex/migration/goldens/pipelex-service-config/[email protected] b/pipelex/migration/goldens/pipelex-service-config/[email protected]deleted file mode 100644index eddf68cc0..000000000--- a/pipelex/migration/goldens/pipelex-service-config/[email protected]+++ /dev/null@@ -1,18 +0,0 @@-{- "surface_id": "pipelex-service-config",- "schema_version": 2,- "document_root_is_open": false,- "paths": {- "onboarding": {- "value_type": "table",- "required": false,- "open_node": false- },- "onboarding.inference_setup_completed": {- "value_type": "bool",- "required": false,- "default": false,- "open_node": false- }- }-}diff --git a/pipelex/migration/ledgers/pipelex-service-config.toml b/pipelex/migration/ledgers/pipelex-service-config.tomldeleted file mode 100644index 82f7f9be2..000000000--- a/pipelex/migration/ledgers/pipelex-service-config.toml+++ /dev/null@@ -1,34 +0,0 @@-# The migration ledger for the Pipelex service onboarding state.-#-# This surface has no tier files: there is one `pipelex_service.toml` per configuration directory-# and nothing layers over it.-#-# See docs/migration-ledger.md for the contract this file obeys.--[surface]-id = "pipelex-service-config"-title = "Pipelex service onboarding state"-base_file = "pipelex_service.toml"-current_schema_version = 2-min_supported_schema_version = 0--[[migration]]-id = "pipelex-service-config@2"-to_schema_version = 2-introduced_in = "0.73.0"-breaking = true-safety = "safe"-title = "Drop the [agreement] section with the Pipelex Gateway"-description = """-The Pipelex Gateway backend left the runtime, and with it the terms of service a user accepted to \-use it. `[agreement]` recorded that acceptance and nothing reads it any more, so a file written \-by an earlier release loses the section; `[onboarding]` is untouched.-"""-guidance = """-Nothing to decide: the terms of service belonged to the Pipelex Gateway backend, which no longer-exists in the runtime. Your inference setup state under `[onboarding]` is kept as it was.-"""--[[migration.ops]]-kind = "delete_table"-table_path = ["agreement"]diff --git a/pipelex/migration/run.py b/pipelex/migration/run.pyindex b5f6e5290..4be02ad5f 100644--- a/pipelex/migration/run.py+++ b/pipelex/migration/run.py@@ -22,7 +22,7 @@ user would be told one thing by their boot and another by their tool.> `inference/deck/` — is never entered at all.>> **A file is claimed by the pair (directory, name), never by its name alone.**-> `.pipelex/inference/backends/pipelex_manifold.toml` is the specimen: its name matches the+> A backend file named `.pipelex/inference/backends/pipelex_<name>.toml` is the specimen: its name matches the> `pipelex-config` tier glob `pipelex_*.toml` exactly, and the directory it sits in is what says> it belongs to `inference-backend` instead. Depth used to be what protected it, back when no> surface owned a subdirectory; now the claim rule is.@@ -112,8 +112,8 @@ def scan_config_surface(*, surface_id: str, config_dirs: list[Path] | None = NonThe scoping is a filter on the *answer*, and the full registry still decides which surfaceowns which file — see `migrate_directories`. Handing it a one-surface registry instead looks- equivalent and is not: `pipelex_service.toml` is another surface's base file *and* a match for- `pipelex-config`'s `pipelex_*.toml`, and with that other surface absent the glob wins.+ equivalent and is not: arbitration between surfaces — exact base files before globs, retired+ file names claimed by none — needs every surface in the registry to decide.Args:surface_id: The surface to answer for.diff --git a/pipelex/migration/runner.py b/pipelex/migration/runner.pyindex 4c9ad53ee..d89ce732e 100644--- a/pipelex/migration/runner.py+++ b/pipelex/migration/runner.py@@ -311,8 +311,8 @@ def migrate_directories(particular model's refusal rather than migrating the machine. **It narrows the result, not theregistry, and that distinction is the whole point**: which surface owns a file is decidedacross *all* of them — an exact base file claims before any glob — so a registry holding one- surface would hand `pipelex_service.toml` to `pipelex-config`'s `pipelex_*.toml` and replay- the wrong ledger over it. Arbitration first, then the filter.+ surface could hand another surface's base file to its glob and replay the wrong ledger over+ it. Arbitration first, then the filter."""stamp = moment if moment is not None else datetime.now(UTC)plans: list[MigrationPlan] = []diff --git a/pipelex/migration/surfaces.py b/pipelex/migration/surfaces.pyindex 068e99cde..81ce55a0f 100644--- a/pipelex/migration/surfaces.py+++ b/pipelex/migration/surfaces.py@@ -33,17 +33,20 @@ from pipelex.system.configuration.config_loader import BACKENDS_DIR_NAME, CONFIGfrom pipelex.system.configuration.config_surface import (INFERENCE_BACKEND_CONFIG_SURFACE_ID,PIPELEX_CONFIG_SURFACE_ID,- PIPELEX_SERVICE_CONFIG_SURFACE_ID,TELEMETRY_CONFIG_SURFACE_ID,)from pipelex.system.configuration.configs import PipelexConfig-from pipelex.system.pipelex_service.pipelex_service_config import PipelexServiceConfig-from pipelex.system.pipelex_service.pipelex_service_onboarding import PIPELEX_SERVICE_CONFIG_FILE_NAMEfrom pipelex.system.telemetry.telemetry_config import TELEMETRY_CONFIG_FILE_NAME, TelemetryConfigfrom pipelex.tools.misc.toml_utils import load_toml_from_pathPIPELEX_CONFIG_FILE_NAME = "pipelex.toml"+# Files an earlier release wrote into a configuration directory that no surface owns any more. An+# installation may still hold one, and it is inert: nothing reads it. It is claimed by no surface,+# which matters because a retired name can still match a live surface's glob — `pipelex_service.toml`+# is a `pipelex_*.toml` — and that surface's ledger must not be replayed over a document it never saw.+RETIRED_CONFIG_FILE_NAMES: frozenset[str] = frozenset({"pipelex_service.toml"})+# The package directory, `pipelex/` — this module sits one level under it._PACKAGE_ROOT = Path(__file__).resolve().parent.parent_KIT_CONFIGS_DIR = _PACKAGE_ROOT / "kit" / "configs"@@ -132,7 +135,7 @@ class Surface(BaseModel):Empty for a surface that lives directly in `~/.pipelex/` or `.pipelex/`. A surface that owns asubdirectory owns it *one level deep and to the exclusion of every other surface*, which is- what makes `inference/backends/pipelex_manifold.toml` safe: its name matches the main+ what makes a backend file named `inference/backends/pipelex_<name>.toml` safe: its name matches the mainconfiguration's tier glob exactly, and only the directory it sits in says it is not a`pipelex.toml` tier file."""@@ -469,11 +472,11 @@ class SurfaceRegistry(BaseModel):> **A file is claimed by the pair (directory, name).** Only the surfaces that own the> directory the file sits in are candidates; among those, exact filenames claim before- > globs.+ > globs. A retired file name directly in a configuration directory is claimed by none.- Both halves are load-bearing and each answers a real collision. Without the *name* rule,- `pipelex_service.toml` is both the base file of one surface and a match for another's- `pipelex_*.toml`. Without the *directory* rule, `inference/backends/pipelex_manifold.toml`+ Each rule answers a real collision. Without the *retired* rule, `pipelex_service.toml` — a+ file earlier releases wrote and nothing reads any more — is a match for `pipelex_*.toml`.+ Without the *directory* rule, a backend file named `inference/backends/pipelex_<name>.toml`is a `pipelex_*.toml` match too — and it is an inference backend definition, so the mainconfiguration's ledger would be replayed over it and rewrite it.@@ -489,6 +492,8 @@ class SurfaceRegistry(BaseModel):contract's *a file claimed by two globs is a registry error* becomes enforceable,by name, on the file that proves it."""+ if subdirectory == Path() and file_name in RETIRED_CONFIG_FILE_NAMES:+ return Nonecandidates = [surface for surface in self.surfaces if surface.subdirectory == subdirectory]for surface in candidates:if surface.base_file == file_name:@@ -578,14 +583,6 @@ def build_config_surface_registry() -> SurfaceRegistry:defaults_layer_kind=DefaultsLayerKind.MODEL_DEFAULTS,kit_template_path=_KIT_CONFIGS_DIR / TELEMETRY_CONFIG_FILE_NAME,),- Surface(- surface_id=PIPELEX_SERVICE_CONFIG_SURFACE_ID,- title="Pipelex service agreement and onboarding state",- base_file=PIPELEX_SERVICE_CONFIG_FILE_NAME,- config_model=PipelexServiceConfig,- defaults_layer_kind=DefaultsLayerKind.MODEL_DEFAULTS,- kit_template_path=_KIT_CONFIGS_DIR / PIPELEX_SERVICE_CONFIG_FILE_NAME,- ),# **Every `*.toml` directly in `inference/backends/`, and nothing else.**## Not `inference/backends.toml`: it sits one level up, it is a different documentdiff --git a/pipelex/pipelex.py b/pipelex/pipelex.pyindex 51d336b56..c6512c6ae 100644--- a/pipelex/pipelex.py+++ b/pipelex/pipelex.py@@ -85,7 +85,6 @@ class Pipelex(RuntimeBoot):integration_mode: IntegrationMode,needs_inference: bool = True,boot_orchestrator: str | None = None,- needs_model_specs: bool | None = None,class_registry: ClassRegistryAbstract | None = None,secrets_provider: SecretsProviderAbstract | None = None,storage_provider: StorageProviderAbstract | None = None,@@ -115,7 +114,6 @@ class Pipelex(RuntimeBoot):integration_mode=integration_mode,needs_inference=needs_inference,boot_orchestrator=boot_orchestrator,- needs_model_specs=needs_model_specs,builtin_plugins=BUILTIN_PLUGINS,core_unconditional_plugin_names=CORE_UNCONDITIONAL_PLUGIN_NAMES,entry_point_groups=ENTRY_POINT_GROUPS,@@ -235,7 +233,6 @@ class Pipelex(RuntimeBoot):integration_mode: IntegrationMode = IntegrationMode.PYTHON,needs_inference: bool = True,boot_orchestrator: str | None = None,- needs_model_specs: bool | None = None,class_registry: ClassRegistryAbstract | None = None,secrets_provider: SecretsProviderAbstract | None = None,storage_provider: StorageProviderAbstract | None = None,@@ -265,17 +262,14 @@ class Pipelex(RuntimeBoot):needs_inference: When False, forces every run THIS process initiates to DRY mode(applied at runtime_hub.resolve_run_mode_for_boot, which every run-params factorycalls: operators dispatch normally and the cogt leaf mocks) and loads backends leniently- (skipping those with missing credentials). This skips the remote config fetch and model- deck validation. Useful for commands like validate/show that don't call inference- APIs. Generator selection stays backend-keyed. Submitter-side contract only: it does- not constrain work this process executes as a Temporal worker.+ (skipping those with missing credentials). This skips model deck validation. Useful for+ commands like validate/show that don't call inference APIs. Generator selection stays+ backend-keyed. Submitter-side contract only: it does not constrain work this process+ executes as a Temporal worker.boot_orchestrator: When provided, boots this process under the orchestrator pluginof this name (e.g. "temporal" to run pipes through the Temporal worker runtime).Any other value (or None) leaves execution in-process. Core names no orchestrator;the matching plugin gates on its own name.- needs_model_specs: When True, load real model specs even if needs_inference- is False. When None (default), follows needs_inference. Useful for validate- commands that need the managed gateways' model specs without enabling full inference.class_registry: Custom class registry for dynamic loadingsecrets_provider: Custom secrets/credentials providerstorage_provider: Custom storage backend@@ -324,7 +318,6 @@ class Pipelex(RuntimeBoot):integration_mode=integration_mode,needs_inference=needs_inference,boot_orchestrator=boot_orchestrator,- needs_model_specs=needs_model_specs,class_registry=class_registry,secrets_provider=secrets_provider,storage_provider=storage_provider,diff --git a/pipelex/runtime_boot.py b/pipelex/runtime_boot.pyindex 83c1b52b7..422de6618 100644--- a/pipelex/runtime_boot.py+++ b/pipelex/runtime_boot.py@@ -35,7 +35,6 @@ orchestration-venue sense and keeps the word for good."""import types-import warningsfrom collections.abc import Callablefrom enum import StrEnumfrom pathlib import Path@@ -97,10 +96,6 @@ from pipelex.system.configuration.config_loader import CONFIG_REFUSED, config_mafrom pipelex.system.configuration.config_root import ConfigRootfrom pipelex.system.configuration.config_surface import INFERENCE_BACKEND_CONFIG_SURFACE_ID, PIPELEX_CONFIG_SURFACE_IDfrom pipelex.system.configuration.configs import PipelexConfig-from pipelex.system.pipelex_service.exceptions import RemoteConfigStaleWarning-from pipelex.system.pipelex_service.managed_gateway_configs import build_managed_gateway_configs-from pipelex.system.pipelex_service.pipelex_service_config import enabled_managed_gateway_sections-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcherfrom pipelex.system.registries.class_registry_access import class_registry_scopingfrom pipelex.system.registries.func_registry import FuncRegistry, func_registryfrom pipelex.system.registries.singleton import MetaSingleton@@ -125,11 +120,8 @@ from pipelex.urls import URLsif TYPE_CHECKING:from collections.abc import Sequence- from pipelex.cogt.model_backends.gateway_config import GatewayConfigfrom pipelex.plugins.contract import PipelexPluginfrom pipelex.plugins.plugin_group import PluginGroup- from pipelex.system.pipelex_service.remote_config import RemoteConfig- from pipelex.system.pipelex_service.types import RemoteConfigSourcePACKAGE_NAME, PACKAGE_VERSION = get_package_info()@@ -341,7 +333,6 @@ If you need help, drop by our Discord: we're happy to assist: {URLs.discord}.integration_mode: IntegrationMode,needs_inference: bool = True,boot_orchestrator: str | None = None,- needs_model_specs: bool | None = None,builtin_plugins: "Sequence[PipelexPlugin] | None" = None,core_unconditional_plugin_names: frozenset[str] | None = None,entry_point_groups: "Sequence[PluginGroup] | None" = None,@@ -373,66 +364,10 @@ If you need help, drop by our Discord: we're happy to assist: {URLs.discord}.msg = f"The base setup method does not support any additional arguments: {kwargs}"raise PipelexSetupError(msg)- # --- Pipelex Service and Telemetry ---------------------------------------------------- # Which Pipelex-managed gateway backends are enabled, and which section of the published- # artifact each takes its model specs from.- try:- managed_gateway_sections = enabled_managed_gateway_sections()- except BACKEND_LIBRARY_REFUSED as backends_document_exc:- # The document is read here before the library loads it: a file that does not parse- # is the library's refusal, and it gets the library's message.- msg = self._get_validation_error_msg(component=BootComponent.INFERENCE_BACKEND_LIBRARY, validation_exc=backends_document_exc)- raise PipelexSetupError(msg) from backends_document_exc- is_pipelex_service_enabled = bool(managed_gateway_sections)-- effective_needs_model_specs = needs_model_specs if needs_model_specs is not None else needs_inference-- remote_config: RemoteConfig | None = None- managed_gateway_configs: dict[str, GatewayConfig] | None = None- gateway_config_source: RemoteConfigSource | None = None- if is_pipelex_service_enabled:- if not effective_needs_model_specs:- # Use dummy config when inference is not needed (for testing without network access)- remote_config = RemoteConfigFetcher.make_dummy_remote_config()- managed_gateway_configs = build_managed_gateway_configs(- remote_config=remote_config,- managed_gateway_sections=managed_gateway_sections,- )- # Keep ``gateway_config_source`` as ``None``: the dummy specs are an empty- # placeholder, not real Gateway data. ``ModelManager._enforce_gateway_model_membership``- # treats ``source is None`` as "nothing to validate against," so the membership- # check is skipped on this path — which is what we want for read-only flows like- # ``pipelex-agent models`` without ``--backend``.- log.verbose("Using dummy remote config (inference not needed)")- else:- # Fetch remote configuration (may fall back to on-disk cache when offline).- remote_config_result = RemoteConfigFetcher.fetch_remote_config()- remote_config = remote_config_result.config- gateway_config_source = remote_config_result.source- log.verbose(f"Successfully fetched the Pipelex remote configuration (source={gateway_config_source})")- managed_gateway_configs = build_managed_gateway_configs(- remote_config=remote_config,- managed_gateway_sections=managed_gateway_sections,- )- # Stale operation: warn loudly so machine consumers can re-surface the provenance.- # Emission lives at this orchestration layer (not in the fetcher) so the fetcher- # stays a pure data-returning function — and so test fixtures that swap in a- # cached fetcher (tests/conftest.py) don't need to special-case warning replay.- if gateway_config_source.is_cached:- cached_at_iso = remote_config_result.cached_at.isoformat() if remote_config_result.cached_at else "unknown"- warnings.warn(- f"The Pipelex-managed gateway backends are running off a cached remote config (snapshot: {cached_at_iso}). "- "Run `pipelex init` while online to refresh.",- RemoteConfigStaleWarning,- stacklevel=2,- )-# --- Plugin discovery -----------------------------------------------------------------# Build the plugin registrar from the fully-resolved config (pure and import-light:# registering the built-ins imports no backend SDK, constructs no client, touches no hub).- # Built here — after the managed-gateway precondition gate above (so a first-run boot fails fast- # before any discovery work) and before the secrets provider and the log sink below, the first two+ # Built here, before the secrets provider and the log sink below, the first two# capabilities resolved out of it: the built-in SecretsPlugin's factory (and any external# pipelex-secrets-<backend>) is looked up from the registrar-derived SecretsProviderRegistry, then# the sink from the LogSinkRegistry. The other registries@@ -476,7 +411,7 @@ If you need help, drop by our Discord: we're happy to assist: {URLs.discord}.# SecretsPlugin supplies the "env" method, so there is no separate core default. Building it ahead# of the sink costs nothing in kind: what the provider logs is held like every line before the sink,# and when it fails to build, the lines held until then reach stderr redacted through the holding- # handler, as they do when a remote-config fetch above fails, while its exception goes up to the+ # handler, as they do when plugin discovery above fails, while its exception goes up to the# caller as raised. It goes on the hub only further down: until then the keyword the sink factory# receives is the one way to reach it.secrets_provider_registry = SecretsProviderRegistry(plugin_registrar.secrets_providers)@@ -577,8 +512,6 @@ If you need help, drop by our Discord: we're happy to assist: {URLs.discord}.# The registrar was built above, before any of this, so its declarations are final here.self.models_manager.setup(secrets_provider=secrets_provider,- managed_gateway_configs=managed_gateway_configs,- gateway_config_source=gateway_config_source,plugin_model_declarations=plugin_registrar.make_model_declarations(),needs_inference=needs_inference,)@@ -943,7 +876,6 @@ If you need help, drop by our Discord: we're happy to assist: {URLs.discord}.integration_mode: IntegrationMode = IntegrationMode.PYTHON,needs_inference: bool = True,boot_orchestrator: str | None = None,- needs_model_specs: bool | None = None,class_registry: ClassRegistryAbstract | None = None,secrets_provider: SecretsProviderAbstract | None = None,storage_provider: StorageProviderAbstract | None = None,@@ -979,7 +911,6 @@ If you need help, drop by our Discord: we're happy to assist: {URLs.discord}.integration_mode=integration_mode,needs_inference=needs_inference,boot_orchestrator=boot_orchestrator,- needs_model_specs=needs_model_specs,class_registry=class_registry,secrets_provider=secrets_provider,storage_provider=storage_provider,diff --git a/pipelex/system/configuration/config_surface.py b/pipelex/system/configuration/config_surface.pyindex 67e6e2be8..dc6c87756 100644--- a/pipelex/system/configuration/config_surface.py+++ b/pipelex/system/configuration/config_surface.py@@ -1,7 +1,7 @@"""Read-side helpers shared by every configuration surface.A **configuration surface** is one family of user-owned TOML files with one schema and one-migration ledger — `pipelex.toml` and its tiers, `telemetry.toml`, `pipelex_service.toml`, and the+migration ledger — `pipelex.toml` and its tiers, `telemetry.toml`, and theinference backend definitions under `inference/backends/`. Two things are the same for all of them onthe read path, and this module is the one place that knows about either.@@ -109,7 +109,6 @@ def version_declared_below_the_floor(*, ledger: MigrationLedger, config_dict: di# loader and the registry from drifting apart on a string literal.PIPELEX_CONFIG_SURFACE_ID = "pipelex-config"TELEMETRY_CONFIG_SURFACE_ID = "telemetry-config"-PIPELEX_SERVICE_CONFIG_SURFACE_ID = "pipelex-service-config"INFERENCE_BACKEND_CONFIG_SURFACE_ID = "inference-backend"diff --git a/pipelex/system/pipelex_service/__init__.py b/pipelex/system/pipelex_service/__init__.pydeleted file mode 100644index e69de29bb..000000000diff --git a/pipelex/system/pipelex_service/exceptions.py b/pipelex/system/pipelex_service/exceptions.pydeleted file mode 100644index 8b4ebb24f..000000000--- a/pipelex/system/pipelex_service/exceptions.py+++ /dev/null@@ -1,66 +0,0 @@-"""Exceptions for Pipelex managed services."""--from pipelex.base_exceptions import ErrorDomain-from pipelex.system.exceptions import PipelexError---class PipelexServiceConfigValidationError(PipelexError):- """Raised when pipelex_service.toml validation fails."""-- error_domain = ErrorDomain.CONFIG---class PipelexServiceError(PipelexError):- """Base exception for Pipelex service errors."""-- error_domain = ErrorDomain.CONFIG---class RemoteConfigFetchError(PipelexServiceError):- """Raised when fetching the Pipelex remote configuration fails.-- This error occurs when:- - The network request fails- - The server answers with an error status- """---class RemoteConfigValidationError(PipelexServiceError):- """Raised when remote configuration payload validation fails.-- This error occurs when:- - JSON payload is not valid- - Payload structure doesn't match expected schema- """---class RemoteConfigUnavailableError(PipelexServiceError):- """Raised when a fresh fetch failed AND no usable cached fallback exists.-- This is the user-facing offline-mode error: a Pipelex-managed gateway backend is enabled but we- have neither a working network path nor a primed local cache to fall back on. The message names- the cache file path and the remediation (``pipelex init`` while online; or disabling the managed- backend in ``backends.toml`` for permanent offline operation).- """---class RemoteConfigStaleWarning(UserWarning):- """Emitted when setup completes using a cached remote-config fallback instead of a fresh fetch.-- Indicates the network was unreachable but a prior ``pipelex init`` had primed the cache.- Stale operation is intentionally safe for dry-run/validation flows; real inference calls- still require network at call time.- """---class GatewayOverrideWarning(UserWarning):- """Warning issued when local overrides are applied to a managed gateway's served model specs."""---class GatewayConfigMergeError(PipelexServiceError):- """Raised when merging a managed gateway's served model specs with local overrides meets invalid data.-- This error occurs when:- - Local override for a model is not a dictionary- - Remote config for a model is not a dictionary- """diff --git a/pipelex/system/pipelex_service/gateway_config_merger.py b/pipelex/system/pipelex_service/gateway_config_merger.pydeleted file mode 100644index 1ed78497c..000000000--- a/pipelex/system/pipelex_service/gateway_config_merger.py+++ /dev/null@@ -1,105 +0,0 @@-import copy-import warnings-from typing import Any, cast--from pipelex.cogt.model_backends.model_spec_factory import BackendModelSpecs-from pipelex.system.pipelex_service.exceptions import GatewayConfigMergeError, GatewayOverrideWarning-from pipelex.tools.log.log import log--# Keys that can be overridden locally-ALLOWED_OVERRIDE_KEYS = frozenset({"sdk", "structure_method"})---class GatewayConfigMerger:- """Merges a managed gateway's served model specs with the local overrides of its backend file.-- Only allows overriding specific keys (sdk, structure_method).- Logs warnings when overrides are applied or when disallowed keys are found.- """-- @classmethod- def merge(- cls,- gateway_model_specs: BackendModelSpecs,- *,- local_overrides: BackendModelSpecs,- ) -> dict[str, Any]:- """Merge remote config with local overrides.-- Args:- gateway_model_specs: Model specs served for the managed gateway backend.- local_overrides: Local overrides from the backend's own file (e.g. `pipelex_manifold.toml`).-- Returns:- Merged configuration with allowed overrides applied.- """- result: dict[str, Any] = copy.deepcopy(gateway_model_specs)-- # Warn if defaults section is present (not allowed for local overrides)- if "defaults" in local_overrides:- log.warning("[GatewayConfigMerger] Local 'defaults' section ignored. Overrides are only allowed per-model, not via defaults.")-- # Handle per-model overrides only- for model_name, local_model_config in local_overrides.items():- if model_name == "defaults":- continue # Skip defaults section (already warned above)-- if not isinstance(local_model_config, dict):- msg = f"Local override for model '{model_name}' must be a dictionary, got {type(local_model_config).__name__}"- raise GatewayConfigMergeError(msg)-- if model_name not in result:- log.warning(f"[GatewayConfigMerger] Local override for model '{model_name}' ignored: model not found in remote configuration")- continue-- remote_model = result[model_name]- if not isinstance(remote_model, dict):- msg = f"Remote config for model '{model_name}' must be a dictionary, got {type(remote_model).__name__}"- raise GatewayConfigMergeError(msg)-- cls._apply_overrides_to_model(- model_name=model_name,- gateway_model_specs=cast("dict[str, Any]", remote_model),- local_model_config=cast("dict[str, Any]", local_model_config),- )-- return result-- @classmethod- def _apply_overrides_to_model(- cls,- *,- model_name: str,- gateway_model_specs: BackendModelSpecs,- local_model_config: BackendModelSpecs,- ) -> None:- """Apply local overrides to a single model configuration.-- Args:- model_name: Name of the model being configured.- gateway_model_specs: Remote model configuration to apply overrides to.- local_model_config: Local overrides for the model.- """- applied_overrides: list[str] = []- ignored_keys: list[str] = []-- for key, value in local_model_config.items():- if key in ALLOWED_OVERRIDE_KEYS:- old_value = gateway_model_specs.get(key)- if old_value != value:- gateway_model_specs[key] = value- applied_overrides.append(f"{key}: {old_value!r} -> {value!r}")- else:- ignored_keys.append(key)-- if applied_overrides:- override_details = ", ".join(applied_overrides)- warning_msg = f"[GatewayConfigMerger] Local overrides applied for '{model_name}': {override_details}. This may affect behavior."- log.warning(warning_msg)- warnings.warn(warning_msg, GatewayOverrideWarning, stacklevel=3)-- if ignored_keys:- log.warning(- f"[GatewayConfigMerger] Ignored non-overridable keys for '{model_name}': "- f"{ignored_keys}. Only {list(ALLOWED_OVERRIDE_KEYS)} can be overridden."- )diff --git a/pipelex/system/pipelex_service/managed_gateway_configs.py b/pipelex/system/pipelex_service/managed_gateway_configs.pydeleted file mode 100644index c7f055996..000000000--- a/pipelex/system/pipelex_service/managed_gateway_configs.py+++ /dev/null@@ -1,50 +0,0 @@-"""Slice the one fetched artifact into one gateway configuration per enabled managed backend.--Its own module rather than a method on the boot, because the doctor asks the same question the boot-does and must get the same answer: it probes a specific `backends.toml` (project vs `--global`) and-then stands up a `ModelManager` over what it found. A second implementation there would be a second-opinion on which backend reads which section.-"""--from pipelex import log-from pipelex.cogt.model_backends.gateway_config import GatewayConfig-from pipelex.system.pipelex_service.remote_config import RemoteConfig---def build_managed_gateway_configs(- *,- remote_config: RemoteConfig,- managed_gateway_sections: dict[str, str],-) -> dict[str, GatewayConfig]:- """One gateway configuration per enabled managed backend, sliced out of the one fetched artifact.-- **One fetch, N configs, kept apart rather than merged.** The artifact is one document with one- version, so there is exactly one network call and one disk cache; but two managed services are- two services, and a handle that one serves and another does not is a legitimate configuration- rather than a conflict to resolve, so the sections never meet.-- A backend whose declared section is absent from the published artifact is **disabled with a named- warning** rather than fatal — the same posture as a managed backend missing one of its `${…}`- variables, and for the same reason: the kit can ship a managed backend declared, so an- installation that has not joined must not fail to boot over a section it never asked for.-- Args:- remote_config: The artifact, fresh or from the on-disk cache.- managed_gateway_sections: `{backend_name: section_name}`, from `enabled_managed_gateway_sections`.-- Returns:- `{backend_name: GatewayConfig}`, carrying an entry only for a backend whose section was- actually published.- """- managed_gateway_configs: dict[str, GatewayConfig] = {}- for backend_name, section_name in managed_gateway_sections.items():- model_specs = remote_config.get_model_specs_section(section_name)- if model_specs is None:- log.warning(- f"Backend '{backend_name}' is disabled: it is a Pipelex-managed gateway backend taking its model specs from the "- f"'{section_name}' section of the Pipelex configuration, and the configuration we read carries no such section. "- f"Set `enabled = false` on it in your backends.toml to silence this warning."- )- continue- managed_gateway_configs[backend_name] = GatewayConfig(model_specs=model_specs)- return managed_gateway_configsdiff --git a/pipelex/system/pipelex_service/pipelex_details.py b/pipelex/system/pipelex_service/pipelex_details.pydeleted file mode 100644index 41e1a97d7..000000000--- a/pipelex/system/pipelex_service/pipelex_details.py+++ /dev/null@@ -1,15 +0,0 @@-import os--_DEFAULT_REMOTE_CONFIG_URL = "https://pipelex-config.s3.eu-west-3.amazonaws.com/pipelex_remote_config_13.json"-REMOTE_CONFIG_URL_ENV_VAR = "PIPELEX_REMOTE_CONFIG_URL"---class PipelexDetails:- @classmethod- def remote_config_url(cls) -> str:- """The URL to fetch the Pipelex remote config from.-- Reads ``PIPELEX_REMOTE_CONFIG_URL`` from the environment when set- (useful for testing/staging), otherwise falls back to the production URL.- """- return os.environ.get(REMOTE_CONFIG_URL_ENV_VAR) or _DEFAULT_REMOTE_CONFIG_URLdiff --git a/pipelex/system/pipelex_service/pipelex_service_config.py b/pipelex/system/pipelex_service/pipelex_service_config.pydeleted file mode 100644index 981303fb8..000000000--- a/pipelex/system/pipelex_service/pipelex_service_config.py+++ /dev/null@@ -1,153 +0,0 @@-from pathlib import Path-from typing import Any, cast--from pydantic import Field, ValidationError--from pipelex import log-from pipelex.cogt.exceptions import InferenceBackendLibraryValidationError-from pipelex.cogt.model_backends.backend import resolve_model_specs_section-from pipelex.system.configuration.config_loader import config_manager-from pipelex.system.configuration.config_model import ConfigModel-from pipelex.system.configuration.config_surface import (- PIPELEX_SERVICE_CONFIG_SURFACE_ID,- replay_surface_files_in_memory,- stale_configuration_warning,- strip_reserved_meta,-)-from pipelex.system.pipelex_service.exceptions import PipelexServiceConfigValidationError-from pipelex.system.pipelex_service.pipelex_service_onboarding import (- PIPELEX_SERVICE_CONFIG_FILE_NAME,- PipelexServiceOnboarding,-)-from pipelex.tools.misc.exceptions import TomlError-from pipelex.tools.misc.toml_utils import describe_toml_base_and_overrides, load_toml_from_base_and_overrides, load_toml_from_path-from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error---class PipelexServiceConfig(ConfigModel):- # A default_factory, not a required field: this is the surface's defaults layer. Every- # in-scope configuration surface must have one, because it is what makes an additive schema- # change absorbable and therefore never a migration — see docs/migration-ledger.md.- onboarding: PipelexServiceOnboarding = Field(default_factory=PipelexServiceOnboarding)---def load_pipelex_service_config_if_exists(config_dir: Path) -> PipelexServiceConfig | None:- """Load Pipelex service configuration if the file exists.-- Args:- config_dir: Path to the .pipelex configuration directory.-- Returns:- PipelexServiceConfig instance or None if file doesn't exist.- """- config_path = config_dir / PIPELEX_SERVICE_CONFIG_FILE_NAME- try:- config_toml = load_toml_from_path(path=config_path)- strip_reserved_meta(config_dict=config_toml)- return PipelexServiceConfig.model_validate(config_toml)- except FileNotFoundError:- return None- except ValidationError as exc:- recovered = _service_config_the_ledger_can_explain(config_path=config_path)- if recovered is not None:- return recovered- validation_error_msg = format_pydantic_validation_error(exc)- msg = f"Invalid Pipelex service configuration: {validation_error_msg}"- raise PipelexServiceConfigValidationError(msg) from exc---def _service_config_the_ledger_can_explain(*, config_path: Path) -> PipelexServiceConfig | None:- """The same service configuration with the ledger replayed over the user's file, or `None`.-- Boot tolerance for the one surface with no tiers: a single file, so the "merge" the shared- helper performs is a merge of one. This is what lets a file written by an earlier release —- one still carrying a table the schema has since dropped — boot with a warning rather than a- refusal, once the ledger carries the entry that drops it.- """- replayed = replay_surface_files_in_memory(surface_id=PIPELEX_SERVICE_CONFIG_SURFACE_ID, paths=[config_path])- if replayed is None:- return None- try:- service_config = PipelexServiceConfig.model_validate(replayed.config_dict)- except ValidationError:- return None- log.warning(stale_configuration_warning(plans=replayed.plans, walked_dirs=config_manager.existing_config_dirs))- return service_config---def _backends_document(*, config_dir: Path | None) -> dict[str, Any] | None:- """The merged ``backends.toml`` document, or ``None`` when there is no base file.-- The same document the library loader reads: the base first, then every- ``backends_override.toml`` that exists, deep-merged in order — from- ``config_manager.backends_file_paths``. The reader below goes through here so it cannot end- up branching on a narrower view of the configuration than the loader it feeds.-- Raises:- InferenceBackendLibraryValidationError: a file in the document does not parse. The same- class the library loader raises for it, so the boot's clause for an unloadable backend- library names the file, rather than a parse error surfacing before any clause is reached.- """- backends_file_paths = config_manager.backends_file_paths(config_dir=config_dir)- try:- return load_toml_from_base_and_overrides(paths=backends_file_paths)- except FileNotFoundError:- return None- except TomlError as toml_exc:- msg = f"Invalid inference backend library {describe_toml_base_and_overrides(paths=backends_file_paths)}: {toml_exc}"- raise InferenceBackendLibraryValidationError(msg) from toml_exc---def enabled_managed_gateway_sections(*, config_dir: Path | None = None) -> dict[str, str]:- """The enabled managed gateway backends, each mapped to the remote-config section its specs come from.-- A *managed gateway backend* is one whose model specs arrive from the Pipelex service's published- artifact rather than from a local per-backend TOML, and naming a section is what declares it one- — see `resolve_model_specs_section`.-- Read here, off the raw document, because the boot needs the answer *before* it can load the- backend library: what it fetches is the input to that load.-- **It must read `enabled` exactly as the library loader does** — the raw value's truthiness, and- enabled when the key is absent, over the same merged document — because the boot acts on the- answer here: it fetches the managed backends' model specs only when this says one is enabled,- then hands them to a loader that decides for itself which backends are enabled. Reading the- literal `true` here while the loader read truthiness would leave `enabled = 1` in a state neither- could name: no specs fetched, backend loaded — refused as *"model specs were not provided"* on a- strict boot, silently dropped from the deck on a lenient one. An override the loader saw and this- did not would be the same split.-- Args:- config_dir: Read the document at that directory — its ``backends.toml`` and its own- ``backends_override.toml`` — as ``pipelex init`` targeting one ``.pipelex/`` and the- doctor's ``--global`` do, so they never branch on a sibling configuration. ``None``- (default) reads the layered document: the resolved base, then the global override, then- the project override.-- Returns:- ``{backend_name: section_name}``, empty when no managed gateway backend is enabled — including- when there is no base file.-- Raises:- InferenceBackendLibraryValidationError: a file in the document does not parse — see- `_backends_document`.- """- backends_toml = _backends_document(config_dir=config_dir)- if backends_toml is None:- return {}-- sections: dict[str, str] = {}- for backend_name, backend_table in backends_toml.items():- if not isinstance(backend_table, dict):- continue- backend_dict = cast("dict[str, Any]", backend_table)- if not bool(backend_dict.get("enabled", True)):- continue- declared_section = backend_dict.get("model_specs_section")- section = resolve_model_specs_section(- backend_name=backend_name,- declared_section=declared_section if isinstance(declared_section, str) else None,- )- if section is not None:- sections[backend_name] = section- return sectionsdiff --git a/pipelex/system/pipelex_service/pipelex_service_onboarding.py b/pipelex/system/pipelex_service/pipelex_service_onboarding.pydeleted file mode 100644index 7584d7be6..000000000--- a/pipelex/system/pipelex_service/pipelex_service_onboarding.py+++ /dev/null@@ -1,46 +0,0 @@-from pathlib import Path--from pydantic import Field-from tomlkit import table as tomlkit_table--from pipelex.kit.paths import get_kit_configs_dir-from pipelex.system.configuration.config_loader import config_manager-from pipelex.system.configuration.config_model import ConfigModel-from pipelex.tools.misc.file_utils import path_exists-from pipelex.tools.misc.toml_utils import load_toml_with_tomlkit, save_toml_to_path--PIPELEX_SERVICE_CONFIG_FILE_NAME = "pipelex_service.toml"---class PipelexServiceOnboarding(ConfigModel):- inference_setup_completed: bool = Field(- default=False,- description="Whether the user has completed inference setup",- )---def update_inference_setup_completed(*, completed: bool, config_dir: Path | None = None) -> None:- """Update the inference setup completed flag in pipelex_service.toml.-- Args:- completed: Whether inference setup has been completed.- config_dir: Explicit config directory path. If None, uses config_manager.global_config_dir.- """- resolved_config_dir = config_dir or config_manager.global_config_dir- service_config_path = resolved_config_dir / PIPELEX_SERVICE_CONFIG_FILE_NAME-- if path_exists(service_config_path):- toml_doc = load_toml_with_tomlkit(service_config_path)- else:- # Load from the kit template- template_path = str(get_kit_configs_dir() / PIPELEX_SERVICE_CONFIG_FILE_NAME)- toml_doc = load_toml_with_tomlkit(template_path)-- # Ensure [onboarding] section exists- if "onboarding" not in toml_doc:- toml_doc["onboarding"] = tomlkit_table()-- toml_doc["onboarding"]["inference_setup_completed"] = completed # type: ignore[index]-- resolved_config_dir.mkdir(parents=True, exist_ok=True)- save_toml_to_path(toml_doc, path=service_config_path)diff --git a/pipelex/system/pipelex_service/remote_config.py b/pipelex/system/pipelex_service/remote_config.pydeleted file mode 100644index f995867bf..000000000--- a/pipelex/system/pipelex_service/remote_config.py+++ /dev/null@@ -1,39 +0,0 @@-from typing import cast--from pydantic import BaseModel, ConfigDict--from pipelex.cogt.model_backends.model_spec_factory import BackendModelSpecs---class RemoteConfig(BaseModel):- """The single artifact the Pipelex service publishes, carrying one model-specs section per managed gateway.-- Every section — `manifold_model_specs` today — arrives through `extra="allow"`, which is what- makes adding one a non-breaking change for a client that predates it: an older runtime parses the- artifact and simply never asks for the new section. The same tolerance covers the keys the- artifact still carries for other consumers (the hosted plane reads it too): the runtime declares- no field of its own and reads only the sections its enabled managed backends name.- """-- model_config = ConfigDict(extra="allow")-- def get_model_specs_section(self, section_name: str) -> BackendModelSpecs | None:- """The named model-specs section, or ``None`` when the artifact does not carry one.-- Looked up by name rather than by field, because which section a managed backend reads is- declared in that backend's configuration and the runtime learns it at boot. ``None`` is a- real answer and not an error here: a backend declaring a section the published artifact does- not carry is disabled with a named warning, the same posture as a missing variable.-- **The lookup is confined to the artifact's own content** — the sections it was published- with — rather than being a bare ``getattr`` on the model. The name arrives from- `model_specs_section` in the user's own `backends.toml`, and a bare ``getattr`` would answer- for pydantic's machinery too: ``model_config`` and ``model_fields`` are both plain dicts on a- v2 model, so either would pass the shape check below and be carried onwards as if the- service had published it. Confined this way, an unmeant name is simply a section the- artifact does not carry, and earns the named disabling warning it should.- """- raw: object | None = (self.__pydantic_extra__ or {}).get(section_name)- if not isinstance(raw, dict):- return None- return cast("BackendModelSpecs", raw)diff --git a/pipelex/system/pipelex_service/remote_config_cache.py b/pipelex/system/pipelex_service/remote_config_cache.pydeleted file mode 100644index 93add9f73..000000000--- a/pipelex/system/pipelex_service/remote_config_cache.py+++ /dev/null@@ -1,144 +0,0 @@-"""On-disk fallback cache for the Pipelex remote config.--The cache is a **last-resort** safety net for offline operation. It is never read for freshness-optimisation. Layout::-- ~/.pipelex/cache/remote_config.json--The on-disk payload is the raw JSON returned by the remote endpoint (not a re-serialised-Pydantic dump), so the cache is stable across minor schema drift. Schema-breaking changes-require bumping both the remote-config URL version (server-side) and-``CACHE_SCHEMA_VERSION`` here; older caches are then rejected on load and re-primed on the-next successful fetch.-"""--from __future__ import annotations--import json-import os-import tempfile-from datetime import UTC, datetime-from json import JSONDecodeError-from pathlib import Path-from typing import Any--from pydantic import BaseModel, ConfigDict, Field, ValidationError--from pipelex import log-from pipelex.system.configuration.config_loader import config_manager-from pipelex.system.pipelex_service.remote_config import RemoteConfig--CACHE_SCHEMA_VERSION = 1-CACHE_SUBDIR_NAME = "cache"-CACHE_FILE_NAME = "remote_config.json"---class CachedRemoteConfig(BaseModel):- """A snapshot of the remote config plus the metadata needed to validate it."""-- model_config = ConfigDict(extra="forbid")-- schema_version: int = Field(description="On-disk schema version; mismatches reject the cache")- cached_at: datetime = Field(description="UTC timestamp when this snapshot was written")- raw_config: dict[str, Any] = Field(description="The raw remote-config JSON payload, untouched")-- def to_remote_config(self) -> RemoteConfig:- """Re-validate the raw payload into a ``RemoteConfig`` model on demand."""- return RemoteConfig.model_validate(self.raw_config)---class RemoteConfigCache:- """Read/write helpers for the on-disk remote-config fallback."""-- @classmethod- def cache_path(cls) -> Path:- """Resolve the cache file path under the global ``~/.pipelex`` directory."""- return config_manager.global_config_dir / CACHE_SUBDIR_NAME / CACHE_FILE_NAME-- @classmethod- def load(cls) -> CachedRemoteConfig | None:- """Return the cached snapshot, or ``None`` when there is no usable cache.-- Any of the following result in ``None``:- - the cache file does not exist- - the file cannot be read or parsed- - the on-disk schema version doesn't match this code's ``CACHE_SCHEMA_VERSION``- - the JSON doesn't validate as ``CachedRemoteConfig``-- Bare ``Exception`` is never caught — only the specific classes raised by the- filesystem, JSON, and Pydantic layers.- """- path = cls.cache_path()- try:- content = path.read_text(encoding="utf-8")- except FileNotFoundError:- return None- except OSError as exc:- log.warning(f"Could not read remote config cache at {path}: {exc}")- return None-- try:- raw = json.loads(content)- except JSONDecodeError as exc:- log.warning(f"Remote config cache at {path} is not valid JSON: {exc}")- return None-- try:- cached = CachedRemoteConfig.model_validate(raw)- except ValidationError as exc:- log.warning(f"Remote config cache at {path} failed validation and will be ignored: {exc}")- return None-- if cached.schema_version != CACHE_SCHEMA_VERSION:- log.warning(f"Remote config cache at {path} has schema_version={cached.schema_version}, expected {CACHE_SCHEMA_VERSION}; ignoring.")- return None-- return cached-- @classmethod- def store(cls, remote_config_payload: dict[str, Any]) -> None:- """Atomically write the raw remote-config payload to disk.-- Writes go to a temp file in the cache directory and are then moved into place with- ``os.replace``, which is atomic on the local filesystem. If the move fails, the temp- file is removed so we don't leave half-written caches around.-- The argument is the **raw** JSON returned by the remote endpoint, NOT a serialised- ``RemoteConfig`` instance — this keeps the cache stable across minor schema drift.- """- path = cls.cache_path()- cache_dir = path.parent- cache_dir.mkdir(parents=True, exist_ok=True)-- cached = CachedRemoteConfig(- schema_version=CACHE_SCHEMA_VERSION,- cached_at=datetime.now(tz=UTC),- raw_config=remote_config_payload,- )- serialised = cached.model_dump_json()-- tmp_file = tempfile.NamedTemporaryFile( # ruff: ignore[open-file-with-context-handler] - we manage the handle manually for atomic replace- mode="w",- encoding="utf-8",- dir=str(cache_dir),- prefix=f".{CACHE_FILE_NAME}.",- suffix=".tmp",- delete=False,- )- tmp_path = Path(tmp_file.name)- replaced = False- try:- try:- tmp_file.write(serialised)- tmp_file.flush()- os.fsync(tmp_file.fileno())- finally:- tmp_file.close()- tmp_path.replace(path)- replaced = True- finally:- if not replaced:- try:- tmp_path.unlink()- except FileNotFoundError:- passdiff --git a/pipelex/system/pipelex_service/remote_config_fetcher.py b/pipelex/system/pipelex_service/remote_config_fetcher.pydeleted file mode 100644index c06fef693..000000000--- a/pipelex/system/pipelex_service/remote_config_fetcher.py+++ /dev/null@@ -1,252 +0,0 @@-"""Fetch the Pipelex remote config with retry, cache, and provenance tracking.--The fetcher is the single entry point used by ``Pipelex.setup`` and the dev/doctor CLIs.-Its public method returns a :class:`RemoteConfigResult` carrying the parsed config plus the-source it came from (``FRESH`` vs ``CACHED``), so downstream code can branch its error-messaging and disable telemetry when running off stale data.--This module emits no warnings — stale-cache surfacing is the orchestration layer's job-(see ``Pipelex.setup``). Keeping the fetcher pure means test fixtures that swap in a cached-fetcher don't need to special-case warning replay.--Behaviour:--- Every successful fetch persists the raw JSON to :class:`RemoteConfigCache` (opportunistic- refresh).-- On network or HTTP failure, the fetcher falls back to the cache if one exists and returns- it tagged ``source=CACHED`` with a ``cached_at`` timestamp. If no usable cache exists, it- raises :class:`RemoteConfigUnavailableError`. The inner :class:`RemoteConfigFetchError` is- chained as ``__cause__`` so existing surfaces (doctor, agent hints) keep working. Warning- emission is the orchestration layer's responsibility — see ``Pipelex.setup`` — so the- fetcher itself remains a pure data-returning function.-- On JSON-validation failure (a server-side schema break — we control the server) the- fetcher raises :class:`RemoteConfigValidationError` and does NOT silently fall back to- cache.-- Callers that must not bake stale data into committed files (doc generators, fixture- preprocessors) pass ``require_fresh=True``, which turns any cache fallback into an- :class:`RemoteConfigUnavailableError` immediately.-"""--from __future__ import annotations--import json-from datetime import datetime-from typing import Any--import httpx-from pydantic import BaseModel, ConfigDict, Field, ValidationError-from tenacity import RetryCallState, retry, retry_if_exception_type, stop_after_attempt, wait_exponential--from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigFetchError,- RemoteConfigUnavailableError,- RemoteConfigValidationError,-)-from pipelex.system.pipelex_service.pipelex_details import PipelexDetails-from pipelex.system.pipelex_service.remote_config import RemoteConfig-from pipelex.system.pipelex_service.remote_config_cache import RemoteConfigCache-from pipelex.system.pipelex_service.types import RemoteConfigSource-from pipelex.system.runtime import runtime_manager-from pipelex.tools.misc.terminal_utils import print_to_stderr-from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error---class RemoteConfigResult(BaseModel):- """Outcome of a fetch attempt: the parsed config plus provenance metadata."""-- model_config = ConfigDict(extra="forbid", strict=True, arbitrary_types_allowed=True)-- config: RemoteConfig = Field(description="The parsed remote configuration")- source: RemoteConfigSource = Field(description="Whether the config came from the network or the on-disk cache")- cached_at: datetime | None = Field(- default=None,- description="UTC timestamp from the cache snapshot when ``source == CACHED``; ``None`` otherwise",- )---class RemoteConfigFetcher:- """Fetches Pipelex Service remote configuration with retry logic and a cache fallback."""-- # Retry configuration for remote config fetch- # Using hardcoded values since this runs before config is fully loaded- FETCH_MAX_RETRIES = 5- FETCH_WAIT_MULTIPLIER = 1- FETCH_WAIT_MIN = 1- FETCH_WAIT_MAX = 10- FETCH_TIMEOUT = 10.0-- @classmethod- def _log_retry_attempt(cls, retry_state: RetryCallState) -> None:- """Log retry attempts for remote config fetch."""- exc = retry_state.outcome.exception() if retry_state.outcome else None- print_to_stderr(f"Remote config fetch attempt {retry_state.attempt_number} failed: {exc}. Retrying...")-- @classmethod- def _fetch_remote_config_with_retry(cls, url: str) -> httpx.Response:- """Fetch remote config with retry logic for transient network errors.-- Args:- url: The URL to fetch the configuration from.-- Returns:- The HTTP response.-- Raises:- httpx.TimeoutException: If the request times out after all retries.- httpx.RequestError: If a network error occurs after all retries.- httpx.HTTPStatusError: If the server returns an error status (not retried).- """-- @retry(- retry=retry_if_exception_type((httpx.TimeoutException, httpx.RequestError)),- stop=stop_after_attempt(cls.FETCH_MAX_RETRIES),- wait=wait_exponential(multiplier=cls.FETCH_WAIT_MULTIPLIER, min=cls.FETCH_WAIT_MIN, max=cls.FETCH_WAIT_MAX),- before_sleep=cls._log_retry_attempt,- reraise=True,- )- def _fetch_with_retry(url: str) -> httpx.Response:- response = httpx.get(url, timeout=cls.FETCH_TIMEOUT, follow_redirects=True)- response.raise_for_status()- return response-- return _fetch_with_retry(url)-- @classmethod- def make_dummy_remote_config(cls) -> RemoteConfig:- """Create a default RemoteConfig for testing in offline environments.-- **Every managed gateway's section is present and empty.** An absent section means "this- backend's specs were not published" and earns a disabling warning; on this path that would- be a warning about a backend nobody asked for, since the boots that take this branch- (``pipelex-agent models``, validation, dry runs) need no specs at all.-- Returns:- A minimal RemoteConfig with empty model specs.- """- return RemoteConfig(**{MANIFOLD_MODEL_SPECS_SECTION: {}})-- @classmethod- def _fetch_fresh(cls, url: str) -> tuple[dict[str, Any], RemoteConfig]:- """Fetch and validate-parse the remote payload. Raises ``RemoteConfigFetchError`` on- network/HTTP failure and ``RemoteConfigValidationError`` on schema breaks. Returns the- raw JSON payload (for cache persistence) alongside the already-parsed config so the- caller does not have to revalidate.- """- try:- response = cls._fetch_remote_config_with_retry(url)- except httpx.TimeoutException as timeout_exc:- msg = f"Timeout while fetching remote configuration from {url}: {timeout_exc}"- raise RemoteConfigFetchError(msg) from timeout_exc- except httpx.HTTPStatusError as http_exc:- msg = f"HTTP error {http_exc.response.status_code} while fetching remote configuration from {url}"- raise RemoteConfigFetchError(msg) from http_exc- except httpx.RequestError as request_exc:- msg = f"Failed to fetch remote configuration from {url} after {cls.FETCH_MAX_RETRIES} attempts: {request_exc}"- raise RemoteConfigFetchError(msg) from request_exc-- try:- payload: dict[str, Any] = response.json()- except (json.JSONDecodeError, UnicodeDecodeError) as parse_exc:- msg = f"Failed to parse remote configuration JSON: {parse_exc}"- raise RemoteConfigValidationError(msg) from parse_exc-- try:- config = RemoteConfig.model_validate(payload)- except ValidationError as validation_error:- formatted = format_pydantic_validation_error(validation_error)- msg = f"Remote configuration validation failed: {formatted}"- raise RemoteConfigValidationError(msg) from validation_error-- return payload, config-- @classmethod- def _build_unavailable_error(- cls,- fetch_error: RemoteConfigFetchError,- *,- cache_refused: bool = False,- ) -> RemoteConfigUnavailableError:- """Build the user-facing offline-mode error with a clear remediation hint.-- Args:- fetch_error: The underlying network/HTTP failure that triggered the unavailable state.- cache_refused: When ``True``, the caller passed ``require_fresh=True`` and refused- to fall back to any cached payload (dev-CLI generators do this). The message- branches to call out that the cache was refused rather than missing or unusable.-- Returns the exception so the caller can ``raise ... from fetch_error`` itself; this- avoids "unreachable code" gymnastics at the call site.- """- cache_path = RemoteConfigCache.cache_path()- if cache_refused:- location = f"and the local cache at {cache_path} was refused because a fresh fetch is required"- else:- location = f"and no usable local cache is available at {cache_path}"- msg = (- f"A Pipelex-managed gateway backend is enabled but the remote configuration is unreachable "- f"{location}.\n"- f"Underlying error: {fetch_error}\n"- "Remediation:\n"- " - Run `pipelex init` while online to prime the cache.\n"- " - Or disable the Pipelex-managed gateway backends in .pipelex/inference/backends.toml to operate "- "permanently offline with your own API keys (BYOK)."- )- return RemoteConfigUnavailableError(msg)-- @classmethod- def fetch_remote_config(cls, *, require_fresh: bool = False) -> RemoteConfigResult:- """Fetch the Pipelex Service remote configuration.-- Args:- require_fresh: When ``True``, refuse to serve a cached fallback. Used by- dev-CLI generators that regenerate committed reference docs/fixtures — they- must never bake stale data into the repo. A cache miss when offline becomes- ``RemoteConfigUnavailableError`` immediately.-- Returns:- A :class:`RemoteConfigResult` carrying the parsed config plus its provenance.-- Raises:- RemoteConfigUnavailableError: Network fetch failed AND no usable cache exists- (or ``require_fresh=True`` and only a cache is available).- RemoteConfigValidationError: The remote responded with a payload that doesn't- match the expected schema. Never falls back to cache for this case.- """- if runtime_manager.is_in_codex_cloud:- print_to_stderr("Skipping remote config fetch in Codex Cloud, using dummy config instead")- return RemoteConfigResult(config=cls.make_dummy_remote_config(), source=RemoteConfigSource.FRESH, cached_at=None)-- url = PipelexDetails.remote_config_url()-- try:- payload, config = cls._fetch_fresh(url)- except RemoteConfigFetchError as fetch_error:- if require_fresh:- raise cls._build_unavailable_error(fetch_error, cache_refused=True) from fetch_error- cached = RemoteConfigCache.load()- if cached is None:- raise cls._build_unavailable_error(fetch_error) from fetch_error- # The wrapper `load()` validated already holds the payload as a JSON object, and- # `RemoteConfig` declares no field of its own, so re-validating it cannot fail.- return RemoteConfigResult(- config=cached.to_remote_config(),- source=RemoteConfigSource.CACHED,- cached_at=cached.cached_at,- )-- # Fresh path: persist the raw payload for future offline fallback. The cache is- # opportunistic — a write failure (read-only $HOME, full disk, permission denied) must- # not abort an otherwise-successful online fetch. We warn so the user can see why a- # later offline run might have to fail loudly with ``RemoteConfigUnavailableError``,- # then return the fresh config regardless.- try:- RemoteConfigCache.store(payload)- except OSError as cache_write_error:- warning_msg = (- f"Warning: failed to persist remote config cache at {RemoteConfigCache.cache_path()}: "- f"{cache_write_error}. Continuing with the fresh fetch; future offline runs may "- "be unable to fall back to a cached config until this is fixed."- )- print_to_stderr(warning_msg)- return RemoteConfigResult(config=config, source=RemoteConfigSource.FRESH, cached_at=None)diff --git a/pipelex/system/pipelex_service/types.py b/pipelex/system/pipelex_service/types.pydeleted file mode 100644index 94a83f78f..000000000--- a/pipelex/system/pipelex_service/types.py+++ /dev/null@@ -1,32 +0,0 @@-"""Leaf-level enums shared by the ``pipelex_service`` public surface.--Lives here — separate from the heavy ``remote_config_fetcher`` module — so that-``cogt/``-side modules (which already need source provenance to branch error messages and-disable telemetry on stale specs) can import the enum without pulling the fetcher and its-``httpx`` + ``tenacity`` dependencies. Keeps the cogt → pipelex_service edge clean and-avoids a layering inversion as more cogt callers acquire a need for provenance metadata.-"""--from __future__ import annotations--from enum import StrEnum---class RemoteConfigSource(StrEnum):- """Where a ``RemoteConfigResult`` was sourced from."""-- FRESH = "fresh"- CACHED = "cached"-- @property- def is_cached(self) -> bool:- """True when the config came from the on-disk fallback rather than the network.-- Use this everywhere instead of ``source == RemoteConfigSource.CACHED`` so the- match/case rule from the project standards stays out of caller code.- """- match self:- case RemoteConfigSource.FRESH:- return False- case RemoteConfigSource.CACHED:- return Truediff --git a/pipelex/tools/misc/diff.py b/pipelex/tools/misc/diff.pyindex 6f585c92c..3c44927f0 100644--- a/pipelex/tools/misc/diff.py+++ b/pipelex/tools/misc/diff.py@@ -27,7 +27,7 @@ def has_diff_dirs(Args:dir1: First directory path.dir2: Second directory path.- exclude_files: Set of file names to exclude from comparison (e.g., {"pipelex_service.toml"}).+ exclude_files: Set of file names to exclude from comparison (e.g., {"pipelex_override.toml"}).exclude_dirs: Set of directory names to exclude from comparison (e.g., {"storage"}).exclude_patterns: Set of glob patterns whose matching file names are excluded fromcomparison (e.g., {"*.bak.*"}). For artifacts whose names carry a timestamp or another@@ -222,7 +222,7 @@ def make_diff_dirs_pretty(Args:dir1: First directory path.dir2: Second directory path.- exclude_files: Set of file names to exclude from comparison (e.g., {"pipelex_service.toml"}).+ exclude_files: Set of file names to exclude from comparison (e.g., {"pipelex_override.toml"}).exclude_dirs: Set of directory names to exclude from comparison (e.g., {"storage"}).exclude_patterns: Set of glob patterns whose matching file names are excluded fromcomparison (e.g., {"*.bak.*"}). Keep it equal to what the matching `has_diff_dirs` calldiff --git a/subject_grants.toml b/subject_grants.tomlindex d359c6907..48576087e 100644--- a/subject_grants.toml+++ b/subject_grants.toml@@ -72,10 +72,6 @@ rationale = "Emits the formatted success result; single operand."param = "exc"rationale = "Extracts from the exc; single operand."-["pipelex/cli/agent_cli/commands/agent_output.py::record_setup_warning"]-param = "warning_payload"-rationale = "Records the setup-warning payload; single operand."-["pipelex/cli/agent_cli/commands/agent_output.py::set_agent_cli_error_format"]param = "error_format"rationale = "Setter: installs the agent-CLI error format; single operand."@@ -652,10 +648,6 @@ rationale = "Renders the value; single operand."param = "category"rationale = "Noun-named derivation: the header text for the category; single operand."-["pipelex/cli/error_handlers.py::handle_gateway_unknown_model_error"]-param = "exc"-rationale = "Error handler: the exc is the single operand handled."-["pipelex/cli/error_handlers.py::handle_model_availability_error"]param = "exc"rationale = "Error handler: the exc is the single operand handled."@@ -668,14 +660,6 @@ rationale = "Error handler: the exc is the single operand handled."param = "exc"rationale = "Error handler: the exc is the single operand handled."-["pipelex/cli/error_handlers.py::handle_remote_config_unavailable_error"]-param = "exc"-rationale = "Error handler: the exc is the single operand handled."--["pipelex/cli/error_handlers.py::handle_remote_config_validation_error"]-param = "exc"-rationale = "Error handler: the exc is the single operand handled."-["pipelex/cli/error_handlers.py::handle_telemetry_config_validation_error"]param = "exc"rationale = "Error handler: the exc is the single operand handled."@@ -1984,10 +1968,6 @@ rationale = "Factory from source: builds the result from the backend_credential_param = "name"rationale = "Factory from source: builds the result from the name; single operand."-["pipelex/cogt/model_backends/backend_library.py::InferenceBackendLibrary._load_gateway_model_specs"]-param = "gateway_config"-rationale = "Loads model specs from the gateway config; single operand."-["pipelex/cogt/model_backends/backend_library.py::InferenceBackendLibrary._load_local_model_specs"]param = "backend_name"rationale = "Loads model specs for the named backend; single operand."@@ -2192,22 +2172,6 @@ rationale = "Predicate on the candidate category; the filter list stays keyword.param = "result"rationale = "Verb-object: formats the list_models result dict; single operand."-["pipelex/cogt/models/model_manager.py::ModelManager._collect_candidates"]-param = "ref"-rationale = "Operates on the ref; single operand (qualifiers keyword-only)."--["pipelex/cogt/models/model_manager.py::ModelManager._collect_deck_referenced_handles"]-param = "deck"-rationale = "Keyed accessor by the deck; single operand."--["pipelex/cogt/models/model_manager.py::ModelManager._enforce_gateway_model_membership"]-param = "managed_gateway_configs"-rationale = "Operates on the managed gateway configs; single operand (qualifiers keyword-only)."--["pipelex/cogt/models/model_manager.py::ModelManager._extract_choice_handle"]-param = "choice"-rationale = "Extracts from the choice; single operand."-["pipelex/cogt/models/model_manager.py::ModelManager.build_deck"]param = "model_deck_blueprint"rationale = "Factory from source: builds the result from the model_deck_blueprint; single operand."@@ -5520,42 +5484,6 @@ rationale = "Predicate on the var named by the key; single operand."param = "key"rationale = "Predicate on the var named by the key; single operand."-["pipelex/system/pipelex_service/gateway_config_merger.py::GatewayConfigMerger.merge"]-param = "gateway_model_specs"-rationale = "Verb-object: merges the gateway model specs; merge context stays keyword."--["pipelex/system/pipelex_service/pipelex_service_config.py::load_pipelex_service_config_if_exists"]-param = "config_dir"-rationale = "Verb-object: loads from the config dir; single operand."--["pipelex/system/pipelex_service/remote_config.py::RemoteConfig.get_model_specs_section"]-param = "section_name"-rationale = "Keyed accessor by the section_name; single operand."--["pipelex/system/pipelex_service/remote_config_cache.py::RemoteConfigCache.store"]-param = "remote_config_payload"-rationale = "Verb-object: stores the payload; options stay keyword."--["pipelex/system/pipelex_service/remote_config_fetcher.py::RemoteConfigFetcher._build_unavailable_error"]-param = "fetch_error"-rationale = "Builds the error from the fetch exception; single operand."--["pipelex/system/pipelex_service/remote_config_fetcher.py::RemoteConfigFetcher._fetch_fresh"]-param = "url"-rationale = "Verb-object: fetches the URL; options stay keyword."--["pipelex/system/pipelex_service/remote_config_fetcher.py::RemoteConfigFetcher._fetch_remote_config_with_retry"]-param = "url"-rationale = "Verb-object: fetches the URL; options stay keyword."--["pipelex/system/pipelex_service/remote_config_fetcher.py::RemoteConfigFetcher._fetch_remote_config_with_retry._fetch_with_retry"]-param = "url"-rationale = "Nested retry closure fetching the URL; single operand."--["pipelex/system/pipelex_service/remote_config_fetcher.py::RemoteConfigFetcher._log_retry_attempt"]-param = "retry_state"-rationale = "Positional Callable protocol: tenacity before_sleep callback, invoked callback(retry_state)."-["pipelex/system/registries/class_registry_utils.py::ClassRegistryUtils.auto_register_all_subclasses"]param = "base_class"rationale = "Verb-object: registers subclasses of the base class; options stay keyword."diff --git a/tests/conftest.py b/tests/conftest.pyindex 9f4307607..2a6cbac42 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -10,9 +10,6 @@ from pipelex import logfrom pipelex.interpreter_hub import clear_current_library, get_current_library_id_or_none, get_library_manager, set_current_libraryfrom pipelex.pipelex import Pipelexfrom pipelex.system.job_metadata import JobMetadata, RunMetadata-from pipelex.system.pipelex_service.remote_config import RemoteConfig-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcher, RemoteConfigResult-from pipelex.system.pipelex_service.types import RemoteConfigSourcefrom pipelex.system.runtime import IntegrationMode, runtime_managerfrom pipelex.system.telemetry.telemetry_manager_abstract import TelemetryManagerAbstract@@ -25,22 +22,6 @@ pytest_plugins = [TEST_OUTPUTS_DIR = "temp/test_outputs"-# Session-level cache for remote config (using dict to avoid global statement)-_remote_config_cache: dict[str, RemoteConfig] = {}-_original_fetch_remote_config = RemoteConfigFetcher.fetch_remote_config---def _cached_fetch_remote_config(require_fresh: bool = False) -> "RemoteConfigResult": # ruff: ignore[unused-function-argument]- """Wrapper that caches the remote config for the entire test session.-- The ``require_fresh`` arg matches the new fetcher signature; ignored here because the- test-session cache exists precisely so we don't re-hit the network mid-suite.- """- if "config" not in _remote_config_cache:- result = _original_fetch_remote_config()- _remote_config_cache["config"] = result.config- return RemoteConfigResult(config=_remote_config_cache["config"], source=RemoteConfigSource.FRESH, cached_at=None)-def _fast_telemetry_teardown(self: "TelemetryManager") -> None:"""Skip expensive OTel/PostHog shutdown during tests (~0.49s per call).@@ -68,9 +49,7 @@ def _fast_telemetry_teardown(self: "TelemetryManager") -> None:@pytest.fixture(scope="session", autouse=True)def cache_configs_for_session(session_mocker: MockerFixture):- """Cache configurations and optimize teardown for the entire test session."""- # Cache remote config to avoid repeated network fetches- session_mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _cached_fetch_remote_config)+ """Optimize teardown for the entire test session."""# Skip expensive telemetry shutdown (OTel + PostHog flush) during testsfrom pipelex.system.telemetry.telemetry_manager import TelemetryManager # ruff: ignore[import-outside-top-level]diff --git a/tests/data/errors/error_identity.txt b/tests/data/errors/error_identity.txtindex 86675e1d9..cc2bf1cc2 100644--- a/tests/data/errors/error_identity.txt+++ b/tests/data/errors/error_identity.txt@@ -102,8 +102,6 @@ FileTypeError | File type | https://docs.pipelex.com/latest/errors/file-type-errFixTransactionError | Fix transaction | https://docs.pipelex.com/latest/errors/fix-transaction-error/FixWriteConflictError | Fix write conflict | https://docs.pipelex.com/latest/errors/fix-write-conflict-error/FuncRegistryError | Func registry | https://docs.pipelex.com/latest/errors/func-registry-error/-GatewayConfigMergeError | Gateway config merge | https://docs.pipelex.com/latest/errors/gateway-config-merge-error/-GatewayUnknownModelError | Gateway unknown model | https://docs.pipelex.com/latest/errors/gateway-unknown-model-error/GcpLogSinkCredentialsError | Log sink credentials missing or refused | https://docs.pipelex.com/latest/errors/gcp-log-sink-credentials-error/GeneratedImageError | Generated image | https://docs.pipelex.com/latest/errors/generated-image-error/GoogleImgGenWorkerError | Google img gen worker | https://docs.pipelex.com/latest/errors/google-img-gen-worker-error/@@ -259,8 +257,6 @@ PipelexCLIError | Pipelex CLI | https://docs.pipelex.com/latest/errors/pipelex-cPipelexConfigError | Pipelex config | https://docs.pipelex.com/latest/errors/pipelex-config-error/PipelexError | Pipelex error | https://docs.pipelex.com/latest/errors/pipelex-error/PipelexRuntimeBridgeError | Pipelex runtime bridge | https://docs.pipelex.com/latest/errors/pipelex-runtime-bridge-error/-PipelexServiceConfigValidationError | Pipelex service config validation | https://docs.pipelex.com/latest/errors/pipelex-service-config-validation-error/-PipelexServiceError | Pipelex service | https://docs.pipelex.com/latest/errors/pipelex-service-error/PipelexSetupError | Pipelex setup | https://docs.pipelex.com/latest/errors/pipelex-setup-error/PipelexUnexpectedError | Unexpected internal error | https://docs.pipelex.com/latest/errors/pipelex-unexpected-error/PipelineExecutionError | Pipeline execution | https://docs.pipelex.com/latest/errors/pipeline-execution-error/@@ -286,9 +282,6 @@ PromptImageFactoryError | Prompt image factory | https://docs.pipelex.com/latestPromptImageFormatError | Prompt image format | https://docs.pipelex.com/latest/errors/prompt-image-format-error/PyPdfium2RendererError | Py pdfium 2 renderer | https://docs.pipelex.com/latest/errors/py-pdfium2-renderer-error/ReadinessCheckError | Readiness check | https://docs.pipelex.com/latest/errors/readiness-check-error/-RemoteConfigFetchError | Remote config fetch | https://docs.pipelex.com/latest/errors/remote-config-fetch-error/-RemoteConfigUnavailableError | Remote config unavailable | https://docs.pipelex.com/latest/errors/remote-config-unavailable-error/-RemoteConfigValidationError | Remote config validation | https://docs.pipelex.com/latest/errors/remote-config-validation-error/RemoteFileFetchError | Remote file could not be fetched | https://docs.pipelex.com/latest/errors/remote-file-fetch-error/ReportingManagerError | Reporting manager | https://docs.pipelex.com/latest/errors/reporting-manager-error/ReservedServiceErrorCodeError | Reserved service error code | https://docs.pipelex.com/latest/errors/reserved-service-error-code-error/diff --git a/tests/data/inference/previous_release_kit/backends.toml b/tests/data/inference/previous_release_kit/backends.tomlnew file mode 100644index 000000000..28a5a7777--- /dev/null+++ b/tests/data/inference/previous_release_kit/backends.toml@@ -0,0 +1,132 @@+####################################################################################################+# Pipelex Inference Backends Configuration+####################################################################################################+#+# This file configures the inference backends available to Pipelex.+# Each backend connects to a different AI service provider (OpenAI, Anthropic, Google, etc.).+#+# Documentation: https://docs.pipelex.com+# Support: https://go.pipelex.com/discord+#+####################################################################################################++[pipelex_gateway]+display_name = "⭐ Pipelex Gateway"+enabled = true # Enable after accepting terms via `pipelex init config`+api_key = "${PIPELEX_GATEWAY_API_KEY}"++# Pipelex Manifold is a closed private beta: leave it off unless you have been invited.+[pipelex_manifold]+display_name = "Pipelex Manifold (private beta)"+enabled = false+endpoint = "${PIPELEX_MANIFOLD_ENDPOINT}"+api_key = "${PIPELEX_MANIFOLD_API_KEY}"+model_specs_section = "manifold_model_specs"+auth_header = "x-pipelex-api-key"++[anthropic]+enabled = true+api_key = "${ANTHROPIC_API_KEY}"++[azure_openai]+display_name = "Azure OpenAI"+enabled = true+endpoint = "${AZURE_API_BASE}"+api_key = "${AZURE_API_KEY}"+api_version = "${AZURE_API_VERSION}"++[bedrock]+display_name = "Amazon Bedrock"+enabled = true+aws_region = "${AWS_REGION}"++[blackboxai]+display_name = "BlackBox AI"+enabled = true+endpoint = "https://api.blackbox.ai/v1"+api_key = "${BLACKBOX_API_KEY}"++[fal]+display_name = "FAL"+enabled = true+api_key = "${FAL_API_KEY}"++[google]+display_name = "Google AI"+enabled = true+api_key = "${GOOGLE_API_KEY}"++[groq]+display_name = "Groq"+enabled = true+endpoint = "https://api.groq.com/openai/v1"+api_key = "${GROQ_API_KEY}"++[huggingface]+display_name = "Hugging Face"+enabled = true+api_key = "${HF_TOKEN}"++[linkup]+display_name = "Linkup"+enabled = true+api_key = "${LINKUP_API_KEY}"++[minimax]+display_name = "MiniMax"+enabled = true+endpoint = "https://api.minimax.io/anthropic"+api_key = "${MINIMAX_API_KEY}"++[mistral]+display_name = "Mistral AI"+enabled = true+api_key = "${MISTRAL_API_KEY}"++[ollama]+enabled = true+endpoint = "http://localhost:11434/v1"++[openai]+display_name = "OpenAI"+enabled = true+api_key = "${OPENAI_API_KEY}"++[openrouter]+display_name = "OpenRouter"+enabled = true+endpoint = "https://openrouter.ai/api/v1"+api_key = "${OPENROUTER_API_KEY}"++[portkey]+display_name = "Portkey"+enabled = true+endpoint = "https://api.portkey.ai/v1"+api_key = "${PORTKEY_API_KEY}"++[scaleway]+display_name = "Scaleway"+enabled = true+endpoint = "${SCALEWAY_ENDPOINT}"+api_key = "${SCALEWAY_API_KEY}"++[typesafe]+display_name = "TypeSafe"+enabled = true+api_key = "${TYPESAFE_API_KEY}"++[vertexai]+display_name = "Google Vertex AI"+enabled = false # This is the only one we disable because setting it up requires internet access just to get credentials so it fails in CI sandboxes+gcp_project_id = "${GCP_PROJECT_ID}"+gcp_location = "${GCP_LOCATION}"+gcp_credentials_file_path = "${GCP_CREDENTIALS_FILE_PATH}"++[xai]+display_name = "xAI"+enabled = true+endpoint = "https://api.x.ai/v1"+api_key = "${XAI_API_KEY}"++[internal] # software-only backend, runs internally, without AI+enabled = truediff --git a/.pipelex/inference/backends/pipelex_manifold.toml b/tests/data/inference/previous_release_kit/backends/pipelex_gateway.tomlsimilarity index 61%rename from .pipelex/inference/backends/pipelex_manifold.tomlrename to tests/data/inference/previous_release_kit/backends/pipelex_gateway.tomlindex d2130ec85..5b02901ee 100644--- a/.pipelex/inference/backends/pipelex_manifold.toml+++ b/tests/data/inference/previous_release_kit/backends/pipelex_gateway.toml@@ -1,24 +1,14 @@################################################################################-# Pipelex Manifold Local Overrides-################################################################################-#-# PRIVATE BETA:-#-# Pipelex Manifold is the Pipelex-operated inference service. It is in private-# beta, it ships disabled in backends.toml, and this file does nothing until you-# enable it there and set PIPELEX_MANIFOLD_ENDPOINT and PIPELEX_MANIFOLD_API_KEY.-#+# Pipelex Gateway Local Overrides################################################################################## TELEMETRY NOTICE:#-# This backend sends no telemetry from your machine: the runtime's only-# telemetry stream is the one you configure yourself in telemetry.toml.-# Manifold is a Pipelex-operated service, though, so your usage of it is-# recorded server-side the way any hosted platform records the calls it serves.+# Using Pipelex Gateway enables identified telemetry tied to your API key+# (hashed for security). This is independent from your telemetry.toml settings.#-# We collect only technical data (model names, token counts, latency, error-# rates). We do NOT collect prompts, completions, pipe codes, or business data.+# We collect only technical data (model names, token counts, latency, error rates).+# We do NOT collect prompts, completions, pipe codes, or business data.## This allows us to monitor service quality, enforce fair usage, and support you.#@@ -47,5 +37,5 @@# Per-model overrides example:# [gpt-4o]-# sdk = "manifold_completions"+# sdk = "gateway_completions"# structure_method = "instructor/openai_tools"diff --git a/tests/data/inference/previous_release_kit/routing_profiles.toml b/tests/data/inference/previous_release_kit/routing_profiles.tomlnew file mode 100644index 000000000..25619b1ee--- /dev/null+++ b/tests/data/inference/previous_release_kit/routing_profiles.toml@@ -0,0 +1,182 @@+# Routing profile library - Routes models to their backends+# =========================================================================================+# This file controls which backend serves which model.+# Simply change the 'active' field to switch profiles,+# or you can add your own custom profiles.+#+# Documentation: https://docs.pipelex.com+# Support: https://go.pipelex.com/discord+# =========================================================================================++# Note: The internal backend (software-only models) is always available regardless of+# which routing profile you select. See the documentation for details.++# Which profile to use (change this to switch routing)+active = "all_pipelex_gateway"++# We recommend using the "all_pipelex_gateway" profile to get a head start with all models.+# To use the Pipelex Gateway backend:+# 1. Get your API key at https://app.pipelex.com (free credits included)+# 2. Add it to your .env file: PIPELEX_GATEWAY_API_KEY=your-key-here+# 3. Run `pipelex init` and accept the Gateway terms of service++# =========================================================================================+# Routing Profiles+# =========================================================================================++[profiles.all_pipelex_gateway]+description = "Use Pipelex Gateway for all its supported models"+default = "pipelex_gateway"++# Judgment models are brought by you rather than served by Pipelex, so they go to their own backend+# whenever it is enabled. An optional route is inert while its backend is disabled.+[profiles.all_pipelex_gateway.optional_routes]+"jev-*" = "typesafe"++# The same model names, served by the Pipelex-operated inference service instead. Switching between+# this profile and the one above needs no other edit: a model's wire id and sdk are per-backend, so+# decks, aliases and presets keep naming the same handles.+[profiles.all_pipelex_manifold]+description = "Use Pipelex Manifold (private beta) for all its supported models"+default = "pipelex_manifold"++# Judgment models are brought by you rather than served by Pipelex, so they go to their own backend+# whenever it is enabled. An optional route is inert while its backend is disabled.+[profiles.all_pipelex_manifold.optional_routes]+"jev-*" = "typesafe"++[profiles.all_anthropic]+description = "Use Anthropic backend for all its supported models"+default = "anthropic"++[profiles.all_azure_openai]+description = "Use Azure OpenAI backend for all its supported models"+default = "azure_openai"++[profiles.all_bedrock]+description = "Use Bedrock backend for all its supported models"+default = "bedrock"++[profiles.all_blackboxai]+description = "Use BlackBoxAI backend for all its supported models"+default = "blackboxai"++[profiles.all_fal]+description = "Use FAL backend for all its supported models"+default = "fal"++[profiles.all_google]+description = "Use Google GenAI backend for all its supported models"+default = "google"++[profiles.all_groq]+description = "Use groq backend for all its supported models"+default = "groq"++[profiles.all_huggingface]+description = "Use HuggingFace backend for all its supported models"+default = "huggingface"++[profiles.all_linkup]+description = "Use Linkup backend for all its supported models"+default = "linkup"++[profiles.all_minimax]+description = "Use MiniMax backend for all its supported models"+default = "minimax"++[profiles.all_mistral]+description = "Use Mistral backend for all its supported models"+default = "mistral"++[profiles.all_ollama]+description = "Use Ollama backend for all its supported models"+default = "ollama"++[profiles.all_openai]+description = "Use OpenAI backend for all its supported models"+default = "openai"++[profiles.all_openrouter]+description = "Use OpenRouter backend for all its supported models"+default = "openrouter"++[profiles.all_portkey]+description = "Use Portkey backend for all its supported models"+default = "portkey"++[profiles.all_scaleway]+description = "Use Scaleway backend for all its supported models"+default = "scaleway"++[profiles.all_typesafe]+description = "Use TypeSafe backend for all its supported models"+default = "typesafe"++[profiles.all_vertexai]+description = "Use Vertex AI backend for all its supported models"+default = "vertexai"++[profiles.all_xai]+description = "Use xAI backend for all its supported models"+default = "xai"++[profiles.all_internal]+description = "Use internal backend for all its supported models"+default = "internal"++# =========================================================================================+# Custom Profiles+# =========================================================================================+# Add your own profiles below following the same pattern:+#+# [profiles.your_profile_name]+# description = "What this profile does"+# default = "backend-name" # Where to route models by default+# [profiles.your_profile_name.routes]+# "model-pattern" = "backend-name" # Specific routing rules+#+# Pattern matching supports:+# - Exact names: "gpt-4o-mini"+# - Wildcards: "claude-*" (matches all models starting with claude-)+# - Partial wildcards: "*-sonnet" (matches all sonnet variants)++# =========================================================================================+# Example of a custom routing profile with mostly pattern matching and one specific model+# =========================================================================================+[profiles.example_routing_using_patterns]+description = "Example routing profile using patterns"+default = "pipelex_gateway"++[profiles.example_routing_using_patterns.routes]+# Pattern matching: "model-pattern" = "backend-name"+"gpt-*" = "azure_openai"+"claude-*" = "bedrock"+"gemini-*" = "google"+"grok-*" = "xai"+"*-sdxl" = "fal"+"flux-*" = "fal"+"gpt-image-1" = "openai"++# =========================================================================================+# Example of a custom routing profile with specific model matching+# =========================================================================================++[profiles.example_routing_using_specific_models]+description = "Example routing profile using specific models"++[profiles.example_routing_using_specific_models.routes]+"gpt-5.4-nano" = "pipelex_gateway"+"gpt-4o-mini" = "blackboxai"+"gpt-5.4-mini" = "openai"+"gpt-5.5" = "azure_openai"++"claude-4-sonnet" = "pipelex_gateway"+"claude-3.7-sonnet" = "blackboxai"++"gemini-2.5-flash-lite" = "pipelex_gateway"+"gemini-2.5-flash" = "blackboxai"+"gemini-2.5-pro" = "vertexai"++"grok-3" = "pipelex_gateway"+"grok-3-mini" = "xai"diff --git a/tests/e2e/agent_cli/conftest.py b/tests/e2e/agent_cli/conftest.pyindex 1e84791e6..857566a9a 100644--- a/tests/e2e/agent_cli/conftest.py+++ b/tests/e2e/agent_cli/conftest.py@@ -2,165 +2,38 @@The tests in this directory invoke ``.venv/bin/pipelex-agent`` directly so we exercise theexact surface that fails under the codex-sandbox handoff. To keep the runs hermetic each-test gets its own ``HOME`` pointing at ``tmp_path`` — that controls both the location of-the ``.pipelex/`` config directory AND the ``~/.pipelex/cache/`` directory the offline-fallback reads.+test gets its own ``HOME`` pointing at ``tmp_path``, which controls the location of the+``.pipelex/`` config directory.The kit configs are copied wholesale so the subprocess sees a realistic Pipelex install,-not a hand-rolled minimal one. Per-test tweaks (manifold enabled/disabled, primed cache-content) layer on top.+not a hand-rolled minimal one. Per-test tweaks (the active routing profile) layer on top."""from __future__ import annotations-import jsonimport shutil-from datetime import UTC, datetimefrom pathlib import Path-from typing import TYPE_CHECKING, Anyimport pytest-from pipelex.cogt.model_backends.backend import PipelexBackend-from pipelex.cogt.model_backends.model_type import ModelType-from pipelex.cogt.models.exceptions import ModelReferenceParseError-from pipelex.cogt.models.model_deck_loader import load_model_deck_blueprint-from pipelex.cogt.models.model_manager import ModelManager-from pipelex.cogt.models.model_reference import ModelReference, ModelReferenceKindfrom pipelex.kit.paths import get_kit_configs_dir-from pipelex.system.pipelex_service.remote_config_cache import CACHE_SCHEMA_VERSION-from pipelex.tools.misc.toml_utils import load_toml_from_path--if TYPE_CHECKING:- from pipelex.cogt.models.model_deck import (- ExtractDeckBlueprint,- ImgGenDeckBlueprint,- LLMDeckBlueprint,- ModelDeckBlueprint,- SearchDeckBlueprint,- )REPO_ROOT = Path(__file__).resolve().parents[3]PIPELEX_AGENT_BIN = REPO_ROOT / ".venv" / "bin" / "pipelex-agent"OFFLINE_BUNDLES_DIR = REPO_ROOT / "tests" / "e2e" / "data" / "offline_mode"-# Reserved/unroutable address — httpx will raise ConnectError immediately without hanging.-UNREACHABLE_REMOTE_CONFIG_URL = "http://127.0.0.1:1/pipelex_remote_config.json"--# Minimal-but-valid manifold spec bodies per model type (valid against InferenceModelSpecBlueprint).-# Each ``sdk`` names the dedicated manifold worker for its type — manifold_completions (LLM),-# manifold_img_gen (image), manifold_extract, manifold_search — i.e. a value the manifold plugin-# registers for that family (an unrecognized sdk would be refused at worker creation).-# The sdk is consumed only at worker creation, which the offline dry-run tests never reach-# (the cogt leaf mocks generation under DRY), so the membership check is indifferent to it — but it must still-# be real so the fake cache stays faithful and any non-dry consumer of this helper can build a worker.-_MANIFOLD_SPEC_TEMPLATE_BY_TYPE: dict[ModelType, dict[str, Any]] = {- ModelType.LLM: {"sdk": "manifold_completions", "model_type": "llm", "inputs": ["text"], "outputs": ["text", "structured"]},- ModelType.IMG_GEN: {"sdk": "manifold_img_gen", "model_type": "img_gen"},- ModelType.TEXT_EXTRACTOR: {"sdk": "manifold_extract", "model_type": "text_extractor"},- ModelType.SEARCH: {"sdk": "manifold_search", "model_type": "search"},-}---def _deck_section_handle_references(- section: LLMDeckBlueprint | ExtractDeckBlueprint | ImgGenDeckBlueprint | SearchDeckBlueprint,-) -> list[str]:- """Every raw model reference a deck section names via aliases, waterfalls, or presets.-- Choice defaults are intentionally NOT read here: in the kit deck they are always- ``@alias`` / ``$preset`` references, so the terminal handles they resolve to are- already named as alias targets / preset models and get collected anyway. Skipping- them keeps this free of the ``disabled`` sentinel and the typed choice-default union.- """- raw_references: list[str] = list(section.aliases.values())- for waterfall_entries in section.waterfalls.values():- raw_references.extend(waterfall_entries)- for preset in section.presets.values():- raw_references.append(preset.model)- return raw_references---def load_kit_model_deck_blueprint() -> ModelDeckBlueprint:- """Load the shipped kit deck blueprint — the same deck files the offline subprocess loads."""- deck_dir = Path(str(get_kit_configs_dir())) / "inference" / "deck"- return load_model_deck_blueprint(model_deck_paths=ModelManager.get_model_deck_paths(deck_dir_path=str(deck_dir)))---def software_only_internal_handles() -> set[str]:- """Handles served by the local ``internal`` backend — the ones Pipelex Manifold never provides.-- ``PipelexBackend.INTERNAL`` is the software-only backend ("runs internally, without AI" — e.g. the- pypdfium2 / docling text extractors). Those handles have no manifold equivalent, so they must be- excluded from the derived manifold specs: otherwise the primed cache would claim the manifold serves a- software-only extractor, and a deck alias like ``@default-no-inference`` / ``@default-text-from-pdf``- could resolve through the fake ``manifold_extract`` worker instead of the real internal backend.-- Read straight from the shipped backend spec file (no booted Pipelex needed) and keyed off the enum- value, so adding a new software-only extractor to the internal backend auto-excludes it here too.- Provider-backed models (claude, gpt, linkup, nano-banana, ...) are intentionally NOT excluded: the- manifold genuinely proxies those, so they belong in the faithful manifold cache.- """- internal_spec_path = Path(str(get_kit_configs_dir())) / "inference" / "backends" / f"{PipelexBackend.INTERNAL}.toml"- raw_specs = load_toml_from_path(path=str(internal_spec_path))- return {name for name, spec in raw_specs.items() if name != "defaults" and isinstance(spec, dict)}---def manifold_model_specs_for_kit_deck() -> dict[str, Any]:- """Build a manifold ``manifold_model_specs`` payload covering every concrete model handle the kit deck names.-- Derived from the shipped kit deck rather than a hand-maintained list, so the primed- offline cache auto-tracks deck changes — e.g. promoting a premium alias to a new model- no longer silently breaks these tests. Every bare handle named in the deck's aliases,- waterfalls, and presets (across all model types) gets a minimal spec declaring the- manifold sdk for its type — all ``ModelManager._enforce_gateway_model_membership`` needs- is name membership. Deck/manifold consistency itself is covered by ``TestModelDeckReferences``.-- Handles served by the software-only ``internal`` backend (see ``software_only_internal_handles``)- are excluded: the manifold never provides them, so claiming it does would make the fake cache- unfaithful and let a software-only extractor alias resolve through the manifold worker. Those- handles are still reachable in the offline subprocess via the local internal backend, so the- membership check passes for them without a manifold spec.- """- blueprint = load_kit_model_deck_blueprint()- excluded_handles = software_only_internal_handles()-- handle_model_types: dict[str, ModelType] = {}- for model_type, section in (- (ModelType.LLM, blueprint.llm),- (ModelType.TEXT_EXTRACTOR, blueprint.extract),- (ModelType.IMG_GEN, blueprint.img_gen),- (ModelType.SEARCH, blueprint.search),- ):- for raw_reference in _deck_section_handle_references(section):- try:- ref = ModelReference.parse(raw_reference)- except ModelReferenceParseError:- continue- match ref.kind:- case ModelReferenceKind.HANDLE:- if ref.name in excluded_handles:- continue- handle_model_types.setdefault(ref.name, model_type)- case ModelReferenceKind.ALIAS | ModelReferenceKind.WATERFALL | ModelReferenceKind.PRESET:- continue-- specs: dict[str, Any] = {"defaults": {"sdk": "manifold_completions"}}- for handle, model_type in handle_model_types.items():- specs[handle] = dict(_MANIFOLD_SPEC_TEMPLATE_BY_TYPE[model_type])- return specs-def _copy_kit_configs_into(pipelex_dir: Path) -> None:"""Mirror the kit's ``configs/`` tree into ``pipelex_dir`` so the subprocess can boot.- Copies the top-level config files (``pipelex.toml``, ``telemetry.toml``,- ``pipelex_service.toml``, ``plxt.toml``) and the ``inference/`` subtree+ Copies the top-level config files (``pipelex.toml``, ``telemetry.toml``, ``plxt.toml``)+ and the ``inference/`` subtree(``backends.toml``, ``routing_profiles.toml``, ``backends/``, ``deck/``)."""kit_configs_dir = Path(str(get_kit_configs_dir()))pipelex_dir.mkdir(parents=True, exist_ok=True)- for top_level_file in ("pipelex.toml", "telemetry.toml", "pipelex_service.toml", "plxt.toml"):+ for top_level_file in ("pipelex.toml", "telemetry.toml", "plxt.toml"):shutil.copy2(kit_configs_dir / top_level_file, pipelex_dir / top_level_file)inference_dir = pipelex_dir / "inference"@@ -176,34 +49,6 @@ def _copy_kit_configs_into(pipelex_dir: Path) -> None:shutil.copy2(source_file, dst / source_file.name)-def set_manifold_enabled(backends_path: Path, *, enabled: bool) -> None:- """Toggle ``[pipelex_manifold].enabled`` in a backends.toml file in place.-- Avoids loading the file through ``tomlkit`` (which the kit configs are encoded with)- by doing a targeted text rewrite of the ``enabled`` line inside the ``[pipelex_manifold]``- section.- """- original_text = backends_path.read_text(encoding="utf-8")- lines = original_text.splitlines(keepends=True)- target_value = "true" if enabled else "false"- in_manifold_section = False- rewrote = False- for index, line in enumerate(lines):- stripped = line.strip()- if stripped.startswith("[") and stripped.endswith("]"):- in_manifold_section = stripped == "[pipelex_manifold]"- continue- if in_manifold_section and stripped.startswith("enabled"):- indent = line[: len(line) - len(line.lstrip())]- lines[index] = f"{indent}enabled = {target_value} # set by offline-mode E2E fixture\n"- rewrote = True- break- if not rewrote:- msg = f"Could not find [pipelex_manifold].enabled in {backends_path}"- raise AssertionError(msg)- backends_path.write_text("".join(lines), encoding="utf-8")--def write_active_routing_profile(routing_profiles_path: Path, active_profile: str) -> None:"""Rewrite the ``active = "..."`` line in routing_profiles.toml in place."""original_text = routing_profiles_path.read_text(encoding="utf-8")@@ -220,26 +65,12 @@ def write_active_routing_profile(routing_profiles_path: Path, active_profile: strouting_profiles_path.write_text("".join(lines), encoding="utf-8")-def write_remote_config_cache(pipelex_dir: Path, raw_config: dict[str, Any]) -> Path:- """Write a primed ``cache/remote_config.json`` matching ``RemoteConfigCache``'s schema."""- cache_dir = pipelex_dir / "cache"- cache_dir.mkdir(parents=True, exist_ok=True)- cache_path = cache_dir / "remote_config.json"- payload = {- "schema_version": CACHE_SCHEMA_VERSION,- "cached_at": datetime.now(tz=UTC).isoformat(),- "raw_config": raw_config,- }- cache_path.write_text(json.dumps(payload), encoding="utf-8")- return cache_path--@pytest.fixturedef hermetic_home(tmp_path: Path) -> Path:"""Return a tmp ``HOME`` that already has a populated ``.pipelex/`` config tree.- Tests further tweak the resulting directory (toggle the manifold, prime cache, ...) before- invoking the subprocess.+ Tests further tweak the resulting directory (the active routing profile) before invoking the+ subprocess."""pipelex_dir = tmp_path / ".pipelex"_copy_kit_configs_into(pipelex_dir)@@ -248,8 +79,7 @@ def hermetic_home(tmp_path: Path) -> Path:@pytest.fixturedef offline_subprocess_env(hermetic_home: Path) -> dict[str, str]:- """Base subprocess env that points the CLI at the hermetic HOME and an unreachable- remote-config URL.+ """Base subprocess env that points the CLI at the hermetic HOME.Tests extend this dict before passing it to ``subprocess.run``. Dummy credentials arepopulated for every backend that the kit's ``backends.toml`` references so the dry-run@@ -261,15 +91,12 @@ def offline_subprocess_env(hermetic_home: Path) -> dict[str, str]:env: dict[str, str] = {"HOME": str(hermetic_home),"PATH": "/usr/bin:/bin:/usr/local/bin",- "PIPELEX_REMOTE_CONFIG_URL": UNREACHABLE_REMOTE_CONFIG_URL,# Force CI test mode so vertexai is skipped."RUN_MODE": "ci_test",# Dummy credentials — the test never makes a real provider call (dry-run only) and# ``lenient=True`` (set by ``--dry-run``) skips backends whose env vars are missing# rather than raising. We populate every key so backend loading is deterministic# regardless of the developer's shell environment.- "PIPELEX_MANIFOLD_ENDPOINT": "https://manifold.example.invalid",- "PIPELEX_MANIFOLD_API_KEY": "dummy-manifold-key","ANTHROPIC_API_KEY": "dummy-anthropic-key","AWS_REGION": "us-east-1","AZURE_API_BASE": "https://example.invalid",@@ -301,11 +128,5 @@ def offline_subprocess_env(hermetic_home: Path) -> dict[str, str]:__all__ = ["OFFLINE_BUNDLES_DIR","PIPELEX_AGENT_BIN",- "UNREACHABLE_REMOTE_CONFIG_URL",- "manifold_model_specs_for_kit_deck",- "load_kit_model_deck_blueprint",- "set_manifold_enabled",- "software_only_internal_handles","write_active_routing_profile",- "write_remote_config_cache",]diff --git a/tests/e2e/agent_cli/test_fix_bundle.py b/tests/e2e/agent_cli/test_fix_bundle.pyindex 6ccd38a59..8fc55f220 100644--- a/tests/e2e/agent_cli/test_fix_bundle.py+++ b/tests/e2e/agent_cli/test_fix_bundle.py@@ -8,7 +8,7 @@ from typing import TYPE_CHECKINGimport pytest-from tests.e2e.agent_cli.conftest import PIPELEX_AGENT_BIN, set_manifold_enabled+from tests.e2e.agent_cli.conftest import PIPELEX_AGENT_BINif TYPE_CHECKING:from pathlib import Path@@ -70,8 +70,6 @@ def _run_fix_bundle(bundle_path: Path, *, env: dict[str, str], cwd: Path) -> sub@pytest.mark.gha_disabledclass TestFixBundleE2E:def test_fixable_bundle_outputs_clean_json_and_writes_file(self, hermetic_home: Path, offline_subprocess_env: dict[str, str]) -> None:- pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=False)bundle_path = hermetic_home / "bundle.mthds"bundle_path.write_text(_FIXABLE_SEQUENCE_MTHDS, encoding="utf-8")@@ -86,8 +84,6 @@ class TestFixBundleE2E:assert 'output = "Idea[]"' in bundle_path.read_text(encoding="utf-8")def test_unfixable_bundle_outputs_json_error_and_exit_one(self, hermetic_home: Path, offline_subprocess_env: dict[str, str]) -> None:- pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=False)bundle_path = hermetic_home / "bundle.mthds"bundle_path.write_text(_UNFIXABLE_MTHDS, encoding="utf-8")diff --git a/tests/e2e/agent_cli/test_offline_run_dry.py b/tests/e2e/agent_cli/test_offline_run_dry.pyindex d20d903d8..9eba71b71 100644--- a/tests/e2e/agent_cli/test_offline_run_dry.py+++ b/tests/e2e/agent_cli/test_offline_run_dry.py@@ -1,10 +1,8 @@"""E2E tests for offline-mode dry-run via the agent CLI subprocess.-These tests pin Phase 5 of the offline-mode plan: invoke the real ``pipelex-agent run-bundle ... --dry-run --mock-inputs`` against the same surface that fails today in-codex-sandbox handoffs, with the remote-config URL pointed at an unreachable address so-the network behaviour is honest (real ``httpx.ConnectError``) rather than mocked. Each-test gets its own ``HOME``; the ``conftest`` fixtures handle the .pipelex/ scaffolding.+These tests invoke the real ``pipelex-agent run bundle ... --dry-run --mock-inputs`` against+the same surface codex-sandbox handoffs use, with no network and dummy credentials. Each test+gets its own ``HOME``; the ``conftest`` fixtures handle the .pipelex/ scaffolding."""from __future__ import annotations@@ -16,15 +14,10 @@ from typing import TYPE_CHECKING, castimport pytest-from pipelex.cogt.models.model_reference import ModelReferencefrom tests.e2e.agent_cli.conftest import (OFFLINE_BUNDLES_DIR,PIPELEX_AGENT_BIN,- load_kit_model_deck_blueprint,- manifold_model_specs_for_kit_deck,- set_manifold_enabled,write_active_routing_profile,- write_remote_config_cache,)if TYPE_CHECKING:@@ -107,20 +100,6 @@ def _parse_agent_json(output: str) -> dict[str, object]:raise AssertionError(msg)-def _cached_remote_config_payload() -> dict[str, object]:- """A structurally complete cached remote-config payload for the primed-cache scenarios.-- The manifold section is derived from the shipped kit deck (see- ``manifold_model_specs_for_kit_deck``) so the gateway-membership check in- ``Pipelex.setup`` accepts the cache without a hand-maintained handle list that goes- stale whenever the deck promotes an alias to a new model.- """- return {- "manifold_model_specs": manifold_model_specs_for_kit_deck(),- "aws_region": "us-east-1",- }--@pytest.mark.gha_disabled # Slow subprocess-based E2E; runs locally and on PR-gated workflows.class TestOfflineDryRun:def test_parse_agent_json_returns_last_when_preamble_present(self) -> None:@@ -146,7 +125,7 @@ class TestOfflineDryRun:"""envelope = {"text": "mock result",- "warnings": [{"id": "WARN-1", "type": "RemoteConfigStale"}],+ "warnings": [{"id": "WARN-1", "type": "SomeWarning"}],}parsed = _parse_agent_json(json.dumps(envelope, indent=2))assert parsed == envelope, parsed@@ -154,9 +133,8 @@ class TestOfflineDryRun:assert "warnings" in parsed, f"the outer envelope (with 'warnings') must be returned: {parsed!r}"def test_byok_offline_succeeds(self, hermetic_home: Path, offline_subprocess_env: dict[str, str]) -> None:- """No managed gateway + no network + no cache → dry-run exits 0 with structured success JSON."""+ """BYOK + no network → dry-run exits 0 with structured success JSON."""pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=False)write_active_routing_profile(pipelex_dir / "inference" / "routing_profiles.toml", "all_anthropic")staged_bundle = _stage_bundle(OFFLINE_BUNDLES_DIR / "byok_simple", hermetic_home)@@ -168,129 +146,3 @@ class TestOfflineDryRun:# synthetic output under "text" (or a typed key) instead.assert "error" not in payload, payloadassert "text" in payload, payload-- def test_manifold_no_cache_no_network_fails_with_unavailable(self, hermetic_home: Path, offline_subprocess_env: dict[str, str]) -> None:- """Manifold enabled + no network + no cache → ``RemoteConfigUnavailableError`` with remediation hint."""- pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=True)- write_active_routing_profile(pipelex_dir / "inference" / "routing_profiles.toml", "all_pipelex_manifold")-- staged_bundle = _stage_bundle(OFFLINE_BUNDLES_DIR / "manifold_known_model", hermetic_home)- result = _run_agent_bundle(staged_bundle, offline_subprocess_env, cwd=hermetic_home)-- assert result.returncode != 0, f"Manifold offline with no cache must fail.\nstdout={result.stdout!r}\nstderr={result.stderr!r}"- payload = _parse_agent_json(result.stderr or result.stdout)- assert payload.get("error_type") == "RemoteConfigUnavailableError", payload- message = str(payload.get("message", ""))- assert "pipelex init" in message.lower(), f"Error must mention `pipelex init` remediation; got: {message!r}"-- def test_primed_cache_specs_track_kit_deck_premium_alias(self) -> None:- """Regression: the primed manifold cache is derived from the kit deck, so it tracks alias promotions.-- Reads the deck's own ``default-premium`` target — whatever model it currently points- to — and asserts the derived manifold specs cover it, without hardcoding the model name.- If a future deck promotes the premium alias to a new handle this keeps passing; if the- derivation ever stops covering a referenced handle it fails fast here (a unit-speed- check) instead of deep inside a subprocess setup with an opaque GatewayUnknownModelError.- """- blueprint = load_kit_model_deck_blueprint()- premium_target = blueprint.llm.aliases["default-premium"]- specs = manifold_model_specs_for_kit_deck()- assert premium_target in specs, (- f"Derived manifold specs must cover the kit deck's default-premium target '{premium_target}'; got handles: {sorted(specs)}"- )-- def test_primed_cache_excludes_software_only_internal_handles(self) -> None:- """Regression: the manifold cache must not claim software-only internal extractors as manifold models.-- ``@default-no-inference`` / ``@default-text-from-pdf`` resolve to an extractor served by the- local ``internal`` backend (``PipelexBackend.INTERNAL`` — "runs internally, without AI"), which- Pipelex Manifold never provides. If the derived manifold specs claimed it, an offline dry-run- could resolve the alias to the fake ``manifold_extract`` worker instead of exercising the real- internal backend. The companion assertion guards the other direction: a genuinely manifold-served- extract model (the first choice of the ``default-extract-document`` waterfall) must stay covered, so the exclusion does- not over-reach onto provider-backed models the manifold does proxy.- """- blueprint = load_kit_model_deck_blueprint()- software_only_target = blueprint.extract.aliases["default-no-inference"]- document_waterfall = ModelReference.parse(blueprint.extract.aliases["default-extract-document"])- manifold_extract_target = blueprint.extract.waterfalls[document_waterfall.name][0]- specs = manifold_model_specs_for_kit_deck()- assert software_only_target not in specs, (- f"Derived manifold specs must exclude software-only internal handle '{software_only_target}'; got handles: {sorted(specs)}"- )- assert manifold_extract_target in specs, (- f"Manifold-served extract target '{manifold_extract_target}' must remain covered; got handles: {sorted(specs)}"- )-- def test_manifold_known_with_cache_succeeds_offline(self, hermetic_home: Path, offline_subprocess_env: dict[str, str]) -> None:- """Manifold enabled + no network + primed cache → dry-run exits 0 with stale-cache warning."""- pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=True)- write_active_routing_profile(pipelex_dir / "inference" / "routing_profiles.toml", "all_pipelex_manifold")- write_remote_config_cache(pipelex_dir, _cached_remote_config_payload())-- staged_bundle = _stage_bundle(OFFLINE_BUNDLES_DIR / "manifold_known_model", hermetic_home)- result = _run_agent_bundle(staged_bundle, offline_subprocess_env, cwd=hermetic_home)-- assert result.returncode == 0, f"Manifold dry-run with primed cache must succeed offline.\nstdout={result.stdout!r}\nstderr={result.stderr!r}"- payload = _parse_agent_json(result.stdout)- assert "error" not in payload, payload- rendered = json.dumps(payload)- assert '"type": "RemoteConfigStale"' in rendered, (- f"Cached-source setup must surface a RemoteConfigStale warning on the envelope; got: {payload!r}"- )-- def test_manifold_img_gen_with_cache_succeeds_offline(self, hermetic_home: Path, offline_subprocess_env: dict[str, str]) -> None:- """Manifold enabled + no network + primed cache → an image-gen pipe dry-runs offline.-- Companion to ``test_manifold_known_with_cache_succeeds_offline``, but the bundle's pipe is a- ``PipeImgGen`` referencing a manifold image handle (``gpt-image-2``). It proves the derived- cache covers img_gen handles too — not just LLMs — so the gateway-membership check passes for- an image model and the offline dry-run completes.-- Scope note: dry-run mocks image generation at the cogt leaf, so this does NOT build- the img-gen worker and therefore does not exercise the spec's ``sdk`` -> worker-factory mapping;- it covers membership + handle resolution for image models. The sdk-vs-factory contract is a- runtime (non-dry) concern.- """- pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=True)- write_active_routing_profile(pipelex_dir / "inference" / "routing_profiles.toml", "all_pipelex_manifold")- write_remote_config_cache(pipelex_dir, _cached_remote_config_payload())-- staged_bundle = _stage_bundle(OFFLINE_BUNDLES_DIR / "manifold_img_gen_model", hermetic_home)- result = _run_agent_bundle(staged_bundle, offline_subprocess_env, cwd=hermetic_home)-- assert result.returncode == 0, (- f"Manifold img-gen dry-run with primed cache must succeed offline.\nstdout={result.stdout!r}\nstderr={result.stderr!r}"- )- payload = _parse_agent_json(result.stdout)- assert "error" not in payload, payload-- def test_manifold_unknown_with_cache_fails_with_clear_error(self, hermetic_home: Path, offline_subprocess_env: dict[str, str]) -> None:- """Bundle pipe references a model absent from the cached manifold specs → clear error.-- The default kit deck only references "known" manifold handles, so this scenario fires- at the pipe-operator layer (the membership check at ``ModelManager.setup`` looks at- deck presets/choice defaults, not raw per-pipe model strings). Either way the agent- CLI must surface a structured error with the unknown handle visible — that is the- user-facing contract.- """- pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=True)- write_active_routing_profile(pipelex_dir / "inference" / "routing_profiles.toml", "all_pipelex_manifold")- write_remote_config_cache(pipelex_dir, _cached_remote_config_payload())-- staged_bundle = _stage_bundle(OFFLINE_BUNDLES_DIR / "manifold_unknown_model", hermetic_home)- result = _run_agent_bundle(staged_bundle, offline_subprocess_env, cwd=hermetic_home)-- assert result.returncode != 0, f"Unknown-model bundle must fail.\nstdout={result.stdout!r}\nstderr={result.stderr!r}"- payload = _parse_agent_json(result.stderr or result.stdout)- # The unknown handle should appear somewhere visible in the JSON envelope (message- # or a structured field). Don't pin the error_type — the failure can surface either- # as ``GatewayUnknownModelError`` (if the deck reaches the membership check) or as- # ``PipeOperatorModelAvailabilityError`` (raw model string in the pipe). Both carry- # the model name; what matters is that the agent gets a clear, structured signal.- rendered = json.dumps(payload)- assert "gpt-future-fake-99" in rendered, f"Unknown-model error must surface the model name in the JSON envelope; got: {payload!r}"diff --git a/tests/e2e/data/offline_mode/manifold_img_gen_model/manifold_img_gen_model.mthds b/tests/e2e/data/offline_mode/manifold_img_gen_model/manifold_img_gen_model.mthdsdeleted file mode 100644index 5aca77c1a..000000000--- a/tests/e2e/data/offline_mode/manifold_img_gen_model/manifold_img_gen_model.mthds+++ /dev/null@@ -1,11 +0,0 @@-domain = "offline_manifold_img_gen"-description = "Pipeline referencing a manifold image-generation model that exists in the cached manifold specs"-main_pipe = "manifold_img_gen_pipe"--[pipe]-[pipe.manifold_img_gen_pipe]-type = "PipeImgGen"-description = "Single image-generation step using a manifold-listed image model handle"-output = "Image"-model = "gpt-image-2"-prompt = "A single red circle on a white background."diff --git a/tests/e2e/data/offline_mode/manifold_known_model/manifold_known_model.mthds b/tests/e2e/data/offline_mode/manifold_known_model/manifold_known_model.mthdsdeleted file mode 100644index e7bbbdaea..000000000--- a/tests/e2e/data/offline_mode/manifold_known_model/manifold_known_model.mthds+++ /dev/null@@ -1,12 +0,0 @@-domain = "offline_manifold_known"-description = "Pipeline referencing a manifold model that exists in the cached manifold specs"-main_pipe = "manifold_known_pipe"--[pipe]-[pipe.manifold_known_pipe]-type = "PipeLLM"-description = "Single LLM step using a manifold-listed model handle"-inputs = { topic = "Text" }-output = "Text"-model = "gpt-5.6-luna"-prompt = "Write a single sentence about $topic.text."diff --git a/tests/e2e/data/offline_mode/manifold_unknown_model/manifold_unknown_model.mthds b/tests/e2e/data/offline_mode/manifold_unknown_model/manifold_unknown_model.mthdsdeleted file mode 100644index 60efe9ae0..000000000--- a/tests/e2e/data/offline_mode/manifold_unknown_model/manifold_unknown_model.mthds+++ /dev/null@@ -1,12 +0,0 @@-domain = "offline_manifold_unknown"-description = "Pipeline referencing a manifold model that does NOT exist in the cached manifold specs"-main_pipe = "manifold_unknown_pipe"--[pipe]-[pipe.manifold_unknown_pipe]-type = "PipeLLM"-description = "Single LLM step using a manifold model handle that is intentionally absent from the test fixture"-inputs = { topic = "Text" }-output = "Text"-model = "gpt-future-fake-99"-prompt = "Write a single sentence about $topic.text."diff --git a/tests/e2e/pipelex/cli/test_fix_bundle_cmd.py b/tests/e2e/pipelex/cli/test_fix_bundle_cmd.pyindex 3b206658c..e9bd5505b 100644--- a/tests/e2e/pipelex/cli/test_fix_bundle_cmd.py+++ b/tests/e2e/pipelex/cli/test_fix_bundle_cmd.py@@ -12,7 +12,7 @@ from typing import TYPE_CHECKINGimport pytest-from tests.e2e.agent_cli.conftest import REPO_ROOT, set_manifold_enabled+from tests.e2e.agent_cli.conftest import REPO_ROOTif TYPE_CHECKING:from pathlib import Path@@ -79,8 +79,6 @@ class TestFixBundleHumanE2E:hermetic_home: Path,offline_subprocess_env: dict[str, str],) -> None:- pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=False)bundle_path = hermetic_home / "bundle.mthds"bundle_path.write_text(_FIXABLE_SEQUENCE_MTHDS, encoding="utf-8")@@ -96,8 +94,6 @@ class TestFixBundleHumanE2E:hermetic_home: Path,offline_subprocess_env: dict[str, str],) -> None:- pipelex_dir = hermetic_home / ".pipelex"- set_manifold_enabled(pipelex_dir / "inference" / "backends.toml", enabled=False)bundle_path = hermetic_home / "bundle.mthds"bundle_path.write_text(_UNFIXABLE_MTHDS, encoding="utf-8")diff --git a/tests/e2e/pipelex/cli/test_init_cmd_focused.py b/tests/e2e/pipelex/cli/test_init_cmd_focused.pyindex 25a0e2cf2..3d243ce8d 100644--- a/tests/e2e/pipelex/cli/test_init_cmd_focused.py+++ b/tests/e2e/pipelex/cli/test_init_cmd_focused.py@@ -5,7 +5,6 @@ from typing import TYPE_CHECKINGfrom pipelex.cli.commands.init.command import init_cmdfrom pipelex.cli.commands.init.ui.types import InitFocus-from pipelex.cogt.model_backends.backend import PipelexBackendfrom pipelex.kit.paths import get_kit_configs_dirfrom pipelex.tools.misc.toml_utils import load_toml_with_tomlkit, save_toml_to_pathfrom tests.helpers.init_cmd_helpers import MockedInitEnvironment, get_backend_indices_helper@@ -196,38 +195,6 @@ class TestFocusedInitialization:# After reconfigure, telemetry should be reset to default (off)env.verify_telemetry("off")- def test_reset_routing_with_pipelex_manifold(self, tmp_path: Path, mocker: MockerFixture) -> None:- """Test Case: Reset routing when only pipelex_manifold is enabled (bug fix test)."""- # Setup environment with existing config and pipelex_manifold enabled- env = MockedInitEnvironment(tmp_path, mocker)- env.setup_with_configs(include_backends=True, include_routing=True, include_telemetry=True)-- # Enable only pipelex_manifold (disable everything else)- backends_path = env.inference_dir / "backends.toml"- toml_doc = load_toml_with_tomlkit(str(backends_path))- for backend_key in toml_doc:- if backend_key == "internal":- continue- toml_doc[backend_key]["enabled"] = backend_key == PipelexBackend.MANIFOLD # type: ignore[index]- save_toml_to_path(toml_doc, path=str(backends_path))-- # Modify routing to have wrong config (simulating the bug scenario)- routing_path = env.inference_dir / "routing_profiles.toml"- routing_doc = load_toml_with_tomlkit(str(routing_path))- routing_doc["active"] = "wrong_profile" # type: ignore[index]- save_toml_to_path(routing_doc, path=str(routing_path))-- # User inputs - need to confirm reset initialization- env.add_confirm_input(True) # Confirm "Continue with initialization?" (reset mode)-- env.setup_mocks()-- # Execute with ROUTING focus and reset flag- init_cmd(focus=InitFocus.ROUTING)-- # Verify routing was reset to all_pipelex_manifold (correct for a single enabled backend)- env.verify_routing(f"all_{PipelexBackend.MANIFOLD}")-def test_everything_already_configured(self, tmp_path: Path, mocker: MockerFixture) -> None:"""Test Case 7.1: Everything configured - decline reconfigure."""# Setup complete environmentdiff --git a/tests/e2e/pipelex/cli/test_migrate_commands.py b/tests/e2e/pipelex/cli/test_migrate_commands.pyindex 5fc4016ff..71346bdea 100644--- a/tests/e2e/pipelex/cli/test_migrate_commands.py+++ b/tests/e2e/pipelex/cli/test_migrate_commands.py@@ -1145,14 +1145,19 @@ class TestAStaleTelemetryFileIsMigratedNotReset:assert "pipelex init telemetry" not in printed+# A backend file earlier kits shipped, whose name matches the main configuration's `pipelex_*.toml` glob.+LEGACY_PREFIXED_BACKEND_FILE_NAME = "pipelex_manifold.toml"+LEGACY_PREFIXED_BACKEND_FILE_CONTENT = "# Per-model overrides for the Pipelex Manifold backend.\n"++class TestAStaleBackendDirectory:"""The fourth surface, end to end: `inference/backends/*.toml` on a machine set up before `#1104`.Everything else in this module is planted on a file that sits *directly* in a configurationdirectory. These files do not: they are the reason the walk learned to enter a subdirectory at- all, and the reason a file is claimed by `(directory, name)` rather than by name — the kit ships- a `pipelex_manifold.toml` in there, which the main configuration's `pipelex_*.toml` glob would- otherwise have claimed. It is present here for that reason, untouched, and the assertions say so.+ all, and the reason a file is claimed by `(directory, name)` rather than by name — earlier kits+ shipped a `pipelex_manifold.toml` in there, which the main configuration's `pipelex_*.toml` glob+ would otherwise have claimed. It is planted here for that reason, untouched, and the assertions say so.What a boot *says* is not asserted here and cannot be: the probe is `pipelex-agent`, which cutslogging off process-wide as its first act. The warning is asserted through the human binary@@ -1163,8 +1168,9 @@ class TestAStaleBackendDirectory:"""Everything in and beside the directory that no migration may rewrite.Excluded by name rather than by extension, and the difference is the whole point of this- class: the kit ships `pipelex_manifold.toml` in this directory, which the main configuration's- `pipelex_*.toml` glob would claim by name alone, so it is the one file a walk that forgot+ class: earlier kits shipped `pipelex_manifold.toml` in this directory, and machines set up with+ them still carry it, so it is planted here as they left it. The main configuration's+ `pipelex_*.toml` glob would claim it by name alone, so it is the one file a walk that forgotabout directories would rewrite. An extension filter dropped it — and every other `.toml` inhere — out of the snapshot, leaving the class's own claim unasserted. Only the files thefixture aged are excluded now. `inference/backends.toml` is added back from one level up,@@ -1175,6 +1181,7 @@ class TestAStaleBackendDirectory:it and cannot break the comparison."""backends_dir = _backends_dir(hermetic_home=hermetic_home)+ backends_dir.joinpath(LEGACY_PREFIXED_BACKEND_FILE_NAME).write_text(LEGACY_PREFIXED_BACKEND_FILE_CONTENT, encoding="utf-8")neighbours = [path for path in sorted(backends_dir.iterdir()) if path not in migrated]neighbours.append(hermetic_home / ".pipelex" / INFERENCE_DIR_NAME / BACKENDS_FILE_NAME)return {path: path.read_bytes() for path in neighbours}diff --git a/tests/integration/pipelex/cli/commands/init/test_cache_priming.py b/tests/integration/pipelex/cli/commands/init/test_cache_priming.pydeleted file mode 100644index 4ee5a2c50..000000000--- a/tests/integration/pipelex/cli/commands/init/test_cache_priming.py+++ /dev/null@@ -1,380 +0,0 @@-"""Phase 4 contract: ``prime_remote_config_cache`` writes the on-disk cache during init.--These tests pin the helper's behaviour:--- When a managed gateway backend is enabled, a successful online fetch persists the raw payload- to ``~/.pipelex/cache/remote_config.json`` (priming).-- When offline at init time, priming logs a yellow warning and continues — the cache stays- empty, the user has been told, init does not crash.-- When no managed gateway backend is enabled in ``backends.toml``, priming is a no-op (BYOK setups- have nothing to cache). Any managed backend counts — the published configuration is one artifact.-- When a cache already exists, a fresh fetch overwrites it (refresh, not skip).-"""--from __future__ import annotations--import json-from pathlib import Path # ruff: ignore[typing-only-standard-library-import] — referenced by pytest fixture type hints at runtime-from typing import TYPE_CHECKING--import httpx-import pytest-from rich.console import Console--from pipelex.cli.commands.init.command import prime_remote_config_cache-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackend-from pipelex.system.configuration.config_loader import ConfigLoader-from pipelex.system.pipelex_service.remote_config_cache import (- RemoteConfigCache,-)-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcher--if TYPE_CHECKING:- from collections.abc import Callable-- from pytest_mock import MockerFixture--INIT_COMMAND_MODULE = "pipelex.cli.commands.init.command"-MANIFOLD_ONLY_SECTIONS = {PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION}--# Capture the unpatched classmethod at module import — the session conftest replaces-# ``fetch_remote_config`` with a cache shim that bypasses ``httpx``. We need the real-# fetch path so the ``httpx.get`` mock actually gets exercised.-_ORIGINAL_FETCH_REMOTE_CONFIG = RemoteConfigFetcher.fetch_remote_config---def _fake_remote_payload() -> dict[str, object]:- """Minimal valid payload for ``RemoteConfig.model_validate``."""- return {- MANIFOLD_MODEL_SPECS_SECTION: {},- "aws_region": "us-east-1",- }---def _store_unreadable_cache(remote_config_payload: dict[str, object]) -> None:- """Drop-in for ``RemoteConfigCache.store`` that writes a cache file ``RemoteConfigCache.load()`` cannot read back.-- Reproduces a write that lands on disk without raising yet leaves nothing an offline run can use.- """- del remote_config_payload # intentionally discarded — we write a deliberately broken file- cache_path = RemoteConfigCache.cache_path()- cache_path.parent.mkdir(parents=True, exist_ok=True)- cache_path.write_text("{not json", encoding="utf-8")---def _make_httpx_response(payload: dict[str, object]) -> httpx.Response:- return httpx.Response(- status_code=200,- request=httpx.Request("GET", "https://example.com/remote_config.json"),- content=json.dumps(payload).encode("utf-8"),- )---def isolated_cache_dir(tmp_path: Path, mocker: MockerFixture) -> Path:- """Redirect ``~/.pipelex`` (and therefore the cache) at a tmp path."""- fake_global_dir = tmp_path / ".pipelex"- mocker.patch.object(- ConfigLoader,- "global_config_dir",- new_callable=mocker.PropertyMock,- return_value=fake_global_dir,- )- return fake_global_dir---def _layered_or_pinned(layered_backends: Path) -> Callable[..., list[Path]]:- """A stand-in for `ConfigLoader.backends_file_paths` that keeps honouring `config_dir`.-- Patched on the class, the method serves every caller: the layered sequence only when no- directory is named, and that directory's own base and override otherwise — which is the whole- contract the priming helper relies on when it passes the target directory.- """-- def backends_file_paths(*, config_dir: Path | None = None) -> list[Path]:- if config_dir is None:- return [layered_backends]- return [config_dir / "inference" / "backends.toml", config_dir / "inference" / "backends_override.toml"]-- return backends_file_paths---class TestCachePriming:- @pytest.mark.usefixtures("isolated_cache_dir")- def test_init_primes_cache_when_online(self, mocker: MockerFixture) -> None:- """Managed gateway enabled + online → cache file written under the global dir."""- mocker.patch(f"{INIT_COMMAND_MODULE}.enabled_managed_gateway_sections", return_value=MANIFOLD_ONLY_SECTIONS)- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch("httpx.get", return_value=_make_httpx_response(_fake_remote_payload()))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console)-- cache_path = RemoteConfigCache.cache_path()- assert cache_path.exists(), "priming should write the on-disk cache"- on_disk = json.loads(cache_path.read_text(encoding="utf-8"))- assert on_disk["raw_config"]["aws_region"] == "us-east-1"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_init_warns_when_offline(self, mocker: MockerFixture) -> None:- """Managed gateway enabled + offline + no cache → warn, do not crash, no cache file."""- mocker.patch(f"{INIT_COMMAND_MODULE}.enabled_managed_gateway_sections", return_value=MANIFOLD_ONLY_SECTIONS)- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console) # must NOT raise-- cache_path = RemoteConfigCache.cache_path()- assert not cache_path.exists(), "priming must not create a cache file when offline"- # Verify the user actually got a visible warning, not a silent swallow.- printed = " ".join(str(call_args) for call_args in console.print.call_args_list)- assert "yellow" in printed.lower(), f"priming offline must print a yellow warning; got: {printed!r}"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_init_skips_priming_when_no_managed_gateway_is_enabled(self, mocker: MockerFixture) -> None:- """No managed gateway backend enabled → priming is a no-op (no fetch, no cache write)."""- mocker.patch(f"{INIT_COMMAND_MODULE}.enabled_managed_gateway_sections", return_value={})- fetch_spy = mocker.spy(RemoteConfigFetcher, "fetch_remote_config")- httpx_get_mock = mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console)-- assert fetch_spy.call_count == 0, "priming must not invoke the fetcher when no managed gateway is enabled"- assert httpx_get_mock.call_count == 0, "priming must not hit the network when no managed gateway is enabled"- assert not RemoteConfigCache.cache_path().exists(), "no cache should be written when no managed gateway is enabled"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_init_warns_when_offline_with_stale_cache_present(self, mocker: MockerFixture) -> None:- """Stale cache exists + offline → priming surfaces an error (not a silent success).-- The fetcher with ``require_fresh=True`` refuses to accept a cached fallback, so an- offline fetch fails even though a usable cache is on disk. The pre-existing cache file- must NOT be wiped — subsequent offline dry-runs should still be able to use it.- """- stale_payload = _fake_remote_payload()- stale_payload["aws_region"] = "eu-west-1"- RemoteConfigCache.store(stale_payload)- cache_path = RemoteConfigCache.cache_path()- stale_on_disk_before = json.loads(cache_path.read_text(encoding="utf-8"))-- mocker.patch(f"{INIT_COMMAND_MODULE}.enabled_managed_gateway_sections", return_value=MANIFOLD_ONLY_SECTIONS)- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console) # must NOT raise-- printed = " ".join(str(call_args) for call_args in console.print.call_args_list)- assert "yellow" in printed.lower(), f"stale-cache-offline priming must warn; got: {printed!r}"- stale_on_disk_after = json.loads(cache_path.read_text(encoding="utf-8"))- assert stale_on_disk_after == stale_on_disk_before, "stale cache must be left intact when priming refuses to use it"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_priming_reads_backends_toml_from_target_dir(self, mocker: MockerFixture, tmp_path: Path) -> None:- """``target_config_dir`` overrides the layered backends.toml so global vs local init- primes based on the directory being initialized — not on whatever the layered config- resolves to first.-- Setup:- - layered ``backends.toml`` (default ``config_manager.backends_file_paths()``) has the manifold DISABLED.- - target_config_dir's ``backends.toml`` has the manifold ENABLED.-- Expected: priming runs (managed gateway enabled at the target). Without the fix, the helper- would consult the layered file and skip priming entirely.- """- # Layered config says the manifold is disabled — without the fix, this is what gets read.- layered_dir = tmp_path / "layered_dir"- layered_backends = layered_dir / "inference" / "backends.toml"- layered_backends.parent.mkdir(parents=True, exist_ok=True)- layered_backends.write_text(- f"[pipelex_manifold]\nenabled = false\nmodel_specs_section = {MANIFOLD_MODEL_SPECS_SECTION!r}\n",- encoding="utf-8",- )- mocker.patch.object(ConfigLoader, "backends_file_paths", side_effect=_layered_or_pinned(layered_backends))-- # Target init dir says the manifold IS enabled. The priming helper must read THIS file.- target_dir = tmp_path / "target_dir"- target_backends = target_dir / "inference" / "backends.toml"- target_backends.parent.mkdir(parents=True, exist_ok=True)- target_backends.write_text(- f"[pipelex_manifold]\nenabled = true\nmodel_specs_section = {MANIFOLD_MODEL_SPECS_SECTION!r}\n",- encoding="utf-8",- )-- # Make the fetcher succeed so we can assert the cache is actually written.- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch("httpx.get", return_value=_make_httpx_response(_fake_remote_payload()))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console, target_config_dir=target_dir)-- assert RemoteConfigCache.cache_path().exists(), (- "priming must run (and write the cache) when the TARGET backends.toml has the manifold "- "enabled, even if the layered backends.toml says otherwise"- )-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_priming_skips_when_target_dir_says_manifold_disabled(self, mocker: MockerFixture, tmp_path: Path) -> None:- """Inverse of the above: target says the manifold is disabled, layered says enabled → skip.-- Without the fix, the helper would see the layered "enabled" file, try to fetch, and- write a cache the user did not opt in to. We assert no fetch attempt and no cache file.- """- # Layered says the manifold is enabled — without the fix, this is what gets read.- layered_dir = tmp_path / "layered_dir"- layered_backends = layered_dir / "inference" / "backends.toml"- layered_backends.parent.mkdir(parents=True, exist_ok=True)- layered_backends.write_text(- f"[pipelex_manifold]\nenabled = true\nmodel_specs_section = {MANIFOLD_MODEL_SPECS_SECTION!r}\n",- encoding="utf-8",- )- mocker.patch.object(ConfigLoader, "backends_file_paths", side_effect=_layered_or_pinned(layered_backends))-- # Target says the manifold is disabled — priming should respect that and become a no-op.- target_dir = tmp_path / "target_dir"- target_backends = target_dir / "inference" / "backends.toml"- target_backends.parent.mkdir(parents=True, exist_ok=True)- target_backends.write_text(- f"[pipelex_manifold]\nenabled = false\nmodel_specs_section = {MANIFOLD_MODEL_SPECS_SECTION!r}\n",- encoding="utf-8",- )-- fetch_spy = mocker.spy(RemoteConfigFetcher, "fetch_remote_config")- httpx_get_mock = mocker.patch("httpx.get", side_effect=httpx.ConnectError("should not be called"))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console, target_config_dir=target_dir)-- assert fetch_spy.call_count == 0, "target dir disables the manifold — priming must NOT consult the layered backends.toml"- assert httpx_get_mock.call_count == 0- assert not RemoteConfigCache.cache_path().exists()-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_priming_runs_for_a_manifold_only_installation(self, mocker: MockerFixture, tmp_path: Path) -> None:- """Priming asks the boot's question — is *any* managed gateway backend enabled. The published- configuration is one artifact carrying every managed backend's section, so a manifold-only- installation has exactly as much to cache as any other, and skipping it would leave the first- offline dry-run after init with no fallback.- """- target_dir = tmp_path / "target_dir"- target_backends = target_dir / "inference" / "backends.toml"- target_backends.parent.mkdir(parents=True, exist_ok=True)- target_backends.write_text(- f"[{PipelexBackend.MANIFOLD}]\nenabled = true\nmodel_specs_section = {MANIFOLD_MODEL_SPECS_SECTION!r}\n",- encoding="utf-8",- )-- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch("httpx.get", return_value=_make_httpx_response(_fake_remote_payload()))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console, target_config_dir=target_dir)-- assert RemoteConfigCache.cache_path().exists(), "a manifold-only installation is behind the same published configuration — priming must run"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_init_warns_when_cache_write_fails(self, mocker: MockerFixture) -> None:- """Online fetch succeeds but the cache write fails → priming reports failure, not success.-- The fetcher treats the cache write as opportunistic and swallows OSErrors with only a- stderr warning. If priming trusted the fetch result alone it would report ``primed=True``- while no usable cache exists, so ``pipelex-agent init`` would emit ``cache_primed: true``- and a later offline run would hit ``RemoteConfigUnavailableError``.- """- mocker.patch(f"{INIT_COMMAND_MODULE}.enabled_managed_gateway_sections", return_value=MANIFOLD_ONLY_SECTIONS)- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch("httpx.get", return_value=_make_httpx_response(_fake_remote_payload()))- mocker.patch.object(RemoteConfigCache, "store", side_effect=OSError("read-only cache directory"))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console) # must NOT raise-- cache_path = RemoteConfigCache.cache_path()- assert not cache_path.exists(), "no cache file should exist when the write failed"- printed = " ".join(str(call_args) for call_args in console.print.call_args_list)- assert "yellow" in printed.lower(), f"a failed cache write must surface a yellow warning; got: {printed!r}"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_init_warns_when_the_written_cache_does_not_read_back(self, mocker: MockerFixture) -> None:- """Online fetch succeeds and a cache file is written, but it does not read back → priming- reports failure, not success.-- Priming reads the cache back rather than trusting the write, otherwise ``pipelex-agent init``- would emit ``cache_primed: true`` while a later offline run hits ``RemoteConfigUnavailableError``.- """- mocker.patch(f"{INIT_COMMAND_MODULE}.enabled_managed_gateway_sections", return_value=MANIFOLD_ONLY_SECTIONS)- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch("httpx.get", return_value=_make_httpx_response(_fake_remote_payload()))- mocker.patch.object(RemoteConfigCache, "store", side_effect=_store_unreadable_cache)-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console) # must NOT raise-- printed = " ".join(str(call_args) for call_args in console.print.call_args_list)- assert "yellow" in printed.lower(), f"a cache that does not read back must surface a yellow warning; got: {printed!r}"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_init_does_not_double_prime(self, mocker: MockerFixture) -> None:- """When a cache already exists, priming online overwrites it (refresh, not skip)."""- # Pre-populate the cache with a stale snapshot so we can prove the file gets rewritten.- stale_payload = _fake_remote_payload()- stale_payload["aws_region"] = "eu-west-1"- RemoteConfigCache.store(stale_payload)- cache_path = RemoteConfigCache.cache_path()- stale_on_disk = json.loads(cache_path.read_text(encoding="utf-8"))- assert stale_on_disk["raw_config"]["aws_region"] == "eu-west-1"-- mocker.patch(f"{INIT_COMMAND_MODULE}.enabled_managed_gateway_sections", return_value=MANIFOLD_ONLY_SECTIONS)- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch("httpx.get", return_value=_make_httpx_response(_fake_remote_payload()))-- console = mocker.create_autospec(Console, instance=True)- prime_remote_config_cache(console=console)-- fresh_on_disk = json.loads(cache_path.read_text(encoding="utf-8"))- assert fresh_on_disk["raw_config"]["aws_region"] == "us-east-1", "priming must overwrite the existing cache"- assert fresh_on_disk["cached_at"] >= stale_on_disk["cached_at"], "refresh must update the timestamp"diff --git a/tests/integration/pipelex/cogt/model_backends/test_managed_gateway_unknown_model.py b/tests/integration/pipelex/cogt/model_backends/test_managed_gateway_unknown_model.pydeleted file mode 100644index e9b0404bc..000000000--- a/tests/integration/pipelex/cogt/model_backends/test_managed_gateway_unknown_model.py+++ /dev/null@@ -1,194 +0,0 @@-"""GatewayUnknownModelError contract.--When a model deck references a handle that a managed gateway should provide but that gateway's-model specs (fresh or cached) don't contain it, setup must raise ``GatewayUnknownModelError``-with provenance so the message can hint stale-cache remediation. This complements the-existing ``LLMHandleNotFoundError`` path: the gateway-specific check fires even when-``missing_presets_reaction = "log"`` (the default), because stale gateway specs are a-distinct, user-actionable failure mode that deserves its own error class.-"""--from __future__ import annotations--from pathlib import Path-from typing import TYPE_CHECKING--import pytest--from pipelex import log-from pipelex.cogt.exceptions import GatewayUnknownModelError-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackend-from pipelex.pipelex import Pipelex-from pipelex.system.configuration.config_loader import ConfigLoader, config_manager-from pipelex.system.pipelex_service.remote_config import RemoteConfig-from pipelex.system.pipelex_service.remote_config_fetcher import (- RemoteConfigFetcher,- RemoteConfigResult,-)-from pipelex.system.pipelex_service.types import RemoteConfigSource-from pipelex.system.runtime import IntegrationMode-from pipelex.tools.misc.toml_utils import load_toml_with_tomlkit, save_toml_to_path--if TYPE_CHECKING:- from collections.abc import Generator-- from pytest_mock import MockerFixture--MANIFOLD_ROUTING_PROFILE = "all_pipelex_manifold"---def _empty_manifold_remote_config_result(source: RemoteConfigSource) -> RemoteConfigResult:- """Build a ``RemoteConfigResult`` whose manifold section has no model specs.-- Forces every deck-referenced handle that should come from the manifold to be missing,- so the membership check trips on the first one.- """- config = RemoteConfig(**{MANIFOLD_MODEL_SPECS_SECTION: {}})- return RemoteConfigResult(config=config, source=source, cached_at=None)--[email protected](scope="module", autouse=True)-def reset_pipelex_config_fixture() -> Generator[None, None, None]:- """Override the global module fixture: each test handles its own ``Pipelex.make``."""- yield- Pipelex.teardown_if_needed()---def manifold_routed_boot(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:- """Boot on the repository's inference documents with the manifold enabled and every model routed to it.-- The membership check only judges the handles the active profile routes to a managed backend, so- enabling the manifold is not enough: the default profile tries it last, after every BYOK backend- that serves the same model. Both sequences are pinned whole, so a personal override on this machine- cannot route the boot elsewhere. The manifold's variables are set, or the loader would disable it- before ever reading its specs.- """- routing_profiles_doc = load_toml_with_tomlkit(str(config_manager.routing_profiles_file_path))- routing_profiles_doc["active"] = MANIFOLD_ROUTING_PROFILE- routing_profiles_path = tmp_path / "routing_profiles.toml"- save_toml_to_path(routing_profiles_doc, path=str(routing_profiles_path))-- backends_base_path = Path(config_manager.backends_file_path)- backends_override_path = tmp_path / "backends_override.toml"- backends_override_path.write_text(f"[{PipelexBackend.MANIFOLD}]\nenabled = true\n", encoding="utf-8")-- def pinned_routing_profiles_file_paths(_self: object, **_kwargs: object) -> list[Path]:- return [routing_profiles_path]-- def pinned_backends_file_paths(_self: object, **_kwargs: object) -> list[Path]:- return [backends_base_path, backends_override_path]-- monkeypatch.setattr(ConfigLoader, "routing_profiles_file_paths", pinned_routing_profiles_file_paths)- monkeypatch.setattr(ConfigLoader, "backends_file_paths", pinned_backends_file_paths)- monkeypatch.setenv("PIPELEX_MANIFOLD_ENDPOINT", "https://manifold.example.test/v1")- monkeypatch.setenv("PIPELEX_MANIFOLD_API_KEY", "test-manifold-key")---class TestGatewayUnknownModel:- def test_known_model_loads(self) -> None:- """Happy path: with no managed gateway enabled by default, the membership check has- nothing to validate and setup is silent.- """- Pipelex.teardown_if_needed()- try:- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=True,- )- finally:- Pipelex.teardown_if_needed()- log.reset()-- @pytest.mark.usefixtures("manifold_routed_boot")- def test_unknown_model_fresh_raises(self, mocker: MockerFixture) -> None:- """The manifold section carries no model specs → the first deck-referenced handle trips- ``GatewayUnknownModelError(source=FRESH)`` with the missing model name surfaced.- """- Pipelex.teardown_if_needed()- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(- RemoteConfigFetcher,- "fetch_remote_config",- return_value=_empty_manifold_remote_config_result(RemoteConfigSource.FRESH),- )-- try:- with pytest.raises(GatewayUnknownModelError) as exc_info:- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=True,- )- assert exc_info.value.source == RemoteConfigSource.FRESH- assert exc_info.value.model_name, "the error must carry the missing model name"- assert exc_info.value.model_name in str(exc_info.value), "the error message must surface the missing model name"- assert exc_info.value.backend_name == PipelexBackend.MANIFOLD, "with more than one managed gateway, the error has to say which"- finally:- Pipelex.teardown_if_needed()- log.reset()-- @pytest.mark.usefixtures("manifold_routed_boot")- def test_dummy_specs_path_skips_membership_check(self, mocker: MockerFixture) -> None:- """When a managed gateway is enabled but ``needs_model_specs=False``, ``Pipelex.setup`` builds- a dummy ``RemoteConfig`` with empty sections. The membership check must NOT run on this- path — its provenance is "no live gateway data," so validating the deck's handles against- an empty spec set would always fail. This covers read-only- flows like ``pipelex-agent models`` (no ``--backend``) where the user did not opt in to- fetching specs.- """- Pipelex.teardown_if_needed()- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- # Spy on the real fetcher: setup must not call it when needs_model_specs=False.- fetch_spy = mocker.spy(RemoteConfigFetcher, "fetch_remote_config")-- try:- # No ``pytest.raises`` — the contract here is exactly that setup succeeds.- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=False,- )- assert fetch_spy.call_count == 0, "needs_model_specs=False must skip the remote fetch entirely (dummy config path)"- finally:- Pipelex.teardown_if_needed()- log.reset()-- @pytest.mark.usefixtures("manifold_routed_boot")- def test_unknown_model_cached_raises_with_stale_hint(self, mocker: MockerFixture) -> None:- """Same scenario as fresh, but the remote config came from the cache → the error- message must point at ``pipelex init`` (while online) to refresh the cache.- """- Pipelex.teardown_if_needed()- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(- RemoteConfigFetcher,- "fetch_remote_config",- return_value=_empty_manifold_remote_config_result(RemoteConfigSource.CACHED),- )-- try:- with pytest.raises(GatewayUnknownModelError) as exc_info:- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=True,- )- assert exc_info.value.source == RemoteConfigSource.CACHED- assert "pipelex init" in str(exc_info.value), "the cached-source variant must hint at re-priming via `pipelex init`"- finally:- Pipelex.teardown_if_needed()- log.reset()diff --git a/tests/integration/pipelex/pipes/operator/pipe_doc_gen/doc_gen_helpers.py b/tests/integration/pipelex/pipes/operator/pipe_doc_gen/doc_gen_helpers.pyindex 783cb5fef..f4224d479 100644--- a/tests/integration/pipelex/pipes/operator/pipe_doc_gen/doc_gen_helpers.py+++ b/tests/integration/pipelex/pipes/operator/pipe_doc_gen/doc_gen_helpers.py@@ -23,9 +23,6 @@ from pipelex.plugins.registrar import PluginOrigin, PluginRegistrarfrom pipelex.plugins.sdk_client_registry import SdkClientRegistryfrom pipelex.reporting.reporting_protocol import ReportingProtocolfrom pipelex.runtime_hub import get_secrets_provider-from pipelex.system.pipelex_service.managed_gateway_configs import build_managed_gateway_configs-from pipelex.system.pipelex_service.pipelex_service_config import enabled_managed_gateway_sections-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcherfrom tests.integration.pipelex.pipes.operator.pipe_doc_gen.test_data import PipeDocGenTestData# The engines the stubs stand in for: the built-in pdf from the layout, and two of the document generation plugin's,@@ -135,21 +132,12 @@ def make_doc_gen_backends(*, registrar: PluginRegistrar) -> dict[str, MakeWorkerdef make_models_manager(*, plugin_model_declarations: PluginModelDeclarations, backends_dir_path: Path | None = None) -> ModelManager:"""A model manager set up from this runtime's configuration with the given plugins' declarations.- Set up the way a boot that needs no model specs is, with the managed gateways' placeholder specs: nothing is- fetched, and the internal models, the plugins' included, resolve through the internal backend. A test that needs- other backend files hands their directory in.+ Set up the way a boot that needs no inference is: the internal models, the plugins' included, resolve through the+ internal backend. A test that needs other backend files hands their directory in."""- managed_gateway_sections = enabled_managed_gateway_sections()- managed_gateway_configs = (- build_managed_gateway_configs(remote_config=RemoteConfigFetcher.make_dummy_remote_config(), managed_gateway_sections=managed_gateway_sections)- if managed_gateway_sections- else None- )models_manager = ModelManager()models_manager.setup(secrets_provider=get_secrets_provider(),- managed_gateway_configs=managed_gateway_configs,- gateway_config_source=None,plugin_model_declarations=plugin_model_declarations,needs_inference=False,backends_dir_path=str(backends_dir_path) if backends_dir_path is not None else None,diff --git a/tests/integration/pipelex/system/pipelex_service/test_offline_baseline.py b/tests/integration/pipelex/system/pipelex_service/test_offline_baseline.pydeleted file mode 100644index 8fbebb221..000000000--- a/tests/integration/pipelex/system/pipelex_service/test_offline_baseline.py+++ /dev/null@@ -1,176 +0,0 @@-"""Pins the offline-mode baseline.--These tests describe the behaviour that must NOT regress:--- BYOK setups (no managed gateway enabled) must complete offline without any remote-config fetch.-- Managed-gateway setups with no network AND no cache must raise- ``RemoteConfigUnavailableError`` (the user-facing offline-mode error introduced in Phase 2).-- A live boot on a managed gateway needs no ``pipelex_service.toml``, in any integration mode.-"""--from __future__ import annotations--from pathlib import Path # ruff: ignore[typing-only-standard-library-import] — referenced by pytest fixture type hints at runtime-from typing import TYPE_CHECKING--import httpx-import pytest--from pipelex import log-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackend-from pipelex.pipelex import Pipelex-from pipelex.system.configuration.config_loader import ConfigLoader-from pipelex.system.pipelex_service.exceptions import RemoteConfigUnavailableError-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcher-from pipelex.system.runtime import IntegrationMode--if TYPE_CHECKING:- from collections.abc import Generator-- from pytest_mock import MockerFixture--RUNTIME_BOOT_MODULE = "pipelex.runtime_boot"--# Capture the original classmethod at module import — the session-scoped fixture in the root-# conftest replaces ``RemoteConfigFetcher.fetch_remote_config`` with a wrapper that caches the-# result for the whole test session. We need the unpatched version to exercise the real fetch-# path against a mocked ``httpx.get``.-_ORIGINAL_FETCH_REMOTE_CONFIG = RemoteConfigFetcher.fetch_remote_config--[email protected](scope="module", autouse=True)-def reset_pipelex_config_fixture() -> Generator[None, None, None]:- """Override the global module fixture: this module sets up and tears down per test."""- yield- Pipelex.teardown_if_needed()---class TestOfflineBaseline:- def test_byok_offline_setup_succeeds_without_fetching_remote_config(- self,- mocker: MockerFixture,- ) -> None:- """No managed gateway enabled: setup must succeed with no network and never hit remote config.-- Even with ``needs_model_specs=True``, when no managed gateway is enabled the fetch is- unreachable and the BYOK setup should complete normally.- """- Pipelex.teardown_if_needed()-- mocker.patch(f"{RUNTIME_BOOT_MODULE}.enabled_managed_gateway_sections", return_value={})- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )-- httpx_get_mock = mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))- fetch_spy = mocker.spy(RemoteConfigFetcher, "fetch_remote_config")-- try:- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=True,- )- finally:- Pipelex.teardown_if_needed()-- assert fetch_spy.call_count == 0, "fetch_remote_config must not be invoked when no managed gateway is enabled"- assert httpx_get_mock.call_count == 0, "httpx.get must not be invoked when no managed gateway is enabled"-- def test_managed_gateway_offline_without_cache_raises_remote_config_unavailable_error(- self,- mocker: MockerFixture,- tmp_path: Path,- ) -> None:- """Managed gateway enabled + offline + no primed cache → ``RemoteConfigUnavailableError``.-- Phase 2 introduced a cache fallback so the fetcher only raises when both the network- and the local cache are unusable. We redirect ``~/.pipelex`` to a tmp path so any- cache the developer has from prior online work doesn't satisfy the fallback.- """- Pipelex.teardown_if_needed()-- # Isolate the cache so a real ``~/.pipelex/cache/`` from prior online runs can't- # accidentally make this test "succeed via cache" and miss the regression.- mocker.patch.object(- ConfigLoader,- "global_config_dir",- new_callable=mocker.PropertyMock,- return_value=tmp_path / ".pipelex",- )-- mocker.patch(- f"{RUNTIME_BOOT_MODULE}.enabled_managed_gateway_sections",- return_value={PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION},- )- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )-- # Bypass the session-level cache patch from tests/conftest.py so we exercise the real- # fetch path against a controlled httpx mock.- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))-- try:- with pytest.raises(RemoteConfigUnavailableError):- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=True,- )- finally:- Pipelex.teardown_if_needed()- # ``Pipelex.make`` clears the singleton on setup failure but does NOT reset the- # global log state, so subsequent ``Pipelex.make`` calls would crash with- # "LogConfig is already set". Reset it manually here so other test modules can- # still spin up a fresh Pipelex instance.- log.reset()-- @pytest.mark.parametrize("integration_mode", [IntegrationMode.FASTAPI, IntegrationMode.CLI, IntegrationMode.PYTEST])- def test_live_boot_on_a_managed_gateway_needs_no_service_file(- self,- mocker: MockerFixture,- tmp_path: Path,- integration_mode: IntegrationMode,- ) -> None:- """A live boot with a managed gateway enabled and no ``pipelex_service.toml`` goes straight to the fetch.-- No first-run check stands in front of the remote config: a server, a worker booting through the- CLI helper or a test suite boots from its config files alone. The fetch is the first thing the- boot does for the managed gateway, so reaching its offline refusal proves nothing stopped earlier.- """- Pipelex.teardown_if_needed()-- # An empty global directory holds no pipelex_service.toml and no primed cache.- mocker.patch.object(- ConfigLoader,- "global_config_dir",- new_callable=mocker.PropertyMock,- return_value=tmp_path / ".pipelex",- )- mocker.patch(- f"{RUNTIME_BOOT_MODULE}.enabled_managed_gateway_sections",- return_value={PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION},- )- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))-- try:- with pytest.raises(RemoteConfigUnavailableError):- Pipelex.make(integration_mode=integration_mode, needs_inference=True)- finally:- Pipelex.teardown_if_needed()- log.reset()- assert not (tmp_path / ".pipelex" / "pipelex_service.toml").exists()diff --git a/tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py b/tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.pydeleted file mode 100644index 098a6fbb3..000000000--- a/tests/integration/pipelex/system/pipelex_service/test_remote_config_fetcher.py+++ /dev/null@@ -1,320 +0,0 @@-"""Phase 2 contract for ``RemoteConfigFetcher.fetch_remote_config``.--These tests pin the post-refactor semantics:--- success → ``RemoteConfigResult(source=FRESH)`` AND the cache is written-- network/HTTP failure with a usable cache → ``RemoteConfigResult(source=CACHED)`` with a- ``cached_at`` timestamp. Warning emission lives at the orchestration layer- (``Pipelex.setup``), not here — the fetcher is a pure data-returning function.-- failure with no cache → ``RemoteConfigUnavailableError`` (cache path in the message)-- malformed JSON → ``RemoteConfigValidationError`` (no silent cache fallback — server-side bug)-- ``require_fresh=True`` (used by the doc generators) refuses cached fallback-"""--from __future__ import annotations--import json-from pathlib import Path # ruff: ignore[typing-only-standard-library-import] — referenced by pytest fixture type hints at runtime-from typing import TYPE_CHECKING, Any--import httpx-import pytest--from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION-from pipelex.system.configuration.config_loader import ConfigLoader-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigFetchError,- RemoteConfigUnavailableError,- RemoteConfigValidationError,-)-from pipelex.system.pipelex_service.remote_config import RemoteConfig-from pipelex.system.pipelex_service.remote_config_cache import RemoteConfigCache-from pipelex.system.pipelex_service.remote_config_fetcher import (- RemoteConfigFetcher,- RemoteConfigResult,-)-from pipelex.system.pipelex_service.types import RemoteConfigSource--if TYPE_CHECKING:- from pytest_mock import MockerFixture--# Bypass the session-scoped cache patch in tests/conftest.py.-_ORIGINAL_FETCH_REMOTE_CONFIG = RemoteConfigFetcher.fetch_remote_config---def _valid_remote_config_payload() -> dict[str, Any]:- return {- MANIFOLD_MODEL_SPECS_SECTION: {"defaults": {"sdk": "manifold_completions"}},- "aws_region": "eu-west-3",- }---def _make_httpx_response(payload: dict[str, Any]) -> httpx.Response:- return httpx.Response(- status_code=200,- request=httpx.Request("GET", "https://example.com/remote_config.json"),- content=json.dumps(payload).encode("utf-8"),- )---def isolated_cache_dir(tmp_path: Path, mocker: MockerFixture) -> Path:- """Redirect ``RemoteConfigCache`` at a tmp ``~/.pipelex`` so tests stay hermetic."""- fake_global_dir = tmp_path / ".pipelex"- mocker.patch.object(- ConfigLoader,- "global_config_dir",- new_callable=mocker.PropertyMock,- return_value=fake_global_dir,- )- return fake_global_dir--[email protected](autouse=True)-def restore_original_fetcher(mocker: MockerFixture) -> None:- """Undo the session-level cached fetch shim from tests/conftest.py."""- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)--[email protected](autouse=True)-def disable_codex_cloud(mocker: MockerFixture) -> None:- """Keep the Codex Cloud short-circuit out of the way for all tests in this module."""- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )---def fast_retry(mocker: MockerFixture) -> None:- """Collapse tenacity's wait/stop so transient-failure tests don't sleep."""- mocker.patch.object(RemoteConfigFetcher, "FETCH_WAIT_MIN", 0)- mocker.patch.object(RemoteConfigFetcher, "FETCH_WAIT_MAX", 0)- mocker.patch.object(RemoteConfigFetcher, "FETCH_WAIT_MULTIPLIER", 0)---class TestRemoteConfigFetcher:- @pytest.mark.usefixtures("isolated_cache_dir")- def test_success_returns_fresh_and_writes_cache(self, mocker: MockerFixture) -> None:- payload = _valid_remote_config_payload()- mocker.patch("httpx.get", return_value=_make_httpx_response(payload))-- result = RemoteConfigFetcher.fetch_remote_config()-- assert isinstance(result, RemoteConfigResult)- assert result.source == RemoteConfigSource.FRESH- assert result.cached_at is None- assert result.config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION) == {"defaults": {"sdk": "manifold_completions"}}-- cached = RemoteConfigCache.load()- assert cached is not None, "successful fetch must persist the raw payload to the cache"- assert cached.raw_config == payload-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_network_failure_with_cache_returns_cached(self, mocker: MockerFixture) -> None:- """Cache fallback returns the cached payload tagged ``source=CACHED`` with a- ``cached_at`` timestamp forwarded verbatim from the on-disk snapshot — not a- fabricated "now" — so callers can reason about staleness accurately. Warning- emission lives at the orchestration layer (``Pipelex.setup``); the fetcher itself- stays a pure data-returning function.- """- payload = _valid_remote_config_payload()- RemoteConfigCache.store(payload)- stored_snapshot = RemoteConfigCache.load()- assert stored_snapshot is not None-- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)-- result = RemoteConfigFetcher.fetch_remote_config()-- assert result.source == RemoteConfigSource.CACHED- assert result.cached_at == stored_snapshot.cached_at, "result must forward the cache's snapshot timestamp, not a freshly-computed one"- assert result.config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION) == {"defaults": {"sdk": "manifold_completions"}}-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_network_failure_without_cache_raises_unavailable(self, mocker: MockerFixture) -> None:- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)-- expected_cache_path = str(RemoteConfigCache.cache_path())-- with pytest.raises(RemoteConfigUnavailableError) as exc_info:- RemoteConfigFetcher.fetch_remote_config()-- assert expected_cache_path in str(exc_info.value), "error message must name the cache path so users can prime it"- assert "pipelex init" in str(exc_info.value), "error message must point at the remediation command"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_http_error_with_cache_returns_cached(self, mocker: MockerFixture) -> None:- """5xx response with a primed cache falls back to cache, same as a connect error.- Asserts the cached payload (not a fabricated empty one) flows back, with its- snapshot timestamp preserved.- """- payload = _valid_remote_config_payload()- RemoteConfigCache.store(payload)- stored_snapshot = RemoteConfigCache.load()- assert stored_snapshot is not None-- failing_response = httpx.Response(- status_code=503,- request=httpx.Request("GET", "https://example.com/remote_config.json"),- content=b"Service Unavailable",- )- mocker.patch("httpx.get", return_value=failing_response)- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)-- result = RemoteConfigFetcher.fetch_remote_config()-- assert result.source == RemoteConfigSource.CACHED- assert result.cached_at == stored_snapshot.cached_at- assert result.config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION) == {"defaults": {"sdk": "manifold_completions"}}-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_http_error_without_cache_raises_unavailable(self, mocker: MockerFixture) -> None:- failing_response = httpx.Response(- status_code=503,- request=httpx.Request("GET", "https://example.com/remote_config.json"),- content=b"Service Unavailable",- )- mocker.patch("httpx.get", return_value=failing_response)- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)-- with pytest.raises(RemoteConfigUnavailableError):- RemoteConfigFetcher.fetch_remote_config()-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_validation_error_does_not_fall_back(self, mocker: MockerFixture) -> None:- """Server-side schema break must surface — we control the server, so a stale cache- would be the wrong answer here. The artifact must be a JSON object; any object parses.- """- # Cache is populated and otherwise usable; we want to assert it's NOT consulted.- RemoteConfigCache.store(_valid_remote_config_payload())-- bad_response = httpx.Response(- status_code=200,- request=httpx.Request("GET", "https://example.com/remote_config.json"),- content=b'["not-an-object"]',- )- mocker.patch("httpx.get", return_value=bad_response)-- with pytest.raises(RemoteConfigValidationError):- RemoteConfigFetcher.fetch_remote_config()-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_codex_cloud_short_circuit_still_works(self, mocker: MockerFixture) -> None:- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=True,- )- httpx_get = mocker.patch("httpx.get")-- result = RemoteConfigFetcher.fetch_remote_config()-- assert result.source == RemoteConfigSource.FRESH- assert result.cached_at is None- assert httpx_get.call_count == 0, "Codex Cloud short-circuit must skip the network call"- assert RemoteConfigCache.load() is None, "Codex Cloud short-circuit must not pollute the cache"-- @pytest.mark.usefixtures("isolated_cache_dir", "fast_retry")- def test_succeeds_after_4_transient_failures_no_cache_fallback(self, mocker: MockerFixture) -> None:- payload = _valid_remote_config_payload()- side_effects: list[Any] = [- httpx.ConnectError("transient 1"),- httpx.ConnectError("transient 2"),- httpx.ConnectError("transient 3"),- httpx.ConnectError("transient 4"),- _make_httpx_response(payload),- ]- mocker.patch("httpx.get", side_effect=side_effects)-- result = RemoteConfigFetcher.fetch_remote_config()-- assert result.source == RemoteConfigSource.FRESH, "tenacity recovered before exhausting attempts; no cache fallback should trigger"- cached = RemoteConfigCache.load()- assert cached is not None- assert cached.raw_config == payload-- @pytest.mark.usefixtures("isolated_cache_dir", "fast_retry")- def test_falls_back_to_cache_after_5_transient_failures(self, mocker: MockerFixture) -> None:- """All retry attempts exhausted, cache primed → cache fallback. Stale-cache warning- emission is the orchestration layer's concern, so it's not asserted here.- """- payload = _valid_remote_config_payload()- RemoteConfigCache.store(payload)-- mocker.patch("httpx.get", side_effect=httpx.ConnectError("always down"))-- result = RemoteConfigFetcher.fetch_remote_config()-- assert result.source == RemoteConfigSource.CACHED-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_require_fresh_refuses_cache(self, mocker: MockerFixture) -> None:- """Doc generators set ``require_fresh=True`` so they never bake stale data into committed files.-- When cache is present, the error message must call out that the cache was refused- (not that it is missing) so the user gets accurate diagnostics.- """- RemoteConfigCache.store(_valid_remote_config_payload())- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)-- with pytest.raises(RemoteConfigUnavailableError) as exc_info:- RemoteConfigFetcher.fetch_remote_config(require_fresh=True)-- assert "was refused because a fresh fetch is required" in str(exc_info.value)-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_inner_retry_layer_still_raises_remote_config_fetch_error(self, mocker: MockerFixture) -> None:- """Internal retry layer keeps raising ``RemoteConfigFetchError``; the outer flow turns it- into a cache hit or an unavailable error. Callers that introspect the inner exception- (doctor, error handlers, agent hints) still see the original class.- """- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)-- with pytest.raises(RemoteConfigUnavailableError) as exc_info:- RemoteConfigFetcher.fetch_remote_config()-- cause = exc_info.value.__cause__- assert isinstance(cause, RemoteConfigFetchError), (- "RemoteConfigUnavailableError must chain from the original RemoteConfigFetchError "- "so existing surfaces (doctor, agent hints) can keep reading the inner exception"- )-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_cache_store_oserror_does_not_abort_fresh_fetch(self, mocker: MockerFixture, capsys: pytest.CaptureFixture[str]) -> None:- """Cache write is opportunistic — a read-only ``$HOME``, full disk, or permission- error on the cache directory must not kill an otherwise-successful online fetch.- ``fetch_remote_config`` should warn to stderr and still return ``source=FRESH``.- """- payload = _valid_remote_config_payload()- mocker.patch("httpx.get", return_value=_make_httpx_response(payload))- mocker.patch.object(RemoteConfigCache, "store", side_effect=OSError("read-only filesystem"))-- result = RemoteConfigFetcher.fetch_remote_config()-- assert result.source == RemoteConfigSource.FRESH- assert result.config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION) == {"defaults": {"sdk": "manifold_completions"}}- captured = capsys.readouterr()- assert "failed to persist remote config cache" in captured.err, (- f"cache-write failure must surface as a warning on stderr; got stderr={captured.err!r}"- )-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_fresh_path_validates_payload_only_once(self, mocker: MockerFixture) -> None:- """``_fetch_fresh`` already validates the payload; the outer flow must reuse the- parsed config rather than re-validating it. We spy on ``RemoteConfig.model_validate``- and assert it was called exactly once for a fresh fetch.- """- payload = _valid_remote_config_payload()- mocker.patch("httpx.get", return_value=_make_httpx_response(payload))- validate_spy = mocker.spy(RemoteConfig, "model_validate")-- result = RemoteConfigFetcher.fetch_remote_config()-- assert result.source == RemoteConfigSource.FRESH- assert validate_spy.call_count == 1, f"fresh path must validate exactly once; got {validate_spy.call_count} calls"diff --git a/tests/integration/pipelex/system/pipelex_service/test_setup_with_cache.py b/tests/integration/pipelex/system/pipelex_service/test_setup_with_cache.pydeleted file mode 100644index 7e5bd6277..000000000--- a/tests/integration/pipelex/system/pipelex_service/test_setup_with_cache.py+++ /dev/null@@ -1,178 +0,0 @@-"""Phase 3 contract: the remote-config cache fallback flows through ``Pipelex.make``.--These tests pin the post-refactor behaviour at the Pipelex-setup boundary (the fetcher-level-contract is locked in by ``test_remote_config_fetcher.py``):--- Dry-run setup ``(needs_inference=False, needs_model_specs=True)`` succeeds with a primed- cache and emits ``RemoteConfigStaleWarning``; cold cache raises ``RemoteConfigUnavailableError``.-- BYOK with no managed gateway enabled never reaches ``fetch_remote_config``, regardless of- ``needs_model_specs``. Explicit regression guard so future refactors can't reintroduce the- phantom network call described in the original offline-mode bug.-"""--from __future__ import annotations--import warnings-from pathlib import Path # ruff: ignore[typing-only-standard-library-import] — referenced by pytest fixture type hints at runtime-from typing import TYPE_CHECKING--import httpx-import pytest--from pipelex import log-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackend-from pipelex.pipelex import Pipelex-from pipelex.system.configuration.config_loader import ConfigLoader-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigStaleWarning,- RemoteConfigUnavailableError,-)-from pipelex.system.pipelex_service.remote_config_cache import RemoteConfigCache-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcher-from pipelex.system.runtime import IntegrationMode--if TYPE_CHECKING:- from collections.abc import Generator-- from pytest_mock import MockerFixture--RUNTIME_BOOT_MODULE = "pipelex.runtime_boot"--# Capture the unpatched classmethod at module import — the session conftest replaces-# ``fetch_remote_config`` with a cached shim. We need the real fetch path to exercise the-# httpx mock for the cache-fallback flow.-_ORIGINAL_FETCH_REMOTE_CONFIG = RemoteConfigFetcher.fetch_remote_config--[email protected](scope="module", autouse=True)-def reset_pipelex_config_fixture() -> Generator[None, None, None]:- """Override the global module fixture: each test handles its own ``Pipelex.make``."""- yield- Pipelex.teardown_if_needed()---def isolated_cache_dir(tmp_path: Path, mocker: MockerFixture) -> Path:- """Redirect ``~/.pipelex`` (and therefore the cache) at a tmp path so a developer's real- cache from prior online runs can't accidentally satisfy the fallback.- """- fake_global_dir = tmp_path / ".pipelex"- mocker.patch.object(- ConfigLoader,- "global_config_dir",- new_callable=mocker.PropertyMock,- return_value=fake_global_dir,- )- return fake_global_dir---class TestSetupWithCache:- @pytest.mark.usefixtures("isolated_cache_dir")- def test_setup_succeeds_with_stale_cache_dry_run(- self,- mocker: MockerFixture,- ) -> None:- """Managed gateway enabled, network down, cache primed → setup completes and emits- ``RemoteConfigStaleWarning``. Validates the end-to-end stale-cache UX (dry-run).- """- Pipelex.teardown_if_needed()-- # Prime the cache by calling the session-cached fetcher (returns a real config),- # then store its raw payload via the cache helper. We do this before re-pointing- # the cache dir... actually the fixture already pointed us to a tmp dir, so- # ``RemoteConfigCache.store`` will write there.- session_result = RemoteConfigFetcher.fetch_remote_config() # patched to session cache- RemoteConfigCache.store(session_result.config.model_dump(mode="json"))-- mocker.patch(- f"{RUNTIME_BOOT_MODULE}.enabled_managed_gateway_sections",- return_value={PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION},- )- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )-- # Restore the real fetcher so the cache fallback path runs.- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))-- try:- with warnings.catch_warnings(record=True) as caught:- warnings.simplefilter("always")- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=True,- )- assert any(issubclass(item.category, RemoteConfigStaleWarning) for item in caught), (- "stale-cache setup must emit RemoteConfigStaleWarning so machine consumers can surface it"- )- finally:- Pipelex.teardown_if_needed()- log.reset()-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_setup_fails_without_cache_dry_run(- self,- mocker: MockerFixture,- ) -> None:- """Managed gateway enabled, network down, no cache → ``RemoteConfigUnavailableError`` surfaces- from ``Pipelex.make`` (not silently swallowed).- """- Pipelex.teardown_if_needed()-- mocker.patch(- f"{RUNTIME_BOOT_MODULE}.enabled_managed_gateway_sections",- return_value={PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION},- )- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", _ORIGINAL_FETCH_REMOTE_CONFIG)- mocker.patch.object(RemoteConfigFetcher, "FETCH_MAX_RETRIES", 1)- mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))-- try:- with pytest.raises(RemoteConfigUnavailableError):- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=True,- )- finally:- Pipelex.teardown_if_needed()- log.reset()-- def test_byok_offline_regression_guard(self, mocker: MockerFixture) -> None:- """No managed gateway enabled in ``backends.toml`` → ``fetch_remote_config`` is never invoked,- even with ``needs_model_specs=True``. Without this guard a future refactor could- reintroduce the phantom network call that originally motivated the offline-mode work.- """- Pipelex.teardown_if_needed()-- mocker.patch(f"{RUNTIME_BOOT_MODULE}.enabled_managed_gateway_sections", return_value={})- mocker.patch(- "pipelex.system.runtime.RuntimeManager.is_in_codex_cloud",- new_callable=mocker.PropertyMock,- return_value=False,- )- fetch_spy = mocker.spy(RemoteConfigFetcher, "fetch_remote_config")- httpx_get_mock = mocker.patch("httpx.get", side_effect=httpx.ConnectError("no network"))-- try:- Pipelex.make(- integration_mode=IntegrationMode.PYTEST,- needs_inference=False,- needs_model_specs=True,- )- finally:- Pipelex.teardown_if_needed()- log.reset()-- assert fetch_spy.call_count == 0, "fetch_remote_config must never be invoked when no managed gateway is enabled"- assert httpx_get_mock.call_count == 0, "httpx.get must never be invoked when no managed gateway is enabled"diff --git a/tests/integration/pipelex/test_rich_free_run.py b/tests/integration/pipelex/test_rich_free_run.pyindex 8b61a7260..1bbcafb21 100644--- a/tests/integration/pipelex/test_rich_free_run.py+++ b/tests/integration/pipelex/test_rich_free_run.py@@ -37,8 +37,7 @@ _NO_RICH_PRELUDE = textwrap.dedent(# A pytest-spawned process, and it says so. The session's run mode is set on the in-process# `runtime_manager` and never exported, so a child can neither read it nor claim `IntegrationMode.CI`- # on the strength of it; what keeps these boots credential-free is `needs_model_specs=False` below,- # not the mode.+ # on the strength of it.INTEGRATION_MODE = IntegrationMode.PYTEST""")@@ -46,11 +45,8 @@ _NO_RICH_PRELUDE = textwrap.dedent(# A live run of an operator pipe that needs no inference, in-process, so the "Output of pipe" panel every# operator prints is on the path. Rich must still be absent from the process when the run is over.#-# `needs_model_specs=False` is what makes the boot runnable on a machine that has never configured-# inference — a CI runner, that is. The bundle below names no model, so the Pipelex service's published-# specs are of no use to it: the boot takes the dummy-specs branch, which asks for neither the gateway-# terms nor the network. `needs_inference` stays True on purpose — a keyless boot forces every run to DRY,-# and the dry path does not print the "Output of pipe" panel, which is the Rich reach under test.+# `needs_inference` stays True on purpose — a keyless boot forces every run to DRY, and the dry path does+# not print the "Output of pipe" panel, which is the Rich reach under test._RUN_SCRIPT = _NO_RICH_PRELUDE + textwrap.dedent("""import asyncio@@ -72,7 +68,6 @@ _RUN_SCRIPT = _NO_RICH_PRELUDE + textwrap.dedent(Pipelex.make(integration_mode=INTEGRATION_MODE,- needs_model_specs=False,config_overrides={"runtime": {"log": {"sink": "json", "pretty_print_mode": sys.argv[1]}}},)result = asyncio.run(PipelexMTHDSProtocol().execute(mthds_contents=[BUNDLE], inputs={"name": {"concept": "Text", "content": "world"}}))@@ -85,9 +80,7 @@ _RUN_SCRIPT = _NO_RICH_PRELUDE + textwrap.dedent()# The pretty-print mode "rich" needs Rich: a boot without it stops at boot, naming the extra and the-# Rich-free modes, rather than at the first pipe that prints its output. `needs_model_specs=False` for-# the same reason as above: the refusal under test must be the one Rich's absence raises, on a machine-# where inference was never set up as much as on one where it was.+# Rich-free modes, rather than at the first pipe that prints its output._RICH_MODE_BOOT_SCRIPT = _NO_RICH_PRELUDE + textwrap.dedent("""from pipelex.system.exceptions import MissingDependencyError@@ -95,7 +88,6 @@ _RICH_MODE_BOOT_SCRIPT = _NO_RICH_PRELUDE + textwrap.dedent(try:Pipelex.make(integration_mode=INTEGRATION_MODE,- needs_model_specs=False,config_overrides={"runtime": {"log": {"sink": "json", "pretty_print_mode": "rich"}}},)except MissingDependencyError as exc:diff --git a/tests/unit/pipelex/cli/dev/test_preprocess_test_models_cmd.py b/tests/unit/pipelex/cli/dev/test_preprocess_test_models_cmd.pydeleted file mode 100644index e76e217b4..000000000--- a/tests/unit/pipelex/cli/dev/test_preprocess_test_models_cmd.py+++ /dev/null@@ -1,75 +0,0 @@-"""Unit tests for the `pipelex-dev preprocess-test-models` command."""--import pytest-from pytest_mock import MockerFixture--from pipelex.cli.dev_cli.commands import preprocess_test_models_cmd-from pipelex.cli.dev_cli.commands.preprocess_test_models_cmd import (- _fetch_managed_gateway_models, # pyright: ignore[reportPrivateUsage]-)-from pipelex.system.pipelex_service.exceptions import RemoteConfigUnavailableError, RemoteConfigValidationError-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcher---class TestPreprocessTestModelsCmd:- @pytest.mark.parametrize(- "gateway_error",- [- RemoteConfigUnavailableError("service offline"),- RemoteConfigValidationError("service schema break"),- ],- )- def test_fetch_managed_gateway_models_propagates_fresh_refusal(self, mocker: MockerFixture, gateway_error: Exception) -> None:- """``require_fresh=True`` must refuse to proceed when the remote config is unavailable- or stale. The error propagates instead of being swallowed into empty model lists, so- offline fixture generation cannot silently drop every managed gateway model.- """- mocker.patch.object(- preprocess_test_models_cmd,- "enabled_managed_gateway_sections",- return_value={"pipelex_manifold": "manifold_model_specs"},- )- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", side_effect=gateway_error)-- with pytest.raises((RemoteConfigUnavailableError, RemoteConfigValidationError)) as exc_info:- _fetch_managed_gateway_models()-- assert exc_info.value is gateway_error, "the fresh-config refusal must propagate verbatim, not be converted into empty model lists"-- def test_fetch_managed_gateway_models_skips_the_fetch_when_none_is_enabled(self, mocker: MockerFixture) -> None:- """No managed gateway backend means no reason to reach the network at all."""- mocker.patch.object(preprocess_test_models_cmd, "enabled_managed_gateway_sections", return_value={})- fetch = mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config")-- assert _fetch_managed_gateway_models() == {}- fetch.assert_not_called()-- def test_fetch_managed_gateway_models_reads_each_backend_its_own_section(self, mocker: MockerFixture) -> None:- """The point of the generalization: two managed backends, two sections, no hardcoded name.-- A backend whose declared section the artifact does not carry contributes nothing rather- than failing the run — the same posture the runtime takes.- """- mocker.patch.object(- preprocess_test_models_cmd,- "enabled_managed_gateway_sections",- return_value={- "pipelex_other": "other_model_specs",- "pipelex_manifold": "manifold_model_specs",- "absent_gateway": "no_such_section",- },- )- sections = {- "other_model_specs": {"defaults": {"model_type": "llm"}, "on-the-cloud": {}},- "manifold_model_specs": {"defaults": {"model_type": "llm"}, "in-our-vpc": {"model_type": "search"}},- }- config = mocker.Mock()- config.get_model_specs_section.side_effect = sections.get- mocker.patch.object(RemoteConfigFetcher, "fetch_remote_config", return_value=mocker.Mock(config=config))-- result = _fetch_managed_gateway_models()-- assert set(result) == {"pipelex_other", "pipelex_manifold"}- assert result["pipelex_other"]["llm"] == ["on-the-cloud"]- assert result["pipelex_manifold"]["llm"] == []- assert result["pipelex_manifold"]["search"] == ["in-our-vpc"]diff --git a/tests/unit/pipelex/cli/test_agent_cli_factory.py b/tests/unit/pipelex/cli/test_agent_cli_factory.pyindex b2f1ef7fb..1a2a15af9 100644--- a/tests/unit/pipelex/cli/test_agent_cli_factory.py+++ b/tests/unit/pipelex/cli/test_agent_cli_factory.py@@ -15,9 +15,6 @@ if TYPE_CHECKING:from pipelex.cli.agent_cli.commands.agent_cli_factory import make_pipelex_for_agent_clifrom pipelex.cogt.exceptions import ModelDeckPresetValidatonErrorfrom pipelex.cogt.model_backends.model_type import ModelType-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigValidationError,-)from pipelex.system.telemetry.exceptions import TelemetryConfigValidationErrorfrom pipelex.tools.misc.pretty import PrettyPrinter@@ -52,7 +49,6 @@ class TestMakePipelexForAgentCli:("exc_class", "exc_args", "expected_error_type"),[(TelemetryConfigValidationError, ("telemetry config bad",), "TelemetryConfigValidationError"),- (RemoteConfigValidationError, ("bad remote config",), "RemoteConfigValidationError"),],)def test_initialization_error_produces_json(diff --git a/tests/unit/pipelex/cli/test_agent_codegen_types_cmd.py b/tests/unit/pipelex/cli/test_agent_codegen_types_cmd.pyindex 525e2656c..81a724d42 100644--- a/tests/unit/pipelex/cli/test_agent_codegen_types_cmd.py+++ b/tests/unit/pipelex/cli/test_agent_codegen_types_cmd.py@@ -141,7 +141,6 @@ class TestAgentCodegenTypesCmd:)assert boot.call_args.kwargs["needs_inference"] is False- assert boot.call_args.kwargs["needs_model_specs"] is Truedef test_expands_home_relative_output(self, mocker: MockerFixture, capsys: pytest.CaptureFixture[str]) -> None:self._neutralize_boot(mocker)diff --git a/tests/unit/pipelex/cli/test_agent_output.py b/tests/unit/pipelex/cli/test_agent_output.pyindex d8a7555cd..7d4762600 100644--- a/tests/unit/pipelex/cli/test_agent_output.py+++ b/tests/unit/pipelex/cli/test_agent_output.py@@ -5,7 +5,7 @@ from __future__ import annotationsimport datetimeimport jsonimport logging-from typing import TYPE_CHECKING, Any+from typing import TYPE_CHECKINGimport pytestimport typer@@ -20,9 +20,7 @@ from pipelex.cli.agent_cli.commands.agent_output import (_build_error_source, # pyright: ignore[reportPrivateUsage]agent_error,agent_success,- consume_setup_warnings,extract_validation_errors,- record_setup_warning,run_failure_fields,set_agent_cli_error_format,)@@ -48,17 +46,6 @@ if TYPE_CHECKING:class TestAgentOutput:"""Tests for agent_error, agent_success, and extract_validation_errors."""- @pytest.fixture(autouse=True)- def _drain_warnings_buffer(self) -> Iterator[None]:- """Isolate the module-level ``_CAPTURED_WARNINGS`` global across tests.-- The buffer is a process-wide global; without this drain a recorded warning- could leak into an unrelated test's envelope.- """- consume_setup_warnings()- yield- consume_setup_warnings()-@pytest.fixture(autouse=True)def _restore_logging_cutoff(self) -> Iterator[None]:"""Restore the process-global ``logging.disable`` threshold after a test that runs the app.@@ -458,65 +445,3 @@ class TestAgentOutput:parsed = json.loads(result.stderr)assert parsed["error"] is Trueassert parsed["error_type"] == "BinaryNotFoundError"-- # -------------------------------------------------------------------------- # Setup-warnings buffer tests (record_setup_warning / consume_setup_warnings- # / the warnings-merge branch of agent_success)- # --------------------------------------------------------------------------- def test_agent_success_attaches_recorded_warning(self, capsys: pytest.CaptureFixture[str]) -> None:- """A warning recorded via record_setup_warning surfaces in the envelope's warnings array."""- record_setup_warning({"type": "RemoteConfigStale", "message": "cache is stale"})- agent_success({"success": True})-- parsed = json.loads(capsys.readouterr().out)- assert parsed["warnings"] == [{"type": "RemoteConfigStale", "message": "cache is stale"}]-- def test_agent_success_does_not_re_emit_drained_warnings(self, capsys: pytest.CaptureFixture[str]) -> None:- """A second agent_success in the same process emits no stale warnings (drain+clear)."""- record_setup_warning({"type": "RemoteConfigStale", "message": "cache is stale"})- agent_success({"success": True})- capsys.readouterr() # discard the first envelope-- agent_success({"success": True})- parsed = json.loads(capsys.readouterr().out)- assert "warnings" not in parsed-- def test_consume_setup_warnings_drains_and_clears(self) -> None:- """consume_setup_warnings returns the recorded list and empties the buffer."""- record_setup_warning({"type": "RemoteConfigStale", "message": "first"})- record_setup_warning({"type": "RemoteConfigStale", "message": "second"})-- drained = consume_setup_warnings()- assert drained == [- {"type": "RemoteConfigStale", "message": "first"},- {"type": "RemoteConfigStale", "message": "second"},- ]- assert consume_setup_warnings() == []-- def test_agent_success_appends_captured_after_caller_warnings(self, capsys: pytest.CaptureFixture[str]) -> None:- """Caller-supplied result['warnings'] are kept; captured ones are appended after them."""- record_setup_warning({"type": "RemoteConfigStale", "message": "captured"})- agent_success({"success": True, "warnings": [{"type": "CallerWarning", "message": "caller"}]})-- parsed = json.loads(capsys.readouterr().out)- assert parsed["warnings"] == [- {"type": "CallerWarning", "message": "caller"},- {"type": "RemoteConfigStale", "message": "captured"},- ]-- def test_agent_success_tolerates_non_list_caller_warnings(self, capsys: pytest.CaptureFixture[str]) -> None:- """A non-list result['warnings'] is treated as empty rather than crashing (isinstance guard)."""- record_setup_warning({"type": "RemoteConfigStale", "message": "captured"})- agent_success({"success": True, "warnings": "not-a-list"})-- parsed = json.loads(capsys.readouterr().out)- assert parsed["warnings"] == [{"type": "RemoteConfigStale", "message": "captured"}]-- def test_agent_success_does_not_mutate_caller_result(self) -> None:- """agent_success copies result before merging captured warnings; the caller dict is untouched."""- record_setup_warning({"type": "RemoteConfigStale", "message": "captured"})- result: dict[str, Any] = {"success": True}- agent_success(result)-- assert "warnings" not in resultdiff --git a/tests/unit/pipelex/cli/test_agent_output_drift.py b/tests/unit/pipelex/cli/test_agent_output_drift.pyindex a60a834c7..cb4e40d6f 100644--- a/tests/unit/pipelex/cli/test_agent_output_drift.py+++ b/tests/unit/pipelex/cli/test_agent_output_drift.py@@ -23,7 +23,6 @@ _EXCEPTION_MODULES: tuple[str, ...] = ("pipelex.pipe_operators.exceptions","pipelex.pipeline.exceptions","pipelex.pipeline.validate_bundle",- "pipelex.system.pipelex_service.exceptions","pipelex.system.telemetry.exceptions","pipelex.tools.misc.json_utils","pipelex.tools.misc.toml_utils",diff --git a/tests/unit/pipelex/cli/test_codegen_cli.py b/tests/unit/pipelex/cli/test_codegen_cli.pyindex 2c12d9262..4a6207f61 100644--- a/tests/unit/pipelex/cli/test_codegen_cli.py+++ b/tests/unit/pipelex/cli/test_codegen_cli.py@@ -84,7 +84,6 @@ class TestCodegenCli:library_dir=None,)assert boot.call_args.kwargs["needs_inference"] is False- assert boot.call_args.kwargs["needs_model_specs"] is Truedef test_types_invalid_library_verdict_propagates(self, mocker: MockerFixture, tmp_path: Path) -> None:self._neutralize_boot(mocker, module=TYPES)diff --git a/tests/unit/pipelex/cli/test_doctor_backend_checks.py b/tests/unit/pipelex/cli/test_doctor_backend_checks.pyindex d78c9d540..705b689a2 100644--- a/tests/unit/pipelex/cli/test_doctor_backend_checks.py+++ b/tests/unit/pipelex/cli/test_doctor_backend_checks.py@@ -244,28 +244,9 @@ class TestDoctorBackendChecks:assert reportsassert all(report.is_valid for report in reports.values())- def test_backend_files_enabled_manifold_is_healthy(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:- """The probe hands the loader no manifold model specs, and that must not be reported as a malformed file.-- The manifold's variables are set, or the loader would skip it before ever asking for its specs.- """- self._copy_kit_inference(tmp_path)- _write_backends_override(tmp_path, "[pipelex_manifold]\nenabled = true\n")- monkeypatch.setenv("PIPELEX_MANIFOLD_ENDPOINT", "https://manifold.example.test/v1")- monkeypatch.setenv("PIPELEX_MANIFOLD_API_KEY", "test-manifold-key")-- healthy, reports, message = check_backend_files(secrets_provider=SECRETS_PROVIDER, config_dir=tmp_path)-- assert healthy is True- assert message == "All backend files are valid"- assert reports["pipelex_manifold"].is_valid is True-- def test_backend_files_malformed_file_still_caught_under_leniency(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:- """Leniency skips the managed gateway, not a malformed file — and the gateway does not hide one behind it."""+ def test_backend_files_malformed_file_still_caught_under_leniency(self, tmp_path: Path) -> None:+ """Leniency skips a backend whose credentials are missing, never a malformed file."""backends_dir = self._copy_kit_inference(tmp_path)- _write_backends_override(tmp_path, "[pipelex_manifold]\nenabled = true\n")- monkeypatch.setenv("PIPELEX_MANIFOLD_ENDPOINT", "https://manifold.example.test/v1")- monkeypatch.setenv("PIPELEX_MANIFOLD_API_KEY", "test-manifold-key")anthropic_file = backends_dir / "anthropic.toml"anthropic_file.write_text(anthropic_file.read_text(encoding="utf-8") + '\n[bogus_key_table]\nfoo = "bar"\n', encoding="utf-8")@@ -276,7 +257,6 @@ class TestDoctorBackendChecks:assert reports["anthropic"].is_valid is Falseassert reports["anthropic"].error_message is not Noneassert "anthropic" in reports["anthropic"].error_message- assert reports["pipelex_manifold"].is_valid is Truedef test_kit_template_exists_for_shipped_backend(self) -> None:"""The kit ships an openai backend template."""diff --git a/tests/unit/pipelex/cli/test_doctor_check_models.py b/tests/unit/pipelex/cli/test_doctor_check_models.pyindex 86b1c5845..e7a372b57 100644--- a/tests/unit/pipelex/cli/test_doctor_check_models.py+++ b/tests/unit/pipelex/cli/test_doctor_check_models.py@@ -1,13 +1,11 @@-"""Unit tests for doctor's check_models — managed-gateway gating and model deck validation paths.+"""Unit tests for doctor's check_models — backend file and model deck validation paths.-All inference-adjacent collaborators (backend files probe, remote config fetch,-ModelManager) are mocked at the doctor module namespace: these tests cover the+All inference-adjacent collaborators (backend files probe, ModelManager) are mocked at the doctor module namespace: these tests cover thedecision tree, not the model loading itself."""from __future__ import annotations-from types import SimpleNamespacefrom typing import TYPE_CHECKING, Anyimport pytest@@ -21,10 +19,6 @@ from pipelex.cogt.exceptions import (ModelDeckValidationError,RoutingProfileLibraryError,)-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackend-from pipelex.system.pipelex_service.exceptions import RemoteConfigUnavailableError-from pipelex.system.pipelex_service.remote_config import RemoteConfig-from pipelex.system.pipelex_service.types import RemoteConfigSourcefrom pipelex.tools.secrets.env_secrets_provider import EnvSecretsProviderif TYPE_CHECKING:@@ -46,10 +40,6 @@ class TestCheckModels:return_value=(True, {}, "All backend files are valid"),)- @pytest.fixture- def gateway_disabled(self, mocker: MockerFixture) -> None:- mocker.patch("pipelex.cli.commands.doctor_cmd.enabled_managed_gateway_sections", return_value={})-@pytest.fixturedef models_manager(self, mocker: MockerFixture) -> Any:manager_mock = mocker.Mock()@@ -77,59 +67,18 @@ class TestCheckModels:assert reports == {"openai": bad_report}manager_class_mock.assert_not_called()- @pytest.mark.usefixtures("healthy_backend_files", "gateway_disabled")- def test_managed_gateway_disabled_happy_path(self, models_manager: Any) -> None:- """With no managed gateway enabled and a valid deck, models are healthy."""+ @pytest.mark.usefixtures("healthy_backend_files")+ def test_happy_path(self, models_manager: Any) -> None:+ """With valid backend files and a valid deck, models are healthy."""healthy, message, reports = check_models(secrets_provider=SECRETS_PROVIDER)assert healthy is Trueassert message == "Models are valid"assert reports == {}models_manager.setup.assert_called_once()- assert models_manager.setup.call_args.kwargs["managed_gateway_configs"] is Nonemodels_manager.validate_model_deck.assert_called_once()@pytest.mark.usefixtures("healthy_backend_files")- def test_managed_gateway_enabled_remote_fetch_failure(self, mocker: MockerFixture) -> None:- """A failed remote-config fetch is unhealthy with the fetch error in the message."""- mocker.patch(- "pipelex.cli.commands.doctor_cmd.enabled_managed_gateway_sections",- return_value={PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION},- )- mocker.patch(- "pipelex.cli.commands.doctor_cmd.RemoteConfigFetcher.fetch_remote_config",- side_effect=RemoteConfigUnavailableError("offline, cold cache"),- )-- healthy, message, _ = check_models(secrets_provider=SECRETS_PROVIDER)-- assert healthy is False- assert message == "Failed to fetch the Pipelex remote configuration: offline, cold cache"-- @pytest.mark.usefixtures("healthy_backend_files")- def test_managed_gateway_enabled_passes_gateway_config_to_setup(self, mocker: MockerFixture, models_manager: Any) -> None:- """A successful fetch builds one GatewayConfig per managed backend and threads them into the model setup."""- mocker.patch(- "pipelex.cli.commands.doctor_cmd.enabled_managed_gateway_sections",- return_value={PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION},- )- fetch_result = SimpleNamespace(- config=RemoteConfig(**{MANIFOLD_MODEL_SPECS_SECTION: {"gpt-5": {"model_id": "gpt-5"}}}),- source=RemoteConfigSource.FRESH,- )- mocker.patch("pipelex.cli.commands.doctor_cmd.RemoteConfigFetcher.fetch_remote_config", return_value=fetch_result)-- healthy, message, _ = check_models(secrets_provider=SECRETS_PROVIDER)-- assert healthy is True- assert message == "Models are valid"- setup_kwargs = models_manager.setup.call_args.kwargs- managed_gateway_configs = setup_kwargs["managed_gateway_configs"]- assert managed_gateway_configs is not None- assert set(managed_gateway_configs[PipelexBackend.MANIFOLD].model_specs) == {"gpt-5"}- assert setup_kwargs["gateway_config_source"] == RemoteConfigSource.FRESH-- @pytest.mark.usefixtures("healthy_backend_files", "gateway_disabled")def test_model_deck_validation_error(self, models_manager: Any) -> None:"""A deck validation failure is reported as a models error."""models_manager.validate_model_deck.side_effect = ModelDeckValidationError("preset broken")@@ -139,7 +88,6 @@ class TestCheckModels:assert healthy is Falseassert message == "Error checking models: preset broken"- @pytest.mark.usefixtures("gateway_disabled")def test_backend_library_error_updates_declared_backend_report(self, mocker: MockerFixture, models_manager: Any) -> None:"""A library error declaring a known backend flips that backend's report to invalid."""openai_report = BackendFileReport(@@ -160,7 +108,6 @@ class TestCheckModels:assert reports["openai"].is_valid is Falseassert reports["openai"].error_message == "cannot resolve model"- @pytest.mark.usefixtures("gateway_disabled")def test_backend_library_error_spares_backend_named_only_in_prose(self, mocker: MockerFixture, models_manager: Any) -> None:"""The loader's unknown-key advice names `x-portkey-provider`, so portkey's name rides in everysuch message. Only the backend the error declares records it — portkey's file is untouched.@@ -186,7 +133,7 @@ class TestCheckModels:assert reports["portkey"].is_valid is Trueassert reports["portkey"].error_message is None- @pytest.mark.usefixtures("healthy_backend_files", "gateway_disabled")+ @pytest.mark.usefixtures("healthy_backend_files")def test_an_active_profile_naming_no_profile_is_a_reported_finding(self, models_manager: Any) -> None:"""The likeliest override typo — `active = "nope"` — is the routing library's own refusal, and the doctor must report it, not crash."""models_manager.setup.side_effect = RoutingProfileLibraryError("Active profile 'nope' not found in the routing profile library")@@ -197,7 +144,7 @@ class TestCheckModels:assert "Active profile 'nope' not found" in messageassert reports == {}- @pytest.mark.usefixtures("healthy_backend_files", "gateway_disabled")+ @pytest.mark.usefixtures("healthy_backend_files")def test_global_pins_both_documents_as_base_plus_override(self, models_manager: Any, tmp_path: Path) -> None:"""`--global` hands the model manager that directory's base and its own override, for both documents."""check_models(secrets_provider=SECRETS_PROVIDER, config_dir=tmp_path)@@ -210,11 +157,10 @@ class TestCheckModels:]@pytest.mark.usefixtures("healthy_backend_files")- def test_a_backends_document_that_does_not_parse_is_a_reported_finding(self, mocker: MockerFixture, models_manager: Any) -> None:- """The managed-gateway gate reads the merged document before any load; its refusal is the Models row's, not a crash."""- mocker.patch(- "pipelex.cli.commands.doctor_cmd.enabled_managed_gateway_sections",- side_effect=InferenceBackendLibraryValidationError("Invalid inference backend library 'x' with overrides 'y': TOML parsing error"),+ def test_a_backends_document_that_does_not_parse_is_a_reported_finding(self, models_manager: Any) -> None:+ """The merged backends document failing to parse is the Models row's finding, not a crash."""+ models_manager.setup.side_effect = InferenceBackendLibraryValidationError(+ "Invalid inference backend library 'x' with overrides 'y': TOML parsing error")healthy, message, reports = check_models(secrets_provider=SECRETS_PROVIDER)@@ -222,9 +168,7 @@ class TestCheckModels:assert healthy is Falseassert "TOML parsing error" in messageassert reports == {}- models_manager.setup.assert_not_called()- @pytest.mark.usefixtures("gateway_disabled")def test_the_configured_secrets_provider_is_the_one_the_backends_are_checked_against(self, mocker: MockerFixture, models_manager: Any) -> None:"""Not a provider of the doctor's own choosing: a deployment on another secrets method is diagnosed against its own secrets."""check_backend_files = mocker.patch(@@ -249,7 +193,7 @@ class TestCheckModels:check_backend_files.assert_not_called()models_manager.setup.assert_not_called()- @pytest.mark.usefixtures("healthy_backend_files", "gateway_disabled")+ @pytest.mark.usefixtures("healthy_backend_files")def test_a_provider_failing_on_a_lookup_is_a_row_finding_quoted_redacted(self, models_manager: Any) -> None:"""An external provider may raise anything on a lookup: the row reports it, scrubbed, instead of the doctor stopping."""models_manager.setup.side_effect = ConnectionError(f"vault unreachable; request headers had Authorization: Bearer {VAULT_TOKEN}")@@ -261,7 +205,7 @@ class TestCheckModels:assert "Authorization: Bearer [REDACTED]" in messageassert VAULT_TOKEN not in message- @pytest.mark.usefixtures("healthy_backend_files", "gateway_disabled")+ @pytest.mark.usefixtures("healthy_backend_files")def test_a_credentials_error_quoting_the_providers_text_is_redacted_in_the_row(self, models_manager: Any) -> None:"""The loader copies a provider's not-found text into its own error, so the row scrubs a Pipelex error too."""models_manager.setup.side_effect = InferenceBackendCredentialsError(diff --git a/tests/unit/pipelex/cli/test_error_handlers_more.py b/tests/unit/pipelex/cli/test_error_handlers_more.pyindex 83a6d56c0..c8d4be84d 100644--- a/tests/unit/pipelex/cli/test_error_handlers_more.py+++ b/tests/unit/pipelex/cli/test_error_handlers_more.py@@ -1,6 +1,6 @@"""Unit tests for the CLI error handlers not covered by test_error_handlers.py.-Covers the shared panel renderer, the remote-config/telemetry/signature handlers, and the+Covers the shared panel renderer, the telemetry and model-deck preset handlers, and thedetailed sections of bundle-validation error display. Assertions are on the recordedplain-text console output plus the exit code."""@@ -18,24 +18,16 @@ from pipelex.base_exceptions import MigrationErrorBlockfrom pipelex.cli.error_handlers import (ErrorContext,display_error_panel,- handle_gateway_unknown_model_error,handle_model_deck_preset_error,- handle_remote_config_unavailable_error,- handle_remote_config_validation_error,handle_telemetry_config_validation_error,handle_validate_bundle_error,)-from pipelex.cogt.exceptions import GatewayUnknownModelError, ModelDeckPresetValidatonError+from pipelex.cogt.exceptions import ModelDeckPresetValidatonErrorfrom pipelex.cogt.inference.error_classification import UserAction, UserActionKindfrom pipelex.cogt.model_backends.model_type import ModelTypefrom pipelex.core.exceptions import DryRunFailureErrorData, PipelexBundleBlueprintValidationErrorData, PipesAndConceptValidationErrorDatafrom pipelex.core.validation import MIGRATE_COMMANDfrom pipelex.pipeline.exceptions import ValidateBundleError-from pipelex.system.pipelex_service.exceptions import (- RemoteConfigUnavailableError,- RemoteConfigValidationError,-)-from pipelex.system.pipelex_service.types import RemoteConfigSourcefrom pipelex.system.telemetry.exceptions import TelemetryConfigValidationErrorfrom pipelex.validation_error_types import PipeValidationErrorType@@ -272,60 +264,12 @@ class TestErrorHandlersExtended:assert f"{MIGRATE_COMMAND} --dry-run" in outputassert "init telemetry" not in output, "a file the migration cannot repair is still never answered with a reset"- def test_handle_remote_config_validation_error(self, console: Console) -> None:- """A malformed remote config is flagged as a server-side bug to report."""- with pytest.raises(typer.Exit) as exc_info:- handle_remote_config_validation_error(RemoteConfigValidationError("missing key 'models'"))-- assert exc_info.value.exit_code == 1- output = console.export_text()- assert "remote configuration is invalid" in output- assert "missing key 'models'" in output- assert "Please report this!" in output-- def test_handle_remote_config_unavailable_error(self, console: Console) -> None:- """Offline with a cold cache yields reconnect-or-BYOK guidance."""- with pytest.raises(typer.Exit) as exc_info:- handle_remote_config_unavailable_error(RemoteConfigUnavailableError("no network, no cache"))-- assert exc_info.value.exit_code == 1- output = console.export_text()- assert "unreachable and no cached config" in output- assert "no network, no cache" in output- assert "pipelex init" in output-- @pytest.mark.parametrize(- ("config_source", "expected_phrase"),- [- (RemoteConfigSource.FRESH, "Check the model handle for typos"),- (RemoteConfigSource.CACHED, "cache may be stale"),- ],- )- def test_handle_gateway_unknown_model_error_branches_on_source(- self,- console: Console,- config_source: RemoteConfigSource,- expected_phrase: str,- ) -> None:- """The unknown-model handler branches its remediation on config provenance."""- exc = GatewayUnknownModelError(model_name="mystery-model", backend_name="pipelex_manifold", source=config_source)-- with pytest.raises(typer.Exit) as exc_info:- handle_gateway_unknown_model_error(exc)-- assert exc_info.value.exit_code == 1- output = console.export_text()- assert "Unknown gateway model handle" in output- assert "'mystery-model'" in output- assert "pipelex_manifold" in output, "the remediation must name the backend that could not serve the handle"- assert expected_phrase in output-def test_handlers_escape_rich_markup_in_messages(self, console: Console) -> None:"""Square brackets in exception text must render literally, not as markup."""- exc = RemoteConfigValidationError("payload has [red]markup[/red] inside")+ exc = TelemetryConfigValidationError("payload has [red]markup[/red] inside")with pytest.raises(typer.Exit):- handle_remote_config_validation_error(exc)+ handle_telemetry_config_validation_error(exc)output = console.export_text()assert "payload has [red]markup[/red] inside" in outputdiff --git a/tests/unit/pipelex/cli/test_resolve_exit_codes.py b/tests/unit/pipelex/cli/test_resolve_exit_codes.pyindex aeb8c0d64..7f10b860c 100644--- a/tests/unit/pipelex/cli/test_resolve_exit_codes.py+++ b/tests/unit/pipelex/cli/test_resolve_exit_codes.py@@ -97,7 +97,6 @@ class TestResolveExitCodes:mocker.patch(f"{MODULE}.encode_crate", return_value="{}")resolve_cmd(paths=None, output_format=CrateEncoding.JSON, library_dir=None)assert boot.call_args.kwargs["needs_inference"] is False- assert boot.call_args.kwargs["needs_model_specs"] is Truedef test_home_relative_library_dirs_are_expanded(self, mocker: MockerFixture) -> None:activate = mocker.patch(f"{CRATE_LOADING}.load_libraries_and_activate", return_value="lib-1")diff --git a/tests/unit/pipelex/cli/test_run_core_wrapper.py b/tests/unit/pipelex/cli/test_run_core_wrapper.pyindex e659649ba..bf5fac105 100644--- a/tests/unit/pipelex/cli/test_run_core_wrapper.py+++ b/tests/unit/pipelex/cli/test_run_core_wrapper.py@@ -80,14 +80,12 @@ class TestExecuteRunWrapper:def test_dry_run_boots_keyless_with_real_model_specs(self, wrapper_mocks: dict[str, Any]) -> None:"""`--dry-run` makes no inference call, so it must not demand credentials — the same boot- `pipelex-agent run --dry-run` uses: keyless (every run forced to DRY) but with real model- specs, so model handles resolve as they would on a live run.+ `pipelex-agent run --dry-run` uses: keyless, every run forced to DRY."""_call_execute_run(dry_run=True)make_kwargs = wrapper_mocks["make_pipelex"].call_args.kwargsassert make_kwargs["needs_inference"] is False- assert make_kwargs["needs_model_specs"] is Truedef test_model_choice_error_dispatched_to_handler(self, wrapper_mocks: dict[str, Any], mocker: MockerFixture) -> None:"""A model-choice error is routed to its dedicated handler."""diff --git a/tests/unit/pipelex/cogt/model_backends/test_backend_boot_tolerance.py b/tests/unit/pipelex/cogt/model_backends/test_backend_boot_tolerance.pyindex d52872135..cd55bb497 100644--- a/tests/unit/pipelex/cogt/model_backends/test_backend_boot_tolerance.py+++ b/tests/unit/pipelex/cogt/model_backends/test_backend_boot_tolerance.py@@ -24,18 +24,24 @@ turns these tests red instead of quietly testing an unplanted document.from __future__ import annotations+import reimport shutilfrom pathlib import Path-from typing import TYPE_CHECKING, Any+from typing import TYPE_CHECKINGimport pytest-from pipelex.cogt.exceptions import InferenceBackendLibraryError-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackend+from pipelex.cogt.exceptions import InferenceBackendLibraryError, InferenceBackendLibraryValidationErrorfrom pipelex.cogt.model_backends.backend_library import InferenceBackendLibrary-from pipelex.cogt.model_backends.gateway_config import GatewayConfig+from pipelex.cogt.model_routing.routing_profile_loader import load_active_routing_profilefrom pipelex.kit.paths import get_kit_configs_dir-from pipelex.system.configuration.config_loader import BACKENDS_DIR_NAME, CONFIG_DIR_NAME, INFERENCE_DIR_NAME+from pipelex.system.configuration.config_loader import (+ BACKENDS_DIR_NAME,+ BACKENDS_FILE_NAME,+ CONFIG_DIR_NAME,+ INFERENCE_DIR_NAME,+ ROUTING_PROFILES_FILE_NAME,+)from pipelex.tools.secrets.env_secrets_provider import EnvSecretsProviderif TYPE_CHECKING:@@ -53,18 +59,19 @@ enabled = trueapi_key = "sk-not-a-real-key-either""""-MANIFOLD_BACKENDS_TOML = f"""-[pipelex_manifold]-enabled = true-model_specs_section = "{MANIFOLD_MODEL_SPECS_SECTION}"-endpoint = "https://manifold.example.com"-api_key = "sk-not-a-real-key"-"""+# The previous release's kit copies of `backends.toml` and `routing_profiles.toml`, as `pipelex init` left+# them on every machine set up with it, plus the per-backend file that kit shipped for an enabled backend+# the current kit no longer carries: a missing per-backend file is fatal for an enabled backend.+PREVIOUS_RELEASE_KIT_DIR = Path("tests/data/inference/previous_release_kit")-MANIFOLD_SERVED_SPECS: dict[str, Any] = {- "defaults": {"model_type": "llm", "sdk": "openai_responses", "thinking_mode": "none"},- "gpt-4o": {"model_id": "gpt-4o"},-}+# The disabled table in the previous kit: its variables are never set here, so a load that substituted+# them before checking `enabled` would fail the strict case.+PREVIOUS_RELEASE_DISABLED_BACKEND = "pipelex_manifold"+PREVIOUS_RELEASE_DISABLED_BACKEND_VARS = ("PIPELEX_MANIFOLD_ENDPOINT", "PIPELEX_MANIFOLD_API_KEY")++# The enabled table in the previous kit whose per-backend file declares no model, and the line enabling it.+PREVIOUS_RELEASE_EMPTY_ENABLED_BACKEND = "pipelex_gateway"+PREVIOUS_RELEASE_GATEWAY_ENABLED_LINE = "enabled = true # Enable after accepting terms via `pipelex init config`"# The key `#1104` deleted, and the two shapes it survives in. The value is immaterial to every# assertion below — what matters is that the blueprint no longer has anywhere to put it.@@ -137,21 +144,13 @@ class TestAStaleBackendDirectory:plant_on_model(path=portkey_file, table_header='["gemini-2.5-pro"]')return openai_file, portkey_file- def _load(- self,- machine: Path,- *,- lenient: bool,- library_body: str = BACKENDS_TOML,- managed_gateway_configs: dict[str, GatewayConfig] | None = None,- ) -> InferenceBackendLibrary:- library_path = self._write_library(machine, body=library_body)+ def _load(self, machine: Path, *, lenient: bool) -> InferenceBackendLibrary:+ library_path = self._write_library(machine)library = InferenceBackendLibrary.make_empty()library.load(secrets_provider=EnvSecretsProvider(),backends_library_paths=[library_path],backends_dir_path=str(self._backends_dir(machine)),- managed_gateway_configs=managed_gateway_configs,lenient=lenient,)return library@@ -254,27 +253,85 @@ class TestAStaleBackendDirectory:assert retry.call_count == 0- def test_a_stale_managed_gateway_override_never_reaches_the_loader_at_all(self, machine: Path) -> None:- """A managed gateway's local file is the one backend file a stale key cannot break, and here is why.- `GatewayConfigMerger` ignores a local `[defaults]` outright and keeps only `sdk` and- `structure_method` from a per-model override, so the retired key is filtered out before any- spec is built. That is why the retry below is wired to local backend files only — and this- test is what would go red if the merger ever stopped filtering, which is the day the gateway- path would need one too. `pipelex migrate` still repairs the file on disk: it is a `*.toml`- in the directory the surface owns, and the walk claims it like any other.- """- gateway_file = self._backends_dir(machine) / f"{PipelexBackend.MANIFOLD}.toml"- gateway_file.write_text(f'[defaults]\n{RETIRED_KEY} = "openai"\n\n[gpt-4o]\n{RETIRED_KEY} = "openai"\n', encoding="utf-8")-- library = self._load(- machine,- lenient=False,- library_body=MANIFOLD_BACKENDS_TOML,- managed_gateway_configs={PipelexBackend.MANIFOLD: GatewayConfig(model_specs=MANIFOLD_SERVED_SPECS)},+def replace_once(*, path: Path, old: str, new: str) -> None:+ text = path.read_text(encoding="utf-8")+ assert text.count(old) == 1, f"expected exactly one {old!r} in {path}"+ path.write_text(text.replace(old, new), encoding="utf-8")+++class TestThePreviousReleaseKit:+ """A machine set up by the previous release is told what to change, then boots once it has.++ As that release left it, its `backends.toml` enables the Pipelex Gateway over a comment-only file and+ its active routing profile sends every model there: that is refused, naming the backend, rather than+ booted with every model silently missing from the deck. Once the user disables that table and picks+ another profile, as the changelog says, the rest loads: the disabled Manifold table, which carries a key+ the backend blueprint does not define, is skipped before its variables are substituted or its file is+ read, and only the active routing profile is validated against the enabled backends.+ """++ @pytest.fixture+ def inference_dir(self, tmp_path: Path) -> Path:+ inference_dir = tmp_path / INFERENCE_DIR_NAME+ inference_dir.mkdir()+ shutil.copy(PREVIOUS_RELEASE_KIT_DIR / BACKENDS_FILE_NAME, inference_dir / BACKENDS_FILE_NAME)+ shutil.copy(PREVIOUS_RELEASE_KIT_DIR / ROUTING_PROFILES_FILE_NAME, inference_dir / ROUTING_PROFILES_FILE_NAME)+ backends_dir = inference_dir / BACKENDS_DIR_NAME+ shutil.copytree(kit_backends_dir(), backends_dir)+ shutil.copytree(PREVIOUS_RELEASE_KIT_DIR / BACKENDS_DIR_NAME, backends_dir, dirs_exist_ok=True)+ assert not (backends_dir / f"{PREVIOUS_RELEASE_DISABLED_BACKEND}.toml").exists(), "the disabled backend must have no file to read"+ return inference_dir++ @pytest.fixture+ def environment(self, inference_dir: Path, monkeypatch: pytest.MonkeyPatch) -> None:+ """A dummy value for every variable the enabled tables reference, and none for the disabled table's."""+ library_text = (inference_dir / BACKENDS_FILE_NAME).read_text(encoding="utf-8")+ referenced_vars = set(re.findall(r"\$\{([A-Z0-9_]+)\}", library_text))+ assert set(PREVIOUS_RELEASE_DISABLED_BACKEND_VARS) <= referenced_vars, "the fixture no longer exercises the disabled table"+ for var_name in referenced_vars - set(PREVIOUS_RELEASE_DISABLED_BACKEND_VARS):+ monkeypatch.setenv(var_name, f"dummy-{var_name.lower()}")+ for var_name in PREVIOUS_RELEASE_DISABLED_BACKEND_VARS:+ monkeypatch.delenv(var_name, raising=False)++ @pytest.mark.usefixtures("environment")+ @pytest.mark.parametrize("lenient", [True, False])+ def test_as_left_its_enabled_gateway_serving_no_model_is_refused(self, inference_dir: Path, lenient: bool) -> None:+ library = InferenceBackendLibrary.make_empty()+ with pytest.raises(InferenceBackendLibraryValidationError) as refused:+ library.load(+ secrets_provider=EnvSecretsProvider(),+ backends_library_paths=[inference_dir / BACKENDS_FILE_NAME],+ backends_dir_path=str(inference_dir / BACKENDS_DIR_NAME),+ lenient=lenient,+ )++ assert refused.value.backend_name == PREVIOUS_RELEASE_EMPTY_ENABLED_BACKEND+ assert "declares no model" in str(refused.value)++ @pytest.mark.usefixtures("environment")+ @pytest.mark.parametrize("lenient", [True, False])+ def test_its_backends_and_active_routing_profile_load_once_remedied(self, inference_dir: Path, lenient: bool) -> None:+ replace_once(path=inference_dir / BACKENDS_FILE_NAME, old=PREVIOUS_RELEASE_GATEWAY_ENABLED_LINE, new="enabled = false")+ replace_once(path=inference_dir / ROUTING_PROFILES_FILE_NAME, old='active = "all_pipelex_gateway"', new='active = "all_openai"')+ library = InferenceBackendLibrary.make_empty()+ library.load(+ secrets_provider=EnvSecretsProvider(),+ backends_library_paths=[inference_dir / BACKENDS_FILE_NAME],+ backends_dir_path=str(inference_dir / BACKENDS_DIR_NAME),+ lenient=lenient,)- backend = library.get_inference_backend(backend_name=PipelexBackend.MANIFOLD)- assert backend is not None- assert backend.model_specs["gpt-4o"].model_id == "gpt-4o", "the served spec is what loads, untouched"+ enabled_backends = library.all_enabled_backends()+ assert PREVIOUS_RELEASE_DISABLED_BACKEND not in library.root+ assert {"openai", "anthropic", "internal"} <= set(enabled_backends)assert library.take_stale_configuration_warning() is None++ routing_profile = load_active_routing_profile(+ routing_profile_library_paths=[inference_dir / ROUTING_PROFILES_FILE_NAME],+ enabled_backends=enabled_backends,+ lenient=lenient,+ )++ assert routing_profile.default in enabled_backends+ assert routing_profile.default != PREVIOUS_RELEASE_DISABLED_BACKENDdiff --git a/tests/unit/pipelex/cogt/model_backends/test_backend_retired_model_specs_section.py b/tests/unit/pipelex/cogt/model_backends/test_backend_retired_model_specs_section.pynew file mode 100644index 000000000..faa948492--- /dev/null+++ b/tests/unit/pipelex/cogt/model_backends/test_backend_retired_model_specs_section.py@@ -0,0 +1,51 @@+"""An enabled backend still naming the retired `model_specs_section` is refused, not booted with no models."""++from pathlib import Path++import pytest++from pipelex.cogt.exceptions import InferenceBackendLibraryValidationError+from pipelex.cogt.model_backends.backend_library import InferenceBackendLibrary+from pipelex.tools.secrets.env_secrets_provider import EnvSecretsProvider++BACKENDS_TOML_TEMPLATE = """+[pipelex_manifold]+display_name = "Pipelex Manifold"+enabled = {enabled}+model_specs_section = "manifold_model_specs"+api_key = "sk-not-a-real-key"+"""++COMMENT_ONLY_BACKEND_TOML = "# The model specs of this backend are served remotely.\n"+++class TestBackendRetiredModelSpecsSection:+ def _load(self, *, tmp_path: Path, enabled: bool, lenient: bool = False) -> InferenceBackendLibrary:+ backends_dir = tmp_path / "backends"+ backends_dir.mkdir()+ (backends_dir / "pipelex_manifold.toml").write_text(COMMENT_ONLY_BACKEND_TOML)+ base_path = tmp_path / "backends.toml"+ base_path.write_text(BACKENDS_TOML_TEMPLATE.format(enabled=str(enabled).lower()))+ library = InferenceBackendLibrary.make_empty()+ library.load(+ secrets_provider=EnvSecretsProvider(),+ backends_library_paths=[base_path],+ backends_dir_path=str(backends_dir),+ lenient=lenient,+ )+ return library++ @pytest.mark.parametrize("lenient", [False, True])+ def test_an_enabled_backend_naming_it_is_refused_in_both_modes(self, tmp_path: Path, lenient: bool) -> None:+ with pytest.raises(InferenceBackendLibraryValidationError) as refused:+ self._load(tmp_path=tmp_path, enabled=True, lenient=lenient)++ message = str(refused.value)+ assert "pipelex_manifold" in message+ assert "model_specs_section" in message+ assert "backends/pipelex_manifold.toml" in message++ def test_a_disabled_backend_naming_it_is_skipped(self, tmp_path: Path) -> None:+ library = self._load(tmp_path=tmp_path, enabled=False)++ assert library.all_enabled_backends() == []diff --git a/tests/unit/pipelex/cogt/model_backends/test_gateway_unknown_defaults.py b/tests/unit/pipelex/cogt/model_backends/test_gateway_unknown_defaults.pydeleted file mode 100644index 88bca9908..000000000--- a/tests/unit/pipelex/cogt/model_backends/test_gateway_unknown_defaults.py+++ /dev/null@@ -1,82 +0,0 @@-"""The remote gateway config may carry keys this client's model-spec blueprint does not know.--It is served by a component that deploys on its own schedule, so a client can read a config written-by a different release than itself. `InferenceModelSpecBlueprint` forbids extra fields, so without-this pruning an unknown key in the remote `defaults` block hard-fails the boot — which is exactly-what happened the day `prompting_target` was removed while the served config still declared it.--The same skew tolerance applies per model, where it is the loader's rule rather than this function's —-see `test_gateway_unknown_per_model_keys.py`. A local backend file gets the strict counterpart of both-rules — see `test_backend_library_leniency.py`.-"""--import logging-from typing import Any, cast--import pytest--from pipelex.cogt.model_backends.gateway_config import drop_unknown_gateway_defaults-from pipelex.cogt.model_backends.model_spec_factory import BackendModelSpecs, InferenceModelSpecBlueprint---class TestGatewayUnknownDefaults:- def _specs(self, *, defaults: dict[str, Any]) -> BackendModelSpecs:- return cast(- "BackendModelSpecs",- {- "defaults": defaults,- "gpt-4o-mini": {"model_id": "gpt-4o-mini", "sdk": "openai"},- },- )-- def test_unknown_default_key_is_dropped(self) -> None:- pruned = drop_unknown_gateway_defaults(gateway_model_specs=self._specs(defaults={"max_tokens": 4096, "a_field_we_removed": "anthropic"}))-- assert pruned["defaults"] == {"max_tokens": 4096}-- def test_the_spec_still_validates_after_pruning(self) -> None:- """The point of the pruning, stated as the thing that used to raise."""- pruned = drop_unknown_gateway_defaults(gateway_model_specs=self._specs(defaults={"max_tokens": 4096, "a_field_we_removed": "anthropic"}))-- merged = dict(cast("dict[str, Any]", pruned["defaults"]))- merged.update(cast("dict[str, Any]", pruned["gpt-4o-mini"]))- blueprint = InferenceModelSpecBlueprint.model_validate(merged)-- assert blueprint.max_tokens == 4096-- def test_known_defaults_are_left_alone(self) -> None:- """No unknown key means the caller gets its own object back, uncopied."""- specs = self._specs(defaults={"max_tokens": 4096})-- assert drop_unknown_gateway_defaults(gateway_model_specs=specs) is specs-- def test_pruning_emits_no_record(self, caplog: pytest.LogCaptureFixture) -> None:- """`drop_unknown_gateway_defaults` is documented as deliberately silent, and this is what holds it to that.-- It runs on the success path of every gateway-backend load, including loads that precede- `runtime_hub.set_config()`. A log call here would turn a plain data transform into a boot-order- dependency: before the dispatch is configured a line takes the stdlib's default handling, so a- warning about the served payload would read differently depending on when the load happened to run.- The guard this replaces asserted that an unconfigured dispatch raised, which is no longer true — a- log call before `configure` is now handled rather than fatal — so nothing fails loudly of its own- accord if a line appears here. Asserting the silence directly is what survives that change.- """- specs = self._specs(defaults={"max_tokens": 4096, "a_field_we_removed": "anthropic"})-- with caplog.at_level(logging.NOTSET):- pruned = drop_unknown_gateway_defaults(gateway_model_specs=specs)-- assert pruned["defaults"] == {"max_tokens": 4096}- assert caplog.records == []-- def test_per_model_unknown_keys_are_untouched(self) -> None:- """This function is scoped to `defaults`; the per-model rule is the loader's, tested in `test_gateway_unknown_per_model_keys.py`."""- # The unknown key in `defaults` is what forces the deep-copy prune to run at all: without it- # the function early-returns and this test proves nothing.- specs = self._specs(defaults={"max_tokens": 4096, "a_field_we_removed": "anthropic"})- cast("dict[str, Any]", specs["gpt-4o-mini"])["x-some-header"] = "value"-- pruned = drop_unknown_gateway_defaults(gateway_model_specs=specs)-- assert pruned is not specs- assert cast("dict[str, Any]", pruned["gpt-4o-mini"])["x-some-header"] == "value"diff --git a/tests/unit/pipelex/cogt/model_backends/test_managed_backend_missing_variable.py b/tests/unit/pipelex/cogt/model_backends/test_managed_backend_missing_variable.pydeleted file mode 100644index 2ca379213..000000000--- a/tests/unit/pipelex/cogt/model_backends/test_managed_backend_missing_variable.py+++ /dev/null@@ -1,105 +0,0 @@-"""A backend that DECLARES a model specs section is disabled when its `${…}` variables are unset; every other backend still stops the boot.--The kit ships `[pipelex_manifold]` declared, so joining the beta is enabling it and setting two-variables rather than editing a config file. That only works if an installation that has *not*-joined boots normally, which is why such a backend whose variables are unset is disabled with a-warning naming it.--**The scoping is the point of these tests, not a detail.** The tolerance sits on a code path every-backend shares, so a global version of it would mean a user who typos `ANTHROPIC_API_KEY` stops-getting a boot failure and starts getting a silently missing backend that resurfaces much later as a-model-resolution error — a behaviour change on every direct-SDK path that must not be made.-"""--from __future__ import annotations--from typing import TYPE_CHECKING--import pytest--from pipelex.cogt.exceptions import InferenceBackendCredentialsError-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackend-from pipelex.cogt.model_backends.backend_library import InferenceBackendLibrary-from pipelex.tools.secrets.env_secrets_provider import EnvSecretsProvider--if TYPE_CHECKING:- from pathlib import Path-- from pytest_mock import MockerFixture-- from pipelex.cogt.model_backends.gateway_config import GatewayConfig--# A name no environment has, so the substitution fails for the reason under test rather than by luck.-UNSET_VAR = "PIPELEX_TEST_VARIABLE_THAT_IS_NEVER_SET"--MANAGED_BACKEND_TOML = f"""-[pipelex_manifold]-enabled = true-model_specs_section = "{MANIFOLD_MODEL_SPECS_SECTION}"-endpoint = "${{{UNSET_VAR}}}"-api_key = "sk-not-a-real-key"-"""--BYOK_BACKEND_TOML = f"""-[anthropic]-enabled = true-api_key = "${{{UNSET_VAR}}}"-"""---def _load(tmp_path: Path, *, body: str, managed_gateway_configs: dict[str, GatewayConfig] | None = None) -> InferenceBackendLibrary:- backends_dir = tmp_path / "backends"- backends_dir.mkdir(exist_ok=True)- library_path = tmp_path / "backends.toml"- library_path.write_text(body, encoding="utf-8")- library = InferenceBackendLibrary.make_empty()- library.load(- secrets_provider=EnvSecretsProvider(),- backends_library_paths=[library_path],- backends_dir_path=str(backends_dir),- managed_gateway_configs=managed_gateway_configs,- lenient=False,- )- return library---class TestAManagedBackendMissingItsVariables:- def test_it_is_disabled_with_a_warning_naming_the_backend_and_the_variable(self, tmp_path: Path, mocker: MockerFixture) -> None:- """The remedy is the warning, so it has to name what to set and where to turn it off."""- warning = mocker.patch("pipelex.cogt.model_backends.backend_library.log.warning")-- library = _load(tmp_path, body=MANAGED_BACKEND_TOML, managed_gateway_configs={})-- assert library.get_inference_backend(backend_name=PipelexBackend.MANIFOLD) is None- warning.assert_called_once()- said = str(warning.call_args.args[0])- assert PipelexBackend.MANIFOLD in said- assert UNSET_VAR in said-- def test_a_byok_backend_missing_its_variables_still_stops_the_boot(self, tmp_path: Path) -> None:- """Unchanged, deliberately: a typo in an API-key variable must stay loud."""- with pytest.raises(InferenceBackendCredentialsError) as refused:- _load(tmp_path, body=BYOK_BACKEND_TOML)-- assert refused.value.key_name == UNSET_VAR---class TestAManagedBackendWithNoPublishedSection:- def test_it_is_disabled_rather_than_refused(self, tmp_path: Path) -> None:- """The config builder already warned by name as it skipped the section; the loader just drops it.-- A mapping that was supplied and simply has no entry for this backend is the user's situation.- The caller's omission — no mapping at all — keeps its own loud refusal, tested below.- """- body = MANAGED_BACKEND_TOML.replace(f"${{{UNSET_VAR}}}", "https://manifold.example.com")-- library = _load(tmp_path, body=body, managed_gateway_configs={})-- assert library.get_inference_backend(backend_name=PipelexBackend.MANIFOLD) is None-- def test_no_managed_configs_at_all_is_the_callers_error(self, tmp_path: Path) -> None:- """Reachable only by loading the library directly without the configs the boot always builds."""- body = MANAGED_BACKEND_TOML.replace(f"${{{UNSET_VAR}}}", "https://manifold.example.com")-- with pytest.raises(Exception, match="managed_gateway_configs"):- _load(tmp_path, body=body, managed_gateway_configs=None)diff --git a/tests/unit/pipelex/cogt/model_backends/test_managed_gateway_unknown_per_model_keys.py b/tests/unit/pipelex/cogt/model_backends/test_managed_gateway_unknown_per_model_keys.pydeleted file mode 100644index e94468566..000000000--- a/tests/unit/pipelex/cogt/model_backends/test_managed_gateway_unknown_per_model_keys.py+++ /dev/null@@ -1,143 +0,0 @@-"""A managed gateway's served config may carry per-model keys this client's model-spec blueprint does not know.--It is served by a component that deploys on its own schedule, so a client can read a config written-by a different release than itself. The loader's per-model rule tolerates that skew: an unknown-per-model key that is header-shaped is a request header the back office started serving on purpose,-and anything else is pruned rather than sent to the provider. The `defaults` block gets the same-tolerance in `test_gateway_unknown_defaults.py`; a local backend file gets the strict counterpart of-the rule — see `test_backend_library_leniency.py`.-"""--from pathlib import Path-from typing import Any, cast--from pytest_mock import MockerFixture--from pipelex.cogt.llm.llm_job import LLMJob-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackend-from pipelex.cogt.model_backends.backend_library import InferenceBackendLibrary-from pipelex.cogt.model_backends.gateway_config import GatewayConfig-from pipelex.cogt.model_backends.model_spec_factory import BackendModelSpecs-from pipelex.providers.manifold.manifold_factory import ManifoldFactory-from pipelex.tools.secrets.env_secrets_provider import EnvSecretsProvider-from tests.unit.pipelex.providers.manifold.test_data import ManifoldMetadataTestData--MANIFOLD_BACKENDS_TOML = f"""-[pipelex_manifold]-enabled = true-model_specs_section = "{MANIFOLD_MODEL_SPECS_SECTION}"-endpoint = "https://manifold.example.com"-api_key = "pk-not-a-real-key"-"""---class TestManagedGatewayUnknownPerModelKeys:- """The loader's per-model rule on a remote payload: header-shaped keys are headers, the rest is pruned."""-- def _load(self, tmp_path: Path, *, model_specs: BackendModelSpecs) -> InferenceBackendLibrary:- backends_dir = tmp_path / "backends"- backends_dir.mkdir()- backends_library_path = tmp_path / "backends.toml"- backends_library_path.write_text(MANIFOLD_BACKENDS_TOML)- library = InferenceBackendLibrary.make_empty()- library.load(- secrets_provider=EnvSecretsProvider(),- backends_library_paths=[backends_library_path],- backends_dir_path=str(backends_dir),- managed_gateway_configs={PipelexBackend.MANIFOLD: GatewayConfig(model_specs=model_specs)},- )- return library-- def _remote_specs(self, *, per_model_extras: dict[str, Any]) -> BackendModelSpecs:- return cast(- "BackendModelSpecs",- {- "defaults": {"model_type": "llm", "sdk": "manifold_completions"},- "gpt-4o-mini": {"model_id": "gpt-4o-mini", **per_model_extras},- },- )-- def test_a_header_shaped_key_becomes_a_request_header(self, tmp_path: Path) -> None:- """`x-portkey-config` is on every served model; without it the gateway cannot route."""- library = self._load(tmp_path, model_specs=self._remote_specs(per_model_extras={"x-portkey-config": "pc-openai-6e7576"}))-- backend = library.get_inference_backend(backend_name="pipelex_manifold")- assert backend is not None- assert backend.model_specs["gpt-4o-mini"].extra_headers == {"x-portkey-config": "pc-openai-6e7576"}-- def test_a_non_header_key_is_pruned_and_the_boot_survives(self, tmp_path: Path) -> None:- """Version skew, same as an unknown `defaults` key: pruned, not fatal, and not sent to the provider."""- library = self._load(- tmp_path,- model_specs=self._remote_specs(per_model_extras={"x-portkey-config": "pc-openai-6e7576", "a_field_we_removed": "openai"}),- )-- backend = library.get_inference_backend(backend_name="pipelex_manifold")- assert backend is not None- model_spec = backend.model_specs["gpt-4o-mini"]- assert model_spec.extra_headers == {"x-portkey-config": "pc-openai-6e7576"}- assert model_spec.model_id == "gpt-4o-mini"-- def test_a_header_shaped_key_with_a_non_string_value_is_pruned_and_the_boot_survives(self, tmp_path: Path) -> None:- """A request header value must be a string. A served non-string one is skew too: pruned, never- stringified onto the wire, and never a boot failure — that would defeat the whole tolerance.- """- library = self._load(- tmp_path,- model_specs=self._remote_specs(per_model_extras={"x-portkey-config": "pc-openai-6e7576", "x-weird": 3}),- )-- backend = library.get_inference_backend(backend_name="pipelex_manifold")- assert backend is not None- assert backend.model_specs["gpt-4o-mini"].extra_headers == {"x-portkey-config": "pc-openai-6e7576"}-- def test_a_header_shaped_key_the_wire_cannot_carry_is_pruned_and_the_boot_survives(self, tmp_path: Path) -> None:- """A served key whose name no header may carry is skew like any other: pruned rather than kept and- left to raise `Illegal header name` on the first inference call.- """- library = self._load(- tmp_path,- model_specs=self._remote_specs(per_model_extras={"x-portkey-config": "pc-openai-6e7576", "x-weird key": "value"}),- )-- backend = library.get_inference_backend(backend_name="pipelex_manifold")- assert backend is not None- assert backend.model_specs["gpt-4o-mini"].extra_headers == {"x-portkey-config": "pc-openai-6e7576"}-- def test_a_header_value_the_wire_cannot_carry_is_pruned_and_the_boot_survives(self, tmp_path: Path) -> None:- """Same for a value the HTTP stack refuses — a line break here would otherwise travel all the way- to the provider call before anyone heard about it.- """- library = self._load(- tmp_path,- model_specs=self._remote_specs(per_model_extras={"x-portkey-config": "pc-openai-6e7576", "x-weird": "two\r\nlines"}),- )-- backend = library.get_inference_backend(backend_name="pipelex_manifold")- assert backend is not None- assert backend.model_specs["gpt-4o-mini"].extra_headers == {"x-portkey-config": "pc-openai-6e7576"}-- def test_a_declared_field_that_used_to_ride_in_the_bag_lands_in_the_field(self, tmp_path: Path) -> None:- """`endpoint_path` is served on the image models today. Had it stayed a bag entry, this rule- would prune it — the whole reason it was promoted to a field first.- """- library = self._load(tmp_path, model_specs=self._remote_specs(per_model_extras={"endpoint_path": "openai/deployments/x/images/generations"}))-- backend = library.get_inference_backend(backend_name="pipelex_manifold")- assert backend is not None- model_spec = backend.model_specs["gpt-4o-mini"]- assert model_spec.endpoint_path == "openai/deployments/x/images/generations"- assert not model_spec.extra_headers-- def test_the_accepted_header_reaches_the_wire(self, tmp_path: Path, mocker: MockerFixture) -> None:- library = self._load(tmp_path, model_specs=self._remote_specs(per_model_extras={"x-portkey-config": "pc-openai-6e7576"}))- backend = library.get_inference_backend(backend_name="pipelex_manifold")- assert backend is not None- model_spec = backend.model_specs["gpt-4o-mini"]-- inference_job = mocker.MagicMock(spec=LLMJob)- inference_job.job_metadata = ManifoldMetadataTestData.JOB_METADATA-- extra_headers, _ = ManifoldFactory.make_extras(model_spec, inference_job=inference_job, output_desc="text")-- assert extra_headers["x-portkey-config"] == "pc-openai-6e7576"diff --git a/tests/unit/pipelex/cogt/model_backends/test_model_spec_document.py b/tests/unit/pipelex/cogt/model_backends/test_model_spec_document.pyindex a87fa1f24..8fcb36f58 100644--- a/tests/unit/pipelex/cogt/model_backends/test_model_spec_document.py+++ b/tests/unit/pipelex/cogt/model_backends/test_model_spec_document.py@@ -84,7 +84,7 @@ class TestABackendFileIsADocumentNotAModel:assert describe_model_spec_document_rejection(document=document) is Nonedef test_a_document_with_no_model_at_all_is_accepted(self) -> None:- """`pipelex_manifold.toml` in the kit is comments only, and the loader loads it without complaint."""+ """A backend file of comments only, and the loader loads it without complaint."""assert describe_model_spec_document_rejection(document={}) is None@pytest.mark.parametrize(diff --git a/tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py b/tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.pydeleted file mode 100644index 4f337102e..000000000--- a/tests/unit/pipelex/cogt/models/test_collect_deck_referenced_handles.py+++ /dev/null@@ -1,170 +0,0 @@-"""Unit coverage for ``ModelManager._collect_deck_referenced_handles`` and ``_extract_choice_handle``.--These two classmethods feed the gateway-membership check in ``ModelManager.setup``:-``_collect_deck_referenced_handles`` gathers every ``(handle, model_type)`` the deck advertises-as usable (presets + choice defaults), and ``_extract_choice_handle`` normalises a ``*ModelChoice``-union to a raw handle string. Aliases and waterfalls are intentionally NOT enumerated directly —-they are reachable through preset/choice references and the resolver walks them.-"""--from __future__ import annotations--import pytest--from pipelex.cogt.config_cogt import ModelDeckConfig-from pipelex.cogt.extract.extract_setting import ExtractModelChoice, ExtractSetting-from pipelex.cogt.img_gen.img_gen_job_components import Quality-from pipelex.cogt.img_gen.img_gen_setting import ImgGenModelChoice, ImgGenSetting-from pipelex.cogt.judgment.judgment_setting import JudgmentModelChoice, JudgmentSetting-from pipelex.cogt.llm.llm_setting import LLMModelChoice, LLMSetting, LLMSettingChoicesDefaults-from pipelex.cogt.model_backends.model_type import ModelType-from pipelex.cogt.models.model_deck import ModelDeck-from pipelex.cogt.models.model_manager import ModelManager-from pipelex.cogt.models.model_reference import ModelReference-from pipelex.cogt.search.search_setting import SearchModelChoice, SearchSetting-from pipelex.system.runtime import ProblemReaction--# Both methods are private leaves of the membership resolver; aliasing them keeps the call-# sites in the tests free of repeated noqa/ignore pragmas.-_collect_deck_referenced_handles = ModelManager._collect_deck_referenced_handles # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]-_extract_choice_handle = ModelManager._extract_choice_handle # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]---def _make_deck(- *,- llm_presets: dict[str, LLMSetting] | None = None,- llm_for_text: LLMModelChoice = "llm-text-handle",- llm_for_object: LLMModelChoice = "llm-object-handle",- extract_presets: dict[str, ExtractSetting] | None = None,- extract_choice_default: ExtractModelChoice = "extract-default-handle",- img_gen_presets: dict[str, ImgGenSetting] | None = None,- img_gen_choice_default: ImgGenModelChoice = "img-gen-default-handle",- search_presets: dict[str, SearchSetting] | None = None,- search_choice_default: SearchModelChoice = "search-default-handle",- judgment_presets: dict[str, JudgmentSetting] | None = None,- judgment_choice_default: JudgmentModelChoice | None = None,- llm_aliases: dict[str, str] | None = None,- llm_waterfalls: dict[str, list[str]] | None = None,-) -> ModelDeck:- """Build a minimal real ModelDeck with all required fields, mirroring test_model_deck.py."""- return ModelDeck(- inference_models={},- # LLM- llm_default_temperature=0.7,- llm_aliases=llm_aliases or {},- llm_waterfalls=llm_waterfalls or {},- llm_presets=llm_presets or {},- llm_choice_defaults=LLMSettingChoicesDefaults(- default_temperature=0.7,- for_text=llm_for_text,- for_object=llm_for_object,- ),- # Extract- extract_aliases={},- extract_waterfalls={},- extract_presets=extract_presets or {},- extract_choice_default=extract_choice_default,- # ImgGen- img_gen_default_quality=Quality.MEDIUM,- img_gen_aliases={},- img_gen_waterfalls={},- img_gen_presets=img_gen_presets or {},- img_gen_choice_default=img_gen_choice_default,- # Search- search_aliases={},- search_waterfalls={},- search_presets=search_presets or {},- search_choice_default=search_choice_default,- # Judgment — its choice default is optional, so the deck's own absent default is the base case here- judgment_aliases={},- judgment_waterfalls={},- judgment_presets=judgment_presets or {},- judgment_choice_default=judgment_choice_default,- model_deck_config=ModelDeckConfig(is_model_fallback_enabled=True, missing_presets_reaction=ProblemReaction.NONE),- )---class TestCollectDeckReferencedHandles:- @pytest.mark.parametrize(- ("choice", "expected"),- [- (None, None),- ("raw-handle", "raw-handle"),- (ModelReference.parse("ref-handle"), "ref-handle"),- (LLMSetting(model="llm-model", temperature=0.5), "llm-model"),- (ExtractSetting(model="extract-model"), "extract-model"),- (ImgGenSetting(model="img-gen-model"), "img-gen-model"),- (SearchSetting(model="search-model"), "search-model"),- (JudgmentSetting(model="judgment-model"), "judgment-model"),- ],- )- def test_extract_choice_handle(- self,- choice: LLMSetting | ExtractSetting | ImgGenSetting | SearchSetting | JudgmentSetting | ModelReference | str | None,- expected: str | None,- ) -> None:- """_extract_choice_handle normalises every choice shape: None, raw str, ModelReference, typed setting."""- assert _extract_choice_handle(choice) == expected-- def test_collects_presets_and_choice_defaults_for_all_types(self) -> None:- """_collect_deck_referenced_handles yields a (handle, ModelType) pair for every preset and choice default."""- deck = _make_deck(- llm_presets={- "fast": LLMSetting(model="llm-preset-fast", temperature=0.3),- "smart": LLMSetting(model="llm-preset-smart", temperature=0.7),- },- llm_for_text="llm-text-handle",- llm_for_object="llm-object-handle",- extract_presets={"doc": ExtractSetting(model="extract-preset-doc")},- extract_choice_default="extract-default-handle",- img_gen_presets={"basic": ImgGenSetting(model="img-gen-preset-basic")},- img_gen_choice_default="img-gen-default-handle",- search_presets={"web": SearchSetting(model="search-preset-web")},- search_choice_default="search-default-handle",- judgment_presets={"verdict": JudgmentSetting(model="judgment-preset-verdict")},- judgment_choice_default="judgment-default-handle",- )-- collected = _collect_deck_referenced_handles(deck)-- assert set(collected) == {- ("llm-preset-fast", ModelType.LLM),- ("llm-preset-smart", ModelType.LLM),- ("llm-text-handle", ModelType.LLM),- ("llm-object-handle", ModelType.LLM),- ("extract-preset-doc", ModelType.TEXT_EXTRACTOR),- ("extract-default-handle", ModelType.TEXT_EXTRACTOR),- ("img-gen-preset-basic", ModelType.IMG_GEN),- ("img-gen-default-handle", ModelType.IMG_GEN),- ("search-preset-web", ModelType.SEARCH),- ("search-default-handle", ModelType.SEARCH),- ("judgment-preset-verdict", ModelType.JUDGMENT),- ("judgment-default-handle", ModelType.JUDGMENT),- }-- def test_aliases_and_waterfalls_are_not_enumerated_directly(self) -> None:- """Alias/waterfall keys and their targets are not surfaced unless referenced by a preset/choice."""- deck = _make_deck(- llm_aliases={"my-alias": "alias-target-handle"},- llm_waterfalls={"my-waterfall": ["waterfall-target-handle"]},- )-- handles = {handle for handle, _ in _collect_deck_referenced_handles(deck)}-- assert "my-alias" not in handles- assert "alias-target-handle" not in handles- assert "my-waterfall" not in handles- assert "waterfall-target-handle" not in handles-- def test_an_absent_judgment_default_contributes_no_reference(self) -> None:- """The judgment family alone may have no choice default, and then it names no handle to check.-- This is what keeps a deck with no judgment backend installed bootable: the gateway's- membership check walks exactly these references, and a default naming a model no enabled- backend serves would fail every boot, judgment or not.- """- deck = _make_deck(judgment_choice_default=None)-- collected = _collect_deck_referenced_handles(deck)-- assert not [pair for pair in collected if pair[1] == ModelType.JUDGMENT]diff --git a/tests/unit/pipelex/cogt/models/test_enforce_gateway_model_membership.py b/tests/unit/pipelex/cogt/models/test_enforce_gateway_model_membership.pydeleted file mode 100644index a70f1c6b8..000000000--- a/tests/unit/pipelex/cogt/models/test_enforce_gateway_model_membership.py+++ /dev/null@@ -1,315 +0,0 @@-"""The deck-integrity check for managed gateways, once there can be more than one of them.--The check answers "does the service this handle is routed to actually carry it?", and with two-services live that question only makes sense per service. Two failure shapes are what this module-pins down, because the single-gateway implementation had no way to tell them apart:--- a **union** across the sections would accept a handle routed to the manifold service purely- because another managed section happens to serve it — a boot that then fails at the first call;-- the same check run twice, once per section, over the *whole* deck would demand that every deck- handle appear in **both** sections, which no mixed routing profile can satisfy.--The routing profile is what separates them: each per-service pass looks only at the handles the-active profile sends to that service.-"""--from __future__ import annotations--from typing import TYPE_CHECKING--import pytest--from pipelex.cogt.config_cogt import ModelDeckConfig-from pipelex.cogt.exceptions import GatewayUnknownModelError-from pipelex.cogt.extract.extract_setting import ExtractModelChoice, ExtractSetting-from pipelex.cogt.img_gen.img_gen_job_components import Quality-from pipelex.cogt.img_gen.img_gen_setting import ImgGenModelChoice, ImgGenSetting-from pipelex.cogt.llm.llm_setting import LLMModelChoice, LLMSetting, LLMSettingChoicesDefaults-from pipelex.cogt.llm.thinking_mode import ThinkingMode-from pipelex.cogt.model_backends.backend import PipelexBackend-from pipelex.cogt.model_backends.gateway_config import GatewayConfig-from pipelex.cogt.model_backends.model_spec import InferenceModelSpec-from pipelex.cogt.model_backends.model_type import ModelType-from pipelex.cogt.model_routing.routing_profile import RoutingProfile-from pipelex.cogt.models.model_deck import ModelDeck-from pipelex.cogt.models.model_manager import ModelManager-from pipelex.cogt.search.search_setting import SearchModelChoice, SearchSetting-from pipelex.cogt.usage.cost_category import CostCategory-from pipelex.system.pipelex_service.types import RemoteConfigSource-from pipelex.system.runtime import ProblemReaction--if TYPE_CHECKING:- from pipelex.cogt.model_backends.model_spec_factory import BackendModelSpecs--BYOK_BACKEND = "xai"-# A second managed service beside the manifold, standing in for the next one the kit could ship.-OTHER_BACKEND = "pipelex_other"-ENABLED_BACKENDS = [OTHER_BACKEND, PipelexBackend.MANIFOLD, BYOK_BACKEND, PipelexBackend.INTERNAL]--# The handles the fixture deck advertises. Everything not matched by a route lands on the profile's-# default backend, which is the other managed service here.-GATEWAY_HANDLE = "gpt-5"-MANIFOLD_HANDLE = "claude-4-sonnet"-BYOK_HANDLE = "grok-3"-EXTRACT_HANDLE = "doc-extract"-IMG_GEN_HANDLE = "img-1"-SEARCH_HANDLE = "web-search"---def _specs(*model_names: str) -> BackendModelSpecs:- """A spec map carrying exactly these model names, plus the `defaults` table the check ignores."""- specs: dict[str, object] = {"defaults": {"model_type": "llm", "sdk": "manifold_completions"}}- for model_name in model_names:- specs[model_name] = {"model_id": model_name}- return specs # pyright: ignore[reportReturnType]---def _resolved(name: str, *, backend_name: str) -> InferenceModelSpec:- """A handle the deck build already resolved — what `deck.inference_models` holds.-- Only the key matters to the membership check; the spec is filled in just enough to be a real- model, and its `backend_name` records which backend the profile matched it to.- """- return InferenceModelSpec(- backend_name=backend_name,- name=name,- sdk="manifold_completions",- model_type=ModelType.LLM,- model_id=name,- costs={CostCategory.INPUT: 0.001, CostCategory.OUTPUT: 0.002},- thinking_mode=ThinkingMode.NONE,- max_tokens=1000,- max_prompt_images=None,- )---def _make_deck(- *,- llm_presets: dict[str, LLMSetting],- inference_models: dict[str, InferenceModelSpec] | None = None,- llm_waterfalls: dict[str, list[str]] | None = None,-) -> ModelDeck:- """A minimal real deck whose only variable part is the LLM presets, mirroring the sibling tests."""- llm_for_text: LLMModelChoice = GATEWAY_HANDLE- llm_for_object: LLMModelChoice = GATEWAY_HANDLE- extract_choice_default: ExtractModelChoice = EXTRACT_HANDLE- img_gen_choice_default: ImgGenModelChoice = IMG_GEN_HANDLE- search_choice_default: SearchModelChoice = SEARCH_HANDLE- return ModelDeck(- inference_models=inference_models if inference_models is not None else {},- # LLM- llm_default_temperature=0.7,- llm_aliases={},- llm_waterfalls=llm_waterfalls if llm_waterfalls is not None else {},- llm_presets=llm_presets,- llm_choice_defaults=LLMSettingChoicesDefaults(- default_temperature=0.7,- for_text=llm_for_text,- for_object=llm_for_object,- ),- # Extract- extract_aliases={},- extract_waterfalls={},- extract_presets={"default": ExtractSetting(model=EXTRACT_HANDLE)},- extract_choice_default=extract_choice_default,- # ImgGen- img_gen_default_quality=Quality.MEDIUM,- img_gen_aliases={},- img_gen_waterfalls={},- img_gen_presets={"default": ImgGenSetting(model=IMG_GEN_HANDLE)},- img_gen_choice_default=img_gen_choice_default,- # Search- search_aliases={},- search_waterfalls={},- search_presets={"default": SearchSetting(model=SEARCH_HANDLE)},- search_choice_default=search_choice_default,- model_deck_config=ModelDeckConfig(is_model_fallback_enabled=True, missing_presets_reaction=ProblemReaction.NONE),- )---def _make_manager(- *,- llm_presets: dict[str, LLMSetting] | None = None,- inference_models: dict[str, InferenceModelSpec] | None = None,- llm_waterfalls: dict[str, list[str]] | None = None,-) -> ModelManager:- """A manager holding the fixture deck and the mixed routing profile, with no boot behind it."""- manager = ModelManager()- manager.model_deck = _make_deck(- llm_presets=llm_presets if llm_presets is not None else {},- inference_models=inference_models,- llm_waterfalls=llm_waterfalls,- )- manager._routing_profile = RoutingProfile( # pyright: ignore[reportPrivateUsage] # ruff: ignore[private-member-access]- name="mixed",- description="The other managed service by default, Claude through the manifold service, grok direct",- default=OTHER_BACKEND,- routes={"claude-*": PipelexBackend.MANIFOLD, "grok-*": BYOK_BACKEND},- )- return manager---def _enforce(- manager: ModelManager,- *,- gateway_specs: BackendModelSpecs,- manifold_specs: BackendModelSpecs,- source: RemoteConfigSource | None = RemoteConfigSource.FRESH,-) -> None:- manager._enforce_gateway_model_membership( # pyright: ignore[reportPrivateUsage] # ruff: ignore[private-member-access]- managed_gateway_configs={- OTHER_BACKEND: GatewayConfig(model_specs=gateway_specs),- PipelexBackend.MANIFOLD: GatewayConfig(model_specs=manifold_specs),- },- gateway_config_source=source,- enabled_backends=ENABLED_BACKENDS,- )---EVERY_DEFAULT_ROUTED_HANDLE = (GATEWAY_HANDLE, EXTRACT_HANDLE, IMG_GEN_HANDLE, SEARCH_HANDLE)---class TestEnforceGatewayModelMembership:- def test_each_service_carrying_what_it_is_routed_is_silent(self) -> None:- """The control: a mixed profile where both sections carry their own share raises nothing."""- manager = _make_manager(llm_presets={"cheap": LLMSetting(model=MANIFOLD_HANDLE, temperature=0.5)})-- _enforce(- manager,- gateway_specs=_specs(*EVERY_DEFAULT_ROUTED_HANDLE),- manifold_specs=_specs(MANIFOLD_HANDLE),- )-- def test_a_handle_absent_from_the_service_it_is_routed_to_raises_naming_that_service(self) -> None:- """The case that must still fail loudly — and the one a union across the sections would miss.-- `claude-4-sonnet` is served by the other managed section here, and the profile routes it to- the manifold service, which does not carry it. Every call would fail; the boot says so.- """- manager = _make_manager(llm_presets={"cheap": LLMSetting(model=MANIFOLD_HANDLE, temperature=0.5)})-- with pytest.raises(GatewayUnknownModelError) as refused:- _enforce(- manager,- gateway_specs=_specs(*EVERY_DEFAULT_ROUTED_HANDLE, MANIFOLD_HANDLE),- manifold_specs=_specs(),- )-- assert refused.value.model_name == MANIFOLD_HANDLE- assert refused.value.backend_name == PipelexBackend.MANIFOLD- assert PipelexBackend.MANIFOLD in str(refused.value), "with two services live, the message has to answer 'which one'"-- def test_a_handle_absent_from_the_other_service_is_not_an_error(self) -> None:- """A handle legitimately absent from one section is normal, not a contradiction.-- This is what a per-service check run over the whole deck would break: nothing routed to the- manifold service here, so its empty section is simply never consulted.- """- manager = _make_manager()-- _enforce(- manager,- gateway_specs=_specs(*EVERY_DEFAULT_ROUTED_HANDLE),- manifold_specs=_specs(),- )-- def test_a_handle_routed_to_a_byok_backend_is_not_this_checks_business(self) -> None:- """Neither managed section carries `grok-3`, and neither is asked to: the profile sends it elsewhere.-- A handle that backend cannot serve either is the generic missing-handle path's problem, and- it reports it against the backend that was actually asked.- """- manager = _make_manager(llm_presets={"fast": LLMSetting(model=BYOK_HANDLE, temperature=0.5)})-- _enforce(- manager,- gateway_specs=_specs(*EVERY_DEFAULT_ROUTED_HANDLE),- manifold_specs=_specs(),- )-- def test_no_live_source_skips_the_check_entirely(self) -> None:- """The dummy-specs path: no provenance means there is nothing to validate against."""- manager = _make_manager(llm_presets={"cheap": LLMSetting(model=MANIFOLD_HANDLE, temperature=0.5)})-- _enforce(manager, gateway_specs=_specs(), manifold_specs=_specs(), source=None)-- @pytest.mark.parametrize("managed_gateway_configs", [None, {}])- def test_no_managed_config_skips_the_check_entirely(self, managed_gateway_configs: dict[str, GatewayConfig] | None) -> None:- """A BYOK-only installation reaches this with nothing managed, and must pass straight through."""- manager = _make_manager(llm_presets={"cheap": LLMSetting(model=MANIFOLD_HANDLE, temperature=0.5)})-- manager._enforce_gateway_model_membership( # pyright: ignore[reportPrivateUsage] # ruff: ignore[private-member-access]- managed_gateway_configs=managed_gateway_configs,- gateway_config_source=RemoteConfigSource.FRESH,- enabled_backends=ENABLED_BACKENDS,- )---class TestAWaterfallSpansBackends:- """A waterfall is "try in order, use whatever works" — and the order may cross backends.-- The per-service filter answers "which candidates is *this* section responsible for", which is- the right question for the section lookup and the wrong one for `deck.inference_models`. That- map is built by routing every handle through the *active profile* and keeping the ones whose- matched backend has a spec, so membership in it already means "resolvable under this profile,- whichever backend serves it" — exactly what `ModelDeck._resolve_waterfall` consults at runtime.- """-- def test_a_waterfall_whose_working_fallback_lives_on_another_service_is_not_an_error(self) -> None:- """The primary is absent from the service it routes to, and the fallback resolves elsewhere.-- `claude-4-sonnet` routes to the manifold service, which carries nothing; `gpt-5` routes to- the other managed one and is already resolved in the deck. At runtime the waterfall walks- past the first and uses the second, so the boot has nothing to refuse.- """- manager = _make_manager(- llm_presets={"premium": LLMSetting(model="~premium", temperature=0.5)},- llm_waterfalls={"premium": [MANIFOLD_HANDLE, GATEWAY_HANDLE]},- inference_models={GATEWAY_HANDLE: _resolved(GATEWAY_HANDLE, backend_name=OTHER_BACKEND)},- )-- _enforce(- manager,- gateway_specs=_specs(*EVERY_DEFAULT_ROUTED_HANDLE),- manifold_specs=_specs(),- )-- def test_a_waterfall_no_backend_can_serve_still_raises(self) -> None:- """The companion guard: widening the deck half must not make the check stop firing.-- Both entries match `claude-*` and route to the manifold service, neither is in its section,- and nothing resolved them — so there is no fallback to walk to and the boot says so.- """- manager = _make_manager(- llm_presets={"premium": LLMSetting(model="~premium", temperature=0.5)},- llm_waterfalls={"premium": [MANIFOLD_HANDLE, "claude-9-unknown"]},- )-- with pytest.raises(GatewayUnknownModelError) as refused:- _enforce(- manager,- gateway_specs=_specs(*EVERY_DEFAULT_ROUTED_HANDLE),- manifold_specs=_specs(),- )-- assert refused.value.model_name == MANIFOLD_HANDLE- assert refused.value.backend_name == PipelexBackend.MANIFOLD---class TestDocumentEnginesAreNotGatewayModels:- """A document engine is software on the host, a `doc_gen` model no managed service serves.-- The kit's deck points `pdf.layout` at `reportlab-pdf`, which the default route sends to the gateway on an- installation whose `internal.toml` predates it or whose internal backend is disabled. Such a step is refused at- load, naming the engine and the fix; the boot must not fail on it, blaming a gateway that was never asked.- """-- def test_a_doc_gen_default_whose_engine_is_undeclared_does_not_fail_the_boot(self) -> None:- manager = _make_manager()- manager.model_deck = manager.get_model_deck().model_copy(update={"doc_gen_choice_defaults": {"pdf.layout": "reportlab-pdf"}})-- _enforce(- manager,- gateway_specs=_specs(*EVERY_DEFAULT_ROUTED_HANDLE),- manifold_specs=_specs(),- )diff --git a/tests/unit/pipelex/cogt/models/test_inference_config_overrides_end_to_end.py b/tests/unit/pipelex/cogt/models/test_inference_config_overrides_end_to_end.pyindex 27db0c39e..74d61ce50 100644--- a/tests/unit/pipelex/cogt/models/test_inference_config_overrides_end_to_end.py+++ b/tests/unit/pipelex/cogt/models/test_inference_config_overrides_end_to_end.py@@ -1,9 +1,8 @@"""The two personal override files, read where the boot reads them: through the global `config_manager`.A developer writes `~/.pipelex/inference/backends_override.toml` and `routing_profiles_override.toml`-once, and every project on the machine follows — the gate the boot branches on to fetch the managed-gateways' specs sees the override, the model manager's default paths carry it, and deleting the two files-restores the shipped default. Built on the kit's own inference tree so the shipped defaults are the+once, and every project on the machine follows — the model manager's default paths carry both, and+deleting the two files restores the shipped default. Built on the kit's own inference tree so the shipped defaults are thefixture, and lenient (`needs_inference=False`) so no credential on this machine is a precondition."""@@ -15,18 +14,17 @@ from typing import TYPE_CHECKINGimport pytest-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION, PipelexBackendfrom pipelex.cogt.models.model_manager import ModelManagerfrom pipelex.kit.paths import get_kit_configs_dirfrom pipelex.plugins.plugin_model_declarations import PluginModelDeclarationsfrom pipelex.system.configuration.config_loader import CONFIG_DIR_NAME, INFERENCE_DIR_NAME-from pipelex.system.pipelex_service.pipelex_service_config import enabled_managed_gateway_sectionsfrom pipelex.tools.secrets.env_secrets_provider import EnvSecretsProviderif TYPE_CHECKING:from pytest_mock import MockerFixture-MANIFOLD_ON_OVERRIDE = "[pipelex_manifold]\nenabled = true\n"+# Ollama needs no credential, so whether it loads depends on the override alone.+OLLAMA_OFF_OVERRIDE = "[ollama]\nenabled = false\n"ANTHROPIC_PROFILE_OVERRIDE = 'active = "all_anthropic"\n'@@ -47,36 +45,40 @@ class TestInferenceConfigOverridesEndToEnd:mocker.patch.object(Path, "cwd", return_value=project_root)return inference_dir- def _active_profile_name(self) -> str:+ def _setup(self) -> ModelManager:models_manager = ModelManager()models_manager.setup(secrets_provider=EnvSecretsProvider(),- managed_gateway_configs=None,- gateway_config_source=None,plugin_model_declarations=PluginModelDeclarations.make_empty(),needs_inference=False,)- return models_manager.routing_profile.name+ return models_manager++ def _active_profile_name(self) -> str:+ return self._setup().routing_profile.name++ def _ollama_is_loaded(self) -> bool:+ return "ollama" in self._setup().inference_backend_library.root@pytest.mark.usefixtures("global_inference_dir")def test_the_shipped_default_needs_no_pipelex_account(self) -> None:"""The control, and the state the overrides must restore when deleted."""- assert enabled_managed_gateway_sections() == {}+ assert self._ollama_is_loaded()assert self._active_profile_name() == "all_enabled_backends"- def test_two_global_override_files_move_the_machine_onto_the_manifold_and_deleting_them_moves_it_back(self, global_inference_dir: Path) -> None:+ def test_two_global_override_files_move_the_machine_and_deleting_them_moves_it_back(self, global_inference_dir: Path) -> None:backends_override = global_inference_dir / "backends_override.toml"routing_override = global_inference_dir / "routing_profiles_override.toml"- backends_override.write_text(MANIFOLD_ON_OVERRIDE, encoding="utf-8")+ backends_override.write_text(OLLAMA_OFF_OVERRIDE, encoding="utf-8")routing_override.write_text(ANTHROPIC_PROFILE_OVERRIDE, encoding="utf-8")- assert enabled_managed_gateway_sections() == {PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION}+ assert not self._ollama_is_loaded()assert self._active_profile_name() == "all_anthropic"backends_override.unlink()routing_override.unlink()- assert enabled_managed_gateway_sections() == {}+ assert self._ollama_is_loaded()assert self._active_profile_name() == "all_enabled_backends"def test_a_project_override_wins_over_the_global_one(self, global_inference_dir: Path, tmp_path: Path) -> None:diff --git a/tests/unit/pipelex/cogt/models/test_model_deck_references.py b/tests/unit/pipelex/cogt/models/test_model_deck_references.pyindex 7d0f928ab..0056abda6 100644--- a/tests/unit/pipelex/cogt/models/test_model_deck_references.py+++ b/tests/unit/pipelex/cogt/models/test_model_deck_references.py@@ -5,7 +5,6 @@ preventing configuration errors from being discovered at runtime."""from collections.abc import Mapping-from typing import castimport pytest@@ -14,7 +13,6 @@ from pipelex.cogt.extract.extract_setting import ExtractSettingfrom pipelex.cogt.img_gen.img_gen_setting import ImgGenSettingfrom pipelex.cogt.judgment.judgment_setting import JudgmentSettingfrom pipelex.cogt.llm.llm_setting import LLMSetting-from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTIONfrom pipelex.cogt.model_backends.model_type import ModelTypefrom pipelex.cogt.models.model_deck import (ModelDeckBlueprint,@@ -24,7 +22,6 @@ from pipelex.cogt.models.model_manager import ModelManagerfrom pipelex.cogt.models.model_reference import ModelReference, ModelReferenceKindfrom pipelex.cogt.search.search_setting import SearchSettingfrom pipelex.system.configuration.config_loader import config_manager-from pipelex.system.pipelex_service.remote_config_fetcher import RemoteConfigFetcherfrom pipelex.tools.misc.file_utils import find_files_in_dirfrom pipelex.tools.misc.toml_utils import load_toml_from_path_if_existsfrom tests.unit.pipelex.cogt.models.model_deck_validation_utils import (@@ -45,40 +42,12 @@ class TestModelDeckReferences:@pytest.fixture(scope="class")def all_known_model_handles(self) -> dict[str, ModelType]:- """Collect all valid model handles with their types from local backends + Pipelex Manifold.-- Sources:- 1. Local backend TOML files (.pipelex/inference/backends/*.toml)- 2. The manifold section of the Pipelex remote config (uses session-level cache from conftest.py)+ """Collect all valid model handles with their types from the local backend TOML files.Returns:Mapping of model_handle -> ModelType"""- known_handles: dict[str, ModelType] = {}-- # 1. Parse local backend TOML files- known_handles.update(self._get_local_backend_models())-- # 2. Get the manifold models from the cached remote config- gateway_specs = RemoteConfigFetcher.fetch_remote_config().config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION) or {}-- # Get default model_type from gateway defaults section (same pattern as local backends)- gateway_defaults = gateway_specs.get("defaults", {})- gateway_default_model_type_str: str | None = None- if isinstance(gateway_defaults, dict):- typed_defaults = cast("dict[str, str]", gateway_defaults)- gateway_default_model_type_str = typed_defaults.get("model_type")-- for model_name, spec in gateway_specs.items():- if model_name == "defaults":- continue # Skip the defaults section itself- if isinstance(spec, dict):- typed_spec = cast("dict[str, str]", spec)- model_type_str: str | None = typed_spec.get("model_type") or gateway_default_model_type_str- if model_type_str:- known_handles[model_name] = ModelType(model_type_str)-- return known_handles+ return self._get_local_backend_models()# ============================================================# Helper methodsdiff --git a/tests/unit/pipelex/cogt/models/test_plugin_model_merge.py b/tests/unit/pipelex/cogt/models/test_plugin_model_merge.pyindex cc7075f7e..938e69ec1 100644--- a/tests/unit/pipelex/cogt/models/test_plugin_model_merge.py+++ b/tests/unit/pipelex/cogt/models/test_plugin_model_merge.py@@ -73,8 +73,6 @@ class TestPluginModelMerge:models_manager = ModelManager()models_manager.setup(secrets_provider=EnvSecretsProvider(),- managed_gateway_configs=None,- gateway_config_source=None,plugin_model_declarations=plugin_model_declarations,needs_inference=False,backends_library_paths=[inference_dir / "backends.toml"],diff --git a/tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py b/tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.pydeleted file mode 100644index d3dd7ba38..000000000--- a/tests/unit/pipelex/cogt/models/test_resolve_terminal_candidates.py+++ /dev/null@@ -1,231 +0,0 @@-"""Unit coverage for ``ModelManager._collect_candidates``.--The resolver underpins the gateway-membership check in ``ModelManager.setup``: it walks-aliases/waterfalls and returns every reachable terminal handle. The membership check accepts-the deck if ANY candidate is in ``deck.inference_models`` or the gateway specs.--Two regressions are pinned here:--- A self-referential alias or waterfall must NOT loop forever.-- A waterfall with multiple fallbacks must surface every fallback as a candidate (when- ``is_model_fallback_enabled`` is true, the default) so the membership check matches the- runtime fallback behaviour at ``model_deck._get_optional_inference_model_with_fallback``.-"""--from __future__ import annotations--import pytest--from pipelex.cogt.models.model_manager import (- ModelManager,-)-from pipelex.cogt.models.model_reference import ModelReference--# ``_collect_candidates`` is the pure-logic leaf of the membership resolver; testing it-# directly keeps the unit tests free of ModelDeck setup boilerplate.-_collect_candidates = ModelManager._collect_candidates # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]---class TestResolveTerminalCandidates:- def test_handle_returns_self(self) -> None:- ref = ModelReference.parse("claude-4.7-opus")- result = _collect_candidates(- ref=ref,- aliases={},- waterfalls={},- is_fallback_enabled=True,- visited=set(),- )- assert result == ["claude-4.7-opus"]-- def test_alias_resolves_to_handle(self) -> None:- ref = ModelReference.parse("@best")- result = _collect_candidates(- ref=ref,- aliases={"best": "claude-4.7-opus"},- waterfalls={},- is_fallback_enabled=True,- visited=set(),- )- assert result == ["claude-4.7-opus"]-- def test_dangling_alias_returns_alias_name(self) -> None:- """When an alias has no target mapping, surface the alias name itself so the- membership check fails with the user-visible identifier (the alias they wrote).- """- ref = ModelReference.parse("@missing-alias")- result = _collect_candidates(- ref=ref,- aliases={},- waterfalls={},- is_fallback_enabled=True,- visited=set(),- )- assert result == ["missing-alias"]-- def test_alias_cycle_returns_empty(self) -> None:- """Self-referential alias chain returns no candidates — the membership check then- skips this reference rather than tripping ``GatewayUnknownModelError`` on a key the- user never asked the gateway to resolve.- """- ref = ModelReference.parse("@loop")- result = _collect_candidates(- ref=ref,- aliases={"loop": "@loop"},- waterfalls={},- is_fallback_enabled=True,- visited=set(),- )- assert result == []-- def test_waterfall_returns_every_fallback(self) -> None:- """The fix for the false ``GatewayUnknownModelError`` when only later fallbacks are- valid. The whole point of a waterfall is "try in order, use whatever works."- """- ref = ModelReference.parse("~fast-llm")- result = _collect_candidates(- ref=ref,- aliases={},- waterfalls={"fast-llm": ["future-model", "current-model"]},- is_fallback_enabled=True,- visited=set(),- )- assert result == ["future-model", "current-model"]-- def test_waterfall_when_fallback_disabled_returns_only_first(self) -> None:- """Mirrors ``model_deck._get_optional_inference_model_with_fallback``: when fallback- is disabled the runtime only tries the first entry, so the membership check should- only validate that one.- """- ref = ModelReference.parse("~fast-llm")- result = _collect_candidates(- ref=ref,- aliases={},- waterfalls={"fast-llm": ["future-model", "current-model"]},- is_fallback_enabled=False,- visited=set(),- )- assert result == ["future-model"]-- def test_self_referential_waterfall_returns_empty(self) -> None:- """Cycle protection on the waterfall branch (issue #3 from PR review).-- Before the fix, ``waterfalls["A"] = ["~A"]`` would loop forever; now the visited- guard short-circuits the recursion.- """- ref = ModelReference.parse("~A")- result = _collect_candidates(- ref=ref,- aliases={},- waterfalls={"A": ["~A"]},- is_fallback_enabled=True,- visited=set(),- )- assert result == []-- def test_waterfall_through_alias_unrolls_both(self) -> None:- """Mixed chains: alias → waterfall with two fallbacks → handles."""- ref = ModelReference.parse("@fast")- result = _collect_candidates(- ref=ref,- aliases={"fast": "~tier"},- waterfalls={"tier": ["a", "b"]},- is_fallback_enabled=True,- visited=set(),- )- assert result == ["a", "b"]-- @pytest.mark.parametrize(- ("ref_str", "aliases", "waterfalls", "expected"),- [- ("@shared", {"shared": "~shared"}, {"shared": ["gpt-4o-mini", "claude-haiku"]}, ["gpt-4o-mini", "claude-haiku"]),- ("~shared", {"shared": "claude-4.7-opus"}, {"shared": ["@shared"]}, ["claude-4.7-opus"]),- ],- )- def test_shared_name_alias_and_waterfall_is_not_a_cycle(- self,- ref_str: str,- aliases: dict[str, str],- waterfalls: dict[str, list[str]],- expected: list[str],- ) -> None:- """An alias and a waterfall may share a name without forming a cycle.-- Aliases and waterfalls live in separate dicts with no cross-validation, so a- deck can hold both ``@shared`` and ``~shared``. Cycle detection must key on- ``(kind, name)``: keying on name alone false-flags the second node as visited,- returns no candidates, and silently skips gateway membership validation.- """- result = _collect_candidates(- ref=ModelReference.parse(ref_str),- aliases=aliases,- waterfalls=waterfalls,- is_fallback_enabled=True,- visited=set(),- )- assert result == expected-- def test_cross_kind_cycle_still_returns_empty(self) -> None:- """Keying on ``(kind, name)`` must not disable detection of a genuine cycle that- alternates kinds: ``@x`` → ``~x`` → ``@x`` revisits the alias node and short-circuits.- """- ref = ModelReference.parse("@x")- result = _collect_candidates(- ref=ref,- aliases={"x": "~x"},- waterfalls={"x": ["@x"]},- is_fallback_enabled=True,- visited=set(),- )- assert result == []-- def test_waterfall_with_invalid_entry_skips_only_that_branch(self) -> None:- """A malformed waterfall entry that fails ``ModelReference.parse`` must not poison- the rest of the list — the resolver moves on to the next entry.- """- ref = ModelReference.parse("~mixed")- result = _collect_candidates(- ref=ref,- aliases={},- waterfalls={"mixed": ["", "good-handle"]},- is_fallback_enabled=True,- visited=set(),- )- assert result == ["good-handle"]-- def test_preset_returns_empty(self) -> None:- """Presets are not handles; the membership check skips them."""- ref = ModelReference.parse("$some-preset")- result = _collect_candidates(- ref=ref,- aliases={},- waterfalls={},- is_fallback_enabled=True,- visited=set(),- )- assert result == []-- @pytest.mark.parametrize(- ("waterfall_entries", "is_fallback_enabled", "expected"),- [- (["a", "b", "c"], True, ["a", "b", "c"]),- (["a", "b", "c"], False, ["a"]),- (["only-one"], True, ["only-one"]),- (["only-one"], False, ["only-one"]),- ],- )- def test_waterfall_entries_respect_fallback_flag(- self,- waterfall_entries: list[str],- is_fallback_enabled: bool,- expected: list[str],- ) -> None:- ref = ModelReference.parse("~name")- result = _collect_candidates(- ref=ref,- aliases={},- waterfalls={"name": waterfall_entries},- is_fallback_enabled=is_fallback_enabled,- visited=set(),- )- assert result == expecteddiff --git a/tests/unit/pipelex/core/test_validation_report.py b/tests/unit/pipelex/core/test_validation_report.pyindex 2197bf360..2a7ad6ce6 100644--- a/tests/unit/pipelex/core/test_validation_report.py+++ b/tests/unit/pipelex/core/test_validation_report.py@@ -157,16 +157,13 @@ class TestWhatTheScanFinds:assert report.migration is None- def test_another_surfaces_base_file_is_not_swept_up_by_this_ones_glob(self, machine: Path) -> None:- """Scoping narrows the answer; it must not narrow the registry that decides ownership.-- `pipelex_service.toml` is `pipelex-service-config`'s base file *and* a match for- `pipelex-config`'s tier glob `pipelex_*.toml`, and the registry resolves that by letting an- exact base file claim before any glob — **across all surfaces**. Scoping the scan by- building a registry that holds only the surface asked about removes the other claimant from- that arbitration, and the glob then wins: the file is replayed under the wrong ledger and- diagnosed against the wrong model, so its perfectly ordinary settings come back reported as- paths this build knows nothing about. Measured, not imagined — that is what it did.+ def test_a_retired_file_is_not_swept_up_by_this_surfaces_glob(self, machine: Path) -> None:+ """A retired configuration file left on the machine is inert, even when its name matches the glob.++ `pipelex_service.toml` matches `pipelex-config`'s tier glob `pipelex_*.toml`, but the file it+ names is no longer read by anything. Replayed under `pipelex-config`'s ledger, its ordinary+ settings would come back reported as paths this build knows nothing about, so the registry+ claims it for no surface and the scan leaves it out."""machine.joinpath("pipelex.toml").write_text("not_a_real_setting = true\n", encoding="utf-8")machine.joinpath("pipelex_service.toml").write_text("[agreement]\nterms_accepted = true\n", encoding="utf-8")diff --git a/tests/unit/pipelex/exceptions/test_class_level_metadata.py b/tests/unit/pipelex/exceptions/test_class_level_metadata.pyindex a1a7f4d17..7f9b9a1f5 100644--- a/tests/unit/pipelex/exceptions/test_class_level_metadata.py+++ b/tests/unit/pipelex/exceptions/test_class_level_metadata.py@@ -28,11 +28,6 @@ from pipelex.pipeline.exceptions import (from pipelex.plugins.exceptions import UnknownSecretsMethodError, UnknownStorageMethodErrorfrom pipelex.system.exceptions import EnvVarNotFoundErrorfrom pipelex.system.pipe_run_mode import PipeRunMode-from pipelex.system.pipelex_service.exceptions import (- PipelexServiceConfigValidationError,- PipelexServiceError,- RemoteConfigFetchError,-)from pipelex.tools.tabular.exceptions import CsvError_PIPELINE_EXEC_ERROR = PipelineExecutionError(@@ -61,9 +56,6 @@ class TestClassLevelMetadata:("interpreter", MthdsParserError("boom"), ErrorDomain.INPUT),("setup", PipelexSetupError("boom"), ErrorDomain.CONFIG),("config", PipelexConfigError("boom"), ErrorDomain.CONFIG),- ("service_base", PipelexServiceError("boom"), ErrorDomain.CONFIG),- ("service_config_validation", PipelexServiceConfigValidationError("boom"), ErrorDomain.CONFIG),- ("remote_config_fetch", RemoteConfigFetchError("boom"), ErrorDomain.CONFIG),("env_var_not_found", EnvVarNotFoundError("boom"), ErrorDomain.CONFIG),],)diff --git a/tests/unit/pipelex/fix_ops/test_fix_applier_config_surface_shapes.py b/tests/unit/pipelex/fix_ops/test_fix_applier_config_surface_shapes.pyindex ad8d9e696..a564e56f2 100644--- a/tests/unit/pipelex/fix_ops/test_fix_applier_config_surface_shapes.py+++ b/tests/unit/pipelex/fix_ops/test_fix_applier_config_surface_shapes.py@@ -40,7 +40,6 @@ _TRACKED_CONFIG_FILES = [Path("pipelex/kit/configs/pipelex.toml"),Path("pipelex/kit/configs/telemetry.toml"),Path("pipelex/kit/configs/telemetry.project.toml"),- Path("pipelex/kit/configs/pipelex_service.toml"),Path("pipelex/kit/configs/plxt.toml"),Path(".pipelex/pipelex.toml"),Path(".pipelex/telemetry.toml"),diff --git a/tests/unit/pipelex/migration/test_real_surfaces.py b/tests/unit/pipelex/migration/test_real_surfaces.pyindex 6c630f51f..c3219bb0a 100644--- a/tests/unit/pipelex/migration/test_real_surfaces.py+++ b/tests/unit/pipelex/migration/test_real_surfaces.py@@ -25,7 +25,6 @@ class TestTheRealRegistry:assert [surface.surface_id for surface in registry.surfaces] == ["pipelex-config","telemetry-config",- "pipelex-service-config","inference-backend",]diff --git a/tests/unit/pipelex/migration/test_surface_registry.py b/tests/unit/pipelex/migration/test_surface_registry.pyindex c9e17ca74..9a57e8be5 100644--- a/tests/unit/pipelex/migration/test_surface_registry.py+++ b/tests/unit/pipelex/migration/test_surface_registry.py@@ -189,7 +189,7 @@ class TestRegistryConsistency:_surface(surface_id="a", base_file=base_file, tier_glob=tier_glob, subdirectory=BACKENDS)def test_a_base_file_matching_another_surfaces_glob_is_fine(self) -> None:- """This is the real configuration: `pipelex_service.toml` matches `pipelex_*.toml`.+ """`pipelex_extra.toml` is one surface's base file and matches another's `pipelex_*.toml`.Exact filenames claim before globs across all surfaces, so the resolution rule separatesthem — which is exactly why it exists, and why this is not a registry error.@@ -197,7 +197,7 @@ class TestRegistryConsistency:registry = SurfaceRegistry(surfaces=[_surface(surface_id="a", base_file="pipelex.toml", tier_glob="pipelex_*.toml"),- _surface(surface_id="b", base_file="pipelex_service.toml"),+ _surface(surface_id="b", base_file="pipelex_extra.toml"),])assert len(registry.surfaces) == 2diff --git a/tests/unit/pipelex/migration/test_surface_resolution.py b/tests/unit/pipelex/migration/test_surface_resolution.pyindex 64cd381f3..b482d9ce9 100644--- a/tests/unit/pipelex/migration/test_surface_resolution.py+++ b/tests/unit/pipelex/migration/test_surface_resolution.py@@ -9,29 +9,51 @@ of a configuration directory. `test_surface_directories.py` is the directory hal"""import re+from fnmatch import fnmatchfrom pathlib import Pathimport pytestfrom pipelex.migration.exceptions import MigrationRegistryError-from pipelex.migration.surfaces import SurfaceRegistry+from pipelex.migration.surfaces import RETIRED_CONFIG_FILE_NAMES, SurfaceRegistryfrom tests.unit.pipelex.migration.conftest import CONFIGURATION_ROOT, SurfaceBuilderclass TestSurfaceResolution:def test_an_exact_base_file_claims_before_another_surfaces_glob(self, build_surface: SurfaceBuilder) -> None:- """The real configuration: `pipelex_service.toml` also matches `pipelex_*.toml`."""registry = SurfaceRegistry(surfaces=[build_surface(surface_id="pipelex-config", base_file="pipelex.toml", tier_glob="pipelex_*.toml"),- build_surface(surface_id="pipelex-service-config", base_file="pipelex_service.toml", tier_glob=None),+ build_surface(surface_id="extra-config", base_file="pipelex_extra.toml", tier_glob=None),])- resolved = registry.surface_for_file(subdirectory=CONFIGURATION_ROOT, file_name="pipelex_service.toml")+ resolved = registry.surface_for_file(subdirectory=CONFIGURATION_ROOT, file_name="pipelex_extra.toml")assert resolved is not None- assert resolved.surface_id == "pipelex-service-config"+ assert resolved.surface_id == "extra-config"++ @pytest.mark.parametrize("retired_file_name", sorted(RETIRED_CONFIG_FILE_NAMES))+ def test_a_retired_file_is_claimed_by_no_surface_even_when_a_glob_matches_it(self, build_surface: SurfaceBuilder, retired_file_name: str) -> None:+ """The real configuration: `pipelex_service.toml` is retired, and it matches `pipelex_*.toml`.++ Nothing reads a retired file any more, so no ledger may be replayed over it, least of all the+ one of a surface that never owned it.+ """+ registry = SurfaceRegistry(surfaces=[build_surface(surface_id="pipelex-config", base_file="pipelex.toml", tier_glob="pipelex_*.toml")])+ assert fnmatch(retired_file_name, "pipelex_*.toml"), "the fixture no longer exercises a glob collision"++ assert registry.surface_for_file(subdirectory=CONFIGURATION_ROOT, file_name=retired_file_name) is None++ def test_a_directory_walk_leaves_a_retired_file_out(self, tmp_path: Path, build_surface: SurfaceBuilder) -> None:+ registry = SurfaceRegistry(surfaces=[build_surface(surface_id="pipelex-config", base_file="pipelex.toml", tier_glob="pipelex_*.toml")])+ (tmp_path / "pipelex.toml").write_text("", encoding="utf-8")+ for retired_file_name in RETIRED_CONFIG_FILE_NAMES:+ (tmp_path / retired_file_name).write_text("", encoding="utf-8")++ claimed = registry.files_by_surface_in_directory(directory=tmp_path)++ assert [path.name for _, path in claimed] == ["pipelex.toml"]def test_a_tier_file_resolves_to_the_surface_whose_glob_matches(self, build_surface: SurfaceBuilder) -> None:registry = SurfaceRegistry(surfaces=[build_surface(surface_id="pipelex-config", base_file="pipelex.toml", tier_glob="pipelex_*.toml")])diff --git a/tests/unit/pipelex/system/configuration/test_boot_tolerance.py b/tests/unit/pipelex/system/configuration/test_boot_tolerance.pyindex 9f9c42ca1..c9c5eaec5 100644--- a/tests/unit/pipelex/system/configuration/test_boot_tolerance.py+++ b/tests/unit/pipelex/system/configuration/test_boot_tolerance.py@@ -35,15 +35,12 @@ from pipelex.system.configuration import config_surface as config_surface_modulefrom pipelex.system.configuration.config_loader import ConfigLoaderfrom pipelex.system.configuration.config_surface import (PIPELEX_CONFIG_SURFACE_ID,- PIPELEX_SERVICE_CONFIG_SURFACE_ID,TELEMETRY_CONFIG_SURFACE_ID,replay_surface_files_in_memory,stale_configuration_warning,)from pipelex.system.configuration.configs import PipelexConfigfrom pipelex.system.exceptions import ConfigValidationError-from pipelex.system.pipelex_service.exceptions import PipelexServiceConfigValidationError-from pipelex.system.pipelex_service.pipelex_service_config import load_pipelex_service_config_if_existsfrom pipelex.system.telemetry import telemetry_loader as telemetry_loader_modulefrom pipelex.system.telemetry.exceptions import TelemetryConfigValidationErrorfrom pipelex.system.telemetry.telemetry_config import PostHogMode, TelemetryConfig@@ -642,36 +639,3 @@ class TestTheMainConfigurationLoader:ConfigLoader().load_config_validated(config_cls=PipelexConfig)assert retry.call_count == 0---class TestTheServiceConfigLoader:- """One file, no tiers — the merge the shared helper performs is a merge of one."""-- def test_an_old_shape_file_boots_with_a_warning(self, tmp_path: Path, synthetic_migration_dir: Path, mocker: MockerFixture) -> None:- write_synthetic_ledger(- migration_dir=synthetic_migration_dir,- surface_id=PIPELEX_SERVICE_CONFIG_SURFACE_ID,- base_file="pipelex_service.toml",- ops_body='[[migration.ops]]\nkind = "rename_table_key"\ntable_path = []\nkey = "setup"\nnew_key = "onboarding"\n',- )- config_dir = tmp_path / "config"- config_dir.mkdir()- stale = config_dir / "pipelex_service.toml"- stale.write_text("[setup]\ninference_setup_completed = true\n", encoding="utf-8")- warning = mocker.patch("pipelex.system.pipelex_service.pipelex_service_config.log.warning")-- config = load_pipelex_service_config_if_exists(config_dir=config_dir)-- assert config is not None- assert config.onboarding.inference_setup_completed is True- assert stale.read_bytes() == b"[setup]\ninference_setup_completed = true\n", "a tolerated boot writes nothing"- assert "pipelex migrate" in warning.call_args.args[0]-- @pytest.mark.usefixtures("synthetic_migration_dir")- def test_a_file_the_ledger_cannot_explain_still_raises(self, tmp_path: Path) -> None:- config_dir = tmp_path / "config"- config_dir.mkdir()- (config_dir / "pipelex_service.toml").write_text("[nonsense]\nwhat = true\n", encoding="utf-8")-- with pytest.raises(PipelexServiceConfigValidationError):- load_pipelex_service_config_if_exists(config_dir=config_dir)diff --git a/tests/unit/pipelex/system/pipelex_service/__init__.py b/tests/unit/pipelex/system/pipelex_service/__init__.pydeleted file mode 100644index e69de29bb..000000000diff --git a/tests/unit/pipelex/system/pipelex_service/conftest.py b/tests/unit/pipelex/system/pipelex_service/conftest.pydeleted file mode 100644index 259b65e1b..000000000--- a/tests/unit/pipelex/system/pipelex_service/conftest.py+++ /dev/null@@ -1,26 +0,0 @@-"""Conftest for pipelex_service unit tests.--These tests are pure unit tests that don't need Pipelex initialization.-We override the autouse fixture from the root conftest to disable it.-"""--import pytest-from pytest_mock import MockerFixture--[email protected](scope="module", autouse=True)-def reset_pipelex_config_fixture():- """Override the root conftest fixture to disable Pipelex initialization for these tests.-- We mock the log module to avoid needing full Pipelex setup.- """- return--[email protected](autouse=True)-def mock_log(mocker: MockerFixture):- """Mock the log module for all tests in this package."""- mock_logger = mocker.MagicMock()- mocker.patch("pipelex.system.pipelex_service.gateway_config_merger.log", mock_logger)- mocker.patch("pipelex.system.pipelex_service.remote_config_cache.log", mock_logger)- return mock_loggerdiff --git a/tests/unit/pipelex/system/pipelex_service/test_gateway_config_merger.py b/tests/unit/pipelex/system/pipelex_service/test_gateway_config_merger.pydeleted file mode 100644index ba793fc1f..000000000--- a/tests/unit/pipelex/system/pipelex_service/test_gateway_config_merger.py+++ /dev/null@@ -1,166 +0,0 @@-"""Unit tests for GatewayConfigMerger."""--import warnings-from typing import Any--import pytest--from pipelex.system.pipelex_service.exceptions import GatewayConfigMergeError, GatewayOverrideWarning-from pipelex.system.pipelex_service.gateway_config_merger import (- ALLOWED_OVERRIDE_KEYS,- GatewayConfigMerger,-)---class TestGatewayConfigMerger:- """Tests for GatewayConfigMerger."""-- def test_merge_no_overrides(self) -> None:- """Test merging with empty local overrides returns copy of remote config."""- remote_config: dict[str, Any] = {- "defaults": {"sdk": "gateway_completions"},- "gpt-4o": {"model_id": "gpt-4o-2024-11-20", "sdk": "gateway_responses"},- }- local_overrides: dict[str, Any] = {}-- result = GatewayConfigMerger.merge(remote_config, local_overrides=local_overrides)-- assert result == remote_config- # Verify it's a copy, not the same object- assert result is not remote_config-- def test_merge_allowed_override_applied(self) -> None:- """Test that allowed keys (sdk, structure_method) are applied."""- remote_config: dict[str, Any] = {- "gpt-4o": {- "model_id": "gpt-4o-2024-11-20",- "sdk": "gateway_completions",- "structure_method": "instructor/openai_tools",- },- }- local_overrides: dict[str, Any] = {- "gpt-4o": {- "sdk": "gateway_responses",- "structure_method": "instructor/openai_responses_tools",- },- }-- with warnings.catch_warnings(record=True) as caught_warnings:- warnings.simplefilter("always")- result = GatewayConfigMerger.merge(remote_config, local_overrides=local_overrides)-- assert result["gpt-4o"]["sdk"] == "gateway_responses"- assert result["gpt-4o"]["structure_method"] == "instructor/openai_responses_tools"- # Original model_id should be preserved- assert result["gpt-4o"]["model_id"] == "gpt-4o-2024-11-20"- # Check warning was issued- assert any(issubclass(warning.category, GatewayOverrideWarning) for warning in caught_warnings)-- def test_merge_disallowed_override_ignored(self) -> None:- """Test that non-allowed keys are ignored."""- remote_config: dict[str, Any] = {- "gpt-4o": {- "model_id": "gpt-4o-2024-11-20",- "costs": {"input": 2.5, "output": 10.0},- },- }- local_overrides: dict[str, Any] = {- "gpt-4o": {- "model_id": "hacked-model", # Should be ignored- "costs": {"input": 0, "output": 0}, # Should be ignored- },- }-- result = GatewayConfigMerger.merge(remote_config, local_overrides=local_overrides)-- # Original values should be preserved- assert result["gpt-4o"]["model_id"] == "gpt-4o-2024-11-20"- assert result["gpt-4o"]["costs"] == {"input": 2.5, "output": 10.0}-- def test_merge_unknown_model_override_ignored(self) -> None:- """Test that overrides for unknown models are ignored."""- remote_config: dict[str, Any] = {- "gpt-4o": {"model_id": "gpt-4o-2024-11-20"},- }- local_overrides: dict[str, Any] = {- "unknown-model": {"sdk": "gateway_responses"},- }-- result = GatewayConfigMerger.merge(remote_config, local_overrides=local_overrides)-- # Unknown model should not be added- assert "unknown-model" not in result-- def test_merge_defaults_override_ignored(self) -> None:- """Test that defaults section overrides are ignored (only per-model overrides allowed)."""- remote_config: dict[str, Any] = {- "defaults": {- "sdk": "gateway_completions",- "structure_method": "instructor/openai_tools",- },- }- local_overrides: dict[str, Any] = {- "defaults": {- "sdk": "gateway_responses", # Should be ignored- },- }-- result = GatewayConfigMerger.merge(remote_config, local_overrides=local_overrides)-- # Defaults override should be ignored - original values preserved- assert result["defaults"]["sdk"] == "gateway_completions"- assert result["defaults"]["structure_method"] == "instructor/openai_tools"-- def test_deep_copy_preserves_nested_dicts(self) -> None:- """Test that deep copy properly copies nested dictionaries."""- remote_config: dict[str, Any] = {- "gpt-4o": {- "model_id": "gpt-4o",- "costs": {"input": 2.5, "output": 10.0},- "inputs": ["text", "images"],- },- }-- result = GatewayConfigMerger.merge(remote_config, local_overrides={})-- # Modify the result- result["gpt-4o"]["costs"]["input"] = 999-- # Original should be unchanged- assert remote_config["gpt-4o"]["costs"]["input"] == 2.5-- def test_allowed_override_keys_contains_expected(self) -> None:- """Test that ALLOWED_OVERRIDE_KEYS contains the expected keys."""- assert "sdk" in ALLOWED_OVERRIDE_KEYS- assert "structure_method" in ALLOWED_OVERRIDE_KEYS- assert len(ALLOWED_OVERRIDE_KEYS) == 2-- def test_merge_with_non_dict_local_override_raises(self) -> None:- """Test that non-dict local override values raise GatewayConfigMergeError."""- remote_config: dict[str, Any] = {- "gpt-4o": {"model_id": "gpt-4o-2024-11-20"},- }- local_overrides: dict[str, Any] = {- "gpt-4o": "not-a-dict",- }-- with pytest.raises(GatewayConfigMergeError) as exc_info:- GatewayConfigMerger.merge(remote_config, local_overrides=local_overrides)-- assert "gpt-4o" in str(exc_info.value)- assert "must be a dictionary" in str(exc_info.value)-- def test_merge_with_non_dict_remote_config_raises(self) -> None:- """Test that non-dict remote config values raise GatewayConfigMergeError."""- remote_config: dict[str, Any] = {- "gpt-4o": "not-a-dict",- }- local_overrides: dict[str, Any] = {- "gpt-4o": {"sdk": "gateway_responses"},- }-- with pytest.raises(GatewayConfigMergeError) as exc_info:- GatewayConfigMerger.merge(remote_config, local_overrides=local_overrides)-- assert "gpt-4o" in str(exc_info.value)- assert "must be a dictionary" in str(exc_info.value)diff --git a/tests/unit/pipelex/system/pipelex_service/test_managed_gateway_backends.py b/tests/unit/pipelex/system/pipelex_service/test_managed_gateway_backends.pydeleted file mode 100644index c392f9560..000000000--- a/tests/unit/pipelex/system/pipelex_service/test_managed_gateway_backends.py+++ /dev/null@@ -1,222 +0,0 @@-"""Which backends are *managed gateway* backends, and how the one artifact is sliced for them.--Three collaborating pieces, one question: a managed gateway backend takes its model specs from the-Pipelex service's published artifact rather than from a local per-backend TOML, and naming a section-is what declares it one.--- `resolve_model_specs_section` decides, per backend, whether there is a section and which;-- `enabled_managed_gateway_sections` answers it for a whole `backends.toml`, before the backend- library can be loaded — the boot needs the answer first, because what it fetches is that load's- input;-- `build_managed_gateway_configs` cuts the single fetched artifact into one configuration per- managed backend, keeping them apart rather than merging them.-"""--from __future__ import annotations--from typing import TYPE_CHECKING--import pytest--from pipelex.cogt.model_backends.backend import (- MANIFOLD_MODEL_SPECS_SECTION,- PipelexBackend,- resolve_model_specs_section,-)-from pipelex.system.pipelex_service.managed_gateway_configs import build_managed_gateway_configs-from pipelex.system.pipelex_service.pipelex_service_config import enabled_managed_gateway_sections-from pipelex.system.pipelex_service.remote_config import RemoteConfig--if TYPE_CHECKING:- from pathlib import Path-- from pytest_mock import MockerFixture--# A second managed section, standing in for the next managed service the kit could ship.-OTHER_SECTION = "other_model_specs"-OTHER_BACKEND = "pipelex_other"---def _remote_config(**sections: object) -> RemoteConfig:- """The published artifact, carrying whichever model-specs sections a test hands it."""- return RemoteConfig(**sections) # pyright: ignore[reportArgumentType]---def _write_backends(tmp_path: Path, body: str) -> Path:- """Write the base document at a config dir and return that dir, which is what the readers take.-- The reader below takes a `config_dir` and resolves the document under it — the base- `inference/backends.toml` plus any `inference/backends_override.toml` — so a test pins a- directory rather than a file.- """- inference_dir = tmp_path / "inference"- inference_dir.mkdir(parents=True, exist_ok=True)- (inference_dir / "backends.toml").write_text(body, encoding="utf-8")- return tmp_path---class TestResolveModelSpecsSection:- def test_a_declared_section_makes_a_backend_managed(self) -> None:- assert resolve_model_specs_section(backend_name="whatever", declared_section="some_section") == "some_section"-- def test_every_backend_without_a_declaration_reads_its_own_file(self) -> None:- """No section means not managed, which is every BYOK backend and the internal one — and no- name resolves to a section it did not declare, the manifold's included.- """- assert resolve_model_specs_section(backend_name="anthropic", declared_section=None) is None- assert resolve_model_specs_section(backend_name=PipelexBackend.MANIFOLD, declared_section=None) is None---class TestEnabledManagedGatewaySections:- def test_it_maps_each_enabled_managed_backend_to_its_section(self, tmp_path: Path) -> None:- config_dir = _write_backends(- tmp_path,- f'[pipelex_manifold]\nmodel_specs_section = "{MANIFOLD_MODEL_SPECS_SECTION}"\nendpoint = "https://gw.example.com"\n\n'- f'[{OTHER_BACKEND}]\nmodel_specs_section = "{OTHER_SECTION}"\n\n'- f'[anthropic]\napi_key = "sk-x"\n',- )-- assert enabled_managed_gateway_sections(config_dir=config_dir) == {- PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION,- OTHER_BACKEND: OTHER_SECTION,- }-- @pytest.mark.parametrize("enabled_value", ["false", "0"])- def test_a_disabled_backend_is_absent_reading_enabled_the_way_the_loader_does(self, tmp_path: Path, enabled_value: str) -> None:- """Truthiness, not the literal `true` — the same reading the backend library applies."""- config_dir = _write_backends(- tmp_path, f'[pipelex_manifold]\nenabled = {enabled_value}\nmodel_specs_section = "{MANIFOLD_MODEL_SPECS_SECTION}"\n'- )-- assert enabled_managed_gateway_sections(config_dir=config_dir) == {}-- @pytest.mark.parametrize("enabled_value", ["1", '"yes"'])- def test_an_enabled_value_the_loader_reads_as_true_is_enabled_here_too(self, tmp_path: Path, enabled_value: str) -> None:- """The two readers of `backends.toml` must agree, or the boot fetches no specs for a backend- the loader then insists is enabled.- """- config_dir = _write_backends(- tmp_path, f'[pipelex_manifold]\nenabled = {enabled_value}\nmodel_specs_section = "{MANIFOLD_MODEL_SPECS_SECTION}"\n'- )-- assert enabled_managed_gateway_sections(config_dir=config_dir) == {PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION}-- def test_the_override_is_read_over_the_base(self, tmp_path: Path) -> None:- """The personal override is the loader's document too, so the gate must see it."""- config_dir = _write_backends(tmp_path, f'[pipelex_manifold]\nenabled = false\nmodel_specs_section = "{MANIFOLD_MODEL_SPECS_SECTION}"\n')- (config_dir / "inference" / "backends_override.toml").write_text("[pipelex_manifold]\nenabled = true\n", encoding="utf-8")-- assert enabled_managed_gateway_sections(config_dir=config_dir) == {PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION}-- def test_a_byok_backend_is_never_managed(self, tmp_path: Path) -> None:- config_dir = _write_backends(tmp_path, '[anthropic]\napi_key = "sk-x"\n\n[openai]\napi_key = "sk-y"\n')-- assert enabled_managed_gateway_sections(config_dir=config_dir) == {}-- def test_a_missing_file_is_no_managed_backends_rather_than_a_refusal(self, tmp_path: Path) -> None:- assert enabled_managed_gateway_sections(config_dir=tmp_path / "absent") == {}-- def test_an_override_cannot_stand_in_for_the_base(self, tmp_path: Path) -> None:- """No document, no managed backend."""- inference_dir = tmp_path / "inference"- inference_dir.mkdir(parents=True)- (inference_dir / "backends_override.toml").write_text(- f'[pipelex_manifold]\nenabled = true\nmodel_specs_section = "{MANIFOLD_MODEL_SPECS_SECTION}"\n', encoding="utf-8"- )-- assert enabled_managed_gateway_sections(config_dir=tmp_path) == {}---class TestBuildManagedGatewayConfigs:- def test_each_backend_gets_its_own_section_unmerged(self) -> None:- """Two services, two spec maps: a handle one serves and the other does not is legitimate."""- remote_config = _remote_config(- **{- OTHER_SECTION: {"gpt-5": {"model_id": "gpt-5"}},- MANIFOLD_MODEL_SPECS_SECTION: {"claude-4-sonnet": {"model_id": "claude-4-sonnet"}},- }- )-- configs = build_managed_gateway_configs(- remote_config=remote_config,- managed_gateway_sections={- OTHER_BACKEND: OTHER_SECTION,- PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION,- },- )-- assert set(configs) == {OTHER_BACKEND, PipelexBackend.MANIFOLD}- assert set(configs[OTHER_BACKEND].model_specs) == {"gpt-5"}- assert set(configs[PipelexBackend.MANIFOLD].model_specs) == {"claude-4-sonnet"}-- def test_a_section_the_artifact_does_not_carry_is_disabled_by_name(self, mocker: MockerFixture) -> None:- """Disabled with a named warning, not fatal: the kit can ship a managed backend declared.-- The warning is the whole remedy here, so it has to name both the backend and the section it- was looking for — otherwise a user who has not joined the beta reads that *something* was- disabled and has nowhere to go.- """- warning = mocker.patch("pipelex.system.pipelex_service.managed_gateway_configs.log.warning")- remote_config = _remote_config(**{OTHER_SECTION: {"gpt-5": {"model_id": "gpt-5"}}})-- configs = build_managed_gateway_configs(- remote_config=remote_config,- managed_gateway_sections={- OTHER_BACKEND: OTHER_SECTION,- PipelexBackend.MANIFOLD: MANIFOLD_MODEL_SPECS_SECTION,- },- )-- assert set(configs) == {OTHER_BACKEND}- warning.assert_called_once()- said = str(warning.call_args.args[0])- assert PipelexBackend.MANIFOLD in said- assert MANIFOLD_MODEL_SPECS_SECTION in said---class TestTheSectionLookupIsConfinedToTheArtifact:- """`model_specs_section` is text from the user's own `backends.toml`, so the lookup it drives- must only ever reach the artifact's own content.-- A bare `getattr` on the model answers for pydantic's machinery as well, and two of those- attributes are plain dicts — so they pass a `isinstance(..., dict)` shape check and travel on as- if the service had published them. The failure that produces is not a refusal but a- `GatewayConfig` built over pydantic internals, which surfaces much later as an unintelligible- model-spec error naming neither the backend nor the mistake.- """-- def test_a_published_section_is_found(self) -> None:- sections: dict[str, dict[str, object]] = {- OTHER_SECTION: {},- MANIFOLD_MODEL_SPECS_SECTION: {"claude-4-sonnet": {"model_id": "claude-4-sonnet"}},- }- remote_config = _remote_config(**sections)-- section = remote_config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION)-- assert section is not None- assert set(section) == {"claude-4-sonnet"}-- @pytest.mark.parametrize("attribute_name", ["model_config", "model_fields"])- def test_a_pydantic_internal_is_not_a_section(self, attribute_name: str) -> None:- """Both are real dict attributes of any v2 model, and neither is anything the service published."""- manifold_only: dict[str, dict[str, object]] = {MANIFOLD_MODEL_SPECS_SECTION: {}}- remote_config = _remote_config(**manifold_only)-- # Read off the class: instance access to `model_fields` is deprecated in pydantic v2.11,- # and the point being made is about the attribute existing as a dict at all.- assert isinstance(getattr(RemoteConfig, attribute_name), dict)- assert remote_config.get_model_specs_section(attribute_name) is None-- def test_a_published_key_that_is_not_a_spec_map_is_not_a_section(self) -> None:- """The artifact carries keys for other consumers too, and one of the wrong shape is not a section."""- sections: dict[str, object] = {MANIFOLD_MODEL_SPECS_SECTION: {}, "aws_region": "eu-west-3"}- remote_config = _remote_config(**sections)-- assert remote_config.get_model_specs_section("aws_region") is None-- def test_an_unknown_name_is_simply_absent(self) -> None:- manifold_only: dict[str, dict[str, object]] = {MANIFOLD_MODEL_SPECS_SECTION: {}}- remote_config = _remote_config(**manifold_only)-- assert remote_config.get_model_specs_section("no_such_section") is Nonediff --git a/tests/unit/pipelex/system/pipelex_service/test_pipelex_service_config.py b/tests/unit/pipelex/system/pipelex_service/test_pipelex_service_config.pydeleted file mode 100644index 46e09b43a..000000000--- a/tests/unit/pipelex/system/pipelex_service/test_pipelex_service_config.py+++ /dev/null@@ -1,42 +0,0 @@-"""Unit tests for PipelexServiceConfig."""--import pathlib-import tempfile--from pipelex.system.pipelex_service.pipelex_service_config import (- PIPELEX_SERVICE_CONFIG_FILE_NAME,- PipelexServiceConfig,- load_pipelex_service_config_if_exists,-)-from pipelex.system.pipelex_service.pipelex_service_onboarding import PipelexServiceOnboarding---class TestPipelexServiceConfig:- """Tests for PipelexServiceConfig and related functions."""-- def test_onboarding_defaults_to_not_completed(self) -> None:- config = PipelexServiceOnboarding()- assert config.inference_setup_completed is False-- def test_pipelex_service_config_with_onboarding(self) -> None:- config = PipelexServiceConfig(onboarding=PipelexServiceOnboarding(inference_setup_completed=True))- assert config.onboarding.inference_setup_completed is True-- def test_load_pipelex_service_config_if_exists_returns_none(self) -> None:- """Test load_pipelex_service_config_if_exists returns None when file doesn't exist."""- with tempfile.TemporaryDirectory() as temp_dir:- config = load_pipelex_service_config_if_exists(config_dir=pathlib.Path(temp_dir))- assert config is None-- def test_load_pipelex_service_config_if_exists_returns_config(self) -> None:- """Test load_pipelex_service_config_if_exists returns config when file exists."""- with tempfile.TemporaryDirectory() as temp_dir:- config_content = """[onboarding]-inference_setup_completed = false-"""- config_path = pathlib.Path(temp_dir) / PIPELEX_SERVICE_CONFIG_FILE_NAME- config_path.write_text(config_content, encoding="utf-8")-- config = load_pipelex_service_config_if_exists(config_dir=pathlib.Path(temp_dir))- assert config is not None- assert config.onboarding.inference_setup_completed is Falsediff --git a/tests/unit/pipelex/system/pipelex_service/test_remote_config.py b/tests/unit/pipelex/system/pipelex_service/test_remote_config.pydeleted file mode 100644index f8909579f..000000000--- a/tests/unit/pipelex/system/pipelex_service/test_remote_config.py+++ /dev/null@@ -1,34 +0,0 @@-from typing import Any--from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION-from pipelex.system.pipelex_service.remote_config import RemoteConfig---class TestRemoteConfig:- """Tests for the RemoteConfig model."""-- def test_remote_config_carries_its_sections_as_extras(self) -> None:- """The artifact declares no field of its own: every section arrives through `extra="allow"`."""- payload: dict[str, Any] = {- MANIFOLD_MODEL_SPECS_SECTION: {- "defaults": {"sdk": "manifold_completions"},- "gpt-4o": {"model_id": "gpt-4o-2024-11-20"},- },- "aws_region": "us-east-1",- }- config = RemoteConfig.model_validate(payload)- section = config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION)- assert section is not None- assert "defaults" in section- assert "gpt-4o" in section-- def test_remote_config_tolerates_keys_it_does_not_read(self) -> None:- """The artifact is shared with other consumers, so a key the runtime never asks for is not a refusal."""- payload: dict[str, Any] = {"other_key": "value"}- config = RemoteConfig.model_validate(payload)- assert config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION) is None-- def test_remote_config_empty_section(self) -> None:- payload: dict[str, Any] = {MANIFOLD_MODEL_SPECS_SECTION: {}}- config = RemoteConfig.model_validate(payload)- assert config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION) == {}diff --git a/tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py b/tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.pydeleted file mode 100644index 335041667..000000000--- a/tests/unit/pipelex/system/pipelex_service/test_remote_config_cache.py+++ /dev/null@@ -1,154 +0,0 @@-"""Pure read/write/version tests for ``RemoteConfigCache``.--These tests treat the cache as an isolated module: nothing else in the codebase calls it-yet at the time these are written (Phase 1 only stands the cache up; Phase 2 wires it-into ``RemoteConfigFetcher``).-"""--from __future__ import annotations--import json-from datetime import UTC, datetime, timedelta-from pathlib import Path-from typing import TYPE_CHECKING--import pytest--from pipelex.cogt.model_backends.backend import MANIFOLD_MODEL_SPECS_SECTION-from pipelex.system.configuration.config_loader import ConfigLoader-from pipelex.system.pipelex_service.remote_config import RemoteConfig-from pipelex.system.pipelex_service.remote_config_cache import (- CACHE_SCHEMA_VERSION,- CachedRemoteConfig,- RemoteConfigCache,-)--if TYPE_CHECKING:- from pytest_mock import MockerFixture, MockType---def _valid_remote_config_payload(extra: dict[str, object] | None = None) -> dict[str, object]:- """Build a minimal remote-config dict that ``RemoteConfig.model_validate`` accepts."""- payload: dict[str, object] = {- MANIFOLD_MODEL_SPECS_SECTION: {},- "aws_region": "eu-west-3",- }- if extra is not None:- payload.update(extra)- return payload---def isolated_cache_dir(tmp_path: Path, mocker: MockerFixture) -> Path:- """Point the cache at a fresh tmp ``~/.pipelex`` to keep tests hermetic."""- fake_global_dir = tmp_path / ".pipelex"- mocker.patch.object(- ConfigLoader,- "global_config_dir",- new_callable=mocker.PropertyMock,- return_value=fake_global_dir,- )- return fake_global_dir---class TestRemoteConfigCache:- @pytest.mark.usefixtures("isolated_cache_dir")- def test_write_then_read_roundtrip(self) -> None:- payload = _valid_remote_config_payload()-- before_store = datetime.now(tz=UTC)- RemoteConfigCache.store(payload)- after_store = datetime.now(tz=UTC)-- loaded = RemoteConfigCache.load()-- assert loaded is not None- assert isinstance(loaded, CachedRemoteConfig)- assert loaded.schema_version == CACHE_SCHEMA_VERSION- assert loaded.raw_config == payload- assert before_store - timedelta(seconds=1) <= loaded.cached_at <= after_store + timedelta(seconds=1)-- # to_remote_config() must produce a valid RemoteConfig- remote_config = loaded.to_remote_config()- assert isinstance(remote_config, RemoteConfig)- assert remote_config.get_model_specs_section(MANIFOLD_MODEL_SPECS_SECTION) == {}-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_read_missing_returns_none(self) -> None:- assert RemoteConfigCache.load() is None-- def test_read_corrupted_json_returns_none_and_logs(- self,- isolated_cache_dir: Path,- mock_log: MockType,- ) -> None:- cache_path = isolated_cache_dir / "cache" / "remote_config.json"- cache_path.parent.mkdir(parents=True, exist_ok=True)- cache_path.write_text("{not valid json", encoding="utf-8")-- assert RemoteConfigCache.load() is None-- assert mock_log.warning.called, "load() must emit a warning when the cache file is unreadable"-- def test_read_wrong_schema_version_returns_none(self, isolated_cache_dir: Path) -> None:- cache_path = isolated_cache_dir / "cache" / "remote_config.json"- cache_path.parent.mkdir(parents=True, exist_ok=True)- cache_path.write_text(- json.dumps(- {- "schema_version": CACHE_SCHEMA_VERSION + 99,- "cached_at": datetime.now(tz=UTC).isoformat(),- "raw_config": _valid_remote_config_payload(),- }- ),- encoding="utf-8",- )-- assert RemoteConfigCache.load() is None-- def test_write_creates_parent_dir(self, isolated_cache_dir: Path) -> None:- cache_dir = isolated_cache_dir / "cache"- assert not cache_dir.exists()-- RemoteConfigCache.store(_valid_remote_config_payload())-- assert cache_dir.is_dir()- assert (cache_dir / "remote_config.json").is_file()-- def test_cache_path_uses_global_config_dir(self, isolated_cache_dir: Path) -> None:- expected = isolated_cache_dir / "cache" / "remote_config.json"-- assert RemoteConfigCache.cache_path() == expected-- def test_write_is_atomic(self, isolated_cache_dir: Path, mocker: MockerFixture) -> None:- """If the atomic rename fails, the destination file must not exist or be corrupted."""- mocker.patch.object(- Path,- "replace",- side_effect=OSError("simulated replace failure"),- )-- with pytest.raises(OSError, match="simulated replace failure"):- RemoteConfigCache.store(_valid_remote_config_payload())-- cache_path = isolated_cache_dir / "cache" / "remote_config.json"- assert not cache_path.exists(), "destination cache file must not be created when replace fails"-- # No leftover temp files in the cache dir either.- leftover = list((isolated_cache_dir / "cache").iterdir()) if (isolated_cache_dir / "cache").exists() else []- assert leftover == [], f"unexpected leftover files in cache dir: {leftover}"-- @pytest.mark.usefixtures("isolated_cache_dir")- def test_raw_payload_extras_preserved(self) -> None:- """Unknown top-level keys must round-trip and be preserved on the loaded ``RemoteConfig``."""- payload = _valid_remote_config_payload(extra={"unknown_future_key": {"hello": "world"}})-- RemoteConfigCache.store(payload)- loaded = RemoteConfigCache.load()-- assert loaded is not None- assert loaded.raw_config["unknown_future_key"] == {"hello": "world"}-- remote_config = loaded.to_remote_config()- # ``RemoteConfig`` declares no field, so ``extra="allow"`` keeps the whole payload in model_extra- assert remote_config.model_extra == payloaddiff --git a/tests/unit/pipelex/test_runtime_boot_backends_document_refusal.py b/tests/unit/pipelex/test_runtime_boot_backends_document_refusal.pyindex c917e17fa..091e5f394 100644--- a/tests/unit/pipelex/test_runtime_boot_backends_document_refusal.py+++ b/tests/unit/pipelex/test_runtime_boot_backends_document_refusal.py@@ -1,44 +1,58 @@-"""A backends document that does not parse is a setup error naming the file, even when the gate reads it before the library does.+"""A backends document that does not parse is a setup error naming the file.-`RuntimeBoot` asks `enabled_managed_gateway_sections` which managed gateway backends to fetch specs for before-the backend library loads, so a `backends_override.toml` with a stray quote used to surface there as a raw-`TomlError` — outside every clause the boot has for an unloadable library. The gate now raises the library's own-refusal class, and this pins that the boot turns it into the setup error the library's refusal gets.--The gate is read exactly once. The telemetry decision further down needs the narrower "is the legacy gateway-enabled" answer, and it reads it off the mapping this gate returned rather than asking the document again — a-second read would be a second way past the clause.+A `backends_override.toml` with a stray quote is a document the backend library cannot load. The library+refuses it with its own validation class, naming the files it merged, and the boot turns that refusal into+the setup error every other unloadable library gets. The refusal here is produced by the real loader over a+real broken override, so a loader that went back to letting the raw `TomlError` through would fail the+first assertion rather than slip past the boot's clause."""+from pathlib import Path+import pytestfrom pytest_mock import MockerFixturefrom pipelex.base_exceptions import PipelexSetupError-from pipelex.cogt.exceptions import InferenceBackendLibraryValidationError+from pipelex.cogt.model_backends.backend_library import InferenceBackendLibraryfrom pipelex.pipelex import Pipelex+from pipelex.runtime_boot import BACKEND_LIBRARY_REFUSEDfrom pipelex.system.runtime import IntegrationMode, runtime_manager+from pipelex.tools.secrets.env_secrets_provider import EnvSecretsProviderdef _test_integration_mode() -> IntegrationMode:return IntegrationMode.CI if runtime_manager.is_ci_testing else IntegrationMode.PYTEST-class TestRuntimeBootBackendsDocumentRefusal:- def test_a_backends_document_that_does_not_parse_is_a_setup_error_that_names_the_file(self, mocker: MockerFixture) -> None:- refusal = InferenceBackendLibraryValidationError(- "Invalid inference backend library 'base' with overrides 'home/backends_override.toml': "- "TOML parsing error in file 'home/backends_override.toml'"+def _refusal_of_a_broken_override(*, tmp_path: Path) -> Exception:+ base = tmp_path / "backends.toml"+ base.write_text("[internal]\nenabled = true\n", encoding="utf-8")+ override = tmp_path / "backends_override.toml"+ override.write_text('[internal]\nenabled = "true\n', encoding="utf-8")+ library = InferenceBackendLibrary.make_empty()+ with pytest.raises(BACKEND_LIBRARY_REFUSED) as refused:+ library.load(+ secrets_provider=EnvSecretsProvider(),+ backends_library_paths=[base, override],+ backends_dir_path=str(tmp_path / "backends"),)- mocker.patch("pipelex.runtime_boot.enabled_managed_gateway_sections", side_effect=refusal)+ return refused.value+++class TestRuntimeBootBackendsDocumentRefusal:+ def test_a_backends_document_that_does_not_parse_is_a_setup_error_that_names_the_file(self, tmp_path: Path, mocker: MockerFixture) -> None:+ refusal = _refusal_of_a_broken_override(tmp_path=tmp_path)+ assert "backends_override.toml" in str(refusal)+ mocker.patch.object(InferenceBackendLibrary, "load", side_effect=refusal)Pipelex.teardown_if_needed()try:with pytest.raises(PipelexSetupError) as raised:Pipelex.make(integration_mode=_test_integration_mode(), needs_inference=False)- assert "home/backends_override.toml" in str(raised.value)+ assert "backends_override.toml" in str(raised.value)assert raised.value.__cause__ is refusalfinally:- mocker.stopall() # the re-boot below must read the real gate+ mocker.stopall() # the re-boot below must load the real libraryPipelex.teardown_if_needed()Pipelex.make(integration_mode=_test_integration_mode())diff --git a/tests/unit/pipelex/test_runtime_boot_closure.py b/tests/unit/pipelex/test_runtime_boot_closure.pyindex fc3068aab..0d7ce2a19 100644--- a/tests/unit/pipelex/test_runtime_boot_closure.py+++ b/tests/unit/pipelex/test_runtime_boot_closure.py@@ -40,7 +40,7 @@ from tests.unit.pipelex.test_kernel_layer_import_closure import INTERPRETER_PACKSUBPROCESS_TIMEOUT_SECONDS = 300#: Boot the kernel layer in a fresh interpreter, then answer the three questions this module exists-#: to ask. `needs_inference=False` keeps it offline: no remote config fetch, no model-deck validation.+#: to ask. `needs_inference=False` skips model-deck validation.#: The `sys.modules` sweep runs *before* `pipelex.interpreter_hub` is imported for the hub assertion,#: so importing it to ask the question cannot be what makes the answer wrong._BOOTED_RUNTIME_SCRIPT = textwrap.dedent(diff --git a/tests/unit/pipelex/test_runtime_boot_stale_backend_error.py b/tests/unit/pipelex/test_runtime_boot_stale_backend_error.pyindex bdb0c516e..f9c3d2da1 100644--- a/tests/unit/pipelex/test_runtime_boot_stale_backend_error.py+++ b/tests/unit/pipelex/test_runtime_boot_stale_backend_error.py@@ -118,7 +118,6 @@ class TestAStaleBackendFileTheLedgerCannotFullyExplain:secrets_provider=EnvSecretsProvider(),backends_library_paths=[machine / INFERENCE_DIR_NAME / "backends.toml"],backends_dir_path=str(machine / INFERENCE_DIR_NAME / BACKENDS_DIR_NAME),- managed_gateway_configs=None,lenient=False,)return refused.value