diff --git a/.github/PULL_REQUEST_TEMPLATE/agents.md b/.github/PULL_REQUEST_TEMPLATE/agents.md index 84541e60a9..e1b12cf000 100644 --- a/.github/PULL_REQUEST_TEMPLATE/agents.md +++ b/.github/PULL_REQUEST_TEMPLATE/agents.md @@ -5,8 +5,8 @@ Briefly describe the change to the agent instruction files and the expected effe Examples: * Add a new repository rule to `AGENTS.md` -* Fix contradictory guidance between `AGENTS.md` and `CLAUDE.md` -* Improve instruction clarity for `GEMINI.md` +* Fix contradictory guidance between `AGENTS.md` and `docs/agents/*` +* Improve instruction clarity for `AGENTS.md` --- @@ -24,8 +24,8 @@ Select the primary intent of this PR: List the touched agent instruction files. * [ ] `AGENTS.md` -* [ ] `CLAUDE.md` -* [ ] `GEMINI.md` +* [ ] `roles//AGENTS.md` +* [ ] `docs/agents/*` Additional notes: @@ -61,7 +61,7 @@ Key points: Describe how the instruction change was validated. * [ ] Conflicting or ambiguous guidance checked -* [ ] Consistency between `AGENTS.md`, `CLAUDE.md`, and `GEMINI.md` verified +* [ ] Consistency between `AGENTS.md`, `roles//AGENTS.md`, and `docs/agents/*` verified * [ ] Examples, workflows, or affected contributor paths reviewed --- diff --git a/AGENTS.md b/AGENTS.md index 5cd5e69a96..14b5e52c05 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,21 +6,17 @@ - You MUST read every file under `docs/contributing/` (full directory walk, including subdirectories) for the full contributor guidance. - You MUST read every file under `docs/agents/` (full directory walk, including subdirectories) for the agent execution flow. - This file extends CONTRIBUTING.md with agent-specific instructions; on conflict between CONTRIBUTING.md and this file, this file wins. +- This file is runtime-agnostic and binding for every agent (Claude Code, Codex, Gemini CLI, other). There are no tool-specific extension files. -## Tool-Specific Extensions 🧩 +## Permission State Announcement at Session Start 📢 -At the start of every conversation, the agent MUST load its matching extension file in addition to AGENTS.md: - -- Claude Code → [CLAUDE.md](CLAUDE.md) -- Gemini CLI → [GEMINI.md](GEMINI.md) - -Agents MUST NOT read another tool's extension file. On conflict between AGENTS.md and the agent's own tool-specific extension file, the tool-specific file wins. +At the start of every new conversation, you MUST read [.claude/settings.json](.claude/settings.json) and output a one-time summary: sandbox status with concrete `allowWrite`/`denyRead` paths, plus the counts of `permissions.allow`/`ask`/`deny`. Derive content from the live file; do not hardcode. Do not repeat unless the operator asks, and do not propose `/sandbox` when it is already active. ## Reloading Instructions 🔄 -If agent instructions change mid-conversation (AGENTS.md, the tool-specific extension file, or any file referenced from them), the agent might not reload them automatically. Trigger a reload with: +If agent instructions change mid-conversation (AGENTS.md or any file referenced from it), the agent might not reload them automatically. Trigger a reload with: -> "Re-read AGENTS.md and the tool-specific extension file (CLAUDE.md or GEMINI.md) and apply all updated instructions." +> "Re-read AGENTS.md and apply all updated instructions." ## Permission Model 🔐 @@ -41,6 +37,50 @@ Agents whose runtime does not consult `.claude/settings.json` MUST still enforce Changes to the policy MUST edit [`.claude/settings.json`](.claude/settings.json). Per-entry rationale: [settings.md](docs/contributing/tools/agents/claude/settings.md); sandbox layer: [sandbox.md](docs/contributing/tools/agents/claude/sandbox.md). +## Interaction Rules 💬 + +- A question MUST NOT modify files, code, or state. Only explicit commands MAY. +- You MUST prefer commands permitted in [.claude/settings.json](.claude/settings.json) over commands that require interactive approval when an equivalent exists. + +## Code Execution ⚙️ + +- You MUST prefer `make` targets over raw `docker`/`docker compose`/`ansible-playbook`/`python`/shell invocations whenever an equivalent target exists in the [`Makefile`](Makefile). Inspect the `Makefile` first; fall back to the raw command only when no target covers the operation. The reason is operational consistency, not permissioning. Raw commands also auto-allow under the sandbox. +- **`docker exec` is FORBIDDEN. ⛔** You MUST NEVER invoke `docker exec` (nor nested `docker exec … docker exec …` into the DiD stack) directly. Always reach the live stack through `make` targets (e.g. `make compose-exec`, or the role-specific targets the `Makefile` exposes). If no `make` target covers what you need, ask the operator instead of falling back to raw `docker exec`. +- You SHOULD run sandbox-confined commands directly on the host. The sandbox bounds what they can read, write, and reach. See [sandbox.md](docs/contributing/tools/agents/claude/sandbox.md). +- For commands that legitimately cannot run inside the sandbox (e.g. operations needing access to `~/.ssh` or `~/.gnupg`), use `make compose-up` to start the stack and `make compose-exec` to drop into a container shell. The repository is mounted at `/opt/src/infinito` (see [compose.yml](compose.yml)), so code changes are immediately available there. +- Commands listed under `permissions.ask` in [.claude/settings.json](.claude/settings.json) still pause for explicit operator confirmation regardless of sandbox state. +- **Shell loops are FORBIDDEN. ⛔** You MUST NOT use `for`, `while`, `until`, or any other shell loop construct in any Bash tool call. Reason: shell control structures fall outside the sandbox auto-allow heuristic and trigger approval prompts even when every subcommand would individually auto-allow. +- **Multi-statement chains in shell invocations are FORBIDDEN. ⛔** You MUST NOT chain independent statements inside a single Bash tool call with **any** statement separator (`;`, literal newline, `&&`, `||`, `&` background operator, or subshell/brace groups around the same). The ban covers causally-dependent chains (`cd X && cmd`) just as much as optional ones, and applies to trailing `&` used to background a command (use the Bash tool's `run_in_background: true` parameter instead). Reason: identical to the loop rule. Split the work across **separate Bash tool calls** or use a single-command equivalent (`xargs`, `grep` with multiple args, a make target). +- **File creation via shell heredoc is FORBIDDEN. ⛔** You MUST NOT use `cat > file < file < file`, `echo "…" > file` for multi-line content) to create or overwrite files. Use the **Write tool**. For editing an existing file, use **Edit**, not `sed -i`/`awk -i`. Reason: Write/Edit land structured in the transcript and diff; heredoc + redirect shapes also fall out of the auto-allow heuristic and drop into ask. +- **For searching file contents, use the Grep tool.** If shelling out is unavoidable, use a single `grep` invocation with multiple file arguments (e.g. `grep -nE 'pattern' file1 file2 file3`) or a recursive call with a path/glob (e.g. `grep -rnE 'pattern' path/`). + +## Command output logging 📜 + +- For ANY non-trivial command (test runs, deploys, long pipelines), you MUST stream the FULL output to a file under `/tmp/` via `… 2>&1 | tee /tmp/.log` and grep / inspect that file repeatedly instead of re-running the command. Reason: re-running `make test` to "find the failure I just lost" costs 2 minutes per cycle; grepping the saved log costs milliseconds. +- Default the filename to a meaningful slug + monotonically increasing index (`/tmp/make-test--.log`, `/tmp/act--.log`) so you can compare runs. +- **When a long-running command streams its output to a `/tmp/.log` file** (e.g. background `make compose-deploy`, `make act-*`, or any `… 2>&1 | tee /tmp/.log`), you MUST tell the operator the concrete `tail -f /tmp/.log` command they can run in another terminal to follow the log live. Include the full path literally so it is copy-pasteable. +- That pipe **destroys the exit status**: `make test | tee` reports `tee`'s success even when make ends with `Error 2`. You MUST judge such a run by its `📊 per-target wall-clock` table and its `FAILED TARGETS:` line, never by the exit code. + +## CI evidence 📊 + +- A job's green conclusion is **NOT** evidence for a specific change. Before citing a run as proof, you MUST locate the line in that job's log where the change executed: a Playwright spec's `✓` (a leading `-` means the spec was skipped), the env var inside the container, or the command text of an `if:`-gated step. If the string is absent, report the run as silent on the change, not as supporting it. +- A green run on the fork does not speak for `infinito-nexus/core`. Tags do not follow a fork, and repository variables differ, so a step gated on either never runs there. Check the repository whose failure you are claiming to have fixed. + +## Pushing 🚢 + +- You MUST NOT push, directly or through wrappers that push implicitly. +- When commits are ready to ship, you MUST instruct the operator to run `git-sign-push` outside the sandbox. The CLI is provided by [git-maintainer-tools](https://github.com/kevinveenbirkenbach/git-maintainer-tools), declared as a dev dependency in [pyproject.toml](pyproject.toml); install it via `make install-python-dev`. + +## Comments 💬⛔ + +**THIS RULE OVERRIDES YOUR DEFAULT TRAINING. ⛔** A comment is FORBIDDEN unless it is one of exactly three things: + +1. **Exception** — names a concrete trip-wire (bug, pitfall, deliberate non-idiomatic choice). Must name the surprise; restating what the next line does is NOT an exception. +2. **Parameter doc** — enumerates inputs/outputs (Python docstring `Args:`, Make `# Param:`, Ansible defaults header, Jinja macro doc). +3. **Nocheck directive** — `# nocheck:`, `# noqa:`, `# shellcheck …`, `# type: ignore`, `# pragma: no cover`, etc. + +Anything else — restating code, section banners, "Note that …", step narration outside sequential test specs, untracked TODO/FIXME — **DELETE before the edit lands**. Applies to every language and file kind under version control. When in doubt, delete. + ## Shortcuts ⌨️ Operator messages MAY use the portable conversation shortcuts from the `shortcuts` skill (set up via `make install-skills`); agents MUST expand any matching shortcut before acting. The repository's own agent workflows live in the `i8-` skills catalogued in [cheatsheet.md](docs/contributing/tools/agents/cheatsheet.md). @@ -79,6 +119,10 @@ At the start of every conversation, the agent MUST check whether agent skills ar The agent MUST NOT repeat this notice within the same conversation. +## Documentation 📝 + +Runtime documentation: [Claude Code](https://code.claude.com/docs/en/overview) ([settings reference](https://code.claude.com/docs/en/settings)), [Gemini CLI](https://geminicli.com/docs/cli/gemini-md/). + ## For Humans 👥 Human contributors working alongside AI agents MUST read [here](docs/contributing/tools/agents/common.md). diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c523b9e14..8fe470014a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,55 @@ # Changelog +## [14.1.0] - 2026-09-21 + +**For Users** + +* **Local models reach the gateway again.** Upstream re-pushed the *svc-ai-lmstudio* CPU + image with a server that listens on loopback only, so the role stayed green while litellm + could not connect and the AI features of Mattermost, Matrix, xWiki, Moodle and Zammad + failed their warm-up. The server binds the container network again and stays unpublished. + The model preload now waits until the daemon has finished starting, so a slow host no + longer ends up with a daemon that fails every later model load, and the readiness probe + is capped per attempt so a silent peer cannot hang it. See + [svc-ai-lmstudio](roles/svc-ai-lmstudio/README.md). + +**For Developers** + +* **CI deploys only the variants a change reaches.** An image bump in a provider no longer + redeploys the variants of its consumers that switch that provider off. The diff-derived + whitelist, used by the weekly update PRs, Dependabot and every other diff-driven run, + narrows each affected role to the variants whose round closure still reaches a changed + role, emitted as *role#0,2* selection tokens. A changed role and a role reached only + through *run_after* keep every variant. A pinned token naming a role that discovery does + not return now warns instead of aborting the run; role names are still checked against + *roles/* before the run starts. + +* **One instruction file for every agent.** *AGENTS.md* now holds every agent rule, and + *CLAUDE.md* and *GEMINI.md* are gone. The rules they carried bind every runtime anyway, + and the PR templates, scope tables, requirement documents and docs that named the old + files now name *AGENTS.md*. + +* Image and dependency version jumps (net since 14.0.0): + * *svc-ai-ollama*: 0.34.0 to 0.34.2 + * *svc-net-tor* (Debian base): 13.6-slim to 13.7-slim + * *web-app-baserow*: 2.3.3 to 2.3.4 + * *web-app-erpnext*: v16.34.2 to v16.35.0 + * *web-app-funkwhale* (front, api): 2.0.10 to 2.0.11 + * *web-app-jitsi* (web, prosody, jicofo, jvb): stable-9646 to stable-11031 + * *web-app-keycloak*: 26.7.3 to 26.7.4 + * *web-app-opentalk* (LiveKit): v1.13.6 to v1.13.7 + * *web-app-opentalk* (RabbitMQ): 4.3.5 to 4.3.6 + * *web-app-peertube*: v8.2.4 to v8.3.0 + * *web-app-pihole*: 2026.07.2 to 2026.09.0 + * *web-app-prometheus* (Alertmanager): v0.34.0 to v0.34.1 + * Ansible collection *hetzner.hcloud*: 7.0.1 to 7.1.0 + * *ruff* (dev): 0.16.6 to 0.16.7 + +**Contributors** + +* [Kevin Veen-Birkenbach](https://veen.world): LM Studio reachability and startup, + variant-narrowed CI selection, the single agent instruction file, and version maintenance + ## [14.0.0] - 2026-09-19 **For Users** @@ -143,6 +193,62 @@ dash. Documentation generators are gathered under *cli/build/docs*, and a new CLI edits role bonds in a matrix instead of hunting through files. +* Image and dependency version jumps (net since 13.0.0): + * *svc-ai-ollama*: 0.32.15 to 0.34.0 + * *svc-db-elasticsearch*: 9.5.2 to 9.5.3 + * *svc-db-qdrant*: v1.19.0 to v1.19.1 + * *sys-ctl-hlth-csp* (csp-checker): 2.2.1 to 3.0.4 + * *sys-lint* (shfmt): v3.13.1 to v3.14.1 + * *test-e2e-playwright*: v1.62.1-noble to v1.63.0-noble + * *web-app-bluesky* (view): 1.131.1 to 1.132.0 + * *web-app-bookwyrm*: v0.9.2 to v0.9.3 + * *web-app-confluence*: 10.2.15 to 10.2.18 + * *web-app-dashboard*: 2.0.0 to 2.1.3 + * *web-app-erpnext*: v16.32.3 to v16.34.2 + * *web-app-espocrm*: 10.0.6 to 10.0.8 + * *web-app-funkwhale*: 2.0.9 to 2.0.10 + * *web-app-gitea*: 1.27.2 to 1.27.3 + * *web-app-gitlab* (webservice, sidekiq, workhorse, gitaly, shell, rails): v19.3.0 to v19.3.2 + * *web-app-jira*: 11.3.10 to 11.3.11 + * *web-app-keycloak*: 26.7.2 to 26.7.3 + * *web-app-matrix* (Synapse): v1.159.0 to v1.160.0 + * *web-app-matrix* (Element): v1.12.26 to v1.12.28 + * *web-app-mattermost*: 11.10.1 to 11.11.0 + * *web-app-n8n*: 1.95.3 to 1.100.1 + * *web-app-nextcloud* (proxy): 1.31.3-alpine to 1.31.5-alpine + * *web-app-opentalk* (LiveKit): v1.13.5 to v1.13.6 + * *web-app-opentalk* (RabbitMQ): 4.3.4 to 4.3.5 + * *web-app-penpot* (frontend, backend, exporter): 2.17.1 to 2.17.2 + * *web-app-seaweedfs*: 4.44 to 4.46 + * *web-app-semaphore*: v2.19.8 to v2.19.14 + * *web-app-socialhome*: 2026.6.16 to 2026.9.18 + * *web-app-yourls*: 1.10.4-apache to 1.10.6-apache + * *web-app-zammad*: 6.5.0 to 7.1.2 + * *web-svc-coturn*: 4.17.2 to 4.18.0 + +* Moving tags that now carry a release, one per role: *web-app-discourse* master to + v2026.8.0, *web-app-jenkins* lts to 2.568.3-lts, *web-app-openwebui* main to 0.11.0, + *web-app-pretix* stable to 2026.7.0, *web-app-xwiki* lts-postgres-tomcat to + 17.10.13-postgres-tomcat, *web-app-pixelfed* latest to 20260917, *web-app-matrix* (upstream + playbook ref) master to a commit pin, *svc-db-memcached* alpine to 1.6.45-alpine, + *svc-db-redis* alpine to 8.10.1-alpine, *svc-prx-openresty* alpine to 1.31.1.1-alpine, + *svc-runner* (BuildKit) buildx-stable-1 to v0.33.0, *web-app-bigbluebutton* (dockerize) + latest to v0.15.1, and the nginx sidecars of *web-app-fediwall*, *web-app-littlejs*, + *web-app-taiga* and *web-svc-coturn* to 1.31.6-alpine. The Debian codename bases became numeric slim tags in + *svc-db-openldap* (12.15-slim), *svc-net-tor* (13.6-slim), *web-app-bookwyrm*, + *web-app-bridgy-fed*, *web-app-postmarks*, *web-app-roulette-wheel*, *web-svc-cdn* and + *web-svc-simpleicons*, and *web-app-flowise* is built from node 24-slim instead of pulled + (Flowise itself stays at 3.1.4). + +**Contributors** + +* [Kevin Veen-Birkenbach](https://veen.world): LLM gateway and model backends, the declared + MCP layer and its sidecar, agent employees and the kernel-isolated tier, Home Assistant, + credential declaration and rotation, firewall/tor/DNS ownership, variant-dictated provider + configuration, the fail-closed lints, CI selection and resume, swarm convergence, and + version maintenance +* [Prageeth Panicker](https://github.com/pragepani): .ansible cache directory ignored + ## [13.0.0] - 2026-08-26 * **Tor as a first-class deployment axis.** The new *svc-net-tor* role routes onion diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 8487cc9e7c..0000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,63 +0,0 @@ -# CLAUDE.md - -## Startup: MUST DO at the Start of Every Conversation 🚀 - -You MUST read `AGENTS.md` and follow all instructions in it at the start of every conversation before doing anything else. - -## Permission State Announcement at Session Start 📢 - -At the start of every new conversation (after reading `AGENTS.md`), you MUST read [.claude/settings.json](.claude/settings.json) and output a one-time summary: sandbox status with concrete `allowWrite`/`denyRead` paths, plus the counts of `permissions.allow`/`ask`/`deny`. Derive content from the live file; do not hardcode. Do not repeat unless the operator asks, and do not propose `/sandbox` when it is already active. - -## Interaction Rules 💬 - -- A question MUST NOT modify files, code, or state. Only explicit commands MAY. -- You MUST prefer commands permitted in [.claude/settings.json](.claude/settings.json) over commands that require interactive approval when an equivalent exists. - -## Code Execution ⚙️ - -- You MUST prefer `make` targets over raw `docker`/`docker compose`/`ansible-playbook`/`python`/shell invocations whenever an equivalent target exists in the [`Makefile`](Makefile). Inspect the `Makefile` first; fall back to the raw command only when no target covers the operation. The reason is operational consistency, not permissioning. Raw commands also auto-allow under the sandbox. -- **`docker exec` is FORBIDDEN. ⛔** You MUST NEVER invoke `docker exec` (nor nested `docker exec … docker exec …` into the DiD stack) directly. Always reach the live stack through `make` targets (e.g. `make compose-exec`, or the role-specific targets the `Makefile` exposes). If no `make` target covers what you need, ask the operator instead of falling back to raw `docker exec`. -- You SHOULD run sandbox-confined commands directly on the host. The sandbox bounds what they can read, write, and reach. See [sandbox.md](docs/contributing/tools/agents/claude/sandbox.md). -- For commands that legitimately cannot run inside the sandbox (e.g. operations needing access to `~/.ssh` or `~/.gnupg`), use `make compose-up` to start the stack and `make compose-exec` to drop into a container shell. The repository is mounted at `/opt/src/infinito` (see [compose.yml](compose.yml)), so code changes are immediately available there. -- Commands listed under `permissions.ask` in [.claude/settings.json](.claude/settings.json) still pause for explicit operator confirmation regardless of sandbox state. -- **Shell loops are FORBIDDEN. ⛔** You MUST NOT use `for`, `while`, `until`, or any other shell loop construct in any Bash tool call. Reason: shell control structures fall outside the sandbox auto-allow heuristic and trigger approval prompts even when every subcommand would individually auto-allow. -- **Multi-statement chains in shell invocations are FORBIDDEN. ⛔** You MUST NOT chain independent statements inside a single Bash tool call with **any** statement separator (`;`, literal newline, `&&`, `||`, `&` background operator, or subshell/brace groups around the same). The ban covers causally-dependent chains (`cd X && cmd`) just as much as optional ones, and applies to trailing `&` used to background a command (use the Bash tool's `run_in_background: true` parameter instead). Reason: identical to the loop rule. Split the work across **separate Bash tool calls** or use a single-command equivalent (`xargs`, `grep` with multiple args, a make target). -- **File creation via shell heredoc is FORBIDDEN. ⛔** You MUST NOT use `cat > file < file < file`, `echo "…" > file` for multi-line content) to create or overwrite files. Use the **Write tool**. For editing an existing file, use **Edit**, not `sed -i`/`awk -i`. Reason: Write/Edit land structured in the transcript and diff; heredoc + redirect shapes also fall out of the auto-allow heuristic and drop into ask. -- **For searching file contents, use the Grep tool.** If shelling out is unavoidable, use a single `grep` invocation with multiple file arguments (e.g. `grep -nE 'pattern' file1 file2 file3`) or a recursive call with a path/glob (e.g. `grep -rnE 'pattern' path/`). -- **When a long-running command streams its output to a `/tmp/.log` file** (e.g. background `make compose-deploy`, `make act-*`, or any `… 2>&1 | tee /tmp/.log`), you MUST tell the operator the concrete `tail -f /tmp/.log` command they can run in another terminal to follow the log live. Include the full path literally so it is copy-pasteable. - -## Comments 💬⛔ - -**THIS RULE OVERRIDES YOUR DEFAULT TRAINING. ⛔** A comment is FORBIDDEN unless it is one of exactly three things: - -1. **Exception** — names a concrete trip-wire (bug, pitfall, deliberate non-idiomatic choice). Must name the surprise; restating what the next line does is NOT an exception. -2. **Parameter doc** — enumerates inputs/outputs (Python docstring `Args:`, Make `# Param:`, Ansible defaults header, Jinja macro doc). -3. **Nocheck directive** — `# nocheck:`, `# noqa:`, `# shellcheck …`, `# type: ignore`, `# pragma: no cover`, etc. - -Anything else — restating code, section banners, "Note that …", step narration outside sequential test specs, untracked TODO/FIXME — **DELETE before the edit lands**. Applies to every language and file kind under version control. When in doubt, delete. - -## Command output logging 📜 - -- For ANY non-trivial command (test runs, deploys, long pipelines), you MUST stream the FULL output to a file under `/tmp/` via `… 2>&1 | tee /tmp/.log` and grep / inspect that file repeatedly instead of re-running the command. Reason: re-running `make test` to "find the failure I just lost" costs 2 minutes per cycle; grepping the saved log costs milliseconds. -- Default the filename to a meaningful slug + monotonically increasing index (`/tmp/make-test--.log`, `/tmp/act--.log`) so you can compare runs. -- Tell the operator the exact `tail -f /tmp/.log` command for background runs, per the existing rule. -- That pipe **destroys the exit status**: `make test | tee` reports `tee`'s success even when make ends with `Error 2`. You MUST judge such a run by its `📊 per-target wall-clock` table and its `FAILED TARGETS:` line, never by the exit code. - -## CI evidence 📊 - -- A job's green conclusion is **NOT** evidence for a specific change. Before citing a run as proof, you MUST locate the line in that job's log where the change executed: a Playwright spec's `✓` (a leading `-` means the spec was skipped), the env var inside the container, or the command text of an `if:`-gated step. If the string is absent, report the run as silent on the change, not as supporting it. -- A green run on the fork does not speak for `infinito-nexus/core`. Tags do not follow a fork, and repository variables differ, so a step gated on either never runs there. Check the repository whose failure you are claiming to have fixed. - -## Pushing 🚢 - -- You MUST NOT push, directly or through wrappers that push implicitly. -- When commits are ready to ship, you MUST instruct the operator to run `git-sign-push` outside the sandbox. The CLI is provided by [git-maintainer-tools](https://github.com/kevinveenbirkenbach/git-maintainer-tools), declared as a dev dependency in [pyproject.toml](pyproject.toml); install it via `make install-python-dev`. - -## Configuration 🛠️ - -- Project-level permissions and sandbox rules are defined in [.claude/settings.json](.claude/settings.json). -- See [code.claude.com](https://code.claude.com/docs/en/settings) for documentation on how to modify it. - -## Documentation 📝 - -See the [Claude Code documentation](https://code.claude.com/docs/en/overview) for further information. For human contributor guidance on working with agents, see [here](docs/contributing/tools/agents/common.md). diff --git a/GEMINI.md b/GEMINI.md deleted file mode 100644 index 0b42f87f5a..0000000000 --- a/GEMINI.md +++ /dev/null @@ -1,13 +0,0 @@ -# GEMINI.md - -## Purpose - -This file extends [AGENTS.md](AGENTS.md) with Gemini-specific additions. You MUST read `AGENTS.md` first as the entry point for all agent instructions. - -## Current Status - -- No Gemini-specific additions are currently defined. - -## Documentation - -See the [Gemini CLI documentation](https://geminicli.com/docs/cli/gemini-md/). For human contributor guidance on working with agents, see [here](docs/contributing/tools/agents/common.md). diff --git a/cli/administration/deploy/development/inventory/legacy_resolver.py b/cli/administration/deploy/development/inventory/legacy_resolver.py index 5b70ba0698..0ea121f90c 100644 --- a/cli/administration/deploy/development/inventory/legacy_resolver.py +++ b/cli/administration/deploy/development/inventory/legacy_resolver.py @@ -6,96 +6,22 @@ to this path — the `CombinedResolver` walks `dependencies` and evaluated at deploy time against `group_names`. `run_after` is NOT followed for inclusion (it is a pure ordering hint), so a variant that disables a service does not get the provider re-added through the -ordering edge. This module owns the two helpers that path needs and -nothing else; the variant-only path lives in `.variants`. +ordering edge. This module owns the include resolution that path needs +and nothing else; the round's variant-merged services maps come from +`utils.roles.applications.variants`, which the CI selection resolves its +closure from as well. """ from __future__ import annotations -from collections.abc import Iterable, Mapping, Sequence -from pathlib import Path +from typing import TYPE_CHECKING -from utils.cache.applications import get_variants -from utils.cache.base import _deep_merge -from utils.cache.yaml import load_yaml_any -from utils.roles.mapping import ROLE_FILE_META_SERVICES +from utils.roles.applications.variants import services_overrides_for_round -from .nested_overrides import apply_topic, collect_provider_overrides +if TYPE_CHECKING: + from collections.abc import Iterable, Sequence - -def _build_services_overrides_for_round( - *, - roles_dir: str, - round_index: int, - primary_app_variants: Mapping[str, int], -) -> dict[str, dict]: - """For every role with `meta/variants.yml`, return the services map - that results from merging the round's variant payload onto the - role's on-disk `meta/services.yml`. - - Apps in `primary_app_variants` use the supplied (already clamped) - index. Other roles with their own variants clamp `round_index` to - their own variant count. Roles without variants are absent from the - result so the resolver falls through to its disk-read path. - - The merged map is what the inventory ALSO bakes into host_vars, so - feeding the same dict into `CombinedResolver(services_overrides=...)` - eliminates the topology-vs-host_vars drift that variant-blind - resolution produced. - """ - variants_per_app = get_variants(roles_dir=roles_dir) - overrides: dict[str, dict] = {} - roles_path = Path(roles_dir) - for role_name, variant_list in variants_per_app.items(): - if not variant_list: - continue - variant_count = max(1, len(variant_list)) - if role_name in primary_app_variants: - idx = primary_app_variants[role_name] - else: - idx = round_index if round_index < variant_count else 0 - if not 0 <= idx < len(variant_list): - idx = 0 - variant_payload = variant_list[idx] if variant_list else {} - if not isinstance(variant_payload, Mapping): - variant_payload = {} - variant_services = variant_payload.get("services", {}) - if not isinstance(variant_services, Mapping): - continue - services_path = roles_path / role_name / ROLE_FILE_META_SERVICES - if not services_path.exists(): - continue - try: - base_services = load_yaml_any(services_path) or {} - except Exception: # noqa: S112 best-effort iteration over role files; skip malformed input - continue - if not isinstance(base_services, Mapping): - continue - merged = _deep_merge(dict(base_services), dict(variant_services)) - if isinstance(merged, dict): - overrides[role_name] = merged - _apply_nested_service_maps(overrides, roles_dir=roles_dir) - return overrides - - -def _apply_nested_service_maps(overrides: dict[str, dict], *, roles_dir: str) -> None: - """Replace a pulled-in provider's services map with what the round demands. - - Only the ``services`` topic reaches this path: the closure walks service - edges, so the other config topics a variant may override are the inventory - bake's business. - - Args: - overrides: ``{role: services map}``, mutated in place. - roles_dir: roles directory the service registry is built from. - """ - payloads = {role: {"services": services} for role, services in overrides.items()} - for provider, topics in collect_provider_overrides( - payloads, roles_dir=roles_dir - ).items(): - if "services" not in topics: - continue - overrides[provider] = apply_topic(overrides.get(provider), topics["services"]) +_build_services_overrides_for_round = services_overrides_for_round def _resolve_round_include( diff --git a/cli/administration/deploy/development/inventory/nested_overrides.py b/cli/administration/deploy/development/inventory/nested_overrides.py deleted file mode 100644 index b17a362b13..0000000000 --- a/cli/administration/deploy/development/inventory/nested_overrides.py +++ /dev/null @@ -1,90 +0,0 @@ -"""Collect the provider config a round's variants dictate. - -The topic vocabulary and merge semantics live in -``utils.roles.applications.topics``; this module resolves which role demands -what, and refuses two roles demanding different things for one provider. - -Only a config topic counts, and only on an entry naming another role's -service. A role's own entity entry is skipped, which is what keeps the two -existing `services..users` / `services..domains` declarations from -being read as overrides. -""" - -from __future__ import annotations - -from collections.abc import Mapping -from pathlib import Path -from typing import Any - -from utils.roles.applications.services.registry import ( - build_service_registry_from_roles_dir, -) -from utils.roles.applications.topics import CONFIG_TOPICS, apply_topic, provider_of - -__all__ = ["CONFIG_TOPICS", "NestedOverrideConflictError", "apply_topic"] - - -class NestedOverrideConflictError(RuntimeError): - """Two roles in one round demand different config for one provider.""" - - -def _claims(payloads: Mapping[str, Any]) -> list[tuple[str, str, str, Any]]: - """Return the ``(role, service_key, topic, value)`` a round's payloads carry. - - Args: - payloads: ``{role: variant payload}`` for one round. - - Reading this before the service registry keeps a round whose variants - override nothing from paying for the registry at all. - """ - claims: list[tuple[str, str, str, Any]] = [] - for role_name, payload in payloads.items(): - if not isinstance(payload, Mapping): - continue - services = payload.get("services") - if not isinstance(services, Mapping): - continue - for service_key, entry in services.items(): - if not isinstance(entry, Mapping): - continue - claims.extend( - (role_name, service_key, topic, entry[topic]) - for topic in sorted(CONFIG_TOPICS & set(entry)) - ) - return claims - - -def collect_provider_overrides( - payloads: Mapping[str, Any], *, roles_dir: str -) -> dict[str, dict[str, Any]]: - """Return ``{provider: {topic: value}}`` demanded by the round's payloads. - - Args: - payloads: ``{role: variant payload}`` for one round. - roles_dir: roles directory the service registry is built from. - - Raises: - NestedOverrideConflictError: two roles demand different values for the - same topic of the same provider. - """ - claims = _claims(payloads) - if not claims: - return {} - - registry = build_service_registry_from_roles_dir(Path(roles_dir)) - demanded: dict[str, dict[str, Any]] = {} - claimed_by: dict[tuple[str, str], str] = {} - for role_name, service_key, topic, value in claims: - provider = provider_of(service_key, registry) - if not provider or provider == role_name: - continue - previous = claimed_by.get((provider, topic)) - if previous and demanded[provider][topic] != value: - raise NestedOverrideConflictError( - f"{role_name} and {previous} demand different " - f"{topic!r} for {provider!r} in the same round; a " - f"round deploys it once, so the two cannot both hold" - ) - demanded.setdefault(provider, {})[topic] = value - claimed_by[(provider, topic)] = role_name - return demanded diff --git a/cli/administration/deploy/development/inventory/payload.py b/cli/administration/deploy/development/inventory/payload.py index 6421739441..ce9b6a4561 100644 --- a/cli/administration/deploy/development/inventory/payload.py +++ b/cli/administration/deploy/development/inventory/payload.py @@ -14,8 +14,8 @@ from collections.abc import Mapping, Sequence from typing import Any from utils.cache.applications import get_variant_overrides_only - -from .nested_overrides import apply_topic, collect_provider_overrides +from utils.roles.applications.topics import apply_topic +from utils.roles.applications.variants import collect_provider_overrides def _resolve_variant_payloads( diff --git a/cli/meta/ci/validate.py b/cli/meta/ci/validate.py index 97708c884d..abc3943f76 100644 --- a/cli/meta/ci/validate.py +++ b/cli/meta/ci/validate.py @@ -15,16 +15,18 @@ here instead, and the exit code gates the run. What makes a token bad, in the order this checks it: * it does not parse, or names a mode or onion state that does not exist; -* it names a role the discovery query does not return -- a typo, a role - outside the run's lifecycle envelope, or a role that no longer exists; * it pins a variant the role does not declare (any more): the usual case is a list carried over from an older run whose variants have since been renumbered; * it pins a mode the row cannot take, an onion state the row, the mode or the run's own tor axis rules out, or a distro or filesystem the run's own pool does not hold. -A bare role name that matches nothing is reported too, but as a warning: the -diff-derived whitelist legitimately names roles the envelope filters out. +A token naming a role the discovery query does not return at all is reported +too, but as a warning, whether or not it pins axes: the diff-derived whitelist +legitimately names roles the envelope filters out, and it pins the variants a +change reaches. Role names themselves are checked against `roles/` before the +run starts (scripts/github/resolve/effective_whitelist.sh), so a typo is caught +there rather than swallowed here. """ from __future__ import annotations @@ -85,12 +87,13 @@ def problems( warnings: list[str] = [] for pin in pins: token = selection.describe(pin) + if pin.app not in discovered_apps: + warnings.append( + f"{label}: {token!r} matches no discovered row " + f"(no row in this run's mode and lifecycle envelope)" + ) + continue if not pin.pinned: - if pin.app not in discovered_apps: - warnings.append( - f"{label}: {token!r} matches no discovered row " - f"(no row in this run's mode and lifecycle envelope)" - ) continue variants = pin.variants or (None,) for variant in variants: diff --git a/cli/meta/roles/applications/resolution/affected/__main__.py b/cli/meta/roles/applications/resolution/affected/__main__.py index 7a600e0056..b834fd2eb4 100755 --- a/cli/meta/roles/applications/resolution/affected/__main__.py +++ b/cli/meta/roles/applications/resolution/affected/__main__.py @@ -10,8 +10,13 @@ Usage: python -m cli.meta.roles.applications.resolution.affected --changed-roles ROLE [ROLE ...] Output: - Whitespace-separated, sorted list of affected role names (single line), - including the seed roles themselves. + Whitespace-separated, sorted list of selection tokens (single line), + including the seed roles themselves. A role whose variants do not all + reach a seed is narrowed to the ones that do (``role#0,2``, + :mod:`utils.github.variant.selection`): a variant that switches its + provider off does not inherit the seed's change, so deploying it verifies + nothing. The narrowing is transitive over the whole chain, because each + round's closure is walked on that round's variant-merged services maps. Exit codes: 0 Success. The closure was computed and printed. @@ -38,9 +43,13 @@ from cli.meta.roles.applications.resolution.combined.role_introspection import ( has_application_id, load_run_after, ) +from utils.cache.applications import get_variants +from utils.roles.applications.variants import services_overrides_for_round +from utils.roles.display import VARIANT_SEPARATOR if TYPE_CHECKING: - from collections.abc import Iterable + from collections.abc import Iterable, Sequence + from pathlib import Path EXIT_NON_MODELLABLE_SEED = 2 @@ -122,12 +131,85 @@ def affected_roles(changed: Iterable[str]) -> list[str]: return sorted(affected) +def _round_resolvers(roles_path: Path, rounds: int) -> list[CombinedResolver]: + """One resolver per deploy round, each walking that round's + variant-merged services maps. + + The maps are built by the same helper + (:func:`utils.roles.applications.variants.services_overrides_for_round`) + the matrix planner feeds its rounds from, so the topology this reads is + the topology round ``i`` deploys -- including every pulled-in role's own + variant, which is what carries the narrowing across generations. + ``run_after`` is not followed, for the reason the planner does not follow + it either: an ordering hint would re-add a provider the variant switched + off. + """ + return [ + CombinedResolver( + services_overrides=services_overrides_for_round( + roles_dir=str(roles_path), + round_index=index, + primary_app_variants={}, + ), + follow_run_after=False, + ) + for index in range(rounds) + ] + + +def _pinned( + role: str, seeds: set[str], resolvers: Sequence[CombinedResolver], count: int +) -> str: + """*role*, narrowed to the variants whose own closure reaches a seed. + + Returns the bare role id whenever the narrowing cannot be trusted: no + variant reaching a seed means the role is affected through an edge the + round closure does not model (a ``run_after`` hint, or a resolution the + variant merge refused), and verifying none of it is worse than verifying + all of it. + """ + try: + hits = [ + index + for index in range(count) + if seeds.intersection(resolvers[index].resolve(role)) + ] + except CombinedResolutionError: + return role + if not hits or len(hits) == count: + return role + return role + VARIANT_SEPARATOR + ",".join(str(index) for index in hits) + + +def affected_selection(changed: Iterable[str]) -> list[str]: + """:func:`affected_roles` as selection tokens, variant-narrowed. + + A seed role keeps every variant: its own files changed, so each of them + has to redeploy regardless of which providers it pulls. + """ + seeds: set[str] = {r.strip() for r in changed if r and r.strip()} + affected = affected_roles(changed) + variants = get_variants(roles_dir=str(roles_dir())) + counts = {role: len(variants.get(role) or ()) for role in affected} + rounds = max(counts.values(), default=0) + if rounds < 2: + return affected + resolvers = _round_resolvers(roles_dir(), rounds) + return [ + role + if role in seeds or counts[role] < 2 + else _pinned(role, seeds, resolvers, counts[role]) + for role in affected + ] + + def main() -> None: parser = argparse.ArgumentParser( description=( "Print all roles whose transitive prerequisite closure " "(run_after + dependencies + services) contains any of the " - "given seed roles. Seed roles themselves are included." + "given seed roles, each narrowed to the variants that reach one. " + "Seed roles themselves are included, with every variant." ) ) parser.add_argument( @@ -137,7 +219,7 @@ def main() -> None: help="Seed role names (folder names under ./roles).", ) args = parser.parse_args() - print(" ".join(affected_roles(args.changed_roles))) + print(" ".join(affected_selection(args.changed_roles))) if __name__ == "__main__": diff --git a/docs/contributing/artefact/git/branch.md b/docs/contributing/artefact/git/branch.md index b7933d5111..020cded368 100644 --- a/docs/contributing/artefact/git/branch.md +++ b/docs/contributing/artefact/git/branch.md @@ -6,7 +6,7 @@ The branch prefix MUST match the type of change. The [PR workflow](pull-request. | Branch prefix | Scope | Matching files | CI behavior | |---|---|---|---| -| `agent` | Changes to agent instructions or prompts | `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `docs/agents/*` | Skips [orchestrator](../../../../.github/workflows/call-orchestrator.yml), finishes green through the lightweight scope gate. | +| `agent` | Changes to agent instructions or prompts | `AGENTS.md`, `roles//AGENTS.md`, `docs/agents/*` | Skips [orchestrator](../../../../.github/workflows/call-orchestrator.yml), finishes green through the lightweight scope gate. | | `documentation` | Documentation-only changes | `**/*.md`, `**/*.rst` (outside agent paths) | Skips [orchestrator](../../../../.github/workflows/call-orchestrator.yml), finishes green through the lightweight scope gate. | | `feature` | New features or enhancements | `*` | Runs the full [orchestrator](../../../../.github/workflows/call-orchestrator.yml) pipeline. | | `fix` | Bug fixes | `*` | Runs the full [orchestrator](../../../../.github/workflows/call-orchestrator.yml) pipeline. | diff --git a/docs/contributing/artefact/git/pipeline.md b/docs/contributing/artefact/git/pipeline.md index e5d8a4f3d2..3cb37ddba5 100644 --- a/docs/contributing/artefact/git/pipeline.md +++ b/docs/contributing/artefact/git/pipeline.md @@ -80,7 +80,9 @@ The two deploy-test workflows listed in the `Infrastructure tests` table of [wor - **No diff at all** OR **any changed path outside `roles//...`**: no whitelist is set, so the full deploy across the workflow's scope runs. - **All changed paths under `roles//...`**: the changed roles become the seed set, and the whitelist is the transitive closure of those seeds expanded upwards over `run_after`, `dependencies`, and shared services. In other words, every role whose prerequisite set as defined by [combined resolver](../../../../cli/meta/roles/applications/resolution/combined/resolver.py) contains one of the seeds is included, together with the seeds themselves. -The reverse closure is fail-safe: any seed that is not modellable in the resolver (no `application_id` and not referenced by any role's `run_after`) MUST trigger a fall-back to a full deploy, as MUST any resolver runtime error. The closure MUST NOT silently shrink the deploy matrix on partial information. +Each role in that closure is then narrowed to the variants that actually reach a seed: variant `i` of a role is kept only when round `i`'s closure — walked on the same variant-merged services maps [the matrix planner](../../../../cli/administration/deploy/development/inventory/planner.py) builds its rounds from, and therefore variant-aware at every generation of the chain — contains one of the seeds. A role whose variants do not all qualify enters the whitelist as a `role#0,2` selection token, so an image bump in a provider no longer redeploys the variants that switch that provider off. This applies to every auto-derived whitelist — the weekly update PRs, Dependabot, and any other diff-driven run — because they all resolve through this one path. + +The reverse closure is fail-safe: any seed that is not modellable in the resolver (no `application_id` and not referenced by any role's `run_after`) MUST trigger a fall-back to a full deploy, as MUST any resolver runtime error. The closure MUST NOT silently shrink the deploy matrix on partial information. The variant narrowing follows the same rule: a role reached only through a `run_after` edge (which the round closure does not follow) keeps every variant, and so does a seed role itself, whose own files changed. The PR-scope short-circuits in [scope.sh](../../../../scripts/meta/resolve/pr/scope.sh) (documentation-only, agent-only) still apply at the entry layer. They skip the orchestrator entirely and are independent of the diff-driven whitelist resolution above. diff --git a/docs/contributing/artefact/git/pull-request.md b/docs/contributing/artefact/git/pull-request.md index 9b3d37233e..a848bcbf55 100644 --- a/docs/contributing/artefact/git/pull-request.md +++ b/docs/contributing/artefact/git/pull-request.md @@ -10,8 +10,8 @@ You MUST pick the template that matches your change. The table below links the a | Workstation and `desk-*` changes | [workstation.md](../../../../.github/PULL_REQUEST_TEMPLATE/workstation.md) | | Shared system changes such as `sys-*`, `svc-*`, `dev-*`, `drv-*`, `pkgmgr`, `update-*`, or `user-*` | [system.md](../../../../.github/PULL_REQUEST_TEMPLATE/system.md) | | CI/CD and workflow changes | [pipeline.md](../../../../.github/PULL_REQUEST_TEMPLATE/pipeline.md) | -| Documentation-only changes limited to `.md` or `.rst` files outside `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, and `docs/agents/*` | [documentation.md](../../../../.github/PULL_REQUEST_TEMPLATE/documentation.md) | -| Agent-specific changes limited to `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, or `docs/agents/*` | [agents.md](../../../../.github/PULL_REQUEST_TEMPLATE/agents.md) | +| Documentation-only changes limited to `.md` or `.rst` files outside `AGENTS.md` and `docs/agents/*` | [documentation.md](../../../../.github/PULL_REQUEST_TEMPLATE/documentation.md) | +| Agent-specific changes limited to `AGENTS.md` or `docs/agents/*` | [agents.md](../../../../.github/PULL_REQUEST_TEMPLATE/agents.md) | ## Branch Naming 🏷️ diff --git a/docs/contributing/tools/agents/claude/security.md b/docs/contributing/tools/agents/claude/security.md index ddbe8cfa55..f099cdb17c 100644 --- a/docs/contributing/tools/agents/claude/security.md +++ b/docs/contributing/tools/agents/claude/security.md @@ -72,7 +72,7 @@ The `Bash(*)` allow lets the agent run any Makefile target without prompting. Th ## Assumption 8: Shell control-flow loops are never necessary 🔁 -[CLAUDE.md](../../../../../CLAUDE.md) forbids `for` / `while` / `until` loops in Bash invocations, and `Bash(for *)` / `Bash(while *)` / `Bash(until *)` are in `deny` to enforce the rule. Every task has a flat-form equivalent: a single `grep` with multiple file arguments, `xargs`, a recursive glob, or a dedicated tool. +[AGENTS.md](../../../../../AGENTS.md) forbids `for` / `while` / `until` loops in Bash invocations, and `Bash(for *)` / `Bash(while *)` / `Bash(until *)` are in `deny` to enforce the rule. Every task has a flat-form equivalent: a single `grep` with multiple file arguments, `xargs`, a recursive glob, or a dedicated tool. **Why this matters:** Loops can hide destructive operations (for example `for f in $(ls); do rm "$f"; done`) behind a single approval step. The deny rule converts a rule violation into a hard failure, so the agent receives concrete feedback and refactors to the flat form. diff --git a/docs/contributing/tools/agents/claude/settings.md b/docs/contributing/tools/agents/claude/settings.md index 9b3668d16b..3faedd79fb 100644 --- a/docs/contributing/tools/agents/claude/settings.md +++ b/docs/contributing/tools/agents/claude/settings.md @@ -97,7 +97,7 @@ These operations are unconditionally blocked, regardless of any `allow` entry or | Permission | Reason | |---|---| -| `for *` / `while *` / `until *` | Shell control-flow loops (`for f in ...; do ...; done`, `while read ...`, `until cond; do ...`). See Assumption 8 in [security.md](security.md) for why loops are banned at the policy layer rather than in the textual [CLAUDE.md](../../../../../CLAUDE.md) rule alone. The sandbox auto-allow heuristic does not recognise loop keywords, so this deny has no cost versus any alternative (allow would also require explicit entries; ask would deadlock). | +| `for *` / `while *` / `until *` | Shell control-flow loops (`for f in ...; do ...; done`, `while read ...`, `until cond; do ...`). See Assumption 8 in [security.md](security.md) for why loops are banned at the policy layer rather than in the textual [AGENTS.md](../../../../../AGENTS.md) rule alone. The sandbox auto-allow heuristic does not recognise loop keywords, so this deny has no cost versus any alternative (allow would also require explicit entries; ask would deadlock). | | `gh api * -X DELETE *` / `gh api * --method DELETE *` | DELETE is irreversible from the API surface: deleting a release, branch ref, deploy key, or webhook destroys data with no undo. Both `-X` and `--method` spellings are blocked so neither shorthand slips through. | | `gh api * -X PUT *` / `gh api * --method PUT *` | PUT replaces a resource wholesale. On endpoints like branch protection or rulesets, a PUT silently overwrites the entire policy with whatever payload is sent; partial JSON drops every unspecified field. PATCH (the merge variant) still goes through `ask`. | | `gh api * /actions/secrets*:*` | Touches GitHub Actions secrets: reading metadata, creating, updating, or deleting. Even GETs leak secret names; mutations rotate credentials CI depends on. Out-of-band secret management only. | diff --git a/docs/contributing/tools/agents/common.md b/docs/contributing/tools/agents/common.md index 9144b9517e..9804b77522 100644 --- a/docs/contributing/tools/agents/common.md +++ b/docs/contributing/tools/agents/common.md @@ -2,14 +2,13 @@ AI assistants are welcome, but they MUST follow the same workflow as humans. -- You MUST treat [AGENTS.md](../../../../AGENTS.md) as the entry point for all agent-specific execution instructions. Tool-specific files such as `CLAUDE.md` and `GEMINI.md` extend `AGENTS.md` and MUST NOT contradict it. +- You MUST treat [AGENTS.md](../../../../AGENTS.md) as the single, runtime-agnostic source of agent-specific execution instructions. There are no tool-specific extension files. - You MUST NOT invent commands, workflows, or files that do not exist. - You MUST NEVER expose secrets in prompts, code, screenshots, or logs. - You MUST treat AI output as a draft that must be reviewed for wrong assumptions, duplicate logic, and security mistakes. - You MUST keep explanations simple and explicit. - You MUST state assumptions clearly. -For tool-specific configuration and additional instructions, see [CLAUDE.md](../../../../CLAUDE.md) and [GEMINI.md](../../../../GEMINI.md). For a full reference of permitted Claude Code operations and their security rationale, see [claude/](claude/README.md). For further support, visit the AI forum at [s.infinito.nexus/aihub](https://s.infinito.nexus/aihub) or join the Matrix group #ai:infinito.nexus. diff --git a/docs/requirements/014-svc-runner-ci.md b/docs/requirements/014-svc-runner-ci.md index 8791fa1106..8ad7faeec0 100644 --- a/docs/requirements/014-svc-runner-ci.md +++ b/docs/requirements/014-svc-runner-ci.md @@ -44,4 +44,4 @@ The implementation of this requirement MUST be executed autonomously by the agen - [x] **Iteration loop.** The agent MUST follow the [Workflow Loop](../agents/action/iteration/workflow.md) for every change to GitHub Actions workflows the implementation touches, and the [Compose Loop](../agents/action/iteration/compose.md) for every change inside `roles/svc-runner/`. The agent MUST NOT skip the loop's debug-locally step in favour of remote CI reruns. - [x] **No `ask` prompts mid-run.** The agent MUST NOT trigger any tool call that routes through `permissions.ask` in [.claude/settings.json](../../.claude/settings.json) during implementation. Where a tool would otherwise route through `ask`, the agent MUST select an equivalent already covered by `permissions.allow`, or rephrase the operation to fit the sandbox. The single permitted exception is the final commit at the end of the run. - [x] **No interruptions.** Bug fixes, deploy failures, lint failures, `make test` failures, healthcheck flaps, and similar issues MUST be resolved at their root inside this same iteration without prompting the operator. Workarounds, ad-hoc skips, retry-until-green loops, or "track in a follow-up" deferrals MUST NOT be used. -- [x] **One commit at the end.** The agent MUST NOT create any intermediate commit. ALL changes (role, CLI, tests, documentation, and the ticked checkboxes in this document) MUST be combined into ONE commit, created only after every Acceptance Criterion above is checked off (`- [x]`) and `make test` is green. Per-step commits, checkpoint commits, and partial commits MUST NOT be created. The agent MUST NOT push; the operator runs `git-sign-push` outside the sandbox per [CLAUDE.md](../../CLAUDE.md). +- [x] **One commit at the end.** The agent MUST NOT create any intermediate commit. ALL changes (role, CLI, tests, documentation, and the ticked checkboxes in this document) MUST be combined into ONE commit, created only after every Acceptance Criterion above is checked off (`- [x]`) and `make test` is green. Per-step commits, checkpoint commits, and partial commits MUST NOT be created. The agent MUST NOT push; the operator runs `git-sign-push` outside the sandbox per [AGENTS.md](../../AGENTS.md). diff --git a/docs/requirements/023-docker-swarm-nfs.md b/docs/requirements/023-docker-swarm-nfs.md index 8403680527..3cb0989d1e 100644 --- a/docs/requirements/023-docker-swarm-nfs.md +++ b/docs/requirements/023-docker-swarm-nfs.md @@ -202,7 +202,7 @@ The implementation of this requirement MUST be executed autonomously by the agen - [ ] **Iteration loop.** The agent MUST follow the [Compose Loop](../agents/action/iteration/compose.md) for every change inside `roles/svc-swarm-node/`, `roles/svc-prx-openresty/` (swarm-mode adaptations), `roles/svc-storage-nfs-server/`, `roles/svc-storage-nfs-client/`, and `roles/web-app-mediawiki/` (pilot). The agent MUST follow the [Workflow Loop](../agents/action/iteration/workflow.md) for every change to `.github/workflows/test-deploy-swarm-nfs.yml`. The agent MUST NOT skip the loop's debug-locally step in favour of remote CI reruns. - [ ] **No `ask` prompts mid-run.** The agent MUST NOT trigger any tool call that routes through `permissions.ask` in [.claude/settings.json](../../.claude/settings.json) during implementation. Where a tool would otherwise route through `ask`, the agent MUST select an equivalent already covered by `permissions.allow`, or rephrase the operation to fit the sandbox. The single permitted exception is the final commit at the end of the run. - [ ] **No interruptions.** Bug fixes, deploy failures, lint failures, `make test` failures, healthcheck flaps, swarm-init flakes, NFS mount races, workflow reruns until green — every issue MUST be resolved at its root inside this same iteration without prompting the operator. Workarounds, ad-hoc skips, retry-until-green loops, or "track in a follow-up" deferrals MUST NOT be used. -- [ ] **One commit at the end.** The agent MUST NOT create any intermediate commit. ALL changes (the three new roles, the openresty swarm-mode adaptations, the pilot role updates, the CI workflow, schema entries, group_vars defaults, documentation, and the ticked checkboxes in this document) MUST be combined into ONE commit, created only after every Acceptance Criterion above is checked off (`- [x]`), `make test` is green, and `.github/workflows/test-deploy-swarm-nfs.yml` is green on its first scheduled run. Per-step commits, checkpoint commits, and partial commits MUST NOT be created. The agent MUST NOT push; the operator runs `git-sign-push` outside the sandbox per [CLAUDE.md](../../CLAUDE.md). +- [ ] **One commit at the end.** The agent MUST NOT create any intermediate commit. ALL changes (the three new roles, the openresty swarm-mode adaptations, the pilot role updates, the CI workflow, schema entries, group_vars defaults, documentation, and the ticked checkboxes in this document) MUST be combined into ONE commit, created only after every Acceptance Criterion above is checked off (`- [x]`), `make test` is green, and `.github/workflows/test-deploy-swarm-nfs.yml` is green on its first scheduled run. Per-step commits, checkpoint commits, and partial commits MUST NOT be created. The agent MUST NOT push; the operator runs `git-sign-push` outside the sandbox per [AGENTS.md](../../AGENTS.md). ## See Also diff --git a/docs/requirements/023-setup-penpot.md b/docs/requirements/023-setup-penpot.md index b708d6c124..cca1c9cfd5 100644 --- a/docs/requirements/023-setup-penpot.md +++ b/docs/requirements/023-setup-penpot.md @@ -90,7 +90,7 @@ The implementation of this requirement MUST be executed autonomously by the agen - [x] **Iteration loops.** The agent MUST follow the [Compose Loop](../agents/action/iteration/compose.md) for every change inside `roles/web-app-penpot/`, and the [Playwright Loop](../agents/action/iteration/playwright.md) for every change to the role's Playwright spec. The debug-locally step MUST NOT be skipped in favour of remote CI reruns. - [x] **No `ask` prompts mid-run.** The agent MUST NOT trigger any tool call that routes through `permissions.ask` in [.claude/settings.json](../../.claude/settings.json) during implementation. Where a tool would otherwise route through `ask`, the agent MUST select an equivalent covered by `permissions.allow`, or rephrase the operation to fit the sandbox. The single permitted exception is the final commit. - [x] **No interruptions.** Bug fixes, deploy failures, lint failures, `make test` failures, and healthcheck flaps MUST be resolved at their root inside this same iteration without prompting the operator. Workarounds, ad-hoc skips, retry-until-green loops, or "track in a follow-up" deferrals MUST NOT be used. -- [ ] **One commit at the end.** ALL changes (role, meta, Playwright spec, documentation, marketplace entry, and the ticked checkboxes in this document) MUST be combined into ONE commit, created only after every Acceptance Criterion above is checked off (`- [x]`) and `make test` is green. The agent MUST NOT push; the operator runs `git-sign-push` outside the sandbox per [CLAUDE.md](../../CLAUDE.md). +- [ ] **One commit at the end.** ALL changes (role, meta, Playwright spec, documentation, marketplace entry, and the ticked checkboxes in this document) MUST be combined into ONE commit, created only after every Acceptance Criterion above is checked off (`- [x]`) and `make test` is green. The agent MUST NOT push; the operator runs `git-sign-push` outside the sandbox per [AGENTS.md](../../AGENTS.md). ## See Also diff --git a/docs/requirements/024-web-app-erpnext.md b/docs/requirements/024-web-app-erpnext.md index d0adeb2676..239e87b4a5 100644 --- a/docs/requirements/024-web-app-erpnext.md +++ b/docs/requirements/024-web-app-erpnext.md @@ -301,7 +301,7 @@ The agent MUST execute this requirement **autonomously**. Open clarifications on - The agent MUST NOT create any git commit until every Acceptance Criterion in this document is checked off (`- [x]`). - A single commit (or a tight, related sequence) lands the whole role addition; no half-scaffolded intermediate commits. -- When all ACs are met, `make test` is green, and the three variants deploy cleanly, the agent instructs the operator to run `git-sign-push` outside the sandbox (per [CLAUDE.md](../../CLAUDE.md)). The agent MUST NOT push. +- When all ACs are met, `make test` is green, and the three variants deploy cleanly, the agent instructs the operator to run `git-sign-push` outside the sandbox (per [AGENTS.md](../../AGENTS.md)). The agent MUST NOT push. ## Context diff --git a/docs/requirements/025-web-app-matrix-ansible-flavor.md b/docs/requirements/025-web-app-matrix-ansible-flavor.md index 4e78f783f2..6b483b4770 100644 --- a/docs/requirements/025-web-app-matrix-ansible-flavor.md +++ b/docs/requirements/025-web-app-matrix-ansible-flavor.md @@ -230,7 +230,7 @@ The agent MUST execute this requirement **autonomously** once Proposed Decisions ## Commit Policy - Single commit (or a tight, related sequence) lands the whole ansible-flavor addition; no half-scaffolded intermediate commits. -- When all ACs are checked off, `make test` is green, and the four variants deploy cleanly, the agent instructs the operator to run `git-sign-push` outside the sandbox (per [CLAUDE.md](../../CLAUDE.md)). The agent MUST NOT push. +- When all ACs are checked off, `make test` is green, and the four variants deploy cleanly, the agent instructs the operator to run `git-sign-push` outside the sandbox (per [AGENTS.md](../../AGENTS.md)). The agent MUST NOT push. ## Context diff --git a/docs/requirements/028-web-app-semaphore.md b/docs/requirements/028-web-app-semaphore.md index 1bc579617f..fc04173124 100644 --- a/docs/requirements/028-web-app-semaphore.md +++ b/docs/requirements/028-web-app-semaphore.md @@ -209,7 +209,7 @@ Execute autonomously; open a clarification only when a decision is genuinely amb - No git commit until every Acceptance Criterion is checked off (`- [x]`). - A single commit (or a tight related sequence) lands the whole role addition. -- When all ACs are met and the variants deploy cleanly, instruct the operator to run `git-sign-push` outside the sandbox (per [CLAUDE.md](../../CLAUDE.md)). The agent MUST NOT push. +- When all ACs are met and the variants deploy cleanly, instruct the operator to run `git-sign-push` outside the sandbox (per [AGENTS.md](../../AGENTS.md)). The agent MUST NOT push. ## Context diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD index 04fdd9b70e..1ee5afb24a 100644 --- a/packaging/arch/PKGBUILD +++ b/packaging/arch/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Kevin Veen-Birkenbach pkgname=infinito-nexus -pkgver=14.0.0 +pkgver=14.1.0 pkgrel=1 pkgdesc="Meta package for Infinito.Nexus host dependencies (dev + CI)." arch=('any') diff --git a/packaging/debian/changelog b/packaging/debian/changelog index 62aa994174..c7b4ff5f77 100644 --- a/packaging/debian/changelog +++ b/packaging/debian/changelog @@ -1,3 +1,57 @@ +infinito-nexus (14.1.0-1) unstable; urgency=medium + + **[14.1.0] - 2026-09-21** + + **For Users** + + * **Local models reach the gateway again.** Upstream re-pushed the *svc-ai-lmstudio* CPU + image with a server that listens on loopback only, so the role stayed green while litellm + could not connect and the AI features of Mattermost, Matrix, xWiki, Moodle and Zammad + failed their warm-up. The server binds the container network again and stays unpublished. + The model preload now waits until the daemon has finished starting, so a slow host no + longer ends up with a daemon that fails every later model load, and the readiness probe + is capped per attempt so a silent peer cannot hang it. See + [svc-ai-lmstudio](roles/svc-ai-lmstudio/README.md). + + **For Developers** + + * **CI deploys only the variants a change reaches.** An image bump in a provider no longer + redeploys the variants of its consumers that switch that provider off. The diff-derived + whitelist, used by the weekly update PRs, Dependabot and every other diff-driven run, + narrows each affected role to the variants whose round closure still reaches a changed + role, emitted as *role#0,2* selection tokens. A changed role and a role reached only + through *run_after* keep every variant. A pinned token naming a role that discovery does + not return now warns instead of aborting the run; role names are still checked against + *roles/* before the run starts. + + * **One instruction file for every agent.** *AGENTS.md* now holds every agent rule, and + *CLAUDE.md* and *GEMINI.md* are gone. The rules they carried bind every runtime anyway, + and the PR templates, scope tables, requirement documents and docs that named the old + files now name *AGENTS.md*. + + * Image and dependency version jumps (net since 14.0.0): + * *svc-ai-ollama*: 0.34.0 to 0.34.2 + * *svc-net-tor* (Debian base): 13.6-slim to 13.7-slim + * *web-app-baserow*: 2.3.3 to 2.3.4 + * *web-app-erpnext*: v16.34.2 to v16.35.0 + * *web-app-funkwhale* (front, api): 2.0.10 to 2.0.11 + * *web-app-jitsi* (web, prosody, jicofo, jvb): stable-9646 to stable-11031 + * *web-app-keycloak*: 26.7.3 to 26.7.4 + * *web-app-opentalk* (LiveKit): v1.13.6 to v1.13.7 + * *web-app-opentalk* (RabbitMQ): 4.3.5 to 4.3.6 + * *web-app-peertube*: v8.2.4 to v8.3.0 + * *web-app-pihole*: 2026.07.2 to 2026.09.0 + * *web-app-prometheus* (Alertmanager): v0.34.0 to v0.34.1 + * Ansible collection *hetzner.hcloud*: 7.0.1 to 7.1.0 + * *ruff* (dev): 0.16.6 to 0.16.7 + + **Contributors** + + * [Kevin Veen-Birkenbach](https://veen.world): LM Studio reachability and startup, + variant-narrowed CI selection, the single agent instruction file, and version maintenance + + -- Kevin Veen-Birkenbach Mon, 21 Sep 2026 23:12:35 +0200 + infinito-nexus (14.0.0-1) unstable; urgency=medium **For Users** diff --git a/packaging/fedora/infinito-nexus.spec b/packaging/fedora/infinito-nexus.spec index 675af778d9..30a470064e 100644 --- a/packaging/fedora/infinito-nexus.spec +++ b/packaging/fedora/infinito-nexus.spec @@ -1,5 +1,5 @@ Name: infinito-nexus -Version: 14.0.0 +Version: 14.1.0 Release: 1%{?dist} Summary: Meta package for Infinito.Nexus host dependencies @@ -58,6 +58,57 @@ install -d %{buildroot}%{_docdir}/%{name} %doc %{_docdir}/%{name}/DEPENDENCIES %changelog +* Mon Sep 21 2026 Kevin Veen-Birkenbach - 14.1.0-1 +- **[14.1.0] - 2026-09-21** + +- **For Users** + +- * **Local models reach the gateway again.** Upstream re-pushed the *svc-ai-lmstudio* CPU +- image with a server that listens on loopback only, so the role stayed green while litellm +- could not connect and the AI features of Mattermost, Matrix, xWiki, Moodle and Zammad +- failed their warm-up. The server binds the container network again and stays unpublished. +- The model preload now waits until the daemon has finished starting, so a slow host no +- longer ends up with a daemon that fails every later model load, and the readiness probe +- is capped per attempt so a silent peer cannot hang it. See +- [svc-ai-lmstudio](roles/svc-ai-lmstudio/README.md). + +- **For Developers** + +- * **CI deploys only the variants a change reaches.** An image bump in a provider no longer +- redeploys the variants of its consumers that switch that provider off. The diff-derived +- whitelist, used by the weekly update PRs, Dependabot and every other diff-driven run, +- narrows each affected role to the variants whose round closure still reaches a changed +- role, emitted as *role#0,2* selection tokens. A changed role and a role reached only +- through *run_after* keep every variant. A pinned token naming a role that discovery does +- not return now warns instead of aborting the run; role names are still checked against +- *roles/* before the run starts. + +- * **One instruction file for every agent.** *AGENTS.md* now holds every agent rule, and +- *CLAUDE.md* and *GEMINI.md* are gone. The rules they carried bind every runtime anyway, +- and the PR templates, scope tables, requirement documents and docs that named the old +- files now name *AGENTS.md*. + +- * Image and dependency version jumps (net since 14.0.0): +- * *svc-ai-ollama*: 0.34.0 to 0.34.2 +- * *svc-net-tor* (Debian base): 13.6-slim to 13.7-slim +- * *web-app-baserow*: 2.3.3 to 2.3.4 +- * *web-app-erpnext*: v16.34.2 to v16.35.0 +- * *web-app-funkwhale* (front, api): 2.0.10 to 2.0.11 +- * *web-app-jitsi* (web, prosody, jicofo, jvb): stable-9646 to stable-11031 +- * *web-app-keycloak*: 26.7.3 to 26.7.4 +- * *web-app-opentalk* (LiveKit): v1.13.6 to v1.13.7 +- * *web-app-opentalk* (RabbitMQ): 4.3.5 to 4.3.6 +- * *web-app-peertube*: v8.2.4 to v8.3.0 +- * *web-app-pihole*: 2026.07.2 to 2026.09.0 +- * *web-app-prometheus* (Alertmanager): v0.34.0 to v0.34.1 +- * Ansible collection *hetzner.hcloud*: 7.0.1 to 7.1.0 +- * *ruff* (dev): 0.16.6 to 0.16.7 + +- **Contributors** + +- * [Kevin Veen-Birkenbach](https://veen.world): LM Studio reachability and startup, +- variant-narrowed CI selection, the single agent instruction file, and version maintenance + * Sat Sep 19 2026 Kevin Veen-Birkenbach - 14.0.0-1 - **For Users** diff --git a/pyproject.toml b/pyproject.toml index a20ef2df66..0fce194410 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "infinito-nexus" -version = "14.0.0" +version = "14.1.0" description = "Infinito.Nexus" readme = "README.md" requires-python = ">=3.11" @@ -33,7 +33,7 @@ deploy = [ "requests", ] dev = [ - "ruff==0.16.6", + "ruff==0.16.7", "import-linter", "pre-commit", "git-maintainer-tools", diff --git a/roles/svc-ai-lmstudio/files/test/test.sh b/roles/svc-ai-lmstudio/files/test/test.sh index c981fce35d..d30ca9b919 100644 --- a/roles/svc-ai-lmstudio/files/test/test.sh +++ b/roles/svc-ai-lmstudio/files/test/test.sh @@ -30,8 +30,10 @@ json_items() { python3 -c 'import json,sys; [print(x) for x in json.loads(sys.argv[1])]' "$1" } +server_url="" + serves_model() { - in_container curl -fsS --connect-timeout 5 --max-time 30 "http://127.0.0.1:${LMSTUDIO_PORT}/v1/models" 2>/dev/null | + in_container curl -fsS --connect-timeout 5 --max-time 30 "${server_url}/v1/models" 2>/dev/null | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(m.get("id","") for m in d.get("data",[])))' 2>/dev/null | grep -qxF "$1" } @@ -78,7 +80,13 @@ for i in "${!blobs[@]}"; do echo "[OK] ${blobs[$i]} present and matching" done -echo "=== 3. the daemon serves every declared model ===" +echo "=== 3. the daemon serves every declared model on its network address ===" +address="$(in_container hostname -I | tr ' ' '\n' | grep -m1 -E '^[0-9]+(\.[0-9]+){3}$')" +if [ -z "${address}" ]; then + echo "[FAIL] hostname -I reported no IPv4 address inside the container" >&2 + exit 1 +fi +server_url="http://${address}:${LMSTUDIO_PORT}" mapfile -t models < <(json_items "${LMSTUDIO_EXPECTED_MODELS}") for model in "${models[@]}"; do attempt=1 @@ -91,8 +99,13 @@ for model in "${models[@]}"; do [ "${attempt}" -le "${RETRIES}" ] && sleep "${SLEEP_SECONDS}" done if [ "${attempt}" -gt "${RETRIES}" ]; then - echo "[FAIL] ${model} is on disk but /v1/models never listed it" >&2 - echo " the daemon did not index the store it was given at startup" >&2 + if ! in_container curl -fsS --connect-timeout 5 --max-time 30 -o /dev/null "${server_url}/v1/models"; then + echo "[FAIL] ${server_url} does not answer" >&2 + echo " other containers cannot reach the server; check that LMS_SERVER_HOST binds it beyond loopback" >&2 + else + echo "[FAIL] ${model} is on disk but /v1/models never listed it" >&2 + echo " the daemon did not index the store it was given at startup" >&2 + fi failed=1 fi done diff --git a/roles/svc-ai-lmstudio/tasks/utils/preload/node.yml b/roles/svc-ai-lmstudio/tasks/utils/preload/node.yml index b89e50e2e5..d4a0aeb063 100644 --- a/roles/svc-ai-lmstudio/tasks/utils/preload/node.yml +++ b/roles/svc-ai-lmstudio/tasks/utils/preload/node.yml @@ -2,6 +2,16 @@ - name: "🔍 Resolve the container before preloading on '{{ lmstudio_node }}'" ansible.builtin.include_tasks: utils/cid.yml +- name: "⏳ Wait until the LM Studio daemon has finished starting on '{{ lmstudio_node }}'" + ansible.builtin.shell: > # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec {{ LMSTUDIO_LOCAL_CID | quote }} {{ 10 | curl(retries=0) }} -fS -o /dev/null http://127.0.0.1:{{ LMSTUDIO_PORT }}/lmstudio-greeting + register: lmstudio_daemon_ready + changed_when: false + retries: 60 + delay: 5 + until: lmstudio_daemon_ready.rc == 0 + delegate_to: "{{ lmstudio_node }}" + - name: "🗄️ Measure the space the model store offers on '{{ lmstudio_node }}'" ansible.builtin.shell: > # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node container exec {{ LMSTUDIO_LOCAL_CID | quote }} df -P -B1 {{ LMSTUDIO_MODELS_TARGET | quote }} diff --git a/roles/svc-ai-lmstudio/templates/compose.yml.j2 b/roles/svc-ai-lmstudio/templates/compose.yml.j2 index 3e05c26133..ba14ab4e22 100644 --- a/roles/svc-ai-lmstudio/templates/compose.yml.j2 +++ b/roles/svc-ai-lmstudio/templates/compose.yml.j2 @@ -7,6 +7,8 @@ {{ lookup('compose_only', 'container_name', LMSTUDIO_CONTAINER) }} expose: - "{{ LMSTUDIO_PORT }}" + environment: + LMS_SERVER_HOST: "0.0.0.0" {{ lookup('container_volumes', service_name) | indent(4) }} {{ lookup('container_networks') | indent(4) }} diff --git a/roles/svc-net-tor/meta/services.yml b/roles/svc-net-tor/meta/services.yml index 0f872d03b9..8ea686d6c8 100644 --- a/roles/svc-net-tor/meta/services.yml +++ b/roles/svc-net-tor/meta/services.yml @@ -20,7 +20,7 @@ tor: # nocheck: category-modes exclusive: true primary: true image: debian - version: 13.6-slim + version: 13.7-slim custom: true name: tor node: "" diff --git a/roles/web-app-erpnext/meta/services.yml b/roles/web-app-erpnext/meta/services.yml index 50c291d0fa..2b96c4d71f 100644 --- a/roles/web-app-erpnext/meta/services.yml +++ b/roles/web-app-erpnext/meta/services.yml @@ -65,7 +65,7 @@ erpnext: enabled: true shared: true image: frappe/erpnext - version: "v16.34.2" + version: "v16.35.0" name: erpnext min_storage: 1017MB ports: diff --git a/roles/web-app-funkwhale/meta/services.yml b/roles/web-app-funkwhale/meta/services.yml index d188bff2fb..de6cb65d1e 100644 --- a/roles/web-app-funkwhale/meta/services.yml +++ b/roles/web-app-funkwhale/meta/services.yml @@ -11,7 +11,7 @@ funkwhale: # nocheck: default-placement-manager embedded typesense index; node-local in swarm placement: manager image: funkwhale/front - version: 2.0.10 + version: 2.0.11 min_storage: 224MB ports: internal: @@ -36,7 +36,7 @@ api: flavor: curl path: api/v1/instance/nodeinfo/2.0 image: funkwhale/api - version: 2.0.10 + version: 2.0.11 min_storage: 588MB ports: internal: diff --git a/roles/web-app-jitsi/meta/services.yml b/roles/web-app-jitsi/meta/services.yml index 5ecf44e8c7..168ad511d5 100644 --- a/roles/web-app-jitsi/meta/services.yml +++ b/roles/web-app-jitsi/meta/services.yml @@ -53,7 +53,7 @@ jitsi: swarm: enabled: true image: jitsi/web - version: "stable-9646" + version: "stable-11031" min_storage: 315MB # nocheck: default-placement-manager meta/volumes.yml uses type:bind config dirs staged on the stack host; a worker-scheduled task lacks the source paths (unpinning requires migrating them to nfs-backed named volumes) placement: manager @@ -87,7 +87,7 @@ prosody: port_key: http name: jitsi-prosody image: jitsi/prosody - version: "stable-9646" + version: "stable-11031" ports: internal: xmpp: 5222 @@ -102,7 +102,7 @@ prosody: jicofo: name: jitsi-jicofo image: jitsi/jicofo - version: "stable-9646" + version: "stable-11031" cpus: "1.0" mem_reservation: 512m mem_limit: 1g @@ -112,7 +112,7 @@ jicofo: jvb: name: jitsi-jvb image: jitsi/jvb - version: "stable-9646" + version: "stable-11031" cpus: "2.0" mem_reservation: 1g mem_limit: 2g diff --git a/roles/web-app-pgadmin/meta/services.yml b/roles/web-app-pgadmin/meta/services.yml index 4f72e5a3fc..4184791bf4 100644 --- a/roles/web-app-pgadmin/meta/services.yml +++ b/roles/web-app-pgadmin/meta/services.yml @@ -11,7 +11,7 @@ pgadmin: # nocheck: default-placement-manager embedded sqlite config db; node-local in swarm placement: manager image: dpage/pgadmin4 - version: "9.17" + version: "9.18" min_storage: 378MB server_mode: false master_password_required: true diff --git a/roles/web-app-pihole/meta/services.yml b/roles/web-app-pihole/meta/services.yml index 2abe5f7b63..e30e2bd67c 100644 --- a/roles/web-app-pihole/meta/services.yml +++ b/roles/web-app-pihole/meta/services.yml @@ -68,7 +68,7 @@ pihole: swarm: enabled: false image: pihole/pihole - version: "2026.07.2" + version: "2026.09.0" upstream_dns: "{{ NETWORK_PUBLIC_DNS_RESOLVERS }}" cpus: "0.5" mem_reservation: "128m" diff --git a/scripts/github/resolve/pr_affected_roles.sh b/scripts/github/resolve/pr_affected_roles.sh index d485039691..9434ae1480 100755 --- a/scripts/github/resolve/pr_affected_roles.sh +++ b/scripts/github/resolve/pr_affected_roles.sh @@ -15,7 +15,9 @@ # PR_BODY PR body markdown (only read on the subset path). # # Outputs (GITHUB_OUTPUT): -# whitelist= +# whitelist= +# a token is a role id, variant-narrowed to `#0,2` where +# only some of the role's variants reach the change. set -euo pipefail diff --git a/scripts/meta/resolve/diff/affected_roles.sh b/scripts/meta/resolve/diff/affected_roles.sh index ef32acb46b..696fb528f2 100755 --- a/scripts/meta/resolve/diff/affected_roles.sh +++ b/scripts/meta/resolve/diff/affected_roles.sh @@ -21,7 +21,11 @@ # (resolver exit 2), OR # * the resolver itself errors out # (any other non-zero exit). -# [ ...] restricted deploy set (whitelist). +# [ ...] restricted deploy set (whitelist). +# A token is a role id, narrowed to the +# variants that reach a seed where not all +# of them do (`web-app-x#0,2`, see +# utils.github.variant.selection). # # Pre-conditions: # - The host Python interpreter referenced by ${PYTHON:-python3} has the diff --git a/tests/performance/test_runtime_performance.py b/tests/performance/test_runtime_performance.py index bad5f4ac0d..5f11fcfac7 100644 --- a/tests/performance/test_runtime_performance.py +++ b/tests/performance/test_runtime_performance.py @@ -97,7 +97,7 @@ class TestRuntimeLookupPerformance(unittest.TestCase): hit the cache and stay under theirs. Using a single for-loop here is test-code-only and not production code - generating files/tasks; the CLAUDE.md shell-loop ban does not apply. + generating files/tasks; the AGENTS.md shell-loop ban does not apply. """ warm = _simulate_ansible_variables(self.shared_applications, self.shared_users) t0 = time.process_time() diff --git a/tests/unit/python/cli/meta/ci/test_validate.py b/tests/unit/python/cli/meta/ci/test_validate.py index e849f331c7..d418efec03 100644 --- a/tests/unit/python/cli/meta/ci/test_validate.py +++ b/tests/unit/python/cli/meta/ci/test_validate.py @@ -54,6 +54,11 @@ class TestProblems(unittest.TestCase): self.assertEqual(errors, []) self.assertIn("web-app-gone", warnings[0]) + def test_a_pinned_role_the_run_never_discovers_only_warns(self) -> None: + errors, warnings = _problems("web-app-gone#0,2") + self.assertEqual(errors, []) + self.assertIn("web-app-gone", warnings[0]) + def test_a_bare_role_the_run_discovers_is_silent(self) -> None: self.assertEqual(_problems("web-app-a"), ([], [])) diff --git a/tests/unit/python/cli/meta/roles/applications/resolution/affected/test_main.py b/tests/unit/python/cli/meta/roles/applications/resolution/affected/test_main.py index 6d354161d6..40314d62bc 100644 --- a/tests/unit/python/cli/meta/roles/applications/resolution/affected/test_main.py +++ b/tests/unit/python/cli/meta/roles/applications/resolution/affected/test_main.py @@ -13,6 +13,7 @@ from utils.cache.yaml import dump_yaml from utils.roles.mapping import ( ROLE_FILE_META_MAIN, ROLE_FILE_META_SERVICES, + ROLE_FILE_META_VARIANTS, ROLE_FILE_VARS_MAIN, ) @@ -38,6 +39,22 @@ def _write_run_after(root: Path, role: str, run_after: list[str]) -> None: ) +def _write_sso_consumer(root: Path, role: str, variants: list[bool]) -> None: + """A role consuming shared `sso`, with one variant per `variants` entry + that either keeps the consumption or switches it off.""" + dump_yaml( + root / "roles" / role / ROLE_FILE_META_SERVICES, + {role: {}, "sso": {"enabled": True, "shared": True, "flavor": "oidc"}}, + ) + dump_yaml( + root / "roles" / role / ROLE_FILE_META_VARIANTS, + [ + {"services": {"sso": {"enabled": consumes, "shared": consumes}}} + for consumes in variants + ], + ) + + def _write_dependencies(root: Path, role: str, deps: list[str]) -> None: dump_yaml( root / "roles" / role / ROLE_FILE_META_MAIN, @@ -104,6 +121,59 @@ class TestAffected(unittest.TestCase): self.assertIn("web-app-keycloak", got) self.assertIn("web-app-consumer", got) + def test_only_the_variants_reaching_the_seed_are_kept(self) -> None: + with tempfile.TemporaryDirectory() as td: + root = Path(td) + _mk_app_role(root, "web-app-keycloak", "keycloak") + _mk_app_role(root, "web-app-consumer", "consumer") + _write_sso_consumer(root, "web-app-consumer", [True, False, True]) + + with patch.object(repo_paths, "PROJECT_ROOT", root): + got = affected_main.affected_selection(["web-app-keycloak"]) + self.assertIn("web-app-consumer#0,2", got) + + def test_a_role_whose_variants_all_reach_the_seed_stays_bare(self) -> None: + with tempfile.TemporaryDirectory() as td: + root = Path(td) + _mk_app_role(root, "web-app-keycloak", "keycloak") + _mk_app_role(root, "web-app-consumer", "consumer") + _write_sso_consumer(root, "web-app-consumer", [True, True]) + + with patch.object(repo_paths, "PROJECT_ROOT", root): + got = affected_main.affected_selection(["web-app-keycloak"]) + self.assertIn("web-app-consumer", got) + + def test_the_narrowing_follows_a_parents_variant_one_generation_up(self) -> None: + with tempfile.TemporaryDirectory() as td: + root = Path(td) + _mk_app_role(root, "web-app-keycloak", "keycloak") + _mk_app_role(root, "web-app-matomo", "matomo") + _mk_app_role(root, "web-app-consumer", "consumer") + _write_sso_consumer(root, "web-app-matomo", [True, False]) + dump_yaml( + root / "roles" / "web-app-consumer" / ROLE_FILE_META_SERVICES, + {"consumer": {}, "matomo": {"enabled": True, "shared": True}}, + ) + dump_yaml( + root / "roles" / "web-app-consumer" / ROLE_FILE_META_VARIANTS, + [{"services": {"matomo": {"enabled": True, "shared": True}}}] * 2, + ) + + with patch.object(repo_paths, "PROJECT_ROOT", root): + got = affected_main.affected_selection(["web-app-keycloak"]) + self.assertIn("web-app-consumer#0", got) + + def test_a_seed_keeps_every_variant_of_its_own_role(self) -> None: + with tempfile.TemporaryDirectory() as td: + root = Path(td) + _mk_app_role(root, "web-app-keycloak", "keycloak") + _mk_app_role(root, "web-app-consumer", "consumer") + _write_sso_consumer(root, "web-app-consumer", [True, False]) + + with patch.object(repo_paths, "PROJECT_ROOT", root): + got = affected_main.affected_selection(["web-app-consumer"]) + self.assertEqual(got, ["web-app-consumer"]) + def test_unknown_role_raises(self) -> None: with tempfile.TemporaryDirectory() as td: root = Path(td) diff --git a/tests/unit/python/utils/github/variant/test_selection.py b/tests/unit/python/utils/github/variant/test_selection.py index 9c990f9110..f150d7378e 100644 --- a/tests/unit/python/utils/github/variant/test_selection.py +++ b/tests/unit/python/utils/github/variant/test_selection.py @@ -199,6 +199,11 @@ class TestApply(unittest.TestCase): def test_a_bare_role_that_matches_nothing_is_tolerated(self) -> None: self.assertEqual(selection.apply(_ROWS, selection.parse_list("web-app-c")), []) + def test_a_pin_on_an_undiscovered_role_is_tolerated_like_a_bare_one(self) -> None: + self.assertEqual( + selection.apply(_ROWS, selection.parse_list("web-app-c#0,2")), [] + ) + if __name__ == "__main__": unittest.main() diff --git a/tests/unit/python/cli/administration/deploy/development/inventory/test_nested_overrides.py b/tests/unit/python/utils/roles/applications/test_variants_overrides.py similarity index 91% rename from tests/unit/python/cli/administration/deploy/development/inventory/test_nested_overrides.py rename to tests/unit/python/utils/roles/applications/test_variants_overrides.py index a473f1031d..a59edde7ba 100644 --- a/tests/unit/python/cli/administration/deploy/development/inventory/test_nested_overrides.py +++ b/tests/unit/python/utils/roles/applications/test_variants_overrides.py @@ -1,4 +1,4 @@ -"""Unit tests for `cli.administration.deploy.development.inventory.nested_overrides`. +"""Unit tests for `utils.roles.applications.variants`' provider overrides. The service registry is stubbed: what matters is which role a claim is attributed to, not how a service key resolves to its provider. @@ -9,7 +9,7 @@ from __future__ import annotations import unittest from unittest.mock import patch -from cli.administration.deploy.development.inventory.nested_overrides import ( +from utils.roles.applications.variants import ( NestedOverrideConflictError, collect_provider_overrides, ) @@ -19,10 +19,7 @@ _REGISTRY = { "gitea": {"role": "web-app-gitea"}, } -_PATCH = ( - "cli.administration.deploy.development.inventory.nested_overrides" - ".build_service_registry_from_roles_dir" -) +_PATCH = "utils.roles.applications.variants.build_service_registry_from_roles_dir" class TestCollectProviderOverrides(unittest.TestCase): diff --git a/utils/github/variant/selection.py b/utils/github/variant/selection.py index 899ab590f1..c75e88f644 100644 --- a/utils/github/variant/selection.py +++ b/utils/github/variant/selection.py @@ -270,14 +270,24 @@ def apply( plus a rotation-picked one on top. Raises: - SystemExit: a token that pins something matched no row at all. Silently - deploying nothing is how a mistyped variant index turns into a - green run that tested nothing. + SystemExit: a token pins a variant of a role the query DID return, and + no row carries that variant. Silently deploying nothing is how a + mistyped variant index turns into a green run that tested nothing. + + A token whose role the query returned nothing for is let through + instead: the diff-derived whitelist legitimately names roles the + run's mode and lifecycle envelope filters out, and since that + resolver now pins the variants a change actually reaches, such a + token would otherwise abort every chunk of the run. Role names are + checked against `roles/` before the run starts + (scripts/github/resolve/effective_whitelist.sh), so a typo is still + caught -- one layer earlier. """ if not pins: return [dict(row) for row in rows] kept: list[dict[str, Any]] = [] matched: set[int] = set() + discovered = {row["name"] for row in rows} for row in rows: hits = [ (index, pin) @@ -302,7 +312,7 @@ def apply( } ) for index, pin in enumerate(pins): - if index not in matched and pin.pinned: + if index not in matched and pin.pinned and pin.app in discovered: raise SystemExit( f"selection {describe(pin)!r} matches no discovered row; " f"check the variant index and the run's lifecycle/mode filters" diff --git a/utils/roles/applications/variants.py b/utils/roles/applications/variants.py new file mode 100644 index 0000000000..9bec87ae56 --- /dev/null +++ b/utils/roles/applications/variants.py @@ -0,0 +1,177 @@ +"""What one round's variants mean for the roles that round pulls in. + +A round picks one variant per role, and that choice decides two things no +single role's `meta/services.yml` can state on its own: which providers the +role still pulls in, and how lean those providers have to be +(:mod:`utils.roles.applications.topics`). Both are resolved here, so the +matrix planner's include set, the inventory bake and the CI selection read +one answer instead of three. + +The module is deliberately free of deploy-runtime imports: the CI selection +resolves its closure on a runner that has no inventory, no container and no +`INFINITO_SRC_DIR`. +""" + +from __future__ import annotations + +from collections.abc import Mapping +from pathlib import Path +from typing import Any + +import yaml + +from utils.cache.applications import get_variants +from utils.cache.base import _deep_merge +from utils.cache.yaml import load_yaml_any +from utils.roles.applications.services.registry import ( + build_service_registry_from_roles_dir, +) +from utils.roles.applications.topics import CONFIG_TOPICS, apply_topic, provider_of +from utils.roles.mapping import ROLE_FILE_META_SERVICES + +__all__ = [ + "NestedOverrideConflictError", + "collect_provider_overrides", + "services_overrides_for_round", +] + + +class NestedOverrideConflictError(RuntimeError): + """Two roles in one round demand different config for one provider.""" + + +def _claims(payloads: Mapping[str, Any]) -> list[tuple[str, str, str, Any]]: + """Return the ``(role, service_key, topic, value)`` a round's payloads carry. + + Args: + payloads: ``{role: variant payload}`` for one round. + + Reading this before the service registry keeps a round whose variants + override nothing from paying for the registry at all. + """ + claims: list[tuple[str, str, str, Any]] = [] + for role_name, payload in payloads.items(): + if not isinstance(payload, Mapping): + continue + services = payload.get("services") + if not isinstance(services, Mapping): + continue + for service_key, entry in services.items(): + if not isinstance(entry, Mapping): + continue + claims.extend( + (role_name, service_key, topic, entry[topic]) + for topic in sorted(CONFIG_TOPICS & set(entry)) + ) + return claims + + +def collect_provider_overrides( + payloads: Mapping[str, Any], *, roles_dir: str +) -> dict[str, dict[str, Any]]: + """Return ``{provider: {topic: value}}`` demanded by the round's payloads. + + Args: + payloads: ``{role: variant payload}`` for one round. + roles_dir: roles directory the service registry is built from. + + Raises: + NestedOverrideConflictError: two roles demand different values for the + same topic of the same provider. + """ + claims = _claims(payloads) + if not claims: + return {} + + registry = build_service_registry_from_roles_dir(Path(roles_dir)) + demanded: dict[str, dict[str, Any]] = {} + claimed_by: dict[tuple[str, str], str] = {} + for role_name, service_key, topic, value in claims: + provider = provider_of(service_key, registry) + if not provider or provider == role_name: + continue + previous = claimed_by.get((provider, topic)) + if previous and demanded[provider][topic] != value: + raise NestedOverrideConflictError( + f"{role_name} and {previous} demand different " + f"{topic!r} for {provider!r} in the same round; a " + f"round deploys it once, so the two cannot both hold" + ) + demanded.setdefault(provider, {})[topic] = value + claimed_by[(provider, topic)] = role_name + return demanded + + +def _apply_nested_service_maps(overrides: dict[str, dict], *, roles_dir: str) -> None: + """Replace a pulled-in provider's services map with what the round demands. + + Only the ``services`` topic reaches this path: the closure walks service + edges, so the other config topics a variant may override are the inventory + bake's business. + + Args: + overrides: ``{role: services map}``, mutated in place. + roles_dir: roles directory the service registry is built from. + """ + payloads = {role: {"services": services} for role, services in overrides.items()} + for provider, topics in collect_provider_overrides( + payloads, roles_dir=roles_dir + ).items(): + if "services" not in topics: + continue + overrides[provider] = apply_topic(overrides.get(provider), topics["services"]) + + +def services_overrides_for_round( + *, + roles_dir: str, + round_index: int, + primary_app_variants: Mapping[str, int], +) -> dict[str, dict]: + """For every role with `meta/variants.yml`, return the services map + that results from merging the round's variant payload onto the + role's on-disk `meta/services.yml`. + + Apps in `primary_app_variants` use the supplied (already clamped) + index. Other roles with their own variants clamp `round_index` to + their own variant count. Roles without variants are absent from the + result so the resolver falls through to its disk-read path. + + The merged map is what the inventory ALSO bakes into host_vars, so + feeding the same dict into `CombinedResolver(services_overrides=...)` + eliminates the topology-vs-host_vars drift that variant-blind + resolution produced. + """ + variants_per_app = get_variants(roles_dir=roles_dir) + overrides: dict[str, dict] = {} + roles_path = Path(roles_dir) + for role_name, variant_list in variants_per_app.items(): + if not variant_list: + continue + variant_count = max(1, len(variant_list)) + if role_name in primary_app_variants: + idx = primary_app_variants[role_name] + else: + idx = round_index if round_index < variant_count else 0 + if not 0 <= idx < len(variant_list): + idx = 0 + variant_payload = variant_list[idx] if variant_list else {} + if not isinstance(variant_payload, Mapping): + variant_payload = {} + variant_services = variant_payload.get("services", {}) + if not isinstance(variant_services, Mapping): + continue + services_path = roles_path / role_name / ROLE_FILE_META_SERVICES + if not services_path.exists(): + continue + try: + base_services = load_yaml_any(services_path) or {} + except (OSError, ValueError, yaml.YAMLError): + continue + if not isinstance(base_services, Mapping): + continue + merged = _deep_merge(dict(base_services), dict(variant_services)) + if isinstance(merged, dict): + overrides[role_name] = merged + _apply_nested_service_maps(overrides, roles_dir=roles_dir) + return overrides