diff --git a/scripts/install.sh b/scripts/install.sh index c9d7879..eee3c98 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -700,18 +700,22 @@ resolve_build_target() { install_config_template() { local template="$1" local dest="$2" - local src modern legacy + local src legacy + local -a modern_candidates=() + local -a legacy_candidates=() - modern="configs/ananke.${template}.yaml" case "${template}" in coordinator) - legacy="configs/hecate.titan-db.yaml" + modern_candidates=("configs/ananke.coordinator.yaml" "configs/ananke.titan-db.yaml") + legacy_candidates=("configs/hecate.titan-db.yaml") ;; peer) - legacy="configs/hecate.tethys.yaml" + modern_candidates=("configs/ananke.peer.yaml" "configs/ananke.tethys.yaml") + legacy_candidates=("configs/hecate.tethys.yaml") ;; example) - legacy="configs/hecate.example.yaml" + modern_candidates=("configs/ananke.example.yaml") + legacy_candidates=("configs/hecate.example.yaml") ;; *) echo "[install] unknown config template key: ${template}" >&2 @@ -719,21 +723,24 @@ install_config_template() { ;; esac - if [[ -f "${modern}" ]]; then - src="${modern}" - install -m 0640 "${src}" "${dest}" - return 0 - fi + for src in "${modern_candidates[@]}"; do + if [[ -f "${src}" ]]; then + install -m 0640 "${src}" "${dest}" + return 0 + fi + done - if [[ -f "${legacy}" ]]; then - src="$(mktemp)" - legacy_path_rewrite "${legacy}" "${src}" - install -m 0640 "${src}" "${dest}" - rm -f "${src}" - return 0 - fi + for legacy in "${legacy_candidates[@]}"; do + if [[ -f "${legacy}" ]]; then + src="$(mktemp)" + legacy_path_rewrite "${legacy}" "${src}" + install -m 0640 "${src}" "${dest}" + rm -f "${src}" + return 0 + fi + done - echo "[install] missing both modern and legacy config templates for '${template}'." >&2 + echo "[install] missing config template sources for '${template}'. modern=[${modern_candidates[*]}] legacy=[${legacy_candidates[*]}]" >&2 return 1 } diff --git a/scripts/quality_gate.sh b/scripts/quality_gate.sh index 55fafd3..06a6490 100755 --- a/scripts/quality_gate.sh +++ b/scripts/quality_gate.sh @@ -105,6 +105,9 @@ cd "${REPO_DIR}" echo "[quality] lint" ./scripts/lint.sh +echo "[quality] installer template contracts" +./scripts/verify_install_templates.sh + echo "[quality] per-file coverage gate (95%)" cd testing ANANKE_ENFORCE_COVERAGE=1 ANANKE_PER_FILE_COVERAGE_TARGET=95 go test ./coverage -run TestPerFileCoverageReport -count=1 -v diff --git a/scripts/verify_install_templates.sh b/scripts/verify_install_templates.sh new file mode 100755 index 0000000..c15ee91 --- /dev/null +++ b/scripts/verify_install_templates.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -euo pipefail + +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "${REPO_DIR}" + +check_template() { + local template="$1" + shift + local found="" + local candidate + for candidate in "$@"; do + if [[ -f "${candidate}" ]]; then + found="${candidate}" + break + fi + done + + if [[ -z "${found}" ]]; then + echo "[template-contract] ${template}: no candidate exists: $*" >&2 + return 1 + fi + + echo "[template-contract] ${template}: ${found}" + return 0 +} + +check_template coordinator \ + "configs/ananke.coordinator.yaml" \ + "configs/ananke.titan-db.yaml" \ + "configs/hecate.titan-db.yaml" + +check_template peer \ + "configs/ananke.peer.yaml" \ + "configs/ananke.tethys.yaml" \ + "configs/hecate.tethys.yaml" + +check_template example \ + "configs/ananke.example.yaml" \ + "configs/hecate.example.yaml"