Files
computer-playbook/scripts/meta/resolve/apps.sh
T
kevinveenbirkenbachandClaude Opus 5 677a63931c Merge branch 'feature/network/multi-network-serving' into feature/store-i18n
Resolves 68 conflicted files. The governing rule was our structure with their
network semantics: the tor boolean becomes a network mode (clearnet | tor |
multi) throughout the variant layer, while this branch's architecture and mesh
axes, its extracted modules and its i18n content stay.

Where the two sides covered different ground, both are kept rather than one
picked:

- ca_injected answers a ca_client on the deployment's TLS mode OR on an SSO
  issuer that resolves self-signed. 3a3e9ed2c9 records why: an issuer is not
  an object store, so keeping only one side drops the other's coverage.
- get_merged_domains keeps the loud refusal when svc-net-tor is deployed
  without a provisioned node, now gated on their tor_serves_host; their
  node_onion_of returns an empty string there, which would have served every
  onion-exclusive app on clearnet in silence.
- sso_cookie_domains stays the single source for oauth2-proxy's cookie scope.
  Their per-network branch omitted the issuer domain on the onion arm, which
  breaks the callback leg.
- The clearnet CSP batch carries --clearnet-timeout again; their batch dict
  hardcoded zero while the role still passes the flag.
- The dashboard keeps its i18n content dir, image, version and design
  resolution; their side reduced the logo sources to the bare service
  provider values.

Their side wins where it is measurably better: the onion mirror rewrite is
gated per vhost rather than per app, the Playwright onion decision reads the
pass's own domain instead of the role's canonical one, and the matomo
reinjection and dashboard config render per network sibling.

Eight files were broken by the merge without ever carrying a conflict marker,
because git marks only the lines both sides touched:

- utils/cache/domains.py lost the onionize block that sat between two hunks
- roles/sys-front-inj-all/templates/body_filter.lua.j2 called it
- web-app-bluesky, keycloak sso_proxy: the get_entity_name filter was renamed
- trigger/__main__.py, playwright_coverage.py and its test: the deleted tor
  module
- cli/administration/deploy/ci/timings.py read Label.tor
- plugins/filter/csp_filters.py called _aligned_url with four of six arguments
- tests/unit/python/utils/cache/test_domains.py referenced a renamed class
- tests/.../sys-ctl-hlth-csp/files/test_script.py mocked a function main no
  longer calls

Verified: the variant layer (155 tests, 65 subtests), ca_injected (18),
the CI layer (175), the domains cache including the restored guard (32),
retrigger inputs (9), timings and the CSP health script (53). make
quality-high clears autoformat; its remaining findings are tracked separately.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-23 09:53:41 +02:00

107 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Resolve the CI deploy matrix for one chunk of one sweep. The pipeline itself
# (two discovery queries, the axis rotations, the chunk split) lives in
# cli.meta.ci.matrix, shared with the deploy-plan table, so the matrix this
# emits and the plan the summary renders can never disagree. Every entry is one
# role#variant row carrying the mode, onion state, distro, filesystem and CPU
# architecture it was assigned, plus the runner label that architecture needs.
#
# Inputs via env (defaults live in default.env, the single source of truth):
# INFINITO_CI_CHUNK chunk index to emit (required)
# INFINITO_CI_SWEEP sweep number driving the axis rotations
# INFINITO_CI_OFFSET regular rows to skip before filling the chunks
# INFINITO_MODES 'auto' or a subset of 'host compose swarm'
# INFINITO_WHITELIST optional space-separated app ids to keep
# INFINITO_PRIORITY optional space-separated app ids to lead
# INFINITO_NETWORK auto|clearnet|tor|multi
# INFINITO_DISTROS distro pool the rows are spread over; empty: all
# INFINITO_DOCKER_FILESYSTEM_ALLOWED filesystem pool; empty: all
# INFINITO_ARCHITECTURES architecture pool; empty: amd64 and arm64
# INFINITO_LIFECYCLES lifecycle envelope for discovery
# INFINITO_DISCOVERY_SORT complexity --sort spec (coverage-first)
# INFINITO_REQUIRED_STORAGE per-runner CI storage budget
# INFINITO_APP_DISCOVERY_RUNNER host|docker
#
# Output: JSON array of matrix entries to stdout (single line, always valid).
PYTHON="${PYTHON:-python3}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
cd "$REPO_ROOT"
if [[ -f "scripts/meta/env/load.sh" ]]; then
# shellcheck source=scripts/meta/env/load.sh
source "scripts/meta/env/load.sh"
fi
json_compact_array() {
jq -c 'if type=="array" then . else [] end'
}
run_meta_cli() {
case "${INFINITO_APP_DISCOVERY_RUNNER:?INFINITO_APP_DISCOVERY_RUNNER must be set}" in
host)
"${PYTHON}" "$@"
;;
docker)
NIX_CONFIG="${NIX_CONFIG:-}" \
INFINITO_DISTRO="${INFINITO_DISTRO}" \
docker compose exec -T infinito "${PYTHON}" "$@"
;;
*)
echo "apps.sh: unknown INFINITO_APP_DISCOVERY_RUNNER='${INFINITO_APP_DISCOVERY_RUNNER}' (expected: host|docker)" >&2
exit 2
;;
esac
}
matrix_json="$(
run_meta_cli -m cli.meta.ci.matrix \
--index "${INFINITO_CI_CHUNK:?INFINITO_CI_CHUNK must be set to the chunk index to emit}" \
--sweep "${INFINITO_CI_SWEEP}" \
--offset "${INFINITO_CI_OFFSET}" \
--modes "${INFINITO_MODES}" \
--whitelist "${INFINITO_WHITELIST}" \
--priority "${INFINITO_PRIORITY}" \
--lifecycles "${INFINITO_LIFECYCLES}" \
--network "${INFINITO_NETWORK}" \
--distros "${INFINITO_DISTROS}" \
--filesystem "${INFINITO_DOCKER_FILESYSTEM_ALLOWED}" \
--architectures "${INFINITO_ARCHITECTURES}"
)"
if [[ -n "${GITHUB_ACTIONS:-}" && -z "${ACT:-}" ]]; then
required_storage="${INFINITO_REQUIRED_STORAGE}"
mapfile -t roles < <(printf '%s\n' "${matrix_json}" | jq -r '.[].apps' | sort -u)
if [[ "${#roles[@]}" -gt 0 ]]; then
run_meta_cli \
-m cli.meta.roles.applications.sufficient_storage \
--roles "${roles[@]}" \
--required-storage "${required_storage}" \
--warnings \
--format json \
>/dev/null || true # nocheck: shell-or-true -- grandfathered: worked in practice; TODO: sharpen to catch only the exact tolerated error
kept_roles="$(
run_meta_cli \
-m cli.meta.roles.applications.sufficient_storage \
--roles "${roles[@]}" \
--required-storage "${required_storage}" \
--format json |
json_compact_array
)"
matrix_json="$(
printf '%s' "${matrix_json}" |
jq -c --argjson keep "${kept_roles}" \
'map(select(.apps as $a | $keep | index($a) != null))'
)"
fi
fi
printf '%s\n' "${matrix_json}" | json_compact_array