From cc16c0a9a3b2b92e3f2f0d26b7e228d34618fcce Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Fri, 11 Sep 2026 12:47:29 +0200 Subject: [PATCH] feat(gate-23): give rules 2 to 6 the exception path ADR-022 already grants ADR-022 says an exception applies where an app-local ADR records it, and it ships a worked example. Gate 23 only ever asked in rule 7: _cap_suppressed() was defined below rules 2 to 6 and called from the rule-7 loop alone. So the gate was narrower than the ADR it enforces. Rules 2 and 4 match on file name. In dossiq that flags TenantService, which calls OpenRegister's OrganisationMapper and TenantLifecycleService::provision(), and TenantAuditTrailService, which writes every entry through AuditTrailMapper::createAuditTrailEntry(). Both are the consumers ADR-022 asks for, both were counted as violations of it, and the only way to clear a name rule is a rename that changes no behaviour. The approved dossiq tenancy migration keeps five Tenant-named satellites on purpose, so it could not clear rule 4 however much of it was built. One exception mechanism now serves every rule: * an app-local ADR that cites ADR-022 and names the path suppresses it * every suppression prints, with the file and the ADR that bought it * an ADR with no sunset still suppresses, but prints a warning naming it * an ADR whose sunset has passed stops suppressing Rule 2 also asks a second question, the way rule 1 does for PDOK: a file that calls AuditTrailMapper is printed as compliant and not counted. The question is asked of code lines, so a docblock buys nothing. This only removes findings, so it cannot newly fail a repo. Measured in forced BLOCK mode: dossiq 5 rule findings to 4, decidiq 1 to 1. New suite scripts/lib/test_or_abstraction_exceptions.sh, 38 assertions, auto-discovered by run-helper-suites.sh. Mutation-checked against the pre-change script: 23 assertions redden, the positive controls stay green. --- .../lib/test_or_abstraction_exceptions.sh | 329 ++++++++++++++++++ .../lint-or-abstraction-anti-patterns.sh | 239 ++++++++++--- 2 files changed, 527 insertions(+), 41 deletions(-) create mode 100755 hydra-gates/scripts/lib/test_or_abstraction_exceptions.sh diff --git a/hydra-gates/scripts/lib/test_or_abstraction_exceptions.sh b/hydra-gates/scripts/lib/test_or_abstraction_exceptions.sh new file mode 100755 index 000000000..f89acde2c --- /dev/null +++ b/hydra-gates/scripts/lib/test_or_abstraction_exceptions.sh @@ -0,0 +1,329 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: EUPL-1.2 +# +# test_or_abstraction_exceptions.sh — self-test for the ADR-022 exception path +# in scripts/lint-or-abstraction-anti-patterns.sh. +# +# WHY THIS EXISTS +# --------------- +# ADR-022 says an exception applies where it is recorded in an app-local ADR, +# and it ships a worked example. Until 2026-09-11 the gate asked only in rule 7 +# (the ADR-051 capability table): `_cap_suppressed()` was defined once, below +# rules 2 to 6, and called from the rule-7 loop alone. Rules 2 to 6 had no +# exception path at all, so the gate was narrower than the ADR it enforces. +# +# Two of those rules match on FILE NAME. In dossiq that flagged +# lib/Service/TenantService.php and lib/Service/TenantAuditTrailService.php — +# the two classes that already consume OpenRegister's OrganisationMapper, +# TenantLifecycleService and AuditTrailMapper. The only way to clear a name +# rule is a rename, which changes nothing. The gate penalised the correct +# architecture and rewarded a cosmetic edit. +# +# WHAT THIS SUITE RATCHETS +# ------------------------ +# An exception path is a hole by construction, so every assertion below is +# about the hole's edges: +# +# * a flagged file with NO ADR still fails (the positive control) +# * an ADR that does not cite ADR-022 buys nothing +# * an ADR naming a SIBLING path buys nothing +# * every suppression is PRINTED with its ADR (no silent exceptions) +# * an ADR with NO sunset suppresses but is PRINTED as a warning, so it +# cannot become permanent quietly +# * an ADR whose sunset has PASSED stops suppressing +# * an audit-trail file that CALLS AuditTrailMapper is compliant and printed; +# a file that only names it in a COMMENT is not +# +# Run: bash scripts/lib/test_or_abstraction_exceptions.sh (exit 0 = pass) +# +# Set GATE= to point the suite at another copy of the gate script. That +# is how these assertions were mutation-checked: run against the pre-change +# script and the suppression, sunset and consumer arms all go red. +set -uo pipefail + +LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" +GATE="${GATE:-${LIB_DIR}/../lint-or-abstraction-anti-patterns.sh}" + +if [ ! -f "${GATE}" ]; then + echo "FAIL — gate script not found at ${GATE}; this suite cannot assert anything." + echo "Refusing to report passes for a subject that is absent." + exit 1 +fi + +FAILS=0 +WORK="$(mktemp -d)" +trap 'rm -rf "${WORK}"' EXIT + +mkdir -p "${WORK}/lib/Service" "${WORK}/lib/Middleware" "${WORK}/appinfo" "${WORK}/openspec/architecture" +printf '\n\n fixtureapp\n\n' > "${WORK}/appinfo/info.xml" + +FUTURE="$(date -u -d '+180 days' +%Y-%m-%d)" +PAST="$(date -u -d '-2 days' +%Y-%m-%d)" + +# Force BOTH epochs so the exit status carries the verdict for the umbrella +# rules AND the capability table. In WARN mode the script returns 0 whether or +# not anything matched, so a suite reading the byte in WARN mode asserts +# nothing — which is how these findings stayed invisible in the first place. +run_gate() ( + cd "${WORK}" \ + && HYDRA_OR_GATE_BLOCK_AFTER_EPOCH=0 \ + HYDRA_OR_CAPABILITY_GATE_BLOCK_AFTER_EPOCH=0 \ + bash "${GATE}" >"${WORK}/.out" 2>&1 + echo $? +) + +assert_rc() { #