From 1079f48febac65f3cc12bf38d1b738c5348f975b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:30:48 +0200 Subject: [PATCH 01/13] fix(env): derive the image and container names from the distro under test A compose deploy job labelled centos or arch built its stack image from pkgmgr-debian and ran it as infinito_nexus_debian (#794). distros.sh exports INFINITO_DISTRO per iteration and sources load.sh again, but the loader returned early because INFINITO_ENV_LOADED and the .env mtime were unchanged. A full reload would not have helped either: the debian values were already exported, so the restore step kept them as caller intent. load.sh now records the distro it loaded for. Another INFINITO_DISTRO defeats the early return and drops INFINITO_CONTAINER, INFINITO_PARENT_IMAGE and INFINITO_IMAGE, the three keys the env handlers derive from the distro. When the requested distro also differs from the one .env was generated for, the loader sources a set that `python -m cli.meta.env --output` generates for it in a private temp directory and leaves .env untouched, so a local multi-distro run does not switch the checkout's distro. A caller value set for the loaded distro still wins. Verified: tests/unit/python/scripts/meta/env/test_load.py and the new distros.sh case pass. Against main's loader both fail with the symptom of the issue: INFINITO_DISTRO=centos next to infinito_nexus_debian and pkgmgr-debian:stable, and distros.sh handing debian, arch and centos the same debian parent. shellcheck is clean. Consequence: CI jobs labelled arch, ubuntu, fedora or centos now build and deploy that distro, so a failure that shows up there was masked before. feature/store-i18n carries 3f973eb137, which resolves the parent image for scripts/image/push.sh on its own, and 05e4dbafcb, which inserts the INFINITO_INSTANCE slot check into the block this commit restructures. The merge keeps the slot check ahead of the distro check. Closes #794 Co-Authored-By: Claude Opus 5.5 (1M context) --- cli/meta/env/__main__.py | 35 +++-- docs/contributing/environment/variables.md | 1 + scripts/meta/env/load.sh | 30 +++- tests/unit/python/cli/meta/env/test_main.py | 20 ++- .../unit/python/scripts/meta/env/__init__.py | 0 .../unit/python/scripts/meta/env/test_load.py | 131 ++++++++++++++++++ .../scripts/tests/deploy/test_distros.py | 11 ++ 7 files changed, 211 insertions(+), 17 deletions(-) create mode 100644 tests/unit/python/scripts/meta/env/__init__.py create mode 100644 tests/unit/python/scripts/meta/env/test_load.py diff --git a/cli/meta/env/__main__.py b/cli/meta/env/__main__.py index d4f7e3764f..d1abfe9c6f 100644 --- a/cli/meta/env/__main__.py +++ b/cli/meta/env/__main__.py @@ -2,8 +2,10 @@ from __future__ import annotations +import argparse import os import sys +from pathlib import Path from utils.env.builder import build_env from utils.env.parser import parse_static_env_with_comments @@ -14,18 +16,34 @@ from . import PROJECT_ROOT as REPO_ROOT HOST_OWNED_KEY = "INFINITO_DOTENV_HOST_OWNED" # nocheck: dotenv-host-owned-marker Reason: set only by compose.yml inside the runner container; not a configuration key, a .env entry could freeze the host .env -def main() -> int: +def main(argv: list[str] | None = None) -> int: + """Generate the env set from default.env and the runtime context. + + Args: + argv: command-line arguments; ``--output PATH`` writes the set to PATH + instead of the repository's ``.env``, which then stays untouched. + + Returns: + 0 on success, 2 when default.env is missing. + """ + parser = argparse.ArgumentParser(prog="python -m cli.meta.env") + parser.add_argument("--output", type=Path) + args = parser.parse_args([] if argv is None else argv) static_path = REPO_ROOT / "default.env" - out_path = REPO_ROOT / ".env" + out_path = args.output or REPO_ROOT / ".env" + out_name = args.output or ".env" if not static_path.is_file(): print(f"ERROR: missing {static_path}", file=sys.stderr) return 2 - if out_path.is_file() and os.environ.get(HOST_OWNED_KEY) == "true": + if ( + args.output is None + and out_path.is_file() + and os.environ.get(HOST_OWNED_KEY) == "true" + ): print( - f"Kept {out_path.relative_to(REPO_ROOT)}: the host checkout owns it " - f"({HOST_OWNED_KEY})", + f"Kept {out_name}: the host checkout owns it ({HOST_OWNED_KEY})", file=sys.stderr, ) return 0 @@ -33,12 +51,9 @@ def main() -> int: static, static_comments = parse_static_env_with_comments(static_path) eb = build_env(static, repo_root=REPO_ROOT, comments=static_comments) write_dotenv(eb, out_path) - print( - f"Wrote {out_path.relative_to(REPO_ROOT)} ({len(eb.values)} variables)", - file=sys.stderr, - ) + print(f"Wrote {out_name} ({len(eb.values)} variables)", file=sys.stderr) return 0 if __name__ == "__main__": - sys.exit(main()) + sys.exit(main(sys.argv[1:])) diff --git a/docs/contributing/environment/variables.md b/docs/contributing/environment/variables.md index a14e12cd88..6b47e34511 100644 --- a/docs/contributing/environment/variables.md +++ b/docs/contributing/environment/variables.md @@ -27,6 +27,7 @@ Already-set env vars take precedence over `default.env` defaults. - [`env/`](../../../utils/env/) (under `utils/`) holds the parser, runtime helpers, writer, and one handler module per dynamically-computed variable under [`handlers/`](../../../utils/env/handlers/). - [`env/`](../../../cli/meta/env/) (under `cli/meta/`) provides the CLI entry point invoked as `python -m cli.meta.env`. - [`load.sh`](../../../scripts/meta/env/load.sh) is the shell loader; it sources `.env` and auto-generates it on a cold clone. + When the exported `INFINITO_DISTRO` differs from the one `.env` was generated for, it loads a set generated for that distro through `python -m cli.meta.env --output ` and leaves `.env` as it is. ## Variables NOT in `default.env` diff --git a/scripts/meta/env/load.sh b/scripts/meta/env/load.sh index b1dff51f4c..1de27c5e2b 100755 --- a/scripts/meta/env/load.sh +++ b/scripts/meta/env/load.sh @@ -7,6 +7,9 @@ # re-entry from generator subshells (BASH_ENV would otherwise recurse). # PYTHON/PATH are re-resolved on every source so a venv created mid-chain wins; # caller-set values are snapshotted and restored after the bulk .env source. +# INFINITO_CONTAINER, INFINITO_PARENT_IMAGE and INFINITO_IMAGE derive from the +# distro: a caller INFINITO_DISTRO other than the one `.env` was generated for +# loads a set generated for that distro instead, and `.env` stays untouched. # zsh cannot run this loader's bash-isms (BASH_SOURCE, ${!indirect}, assoc-array # key expansion). When sourced from zsh, delegate to bash and import the @@ -44,7 +47,7 @@ if [[ -n "${VENV:-}" && -d "${VENV%/}/bin" ]]; then fi _infinito_env_mtime="$(stat -c %Y "${_infinito_env_dotenv}" 2>/dev/null || echo 0)" -if [[ "${INFINITO_ENV_LOADED:-}" == "1" && "${INFINITO_ENV_LOADED_MTIME:-}" == "${_infinito_env_mtime}" ]]; then # nocheck: env-loader-internal-guard +if [[ "${INFINITO_ENV_LOADED:-}" == "1" && "${INFINITO_ENV_LOADED_MTIME:-}" == "${_infinito_env_mtime}" && "${INFINITO_ENV_LOADED_DISTRO:-}" == "${INFINITO_DISTRO:-}" ]]; then # nocheck: env-loader-internal-guard unset _infinito_env_repo_root _infinito_env_dotenv _infinito_env_mtime return 0 fi @@ -53,11 +56,22 @@ if [[ "${INFINITO_ENV_GENERATING:-}" == "1" ]]; then # nocheck: env-loader-inter return 0 fi -if [[ ! -f "${_infinito_env_dotenv}" ]]; then +if [[ -n "${INFINITO_ENV_LOADED_DISTRO:-}" && "${INFINITO_ENV_LOADED_DISTRO}" != "${INFINITO_DISTRO:-}" ]]; then # nocheck: env-loader-internal-guard + unset INFINITO_CONTAINER INFINITO_PARENT_IMAGE INFINITO_IMAGE +fi + +_infinito_env_source="${_infinito_env_dotenv}" +_infinito_env_scratch="" +if [[ -f "${_infinito_env_dotenv}" && -n "${INFINITO_DISTRO:-}" && "${INFINITO_DISTRO}" != "$(sed -n 's/^INFINITO_DISTRO=//p' "${_infinito_env_dotenv}")" ]]; then + _infinito_env_scratch="$(mktemp -d)" + _infinito_env_source="${_infinito_env_scratch}/env" +fi + +if [[ ! -f "${_infinito_env_source}" ]]; then ( cd "${_infinito_env_repo_root}" || exit 1 export INFINITO_ENV_GENERATING=1 - "${PYTHON}" -m cli.meta.env + "${PYTHON}" -m cli.meta.env --output "${_infinito_env_source}" ) >&2 fi @@ -73,14 +87,19 @@ while IFS= read -r _infinito_env_line; do if [[ -n "${!_infinito_env_key:-}" ]]; then _infinito_env_preserved["${_infinito_env_key}"]="${!_infinito_env_key}" fi -done <"${_infinito_env_dotenv}" +done <"${_infinito_env_source}" unset _infinito_env_line _infinito_env_key set -a # shellcheck disable=SC1090 -source "${_infinito_env_dotenv}" +source "${_infinito_env_source}" set +a +if [[ -n "${_infinito_env_scratch}" ]]; then + rm -rf "${_infinito_env_scratch}" +fi +unset _infinito_env_source _infinito_env_scratch + for _infinito_env_key in "${!_infinito_env_preserved[@]}"; do declare -gx "${_infinito_env_key}=${_infinito_env_preserved[${_infinito_env_key}]}" done @@ -100,4 +119,5 @@ fi export INFINITO_ENV_LOADED="1" _infinito_env_mtime="$(stat -c %Y "${_infinito_env_dotenv}" 2>/dev/null || echo 0)" export INFINITO_ENV_LOADED_MTIME="${_infinito_env_mtime}" +export INFINITO_ENV_LOADED_DISTRO="${INFINITO_DISTRO:-}" unset _infinito_env_repo_root _infinito_env_dotenv _infinito_env_mtime diff --git a/tests/unit/python/cli/meta/env/test_main.py b/tests/unit/python/cli/meta/env/test_main.py index d2cc44c42f..261857a54e 100644 --- a/tests/unit/python/cli/meta/env/test_main.py +++ b/tests/unit/python/cli/meta/env/test_main.py @@ -9,7 +9,13 @@ import cli.meta.env.__main__ as env_main class TestDotenvHostOwned(unittest.TestCase): - def _run(self, *, dotenv_exists: bool, host_owned: str | None) -> tuple[int, bool]: + def _run( + self, + *, + dotenv_exists: bool, + host_owned: str | None, + argv: list[str] | None = None, + ) -> tuple[int, bool]: with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) (root / "default.env").write_text("INFINITO_DISTRO=debian\n") @@ -28,7 +34,7 @@ class TestDotenvHostOwned(unittest.TestCase): patch.object(env_main, "write_dotenv") as write_dotenv, ): build_env.return_value.values = {} - rc = env_main.main() + rc = env_main.main(argv) return rc, write_dotenv.called def test_a_host_owned_dotenv_is_kept(self) -> None: @@ -40,6 +46,16 @@ class TestDotenvHostOwned(unittest.TestCase): def test_without_the_marker_the_dotenv_is_regenerated(self) -> None: self.assertEqual(self._run(dotenv_exists=True, host_owned=None), (0, True)) + def test_an_explicit_output_is_written_even_when_host_owned(self) -> None: + self.assertEqual( + self._run( + dotenv_exists=True, + host_owned="true", + argv=["--output", "/nonexistent/distro.env"], + ), + (0, True), + ) + if __name__ == "__main__": # pragma: no cover unittest.main() diff --git a/tests/unit/python/scripts/meta/env/__init__.py b/tests/unit/python/scripts/meta/env/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/scripts/meta/env/test_load.py b/tests/unit/python/scripts/meta/env/test_load.py new file mode 100644 index 0000000000..af61434b78 --- /dev/null +++ b/tests/unit/python/scripts/meta/env/test_load.py @@ -0,0 +1,131 @@ +"""The distro-derived keys follow the distro the caller asks for. + +``scripts/tests/deploy/distros.sh`` exports ``INFINITO_DISTRO`` per iteration +and sources the loader again. The keys composed from the distro must then name +that distro, not the one ``.env`` was generated for, and ``.env`` itself must +stay as it was. +""" + +from __future__ import annotations + +import os +import shutil +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path +from typing import ClassVar + +from utils.cache.files import PROJECT_ROOT + +LOADER_DIR = Path(PROJECT_ROOT) / "scripts" / "meta" / "env" +SHOWN = ( + "INFINITO_DISTRO", + "INFINITO_CONTAINER", + "INFINITO_PARENT_IMAGE", + "INFINITO_IMAGE", +) +SHOW = "printf '%s\\n' " + " ".join(f'"{key}=${{{key}:-}}"' for key in SHOWN) + + +def clean_env(**overrides: str) -> dict[str, str]: + env = { + k: v + for k, v in os.environ.items() + if not k.startswith("INFINITO_") + and k not in ("BASH_ENV", "PYTHONPATH", "VENV", "PYTHON", "VIRTUAL_ENV") + } + env["PYTHONPATH"] = str(PROJECT_ROOT) + env.update(overrides) + return env + + +def bash(script: str, cwd: Path) -> dict[str, str]: + proc = subprocess.run( + ["bash", "-c", f"{script}\n{SHOW}"], + env=clean_env(), + cwd=cwd, + capture_output=True, + text=True, + check=True, + ) + return dict(line.split("=", 1) for line in proc.stdout.splitlines()) + + +class TestDistroDerivedKeys(unittest.TestCase): + scratch: ClassVar[Path] + expected: ClassVar[dict[str, dict[str, str]]] + + @classmethod + def setUpClass(cls) -> None: + cls.scratch = Path(tempfile.mkdtemp()) + cls.expected = {} + for distro in ("debian", "centos"): + path = cls.scratch / f"{distro}.env" + subprocess.run( + [sys.executable, "-m", "cli.meta.env", "--output", str(path)], + env=clean_env(INFINITO_DISTRO=distro), + cwd=PROJECT_ROOT, + capture_output=True, + check=True, + ) + cls.expected[distro] = bash(f'set -a; source "{path}"', cls.scratch) + + @classmethod + def tearDownClass(cls) -> None: + shutil.rmtree(cls.scratch) + + def run_loader(self, steps: str) -> dict[str, str]: + """Source a copy of the loader in a checkout whose ``.env`` is debian's. + + Args: + steps: bash run before the keys are shown; ``load`` sources the + loader. + + Returns: + The keys as the steps leave them. + """ + checkout = Path(tempfile.mkdtemp()) + self.addCleanup(shutil.rmtree, checkout) + (checkout / "scripts" / "meta" / "env").mkdir(parents=True) + for name in ("load.sh", "python.sh"): + shutil.copy(LOADER_DIR / name, checkout / "scripts" / "meta" / "env") + dotenv = checkout / ".env" + shutil.copy(self.scratch / "debian.env", dotenv) + before = dotenv.read_bytes() + shown = bash(f"load() {{ source scripts/meta/env/load.sh; }}\n{steps}", checkout) + self.assertEqual(dotenv.read_bytes(), before, ".env was rewritten") + return shown + + def test_the_two_distros_derive_different_keys(self): + self.assertNotEqual( + self.expected["debian"]["INFINITO_PARENT_IMAGE"], + self.expected["centos"]["INFINITO_PARENT_IMAGE"], + ) + + def test_a_distro_exported_after_the_first_load_gets_its_own_keys(self): + shown = self.run_loader("load\nexport INFINITO_DISTRO=centos\nload") + self.assertEqual(shown, self.expected["centos"]) + + def test_a_distro_exported_before_the_first_load_gets_its_own_keys(self): + shown = self.run_loader("export INFINITO_DISTRO=centos\nload") + self.assertEqual(shown, self.expected["centos"]) + + def test_switching_back_restores_the_keys_of_the_dotenv(self): + shown = self.run_loader( + "load\nexport INFINITO_DISTRO=centos\nload\n" + "export INFINITO_DISTRO=debian\nload" + ) + self.assertEqual(shown, self.expected["debian"]) + + def test_a_caller_value_for_the_loaded_distro_still_wins(self): + shown = self.run_loader( + "load\nexport INFINITO_PARENT_IMAGE=caller/image:pinned\n" + "touch -d '+1 minute' .env\nload" + ) + self.assertEqual(shown["INFINITO_PARENT_IMAGE"], "caller/image:pinned") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/unit/python/scripts/tests/deploy/test_distros.py b/tests/unit/python/scripts/tests/deploy/test_distros.py index 4b6cb76aee..fd9cc2b499 100644 --- a/tests/unit/python/scripts/tests/deploy/test_distros.py +++ b/tests/unit/python/scripts/tests/deploy/test_distros.py @@ -76,6 +76,17 @@ class TestDistrosLoop(unittest.TestCase): self.assertEqual(proc.returncode, 0, proc.stderr) self.assertEqual(sorted(record.split()), sorted(DISTROS.split())) + def test_every_distro_runs_with_a_parent_image_of_its_own(self) -> None: + proc, record = self._run( + DISTROS, + 'echo "${INFINITO_DISTRO} ${INFINITO_PARENT_IMAGE}" >> "${RECORD}"', + INFINITO_CI_DISTRO_BUDGET_SECONDS="600", + ) + self.assertEqual(proc.returncode, 0, proc.stderr) + images = dict(line.split() for line in record.splitlines()) + self.assertEqual(sorted(images), sorted(DISTROS.split())) + self.assertEqual(len(set(images.values())), len(images), images) + def test_the_command_inherits_the_env_layer(self) -> None: proc, record = self._run( "debian", From 62f31fe675fe35cc8882be72bdf1ef185e12896c Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:32:33 +0200 Subject: [PATCH 02/13] fix(sys-service): judge a unit's result only after a deploy started it The handlers after "Set systemctl service state" read Result and ExecMainStatus and fail the deploy with "Unable to start service ..." when either reports a failure. Most roles leave system_service_state omitted (SYS_SERVICE_DEFAULT_STATE is omit outside MODE_DEBUG, and the backup roles start their unit only in MODE_BACKUP), so the state task changes nothing, and the two properties describe the unit's last run, whenever it was. Measured on a local stack: the volume backup unit had failed on 2026-10-12 in the CLI test of another deploy, when a container it had stopped was recreated before it could start it again. The next day a deploy of web-app-seaweedfs and web-app-prometheus, which did not run the unit, read Result=exit-code and failed in the backup role. The diagnostics now fire on a stale result only when the deploy set a state itself. A failed state change still fails as before. Verified in the stack container against a oneshot unit whose ExecStart is /bin/false, left failed before each run, with the real handler file: with the state omitted, main's handler fails with "Unable to start service" and the new one passes; with state=started, which reruns the unit, both fail. ansible lints and test_comments_valid pass. Closes #914 Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/sys-service/handlers/refresh_systemctl_service.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/sys-service/handlers/refresh_systemctl_service.yml b/roles/sys-service/handlers/refresh_systemctl_service.yml index ac19505e55..6c8fb43bca 100644 --- a/roles/sys-service/handlers/refresh_systemctl_service.yml +++ b/roles/sys-service/handlers/refresh_systemctl_service.yml @@ -53,5 +53,6 @@ Unable to start service {{ system_service_name }}. See shared service diagnostics above. when: - not (system_service_suppress_flush | bool) - - (systemd_set_state.failed | default(false) | bool) or (system_service_result.stdout | default('') | trim) not in ['success', ''] or - (system_service_exec_status.stdout | default('') | trim) not in ['0', ''] + - (systemd_set_state.failed | default(false) | bool) or (system_service_state != omit and ( + (system_service_result.stdout | default('') | trim) not in ['success', ''] or + (system_service_exec_status.stdout | default('') | trim) not in ['0', ''])) From c94193c51ca6e09baca702b3c88f45feae22a176 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:43:11 +0200 Subject: [PATCH 03/13] fix(web-app-bluesky): move the PDS to 0.4.66 so AppView proxy calls carry lxm PDS 0.4.0 (@atproto/pds 0.4.0-beta.7) signs the service-auth JWT it attaches to proxied app.bsky.* calls with iss, aud and exp only (createServiceJwt in dist/index.js of the image). The AppView requires the lxm claim and rejects every such call with 401 BadJwtLexiconMethod, so social-app shows errorMessageView on Following and Notifications. 0.4.66 passes the called method as lxm into every service JWT it signs and sends every proxied call through the SSRF-guarded proxy agent. 0.4.66 also replaces the whole-handle limit of 0.4.0 (30 characters for the entire handle) with a limit of 18 on the part in front of the service domain, so kc-administrator. passes for any domain length, including kc-administrator.infinito.nexus (31). - meta/services.yml: pin ghcr.io/bluesky-social/pds to 0.4.66. - vars/main.yml: the public AppView URL is always https. Onion-primary deployments took the protocol from the local TLS setting and sent the service JWT to api.bsky.app over plain http. services.view.enabled is evaluated as a bool. - templates/env.j2: drop PDS_ADMIN_EMAIL, which neither 0.4.0 nor 0.4.66 reads. PDS_CONTACT_EMAIL_ADDRESS stays unset on purpose: describeServer would publish the administrator's address. - Administration.md: the account database only migrates forward; a rollback restores the bluesky_pds_data backup together with the old pin. - Playwright: the broker login moves into _shared.js and waits for a landing outside /oauth2/, because the bare base URL also matches the intermediate /oauth2/callback hop. New scenarios check that the PDS proxies getTimeline and listNotifications to the AppView with a JWT it accepts, for the broker session (OIDC) and for a native session (oauth2 disabled), and that social-app renders Following and Notifications without errorMessageView or lxm page errors. The rendering scenario is clearnet only: social-app boots only after loading its age-assurance config from public.api.bsky.app. Merge note for feature/store-i18n: 19b491b014 raises the pin to 0.4.21 and renames the contact-mail line to PDS_CONTACT_EMAIL_ADDRESS. Resolve the pin to 0.4.66 (0.4.21 still signs without lxm, and the account database cannot migrate back) and keep the line deleted. Take the union of both sides in _shared.js and playwright.spec.js. Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-bluesky/Administration.md | 20 ++- .../files/playwright/_appview.js | 133 ++++++++++++++++++ .../files/playwright/_shared.js | 33 +++++ .../files/playwright/playwright.spec.js | 3 + .../files/playwright/test-appview-native.js | 25 ++++ .../files/playwright/test-appview-oidc-api.js | 14 ++ .../playwright/test-appview-oidc-render.js | 58 ++++++++ .../playwright/test-oidc-broker-handoff.js | 41 +----- roles/web-app-bluesky/meta/services.yml | 2 +- roles/web-app-bluesky/templates/env.j2 | 1 - roles/web-app-bluesky/vars/main.yml | 4 +- 11 files changed, 285 insertions(+), 49 deletions(-) create mode 100644 roles/web-app-bluesky/files/playwright/_appview.js create mode 100644 roles/web-app-bluesky/files/playwright/test-appview-native.js create mode 100644 roles/web-app-bluesky/files/playwright/test-appview-oidc-api.js create mode 100644 roles/web-app-bluesky/files/playwright/test-appview-oidc-render.js diff --git a/roles/web-app-bluesky/Administration.md b/roles/web-app-bluesky/Administration.md index 2f5829d46d..a610f909dd 100644 --- a/roles/web-app-bluesky/Administration.md +++ b/roles/web-app-bluesky/Administration.md @@ -1,10 +1,10 @@ # Administration -## create user via POST +## Create a user via POST ```bash curl -X POST https://your-pds-domain/xrpc/com.atproto.server.createAccount \ - --user "admin:$admin-password" + --user "admin:${PDS_ADMIN_PASSWORD}" \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com", @@ -16,13 +16,23 @@ curl -X POST https://your-pds-domain/xrpc/com.atproto.server.createAccount \ ## Use pdsadmin +```bash compose exec -it pds pdsadmin - compose exec -it pds pdsadmin account create-invite-code +``` + +## Roll back the PDS image + +The PDS migrates its account database forward when it starts. An older image refuses a database that a newer image has migrated and stops with `corrupted migrations: previously executed migration ... is missing`. + +- You MUST NOT lower `services.pds.version` on its own. +- To roll back, you MUST restore the `bluesky_pds_data` volume from the backup generation taken before the update and pin the old version in the same step. Follow [A single volume](../svc-bkp-volume-2-local/README.md#a-single-volume) for the restore. +- That backup generation exists only when `svc-bkp-volume-2-local` is deployed and `MODE_BACKUP` is enabled. +- The restore discards everything the PDS stored after the update. ## Debugging -- Websocket: [piehost.com/websocket-tester](https://piehost.com/websocket-tester) +- Websocket: [piehost.com](https://piehost.com/websocket-tester) - Instance: [bsky-debug.app](https://bsky-debug.app) -Initial setup keine top level domain +Initial setup: no top-level domain. diff --git a/roles/web-app-bluesky/files/playwright/_appview.js b/roles/web-app-bluesky/files/playwright/_appview.js new file mode 100644 index 0000000000..d5e89d07e9 --- /dev/null +++ b/roles/web-app-bluesky/files/playwright/_appview.js @@ -0,0 +1,133 @@ +const { expect } = require("@playwright/test"); +const { resolveTimeout } = require("./timeouts"); +const { apiFetchOnion, apiGetOnion } = require("./personas"); + +const LXM_PATTERN = /lxm|lexicon method/i; +const PROXIED_METHODS = ["app.bsky.feed.getTimeline", "app.bsky.notification.listNotifications"]; +const PERSONAL_DETAILS = "app.bsky.actor.defs#personalDetailsPref"; +const ADULT_BIRTHDATE = "1990-01-01"; + +async function expectPdsProxiesAppView(request, pdsBaseUrl, accessJwt) { + for (const nsid of PROXIED_METHODS) { + const response = await apiGetOnion(request, `${pdsBaseUrl}/xrpc/${nsid}`, { + headers: { authorization: `Bearer ${accessJwt}` }, + timeout: resolveTimeout(30_000), + }); + const body = await response.text(); + expect( + response.status(), + `PDS must proxy ${nsid} to PDS_BSKY_APP_VIEW_URL with a service JWT the AppView accepts (got body: ${body})`, + ).toBe(200); + } +} + +async function brokerAccessJwt(page) { + let accessJwt = ""; + await expect + .poll( + async () => { + accessJwt = await page + .evaluate(() => JSON.parse(localStorage.getItem("BSKY_STORAGE") || "{}").session?.currentAccount?.accessJwt || "") + .catch(() => ""); + return accessJwt; + }, + { timeout: resolveTimeout(60_000), message: "broker handoff left no accessJwt in BSKY_STORAGE" }, + ) + .not.toBe(""); + return accessJwt; +} + +async function readPreferences(request, pdsBaseUrl, accessJwt) { + const response = await apiGetOnion(request, `${pdsBaseUrl}/xrpc/app.bsky.actor.getPreferences`, { + headers: { authorization: `Bearer ${accessJwt}` }, + timeout: resolveTimeout(30_000), + }); + expect(response.status(), `PDS getPreferences must return 200 (got body: ${await response.text()})`).toBe(200); + return (await response.json()).preferences; +} + +async function restorePreferences(request, pdsBaseUrl, accessJwt, preferences) { + if (preferences.some((entry) => entry.$type === PERSONAL_DETAILS && entry.birthDate)) return; + const restore = apiFetchOnion(request, `${pdsBaseUrl}/xrpc/app.bsky.actor.putPreferences`, { + method: "POST", + headers: { authorization: `Bearer ${accessJwt}`, "content-type": "application/json" }, + data: { preferences }, + timeout: resolveTimeout(30_000), + }).then((response) => { + if (response.status() !== 200) throw new Error(`putPreferences answered ${response.status()}`); + }); + const deadline = new Promise((_, reject) => { + setTimeout(() => reject(new Error("putPreferences timed out")), resolveTimeout(45_000)); + }); + await Promise.race([restore, deadline]).catch((err) => console.warn(`bluesky: preferences not restored: ${err.message}`)); +} + +function collectAppViewResponses(page) { + const seen = []; + page.on("response", (response) => { + const { pathname } = new URL(response.url()); + if (!pathname.startsWith("/xrpc/app.bsky.") || response.request().method() !== "GET") return; + const status = response.status(); + seen.push({ + nsid: pathname.slice("/xrpc/".length), + status, + body: status === 200 ? Promise.resolve("") : response.text().catch((err) => ``), + }); + }); + return seen; +} + +async function waitForResponseTo(seen, nsid, from = 0) { + await expect + .poll(() => seen.slice(from).some((entry) => entry.nsid === nsid), { + timeout: resolveTimeout(60_000), + message: `social-app never requested ${nsid}`, + }) + .toBe(true); +} + +async function expectNoFailures(seen, nsid) { + const failed = seen.filter((entry) => entry.nsid === nsid && entry.status !== 200); + expect( + await Promise.all(failed.map(async (entry) => `${entry.status} ${await entry.body}`)), + `PDS must proxy ${nsid} to the AppView with a service JWT the AppView accepts`, + ).toEqual([]); +} + +async function expectNoLxmRejections(seen, pageErrors) { + const lines = await Promise.all(seen.map(async (entry) => `${entry.nsid} ${entry.status} ${await entry.body}`)); + expect( + lines.filter((line) => LXM_PATTERN.test(line)), + "no AppView call may be rejected for a missing lxm claim", + ).toEqual([]); + expect( + pageErrors.filter((message) => LXM_PATTERN.test(message)), + "social-app must not raise lxm page errors after login", + ).toEqual([]); +} + +async function reachFollowingFeed(page) { + const home = page.getByTestId("followingFeedPage"); + const birthdateGate = page.getByRole("button", { name: "Click here to update your birthdate" }).first(); + await expect(async () => { + if (await birthdateGate.isVisible()) { + await birthdateGate.click(); + const dialog = page.getByTestId("birthDateSettingsDialog"); + await dialog.getByTestId("birthdayInput").fill(ADULT_BIRTHDATE); + await dialog.getByRole("button", { name: "Save birthdate" }).click(); + } + await expect(home).toBeVisible({ timeout: resolveTimeout(5_000) }); + }).toPass({ timeout: resolveTimeout(120_000) }); +} + +module.exports = { + brokerAccessJwt, + collectAppViewResponses, + expectNoFailures, + expectNoLxmRejections, + expectPdsProxiesAppView, + reachFollowingFeed, + readPreferences, + restorePreferences, + waitForResponseTo, +}; diff --git a/roles/web-app-bluesky/files/playwright/_shared.js b/roles/web-app-bluesky/files/playwright/_shared.js index c8e0b6698f..a771f91692 100644 --- a/roles/web-app-bluesky/files/playwright/_shared.js +++ b/roles/web-app-bluesky/files/playwright/_shared.js @@ -1,7 +1,9 @@ const { expect } = require("@playwright/test"); const { skipUnlessServiceEnabled } = require("./service-gating"); +const { resolveTimeout } = require("./timeouts"); const { decodeDotenvQuotedValue, + gotoOnion, normalizeBaseUrl, performKeycloakLoginForm, runAdminFlow, @@ -23,6 +25,36 @@ async function beforeEach({ page }) { await page.context().clearCookies(); } +async function loginThroughBroker(page) { + expect(adminUsername, "ADMIN_USERNAME must be set when OIDC is enabled").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set when OIDC is enabled").toBeTruthy(); + expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set when OIDC is enabled").toBeTruthy(); + + const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; + const expectedBaseUrl = baseUrl.replace(/\/$/, ""); + + await gotoOnion(page, `${expectedBaseUrl}/`); + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(60_000), + message: `expected redirect to Keycloak OIDC auth (${expectedOidcAuthUrl})`, + }) + .toContain(expectedOidcAuthUrl); + + await performKeycloakLoginForm(page, adminUsername, adminPassword); + + await expect + .poll(() => page.url(), { + timeout: resolveTimeout(90_000), + message: `expected post-OIDC URL to land on Bluesky outside /oauth2/* (got: ${page.url()})`, + }) + .toMatch(new RegExp(`^${expectedBaseUrl.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/(?!oauth2/)`)); + + await page.waitForLoadState("networkidle", { timeout: resolveTimeout(30_000) }).catch(() => {}); + await expect(page.locator("body")).toBeVisible({ timeout: resolveTimeout(60_000) }); +} + module.exports = { env: { baseUrl, @@ -34,6 +66,7 @@ module.exports = { pdsBaseUrl, }, skipUnlessServiceEnabled, + loginThroughBroker, performKeycloakLoginForm, runAdminFlow, runBiberFlow, diff --git a/roles/web-app-bluesky/files/playwright/playwright.spec.js b/roles/web-app-bluesky/files/playwright/playwright.spec.js index 3aef5c3604..419d563f3e 100644 --- a/roles/web-app-bluesky/files/playwright/playwright.spec.js +++ b/roles/web-app-bluesky/files/playwright/playwright.spec.js @@ -8,6 +8,9 @@ test.beforeEach(shared.beforeEach); require("./test-baseline").register(shared); require("./test-oidc-broker-handoff").register(shared); +require("./test-appview-oidc-api").register(shared); +require("./test-appview-oidc-render").register(shared); +require("./test-appview-native").register(shared); require("./test-native-admin").register(shared); require("./test-guest-persona").register(shared); require("./test-biber-persona").register(shared); diff --git a/roles/web-app-bluesky/files/playwright/test-appview-native.js b/roles/web-app-bluesky/files/playwright/test-appview-native.js new file mode 100644 index 0000000000..17e944015a --- /dev/null +++ b/roles/web-app-bluesky/files/playwright/test-appview-native.js @@ -0,0 +1,25 @@ +const { test, expect } = require("@playwright/test"); +const { resolveTimeout } = require("./timeouts"); +const { apiFetchOnion } = require("./personas"); +const { skipUnlessServiceDisabled } = require("./service-gating"); +const { expectPdsProxiesAppView } = require("./_appview"); + +exports.register = function (shared) { + test("native: PDS proxies Following and Notifications to its configured AppView with an lxm-bound service JWT (no oauth2)", async ({ page }) => { + skipUnlessServiceDisabled("sso"); + const { adminHandle, adminPassword, pdsBaseUrl } = shared.env; + expect(adminHandle, "ADMIN_HANDLE must be set when oauth2 is disabled").toBeTruthy(); + expect(adminPassword, "ADMIN_PASSWORD must be set when oauth2 is disabled").toBeTruthy(); + expect(pdsBaseUrl, "PDS_BASE_URL must be set when oauth2 is disabled").toBeTruthy(); + + const session = await apiFetchOnion(page.request, `${pdsBaseUrl}/xrpc/com.atproto.server.createSession`, { + method: "POST", + data: { identifier: adminHandle, password: adminPassword }, + timeout: resolveTimeout(30_000), + }); + expect(session.status(), `PDS createSession must return 200 (got body: ${await session.text()})`).toBe(200); + const { accessJwt } = await session.json(); + + await expectPdsProxiesAppView(page.request, pdsBaseUrl, accessJwt); + }); +}; diff --git a/roles/web-app-bluesky/files/playwright/test-appview-oidc-api.js b/roles/web-app-bluesky/files/playwright/test-appview-oidc-api.js new file mode 100644 index 0000000000..91ab38ec50 --- /dev/null +++ b/roles/web-app-bluesky/files/playwright/test-appview-oidc-api.js @@ -0,0 +1,14 @@ +const { test } = require("@playwright/test"); +const { resolveTimeout } = require("./timeouts"); +const { brokerAccessJwt, expectPdsProxiesAppView } = require("./_appview"); + +exports.register = function (shared) { + test("OIDC: PDS proxies Following and Notifications to the AppView for the broker session", async ({ page }) => { + shared.skipUnlessServiceEnabled("sso"); + test.setTimeout(resolveTimeout(480_000)); + + await shared.loginThroughBroker(page); + const accessJwt = await brokerAccessJwt(page); + await expectPdsProxiesAppView(page.request, shared.env.pdsBaseUrl, accessJwt); + }); +}; diff --git a/roles/web-app-bluesky/files/playwright/test-appview-oidc-render.js b/roles/web-app-bluesky/files/playwright/test-appview-oidc-render.js new file mode 100644 index 0000000000..c87c96954e --- /dev/null +++ b/roles/web-app-bluesky/files/playwright/test-appview-oidc-render.js @@ -0,0 +1,58 @@ +const { test, expect } = require("@playwright/test"); +const { isOnionTarget, resolveTimeout } = require("./timeouts"); +const { gotoOnion } = require("./personas"); +const { + brokerAccessJwt, + collectAppViewResponses, + expectNoFailures, + expectNoLxmRejections, + reachFollowingFeed, + readPreferences, + restorePreferences, + waitForResponseTo, +} = require("./_appview"); + +exports.register = function (shared) { + test("OIDC: social-app renders Following and Notifications without errorMessageView or lxm page errors", async ({ page }) => { + shared.skipUnlessServiceEnabled("sso"); + test.skip( + isOnionTarget(), + "social-app only boots after loading its age-assurance config from public.api.bsky.app, which a Tor-routed test browser cannot reliably reach", + ); + test.setTimeout(resolveTimeout(900_000)); + + const pageErrors = []; + page.on("pageerror", (err) => pageErrors.push(err.message)); + const seen = collectAppViewResponses(page); + const { pdsBaseUrl } = shared.env; + + await shared.loginThroughBroker(page); + const accessJwt = await brokerAccessJwt(page); + const preferences = await readPreferences(page.request, pdsBaseUrl, accessJwt); + try { + await waitForResponseTo(seen, "app.bsky.notification.listNotifications"); + await expectNoLxmRejections(seen, pageErrors); + + await reachFollowingFeed(page); + await waitForResponseTo(seen, "app.bsky.feed.getTimeline"); + await expectNoFailures(seen, "app.bsky.feed.getTimeline"); + const following = page.getByTestId("followingFeedPage"); + await expect(following.locator('[data-testid^="feedItem-by-"]').or(following.getByTestId("errorMessageView")).first()).toBeVisible({ + timeout: resolveTimeout(60_000), + }); + await expect(following.getByTestId("errorMessageView"), "Following must render without an errorMessageView").toHaveCount(0); + + const notificationsFrom = seen.length; + await gotoOnion(page, `${shared.env.baseUrl}/notifications`); + const notifications = page.getByTestId("notificationsScreen"); + await expect(notifications).toBeVisible({ timeout: resolveTimeout(60_000) }); + await waitForResponseTo(seen, "app.bsky.notification.listNotifications", notificationsFrom); + await expectNoFailures(seen, "app.bsky.notification.listNotifications"); + await expect(notifications.getByTestId("errorMessageView"), "Notifications must render without an errorMessageView").toHaveCount(0); + + await expectNoLxmRejections(seen, pageErrors); + } finally { + await restorePreferences(page.request, pdsBaseUrl, accessJwt, preferences); + } + }); +}; diff --git a/roles/web-app-bluesky/files/playwright/test-oidc-broker-handoff.js b/roles/web-app-bluesky/files/playwright/test-oidc-broker-handoff.js index eb819c61eb..e7af8f9962 100644 --- a/roles/web-app-bluesky/files/playwright/test-oidc-broker-handoff.js +++ b/roles/web-app-bluesky/files/playwright/test-oidc-broker-handoff.js @@ -1,6 +1,4 @@ const { test, expect } = require("@playwright/test"); -const { resolveTimeout } = require("./timeouts"); -const { gotoOnion } = require("./personas"); exports.register = function (shared) { test("OIDC: oauth2-proxy + login-broker drop a Bluesky session into social-app via Keycloak (variant A+)", async ({ page }) => { @@ -18,44 +16,7 @@ exports.register = function (shared) { // without ever showing the synthesised app-password to the // browser. shared.skipUnlessServiceEnabled("sso"); - const { baseUrl, oidcIssuerUrl, adminUsername, adminPassword } = shared.env; - expect(adminUsername, "ADMIN_USERNAME must be set when OIDC is enabled").toBeTruthy(); - expect(adminPassword, "ADMIN_PASSWORD must be set when OIDC is enabled").toBeTruthy(); - expect(oidcIssuerUrl, "OIDC_ISSUER_URL must be set when OIDC is enabled").toBeTruthy(); - - const expectedOidcAuthUrl = `${oidcIssuerUrl}/protocol/openid-connect/auth`; - const expectedBaseUrl = baseUrl.replace(/\/$/, ""); - - await gotoOnion(page, `${expectedBaseUrl}/`); - - await expect - .poll(() => page.url(), { - timeout: resolveTimeout(60_000), - message: `expected redirect to Keycloak OIDC auth (${expectedOidcAuthUrl})`, - }) - .toContain(expectedOidcAuthUrl); - - await shared.performKeycloakLoginForm(page, adminUsername, adminPassword); - - // Wait for the post-OIDC redirect chain to settle. After Keycloak - // accepts the credentials, the browser bounces through - // /oauth2/callback → / → broker handoff → social-app - // and we want the URL to come to rest on the Bluesky base URL — - // NOT on an `/oauth2/*` path. The `expect.poll` form alone matches - // any URL containing the base, including the intermediate - // `/oauth2/start` redirect, so we additionally pin the path to - // not be under `/oauth2/`. - await expect - .poll(() => page.url(), { - timeout: resolveTimeout(90_000), - message: `expected post-OIDC URL to land on Bluesky outside /oauth2/* (got: ${page.url()})`, - }) - .toMatch(new RegExp(`^${expectedBaseUrl.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/(?!oauth2/)`)); - - // Wait for the network to settle so the broker's handoff JS can - // commit localStorage + cookie before we inspect them. - await page.waitForLoadState("networkidle", { timeout: resolveTimeout(30_000) }).catch(() => {}); - await expect(page.locator("body")).toBeVisible({ timeout: resolveTimeout(60_000) }); + await shared.loginThroughBroker(page); // The broker writes a schema-compliant `BSKY_STORAGE` payload // built from upstream `social-app@1.121.0`'s persisted defaults diff --git a/roles/web-app-bluesky/meta/services.yml b/roles/web-app-bluesky/meta/services.yml index c4d80283b4..0c91d3cb3a 100644 --- a/roles/web-app-bluesky/meta/services.yml +++ b/roles/web-app-bluesky/meta/services.yml @@ -75,7 +75,7 @@ view: pids_limit: 256 pds: image: ghcr.io/bluesky-social/pds - version: 0.4.0 + version: 0.4.66 min_storage: 290MB cpus: "1.0" mem_reservation: 1g diff --git a/roles/web-app-bluesky/templates/env.j2 b/roles/web-app-bluesky/templates/env.j2 index 8716c7d9c0..e0a1050b73 100644 --- a/roles/web-app-bluesky/templates/env.j2 +++ b/roles/web-app-bluesky/templates/env.j2 @@ -15,7 +15,6 @@ PDS_SERVICE_DID=did:web:{{ BLUESKY_API_DOMAIN }} {% set email = lookup('email', application_id) %} {% if email.enabled | bool %} -PDS_ADMIN_EMAIL={{ BLUESKY_ADMIN_EMAIL }} PDS_EMAIL_SMTP_URL=smtps://{{ email.username }}:{{ email.password }}@{{ email.host }}:{{ email.port }}/ PDS_EMAIL_FROM_ADDRESS={{ email['from'] }} {% endif %} diff --git a/roles/web-app-bluesky/vars/main.yml b/roles/web-app-bluesky/vars/main.yml index 6194dfd414..32a4c59fb8 100644 --- a/roles/web-app-bluesky/vars/main.yml +++ b/roles/web-app-bluesky/vars/main.yml @@ -20,8 +20,8 @@ BLUESKY_WEB_IMAGE_CUSTOM: "bluesky_web_custom" BLUESKY_VIEW_ENABLED: "{{ lookup('config', application_id, 'services.view.enabled') }}" BLUESKY_VIEW_DOMAIN_LOCAL: "{{ lookup('domains', application_id).view }}" -BLUESKY_VIEW_DOMAIN_FINAL: "{{ BLUESKY_VIEW_DOMAIN_LOCAL if BLUESKY_VIEW_ENABLED else 'api.bsky.app' }}" -BLUESKY_VIEW_URL: "{{ lookup('tls', application_id, 'protocols.web') }}://{{ BLUESKY_VIEW_DOMAIN_FINAL }}" +BLUESKY_VIEW_DOMAIN_FINAL: "{{ BLUESKY_VIEW_DOMAIN_LOCAL if BLUESKY_VIEW_ENABLED | bool else 'api.bsky.app' }}" +BLUESKY_VIEW_URL: "{{ lookup('tls', application_id, 'protocols.web') if BLUESKY_VIEW_ENABLED | bool else 'https' }}://{{ BLUESKY_VIEW_DOMAIN_FINAL }}" BLUESKY_VIEW_DID: "did:web:{{ BLUESKY_VIEW_DOMAIN_FINAL }}" BLUESKY_VIEW_PORT: "{{ lookup('config', 'web-app-bluesky', 'services.view.ports.local.http') }}" From 3fff830b9c19c2d47f4c8ab6209182192c61a31d Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:57:20 +0200 Subject: [PATCH 04/13] feat(skills): add i8-cleanup on top of the portable cleanup skill Routes disk and /tmp cleanup through the cleanup skill and adds the repository rules: compose-project attribution, the shared cache stack that is never a candidate, act and swarm keep rules, teardown targets with what each destroys, and the targets that must never run as a cleanup step. Listed in the agent cheatsheet. Co-Authored-By: Claude Opus 5.5 (1M context) --- docs/contributing/tools/agents/cheatsheet.md | 1 + skills/i8-cleanup/SKILL.md | 76 ++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 skills/i8-cleanup/SKILL.md diff --git a/docs/contributing/tools/agents/cheatsheet.md b/docs/contributing/tools/agents/cheatsheet.md index 9ebae273cd..1233c92a11 100644 --- a/docs/contributing/tools/agents/cheatsheet.md +++ b/docs/contributing/tools/agents/cheatsheet.md @@ -29,6 +29,7 @@ from its procedure file. Run `make install-skills` to (re)install them. | Cleaning up code, docs, or roles after a change | `i8-refactor` | | Checking a branch out into a parallel worktree | `i8-worktree-create` | | Releasing a parallel worktree and its slot | `i8-worktree-down` | +| Freeing disk space and `/tmp` that agents filled | `i8-cleanup` | | A GitHub Actions / CI run failed and needs triage | `triage` | | A local deploy is failing on the host | `i8-debug-local` | | Inspecting a `*.log` or `*job-logs.txt` file dropped in the workdir | `i8-debug-log` | diff --git a/skills/i8-cleanup/SKILL.md b/skills/i8-cleanup/SKILL.md new file mode 100644 index 0000000000..0fc2fb1c3b --- /dev/null +++ b/skills/i8-cleanup/SKILL.md @@ -0,0 +1,76 @@ +--- +name: i8-cleanup +description: > + Free the disk space and /tmp that agents filled on an Infinito.Nexus host: + run the portable `cleanup` skill and apply this repository's rules for + stacks, worktrees, images, shared caches and teardown targets on top of it. + Trigger on /i8-cleanup or when the operator asks to clean up after agents in + this repository. Infinito.Nexus specific. +--- + +Follow the instructions from AGENTS.md, then run the `cleanup` skill (installed +by `make install-skills`) and apply the rules below on top of it; where a rule +here is stricter, it wins. This skill never runs under the `robot` skill. + +## Attribution + +- **Stacks**: group containers, volumes and networks by their + `com.docker.compose.project` label and map each project to its worktree with + `git worktree list`. A stack consists of the DinD container, its `-coredns` + sidecar, the volumes `_docker` (the nested Docker of the whole + deployment), `_infinito`, `_letsencrypt`, the network + `_default` and the image `/debian:latest`. +- **Orphaned images**: a `/debian:latest` whose worktree no longer + exists has no owner. +- **Shared cache stack**, claimed by every session and never a candidate: + `infinito-registry-cache`, `infinito-package-cache`, + `infinito-package-cache-frontend`, `infinito-coredns`, the network + `infinito-nexus-core_default` and `/var/cache/infinito/core/cache`. +- **Act and swarm**: `local/act-runner-fixed:latest`, + `infinito-swarm-node:latest`, the volume `act-toolcache` and `~/.cache/act` + stay while any peer runs a swarm step or a roundtrip. +- **`infinito-i18n-libretranslate`**: model weights; downloading them again + needs an `allowed_domains` entry. High risk. +- **/tmp**: deploy and gate logs follow `/tmp/-.log`. A log whose name + contains a role name can be requirement evidence; it stays unless its + session releases it. Session scratch lives under + `/tmp/claude-///`. +- **Archive duties**: before deleting a scratchpad, grep the memory directory + for its name and for `archiv`. The designer generator dirs + (`scratchpad/cssmap/`) go to `refs/backup/designer/tools/` first. + +## Teardown and delete paths + +| Target | Command | Destroys | +| ------ | ------- | -------- | +| Stack of a worktree | `make -C compose-down` | containers and volumes including `_docker`; the next deploy needs `mode=initialize` | +| Stack, checkout and slot | `make worktree-down branch=` | as above plus the checkout; refuses uncommitted changes | +| One app inside a stack | `make -C compose-entity-purge apps=` | the app's containers, volumes and inventory group; the output must name `removed '' from inventory` | +| One swarm cluster | `make swarm-down name=` | its DinD nodes, lab network and act outer container | +| Every act-swarm leftover | `make swarm-clean` | all clusters including in-flight runs; only when no peer runs a swarm step | +| Container-owned files in a checkout | `make -C clean-container-owned` or `make -C compose-exec cmd='rm -rf '` | the named paths | +| The dev container's own `/tmp` (tmpfs) | `make compose-exec cmd='df -h /tmp'`, then `make compose-exec cmd='rm -rf /tmp/playwright-transform-cache-0'` | the Playwright transform cache | + +- Run `compose-down`, `compose-entity-purge` and `worktree-down` for another + worktree with the inherited `INFINITO_*` variables stripped: + `env $(printenv | grep -o -E '^INFINITO_[A-Z0-9_]+' | sed 's/^/-u /') make ...`. +- A worktree that ran a container gate keeps container-owned files: remove + them from inside it with `make compose-exec` before `make worktree-down`. +- After removing `/debian` images, offer + `docker builder prune --filter until=24h`; their layers stay in the build + cache until then. +- When the classifier refuses a purge or teardown, report the exact `make` + command to the operator. + +## Never + +- `make system-purge`: runs `docker compose down --volumes` and + `docker system prune -a --volumes` across every stack. +- `make clean-cache`: wipes `/var/cache/infinito/core/cache` and stops the + cache containers every deploy builds through. +- `make worktree-prune` as a cleanup step: it also drops detached-HEAD + registrations whose commits may be reachable only through them. + +Begin by clarifying every open requirement with the `active-listening` skill. +The task is finished when the `cleanup` report shows the before and after sizes +and every peer that answered has been told what was removed near its items. From 1d970fe5bd611f538f721fc83b0337e2505e23fe Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 01:32:24 +0200 Subject: [PATCH 05/13] fix(env): keep shellcheck and the cache-read lint green on the distro switch The loader copies INFINITO_DISTRO into a loader-local variable before it compares the value with the one in .env. With INFINITO_DISTRO read directly in that condition, `shellcheck -x scripts/meta/resolve/apps.sh` reported SC2153 for INFINITO_DISTROS, which apps.sh takes from the sourced .env; with the copy it reports nothing, as on main. The loader test checks that .env is unchanged with filecmp against the file it was copied from, instead of reading it twice with Path.read_bytes, which test_no_uncached_file_reads rejects. Co-Authored-By: Claude Opus 5.5 (1M context) --- scripts/meta/env/load.sh | 5 +++-- tests/unit/python/scripts/meta/env/test_load.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/meta/env/load.sh b/scripts/meta/env/load.sh index 1de27c5e2b..dfb67daf3a 100755 --- a/scripts/meta/env/load.sh +++ b/scripts/meta/env/load.sh @@ -62,7 +62,8 @@ fi _infinito_env_source="${_infinito_env_dotenv}" _infinito_env_scratch="" -if [[ -f "${_infinito_env_dotenv}" && -n "${INFINITO_DISTRO:-}" && "${INFINITO_DISTRO}" != "$(sed -n 's/^INFINITO_DISTRO=//p' "${_infinito_env_dotenv}")" ]]; then +_infinito_env_distro="${INFINITO_DISTRO:-}" +if [[ -f "${_infinito_env_dotenv}" && -n "${_infinito_env_distro}" && "${_infinito_env_distro}" != "$(sed -n 's/^INFINITO_DISTRO=//p' "${_infinito_env_dotenv}")" ]]; then _infinito_env_scratch="$(mktemp -d)" _infinito_env_source="${_infinito_env_scratch}/env" fi @@ -98,7 +99,7 @@ set +a if [[ -n "${_infinito_env_scratch}" ]]; then rm -rf "${_infinito_env_scratch}" fi -unset _infinito_env_source _infinito_env_scratch +unset _infinito_env_source _infinito_env_scratch _infinito_env_distro for _infinito_env_key in "${!_infinito_env_preserved[@]}"; do declare -gx "${_infinito_env_key}=${_infinito_env_preserved[${_infinito_env_key}]}" diff --git a/tests/unit/python/scripts/meta/env/test_load.py b/tests/unit/python/scripts/meta/env/test_load.py index af61434b78..1fa719719d 100644 --- a/tests/unit/python/scripts/meta/env/test_load.py +++ b/tests/unit/python/scripts/meta/env/test_load.py @@ -8,6 +8,7 @@ stay as it was. from __future__ import annotations +import filecmp import os import shutil import subprocess @@ -93,9 +94,13 @@ class TestDistroDerivedKeys(unittest.TestCase): shutil.copy(LOADER_DIR / name, checkout / "scripts" / "meta" / "env") dotenv = checkout / ".env" shutil.copy(self.scratch / "debian.env", dotenv) - before = dotenv.read_bytes() - shown = bash(f"load() {{ source scripts/meta/env/load.sh; }}\n{steps}", checkout) - self.assertEqual(dotenv.read_bytes(), before, ".env was rewritten") + shown = bash( + f"load() {{ source scripts/meta/env/load.sh; }}\n{steps}", checkout + ) + self.assertTrue( + filecmp.cmp(dotenv, self.scratch / "debian.env", shallow=False), + ".env was rewritten", + ) return shown def test_the_two_distros_derive_different_keys(self): From ee8d2bd983ddef7a399e2eb79695c4f8ce189b70 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 01:32:24 +0200 Subject: [PATCH 06/13] test(env): check each distro's parent image against its own reference The loop test only required three different parent images for three distros, which a swap between two of them would still pass. Each iteration now also records the owner and tag it sees, and its image must equal pkgmgr_image(distro, owner, tag). With the loader of main the test fails on arch with pkgmgr-debian:stable. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../unit/python/scripts/tests/deploy/test_distros.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/unit/python/scripts/tests/deploy/test_distros.py b/tests/unit/python/scripts/tests/deploy/test_distros.py index fd9cc2b499..80c4d7903f 100644 --- a/tests/unit/python/scripts/tests/deploy/test_distros.py +++ b/tests/unit/python/scripts/tests/deploy/test_distros.py @@ -20,6 +20,7 @@ import unittest from pathlib import Path from utils.cache.files import PROJECT_ROOT, read_text +from utils.distros import pkgmgr_image from utils.env.parser import parse_static_env LOOP = PROJECT_ROOT / "scripts" / "tests" / "deploy" / "distros.sh" @@ -79,13 +80,15 @@ class TestDistrosLoop(unittest.TestCase): def test_every_distro_runs_with_a_parent_image_of_its_own(self) -> None: proc, record = self._run( DISTROS, - 'echo "${INFINITO_DISTRO} ${INFINITO_PARENT_IMAGE}" >> "${RECORD}"', + 'echo "${INFINITO_DISTRO} ${INFINITO_PARENT_IMAGE}' + ' ${INFINITO_PARENT_IMAGE_OWNER} ${INFINITO_PARENT_IMAGE_TAG}" >> "${RECORD}"', INFINITO_CI_DISTRO_BUDGET_SECONDS="600", ) self.assertEqual(proc.returncode, 0, proc.stderr) - images = dict(line.split() for line in record.splitlines()) - self.assertEqual(sorted(images), sorted(DISTROS.split())) - self.assertEqual(len(set(images.values())), len(images), images) + rows = [line.split() for line in record.splitlines()] + self.assertEqual(sorted(row[0] for row in rows), sorted(DISTROS.split())) + for distro, image, owner, tag in rows: + self.assertEqual(image, pkgmgr_image(distro, owner=owner, tag=tag)) def test_the_command_inherits_the_env_layer(self) -> None: proc, record = self._run( From 46373c1ba32bdfd39d36c096373ff620dabf980e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 13:50:07 +0200 Subject: [PATCH 07/13] fix(act): remove only the own worktree's act containers down_act_outer.sh removed every container named act-*, so starting or releasing a swarm drill in one worktree killed the act container of a drill another worktree had running. workflow.sh now labels act's job containers with infinito.worktree=${INFINITO_CONTAINER} through the default ACT_CONTAINER_OPTIONS, and down_act_outer.sh removes only containers carrying the own label. Both scripts refuse to run without INFINITO_CONTAINER, so the filter never widens to every act container; make exports BASH_ENV, which loads it from .env. Worktrees without a custom.env share the default container name and therefore still share one label among themselves. Closes #933 Co-Authored-By: Claude Opus 5.5 (1M context) --- scripts/tests/deploy/act/down_act_outer.sh | 7 +- scripts/tests/deploy/act/workflow.sh | 3 +- .../scripts/tests/deploy/act/__init__.py | 0 .../tests/deploy/act/test_down_act_outer.py | 74 +++++++++++++++++++ 4 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 tests/unit/python/scripts/tests/deploy/act/__init__.py create mode 100644 tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py diff --git a/scripts/tests/deploy/act/down_act_outer.sh b/scripts/tests/deploy/act/down_act_outer.sh index af792d57f2..f8d0340ae2 100755 --- a/scripts/tests/deploy/act/down_act_outer.sh +++ b/scripts/tests/deploy/act/down_act_outer.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash set +e -# Match act's outer-runner name prefix, not the image: ACT_PLATFORM_IMAGE varies the ancestor. -ids="$(docker ps -aq --filter "name=^act-")" +: "${INFINITO_CONTAINER:?INFINITO_CONTAINER is not set; source scripts/meta/env/load.sh or invoke via make}" + +ids="$(docker ps -aq --filter "name=^act-" --filter "label=infinito.worktree=${INFINITO_CONTAINER}")" if [ -n "${ids}" ]; then - echo "→ removing act outer container(s): ${ids}" + echo "→ removing act outer container(s) of ${INFINITO_CONTAINER}: ${ids}" # shellcheck disable=SC2086 docker rm -f ${ids} >/dev/null 2>&1 else diff --git a/scripts/tests/deploy/act/workflow.sh b/scripts/tests/deploy/act/workflow.sh index 2d5e126a9a..7be72c21a6 100755 --- a/scripts/tests/deploy/act/workflow.sh +++ b/scripts/tests/deploy/act/workflow.sh @@ -5,7 +5,8 @@ set -euo pipefail : "${ACT_EVENT:=workflow_dispatch}" : "${ACT_JOB:=}" : "${ACT_MATRIX:=}" -: "${ACT_CONTAINER_OPTIONS:=--privileged}" +: "${INFINITO_CONTAINER:?INFINITO_CONTAINER is not set; source scripts/meta/env/load.sh or invoke via make}" +: "${ACT_CONTAINER_OPTIONS:=--privileged --label infinito.worktree=${INFINITO_CONTAINER}}" : "${ACT_NETWORK:=host}" : "${ACT_PULL:=false}" : "${ACT_RM:=true}" diff --git a/tests/unit/python/scripts/tests/deploy/act/__init__.py b/tests/unit/python/scripts/tests/deploy/act/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py b/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py new file mode 100644 index 0000000000..425e7566c2 --- /dev/null +++ b/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py @@ -0,0 +1,74 @@ +from __future__ import annotations + +import os +import subprocess +import tempfile +import unittest +from pathlib import Path + +from utils.cache.files import PROJECT_ROOT + +SCRIPT = PROJECT_ROOT / "scripts" / "tests" / "deploy" / "act" / "down_act_outer.sh" +DOCKER_STUB = ( + "#!/usr/bin/env bash\n" + 'printf "%s\\n" "$*" >>"${STUB_LOG}"\n' + 'if [ "$1" = ps ]; then\n' + ' case "$*" in *"label=infinito.worktree=own"*) echo own-id ;; esac\n' + "fi\n" +) + + +def teardown(container: str | None) -> tuple[subprocess.CompletedProcess, list[str]]: + """Run the teardown against a ``docker`` stub that only knows ``own-id``. + + Args: + container: value of ``INFINITO_CONTAINER``, or None to leave it unset. + + Returns: + The finished process and the docker invocations it made. + """ + with tempfile.TemporaryDirectory() as tmp: + stub = Path(tmp) / "docker" + stub.write_text(DOCKER_STUB) + stub.chmod(0o755) + log = Path(tmp) / "docker.log" + log.touch() + env = { + k: v + for k, v in os.environ.items() + if k not in ("BASH_ENV", "INFINITO_CONTAINER") + } + env.update(PATH=f"{tmp}{os.pathsep}{os.environ['PATH']}", STUB_LOG=str(log)) + if container is not None: + env["INFINITO_CONTAINER"] = container + done = subprocess.run( + ["bash", str(SCRIPT)], + env=env, + capture_output=True, + text=True, + check=False, + ) + return done, log.read_text().splitlines() + + +class TestDownActOuter(unittest.TestCase): + def test_only_the_own_worktrees_act_containers_are_listed(self) -> None: + _, calls = teardown("own") + self.assertIn("label=infinito.worktree=own", calls[0]) + + def test_the_own_act_container_is_removed(self) -> None: + _, calls = teardown("own") + self.assertEqual(calls[1], "rm -f own-id") + + def test_a_foreign_worktrees_act_container_is_left_alone(self) -> None: + _, calls = teardown("foreign") + self.assertEqual(len(calls), 1) + + def test_an_unset_container_name_removes_nothing(self) -> None: + done, calls = teardown(None) + self.assertNotEqual(done.returncode, 0) + self.assertEqual(calls, []) + + +if __name__ == "__main__": + unittest.main() From df0a91aa1c182efa0856e912696bff90fda64cad Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:55:07 +0000 Subject: [PATCH 08/13] update(images): update Docker image versions (web-app-mattermost) --- roles/web-app-mattermost/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-mattermost/meta/services.yml b/roles/web-app-mattermost/meta/services.yml index 9055d0823d..eb42143a3e 100644 --- a/roles/web-app-mattermost/meta/services.yml +++ b/roles/web-app-mattermost/meta/services.yml @@ -46,7 +46,7 @@ mattermost: shared: true user_access_token_enabled: "{{ 'web-app-nextcloud' in group_names }}" image: mattermost/mattermost-team-edition - version: 11.11.1 + version: 12.0.0 min_storage: 659MB backup: no_stop_required: true From 753badd8b880e69076b5160f5d28125e6fe795c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 20:44:24 +0000 Subject: [PATCH 09/13] chore(deps-dev): Bump ruff from 0.16.10 to 0.17.0 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.16.10 to 0.17.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.16.10...0.17.0) --- updated-dependencies: - dependency-name: ruff dependency-version: 0.17.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bd4e1d5efc..77d63272ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ deploy = [ "requests", ] dev = [ - "ruff==0.16.10", + "ruff==0.17.0", "import-linter", "pre-commit", "git-maintainer-tools", From 87c9a5f41b34c9259eadf59af0a4c9dd2c1b976f Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 15 Oct 2026 01:07:50 +0200 Subject: [PATCH 10/13] test(act): mark the docker stub log read as outside the file cache The teardown test reads the call log its docker stub writes into a temporary directory. test_no_uncached_file_reads flagged that read in CI; the path-keyed read cache does not fit a file written per run, so the read keeps Path.read_text with the cache-read opt-out, as the other stub-log tests do. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../unit/python/scripts/tests/deploy/act/test_down_act_outer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py b/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py index 425e7566c2..8082bf8f20 100644 --- a/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py +++ b/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py @@ -48,7 +48,7 @@ def teardown(container: str | None) -> tuple[subprocess.CompletedProcess, list[s text=True, check=False, ) - return done, log.read_text().splitlines() + return done, log.read_text().splitlines() # nocheck: cache-read stub call log class TestDownActOuter(unittest.TestCase): From 47565781ead619e9ce6be717d86cd0477dd47a3a Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 15 Oct 2026 01:24:31 +0200 Subject: [PATCH 11/13] style(python): import datetime as dt for ruff 0.17 ruff 0.17.0 adds `datetime` -> `dt` to the default aliases of flake8-import-conventions, and the project selects ICN, so lint-python failed with ICN001 in seven files. The files now import `datetime as dt`. ruff's unsafe fix also renamed two local names in utils/github/playwright_summary.py into the alias: the `_to_iso_z` parameter and the parsed value in `_parse_iso_timestamp`. Both are now called `moment`; with the bare fix, nine tests of test_playwright_summary.py failed with UnboundLocalError and AttributeError. Co-Authored-By: Claude Opus 5.5 (1M context) --- cli/administration/deploy/dedicated/runner.py | 6 ++--- .../files/python/script.py | 5 ++-- .../files/python/script.py | 18 +++++++------- .../roles/test_server_meta_no_split_fields.py | 6 ++--- .../files/test_script.py | 16 ++++++------- .../utils/github/test_playwright_summary.py | 10 +++----- utils/github/playwright_summary.py | 24 +++++++++---------- 7 files changed, 40 insertions(+), 45 deletions(-) diff --git a/cli/administration/deploy/dedicated/runner.py b/cli/administration/deploy/dedicated/runner.py index e388d7555f..d1816a0047 100644 --- a/cli/administration/deploy/dedicated/runner.py +++ b/cli/administration/deploy/dedicated/runner.py @@ -1,6 +1,6 @@ from __future__ import annotations -import datetime +import datetime as dt import json import os import subprocess @@ -33,7 +33,7 @@ def run_ansible_playbook( ansible_args: list[str] | None = None, ) -> None: """Run ansible-playbook with the given parameters and execution modes.""" - start_time = datetime.datetime.now(tz=datetime.UTC) + start_time = dt.datetime.now(tz=dt.UTC) print(f"\n▶️ Script started at: {start_time.isoformat()}\n", flush=True) if modes.get("MODE_CLEANUP", False): @@ -146,6 +146,6 @@ def run_ansible_playbook( ) sys.exit(2) - end_time = datetime.datetime.now(tz=datetime.UTC) + end_time = dt.datetime.now(tz=dt.UTC) print(f"\n✅ Script ended at: {end_time.isoformat()}\n") print(f"⏱️ Total execution time: {end_time - start_time}\n") diff --git a/roles/svc-bkp-local-2-device/files/python/script.py b/roles/svc-bkp-local-2-device/files/python/script.py index bd8ed49054..222193d962 100755 --- a/roles/svc-bkp-local-2-device/files/python/script.py +++ b/roles/svc-bkp-local-2-device/files/python/script.py @@ -3,7 +3,7 @@ # subprocess calls against an attached backup device; every branch it has is a return # code from the host, so the assertions would only restate the mocks -import datetime +import datetime as dt import glob import os import subprocess @@ -42,8 +42,7 @@ def main(): print(f"previous versions path: {previous_version_path}") current_version_path = str( - Path(versions_path) - / datetime.datetime.now(tz=datetime.UTC).strftime("%Y%m%d%H%M%S") + Path(versions_path) / dt.datetime.now(tz=dt.UTC).strftime("%Y%m%d%H%M%S") ) print(f"current versions path: {current_version_path}") diff --git a/roles/svc-opt-keyboard-color/files/python/script.py b/roles/svc-opt-keyboard-color/files/python/script.py index a5e977eaec..b223dda10a 100644 --- a/roles/svc-opt-keyboard-color/files/python/script.py +++ b/roles/svc-opt-keyboard-color/files/python/script.py @@ -1,4 +1,4 @@ -import datetime +import datetime as dt import subprocess import sys @@ -51,7 +51,7 @@ def get_current_period(current_time, color_times): """ sorted_periods = sorted(color_times.items()) for i, (period_start_str, _colors) in enumerate(sorted_periods): - period_start_time = datetime.datetime.strptime( # noqa: DTZ007 HH:MM is local time-of-day; no timezone applies + period_start_time = dt.datetime.strptime( # noqa: DTZ007 HH:MM is local time-of-day; no timezone applies period_start_str, "%H:%M" ).time() if current_time <= period_start_time: @@ -71,15 +71,15 @@ def calculate_transition_ratio(current_time, start_time, end_time): Returns: float: The transition ratio between 0 and 1. """ - today = datetime.datetime.now().date() # noqa: DTZ005 user's local "today" for time-of-day color picking + today = dt.datetime.now().date() # noqa: DTZ005 user's local "today" for time-of-day color picking - start_timestamp = datetime.datetime.combine(today, start_time).timestamp() - end_timestamp = datetime.datetime.combine(today, end_time).timestamp() + start_timestamp = dt.datetime.combine(today, start_time).timestamp() + end_timestamp = dt.datetime.combine(today, end_time).timestamp() if start_timestamp == end_timestamp: return 0 - current_timestamp = datetime.datetime.combine(today, current_time).timestamp() + current_timestamp = dt.datetime.combine(today, current_time).timestamp() transition_duration = end_timestamp - start_timestamp time_since_start = current_timestamp - start_timestamp @@ -117,12 +117,12 @@ def main(vendor_and_product_id): "04:00": ("990000", "5bc0eb"), } - current_time = datetime.datetime.now().time() # noqa: DTZ005 user's local time-of-day for color picking + current_time = dt.datetime.now().time() # noqa: DTZ005 user's local time-of-day for color picking start_color, end_color = get_current_period(current_time, color_times) sorted_times = sorted(color_times.keys()) for time_str in [*sorted_times, sorted_times[0]]: - next_start_time_obj = datetime.datetime.strptime( # noqa: DTZ007 HH:MM is local time-of-day; no timezone applies + next_start_time_obj = dt.datetime.strptime( # noqa: DTZ007 HH:MM is local time-of-day; no timezone applies time_str, "%H:%M" ).time() if current_time < next_start_time_obj: @@ -133,7 +133,7 @@ def main(vendor_and_product_id): for time, colors in color_times.items() if colors == (start_color, end_color) ) - current_period_start_time_obj = datetime.datetime.strptime( # noqa: DTZ007 HH:MM is local time-of-day; no timezone applies + current_period_start_time_obj = dt.datetime.strptime( # noqa: DTZ007 HH:MM is local time-of-day; no timezone applies current_period_start_time_str, "%H:%M" ).time() diff --git a/tests/lint/ansible/roles/test_server_meta_no_split_fields.py b/tests/lint/ansible/roles/test_server_meta_no_split_fields.py index dc99f6f18f..3438671176 100644 --- a/tests/lint/ansible/roles/test_server_meta_no_split_fields.py +++ b/tests/lint/ansible/roles/test_server_meta_no_split_fields.py @@ -16,7 +16,7 @@ open. From 2026-12-28 it deliberately fails with a reminder to delete it. from __future__ import annotations -import datetime +import datetime as dt import unittest from utils.cache.yaml import load_yaml_any @@ -25,12 +25,12 @@ from utils.roles.mapping import ROLE_FILE_META_SERVER from . import PROJECT_ROOT _SPLIT_FIELDS: tuple[str, ...] = ("csp", "domains", "networks") -_SUNSET = datetime.date(2026, 12, 28) +_SUNSET = dt.date(2026, 12, 28) class TestServerMetaNoSplitFields(unittest.TestCase): def test_server_yml_has_no_split_fields(self) -> None: - if datetime.datetime.now(tz=datetime.UTC).date() >= _SUNSET: + if dt.datetime.now(tz=dt.UTC).date() >= _SUNSET: self.fail( "Migration guard expired (>= 2026-12-28): the meta/server.yml " "-> csp/domains/networks.yml split is long merged. DELETE this " diff --git a/tests/unit/python/roles/svc-opt-keyboard-color/files/test_script.py b/tests/unit/python/roles/svc-opt-keyboard-color/files/test_script.py index 695b4af265..d61a6f9ff2 100755 --- a/tests/unit/python/roles/svc-opt-keyboard-color/files/test_script.py +++ b/tests/unit/python/roles/svc-opt-keyboard-color/files/test_script.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import datetime +import datetime as dt import importlib.util from unittest import TestCase, main @@ -70,19 +70,19 @@ class CalculateColorTests(TestCase): class GetCurrentPeriodTests(TestCase): def test_a_time_inside_a_period_returns_that_period_colors(self): self.assertEqual( - SCRIPT.get_current_period(datetime.time(12, 0), COLOR_TIMES), + SCRIPT.get_current_period(dt.time(12, 0), COLOR_TIMES), ("ff0000", "00ff00"), ) def test_a_time_before_the_first_period_wraps_to_the_last(self): self.assertEqual( - SCRIPT.get_current_period(datetime.time(3, 0), COLOR_TIMES), + SCRIPT.get_current_period(dt.time(3, 0), COLOR_TIMES), ("0000ff", "ff0000"), ) def test_a_time_after_the_last_period_returns_the_first(self): self.assertEqual( - SCRIPT.get_current_period(datetime.time(23, 0), COLOR_TIMES), + SCRIPT.get_current_period(dt.time(23, 0), COLOR_TIMES), ("ff0000", "00ff00"), ) @@ -91,7 +91,7 @@ class CalculateTransitionRatioTests(TestCase): def test_the_start_of_a_window_is_ratio_zero(self): self.assertEqual( SCRIPT.calculate_transition_ratio( - datetime.time(6, 0), datetime.time(6, 0), datetime.time(12, 0) + dt.time(6, 0), dt.time(6, 0), dt.time(12, 0) ), 0, ) @@ -99,7 +99,7 @@ class CalculateTransitionRatioTests(TestCase): def test_the_end_of_a_window_is_ratio_one(self): self.assertEqual( SCRIPT.calculate_transition_ratio( - datetime.time(12, 0), datetime.time(6, 0), datetime.time(12, 0) + dt.time(12, 0), dt.time(6, 0), dt.time(12, 0) ), 1, ) @@ -107,7 +107,7 @@ class CalculateTransitionRatioTests(TestCase): def test_the_middle_of_a_window_is_ratio_one_half(self): self.assertEqual( SCRIPT.calculate_transition_ratio( - datetime.time(9, 0), datetime.time(6, 0), datetime.time(12, 0) + dt.time(9, 0), dt.time(6, 0), dt.time(12, 0) ), 0.5, ) @@ -115,7 +115,7 @@ class CalculateTransitionRatioTests(TestCase): def test_a_zero_length_window_returns_zero_instead_of_dividing_by_it(self): self.assertEqual( SCRIPT.calculate_transition_ratio( - datetime.time(6, 0), datetime.time(6, 0), datetime.time(6, 0) + dt.time(6, 0), dt.time(6, 0), dt.time(6, 0) ), 0, ) diff --git a/tests/unit/python/utils/github/test_playwright_summary.py b/tests/unit/python/utils/github/test_playwright_summary.py index 25743f31b7..36b0ebb07f 100644 --- a/tests/unit/python/utils/github/test_playwright_summary.py +++ b/tests/unit/python/utils/github/test_playwright_summary.py @@ -10,7 +10,7 @@ directories / no junit files / unparseable junit files. from __future__ import annotations -import datetime +import datetime as dt import io import os import unittest @@ -56,9 +56,7 @@ def _write(path: Path, content: str) -> Path: class TestToIsoZ(unittest.TestCase): def test_utc_datetime_formats_with_z_suffix(self) -> None: self.assertEqual( - ps._to_iso_z( - datetime.datetime(2026, 5, 17, 12, 34, 56, tzinfo=datetime.UTC) - ), + ps._to_iso_z(dt.datetime(2026, 5, 17, 12, 34, 56, tzinfo=dt.UTC)), "2026-05-17T12:34:56Z", ) @@ -263,9 +261,7 @@ class TestSummarizeFile(unittest.TestCase): Path(tmp) / "web-app-foo" / "playwright-junit.xml", no_timestamp_fixture, ) - target = datetime.datetime( - 2025, 5, 17, 5, 34, 56, tzinfo=datetime.UTC - ).timestamp() + target = dt.datetime(2025, 5, 17, 5, 34, 56, tzinfo=dt.UTC).timestamp() os.utime(xml_path, (target, target)) summary = ps._summarize_file(xml_path) assert summary is not None diff --git a/utils/github/playwright_summary.py b/utils/github/playwright_summary.py index e448f531df..ef33a84d75 100644 --- a/utils/github/playwright_summary.py +++ b/utils/github/playwright_summary.py @@ -12,7 +12,7 @@ Usage: from __future__ import annotations import contextlib -import datetime +import datetime as dt import sys import xml.etree.ElementTree as ET from pathlib import Path @@ -29,12 +29,12 @@ _STATUS_EMOJI: dict[str, str] = { } -def _to_iso_z(dt: datetime.datetime) -> str: - """Format ``dt`` as ``YYYY-MM-DDTHH:MM:SSZ`` (UTC, second precision).""" - return dt.astimezone(datetime.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") +def _to_iso_z(moment: dt.datetime) -> str: + """Format ``moment`` as ``YYYY-MM-DDTHH:MM:SSZ`` (UTC, second precision).""" + return moment.astimezone(dt.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") -def _parse_iso_timestamp(value: str | None) -> datetime.datetime | None: +def _parse_iso_timestamp(value: str | None) -> dt.datetime | None: """Parse a JUnit ``timestamp`` attribute. Treat tz-naive values as UTC. Returns ``None`` when the value is empty or unparseable so callers @@ -43,17 +43,17 @@ def _parse_iso_timestamp(value: str | None) -> datetime.datetime | None: if not value: return None try: - dt = datetime.datetime.fromisoformat(value) + moment = dt.datetime.fromisoformat(value) except ValueError: return None - if dt.tzinfo is None: - dt = dt.replace(tzinfo=datetime.UTC) - return dt + if moment.tzinfo is None: + moment = moment.replace(tzinfo=dt.UTC) + return moment -def _file_mtime_utc(path: Path) -> datetime.datetime: +def _file_mtime_utc(path: Path) -> dt.datetime: """Last-modified time of *path* as a UTC ``datetime``.""" - return datetime.datetime.fromtimestamp(path.stat().st_mtime, tz=datetime.UTC) + return dt.datetime.fromtimestamp(path.stat().st_mtime, tz=dt.UTC) def _format_duration(seconds: float) -> str: @@ -153,7 +153,7 @@ def _summarize_file(path: Path) -> dict | None: base_records = _extract_records(cases) offset_seconds = 0.0 for name, status, msg, duration in base_records: - case_start = suite_ts + datetime.timedelta(seconds=offset_seconds) + case_start = suite_ts + dt.timedelta(seconds=offset_seconds) enriched.append((_to_iso_z(case_start), name, status, msg, duration)) offset_seconds += duration if not enriched: From 1ff4f57bac34410c4802df8f70b0b49383f7f9a4 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 01:08:52 +0000 Subject: [PATCH 12/13] update(images): update Docker image versions (web-app-erpnext) --- roles/web-app-erpnext/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-erpnext/meta/services.yml b/roles/web-app-erpnext/meta/services.yml index cc24f369e8..aeadaa0b54 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.50.0" + version: "v16.51.0" name: erpnext min_storage: 1017MB ports: From afa5abe74da9e545f3f17fdc081a61215aa19435 Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 02:02:56 +0000 Subject: [PATCH 13/13] update(repos): bump git refs to latest semver tags (web-app-bluesky) --- roles/web-app-bluesky/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-bluesky/meta/services.yml b/roles/web-app-bluesky/meta/services.yml index c4d80283b4..d6bf4db040 100644 --- a/roles/web-app-bluesky/meta/services.yml +++ b/roles/web-app-bluesky/meta/services.yml @@ -62,7 +62,7 @@ web: view: enabled: false repository: https://github.com/bluesky-social/social-app.git - ref: "1.134.0" + ref: "1.135.0" ports: local: http: 8051