diff --git a/hydra-gates/scripts/lib/check_visual_coverage.py b/hydra-gates/scripts/lib/check_visual_coverage.py index 8a1690259..123a06ec8 100644 --- a/hydra-gates/scripts/lib/check_visual_coverage.py +++ b/hydra-gates/scripts/lib/check_visual_coverage.py @@ -31,7 +31,10 @@ ========== ADDED ``.vue`` files are derived from ``git diff --diff-filter=A`` against -``$HYDRA_GATE_BASE_REF`` (default ``origin/development``). For manifest pages, +``$HYDRA_GATE_BASE_REF`` **when the caller sets it**. With no base ref the run +is a FULL-TREE audit — every page component in the app — because a caller who +asked for no scoping must not have its request silently narrowed to a diff +(.github#242). For manifest pages, the page is in scope only when its ``component`` file is itself an ADDED file in the diff — so re-pointing an existing manifest entry at an existing component never trips the gate. Pre-existing pages (untouched legacy debt) are never @@ -41,6 +44,33 @@ HYDRA_GATE_BASE_REF=origin/development python3 scripts/lib/check_visual_coverage.py [app-dir] python3 scripts/lib/check_visual_coverage.py [app-dir] --mode report + +Exit status is a STATUS, never a count +====================================== + +``run_gate`` used to ``return count`` — the number of uncovered page +components — straight into ``sys.exit``. An exit status is ONE BYTE, so the +count was taken mod 256 on its way out, and the caller +(``run-hydra-gates.sh`` gate-26) read that byte as the finding count: + + 260 uncovered pages -> exit 4 -> "[gate-26] FAIL — 4 ..." + 256 uncovered pages -> exit 0 -> "[gate-26] visual-coverage: PASS" + +Both were measured on openregister on 2026-08-08 with this file's own stdout +reading ``FAIL — 256 new page component(s) without a visual baseline`` on the +same run that the gate reported PASS. Two numbers for one measurement means +one of them came through a lossy channel. This is the identical defect +ConductionNL/.github#209 fixed in gate-19's helper. + +The status vocabulary now matches gate-25's helper +(``check_contract_coverage.py``), which the runner already knows how to read: + + 0 pass — pages were inspected (or there were none) and all are covered + 1 fail — at least one uncovered page; the COUNT is on stdout as + ``FAIL — new page component(s)`` + 2 error + 3 empty scope — the diff added no page component, so nothing was + inspected. NOT APPLICABLE, not a pass (#268). """ from __future__ import annotations @@ -53,6 +83,12 @@ GATE_NUM = 26 +# Exit STATUS vocabulary — see the module docstring. Never a finding count. +EXIT_PASS = 0 +EXIT_FAIL = 1 +EXIT_ERROR = 2 +EXIT_EMPTY_SCOPE = 3 + _PAGE_DIRS = ("src/views/", "src/pages/") _VISUAL_EXCLUDE_RE = re.compile( @@ -237,17 +273,51 @@ def is_covered(page: dict, visual_corpus: str, e2e_corpus: str) -> bool: # --------------------------------------------------------------------------- -def _collect(app_dir: Path, base_ref: str) -> list[dict]: - added = added_files(base_ref, app_dir) - return discover_new_pages(app_dir, added) +def _all_page_components(app_dir: Path) -> set[str]: + """Every page component in the tree, ignoring the diff entirely.""" + found: set[str] = set() + for d in _PAGE_DIRS: + root = app_dir / d + if root.is_dir(): + for p in root.rglob("*.vue"): + found.add(str(p.relative_to(app_dir)).replace("\\", "/")) + found.update(_manifest_page_components(app_dir).keys()) + return found + + +def _collect(app_dir: Path, base_ref: str | None) -> list[dict]: + if base_ref: + return discover_new_pages(app_dir, added_files(base_ref, app_dir)) + # SCOPE IS THE CALLER'S DECISION, AND IT IS NOT DEFAULTED (.github#242, + # applied here). This helper defaulted `HYDRA_GATE_BASE_REF` to + # `origin/development` even on a run the caller had asked NOT to scope, so + # a full-tree audit was silently narrowed to a diff, came back empty, and + # printed a verdict having opened nothing — the same defect #242 fixed in + # gate-25's helper, where the honest full-tree number on openconnector was + # 32 endpoints against a scoped PASS. With no base ref, audit every page. + return discover_new_pages(app_dir, _all_page_components(app_dir)) def run_gate(app_dir: Path) -> int: - base_ref = os.environ.get("HYDRA_GATE_BASE_REF", "origin/development") + base_ref = os.environ.get("HYDRA_GATE_BASE_REF") or None pages = _collect(app_dir, base_ref) if not pages: - print(f"[gate-{GATE_NUM}] visual-coverage: PASS — no new page components in diff") - return 0 + # EMPTY SCOPE IS NOT A PASS (#268). The diff added no page component, + # so this run inspected nothing and has no verdict to give about the + # repository. The caller reports NOT APPLICABLE. + if base_ref: + print( + f"[gate-{GATE_NUM}] visual-coverage: EMPTY SCOPE — " + f"the diff against '{base_ref}' ADDED no page component, so no " + f"screen was inspected" + ) + return EXIT_EMPTY_SCOPE + print( + f"[gate-{GATE_NUM}] visual-coverage: NOT APPLICABLE — this app has " + f"no page component at all (nothing under src/views|src/pages, no " + f"manifest \"type\":\"page\" entry resolving to a .vue)" + ) + return EXIT_EMPTY_SCOPE visual_corpus = _e2e_corpus(app_dir, visual_only=True) e2e_corpus = _e2e_corpus(app_dir, visual_only=False) findings: list[str] = [] @@ -271,16 +341,19 @@ def run_gate(app_dir: Path) -> int: f"[gate-{GATE_NUM}] visual-coverage: PASS — " f"{len(pages)} new page(s), all have a visual proof" ) - else: - print( - f"[gate-{GATE_NUM}] visual-coverage: FAIL — " - f"{count} new page component(s) without a visual baseline" - ) - return count + return EXIT_PASS + # THE COUNT TRAVELS ON STDOUT. Returning it as the exit status truncated it + # to one byte and made 256 findings indistinguishable from zero — see the + # module docstring. + print( + f"[gate-{GATE_NUM}] visual-coverage: FAIL — " + f"{count} new page component(s) without a visual baseline" + ) + return EXIT_FAIL def run_report(app_dir: Path) -> int: - base_ref = os.environ.get("HYDRA_GATE_BASE_REF", "origin/development") + base_ref = os.environ.get("HYDRA_GATE_BASE_REF") or None pages = _collect(app_dir, base_ref) visual_corpus = _e2e_corpus(app_dir, visual_only=True) e2e_corpus = _e2e_corpus(app_dir, visual_only=False) diff --git a/hydra-gates/scripts/lib/filter_preexisting_methods.py b/hydra-gates/scripts/lib/filter_preexisting_methods.py index 138c6b2de..5cc879b8a 100644 --- a/hydra-gates/scripts/lib/filter_preexisting_methods.py +++ b/hydra-gates/scripts/lib/filter_preexisting_methods.py @@ -154,10 +154,59 @@ def _extract_method_body(content: str, method: str) -> str | None: depth -= 1 j += 1 if started and depth == 0: - return "\n".join(body_lines) + return "\n".join(_annotation_prefix(lines, start) + body_lines) return None +_ANNOTATION_LINE = re.compile(r"^\s*(#\[|/\*|\*|//|\]|'|\"|[A-Za-z_\\][\w\\]*\s*[:=]|\))") + + +def _annotation_prefix(lines: list[str], start: int) -> list[str]: + """The attribute + docblock region immediately above the declaration. + + WHY THIS EXISTS — A DEFECT THIS FILTER USED TO ERASE + ---------------------------------------------------- + Extraction began at the ``function NAME(`` line, so a method's ATTRIBUTES + and DOCBLOCK were outside the comparison. Delete ``#[PublicPage]`` from a + controller method and the body is byte-identical to the base ref, so the + entry was classified pre-existing and MOVED OUT of the gate log. + + That is not a corner case: it is the ordinary way the defect enters a + repository. Measured 2026-08-08 on openregister — ``#[PublicPage]`` + deleted from the engine's own ``GenericHealthController::index`` in the + diff under test: + + hydra-gate-public-monitoring.log (empty) -> gate-30 PASS + hydra-gate-public-monitoring.log.preexisting lib/AppHost/Controller/ + GenericHealthController.php:78 method=index + rule=monitoring-endpoint-missing-public-page + + The gate found it and this filter deleted it. Gates 5, 9 and 30 judge the + annotation region and nothing else, so for them a method whose annotations + changed IS a changed method. + + Direction of the change: including more lines can only move entries from + ``preexisting`` back into the findings log. It cannot hide anything. + """ + out: list[str] = [] + i = start - 1 + while i >= 0: + stripped = lines[i].strip() + if not stripped: + # A blank line ends the region: a docblock/attribute stack sits + # flush against its declaration. + break + if stripped.startswith(("}", "{")) or stripped.endswith((";", "{")): + # Previous statement / end of the preceding member. + break + if not _ANNOTATION_LINE.match(lines[i]): + break + out.append(lines[i]) + i -= 1 + out.reverse() + return out + + def _normalise(body: str) -> str: """Whitespace-tolerant comparison key: strip trailing space + collapse blanks.""" return "\n".join(ln.rstrip() for ln in body.splitlines()).strip() diff --git a/hydra-gates/scripts/lib/test_check_visual_coverage.py b/hydra-gates/scripts/lib/test_check_visual_coverage.py new file mode 100644 index 000000000..08b9daf49 --- /dev/null +++ b/hydra-gates/scripts/lib/test_check_visual_coverage.py @@ -0,0 +1,205 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: EUPL-1.2 +"""test_check_visual_coverage.py — gate-26 helper self-tests. + +WHY THIS EXISTS +=============== +``check_visual_coverage.py`` shipped with no test suite at all, and it +returned its FINDING COUNT as its exit status: + + return count # -> sys.exit(count) + +An exit status is one byte. Measured on openregister 2026-08-08 by planting +uncovered page components under ``src/views/``: + + 260 findings -> exit 4 -> runner printed "FAIL — 4 new page component(s)" + 256 findings -> exit 0 -> runner printed "[gate-26] visual-coverage: PASS" + +while this helper's own stdout read ``FAIL — 256 new page component(s)`` on +the very same run. Two numbers for one measurement means one of them came +through a lossy channel. It is the identical defect ConductionNL/.github#209 +fixed in gate-19's helper. + +``test_the_256_case`` below is the one that matters: it constructs exactly the +count whose low byte is zero, so the pre-fix helper reports success. The other +tests keep the repair honest in the opposite direction — an empty scope is not +a pass, and a covered page is not a finding. +""" +from __future__ import annotations + +import os +import subprocess +import sys +import tempfile +from pathlib import Path + +HERE = Path(__file__).resolve().parent + +# The expected statuses are written as LITERALS, deliberately. Importing the +# module's own EXIT_* names would make the test agree with whatever the module +# currently believes, and a suite that cannot disagree with its subject is not +# a test. These are the values the runner's gate-26 branch reads. +EXIT_PASS = 0 +EXIT_FAIL = 1 +EXIT_EMPTY_SCOPE = 3 + +_passed = 0 +_failed: list[str] = [] + + +def check(name: str, cond: bool, detail: str = "") -> None: + global _passed + if cond: + _passed += 1 + print(f" PASS {name}") + else: + _failed.append(name) + print(f" FAIL {name}{(' — ' + detail) if detail else ''}") + + +PAGE = """ + + +""" + + +def _git(args: list[str], cwd: Path) -> None: + subprocess.run( + ["git", "-c", "user.email=t@t", "-c", "user.name=t", *args], + cwd=str(cwd), + check=True, + capture_output=True, + ) + + +def _repo(n_pages: int, *, covered: bool = False) -> tempfile.TemporaryDirectory: + """A git repo whose HEAD commit ADDS ``n_pages`` page components.""" + tmp = tempfile.TemporaryDirectory() + root = Path(tmp.name) + (root / "src" / "views").mkdir(parents=True) + (root / "README.md").write_text("base\n") + # `git init -b` is not available on older gits in the fleet images. + _git(["init", "-q"], root) + _git(["add", "-A"], root) + _git(["commit", "-qm", "base"], root) + for i in range(1, n_pages + 1): + (root / "src" / "views" / f"P{i}.vue").write_text(PAGE.format(n=i)) + if covered: + vis = root / "tests" / "e2e" / "visual" + vis.mkdir(parents=True) + for i in range(1, n_pages + 1): + (vis / f"p{i}.spec.js").write_text( + f"test('P{i}', async () => {{ await expect(page)" + f".toHaveScreenshot('P{i}.png') }})\n" + ) + _git(["add", "-A"], root) + _git(["commit", "-qm", "add pages", "--allow-empty"], root) + return tmp + + +def _run(root: Path, base_ref: str | None) -> tuple[int, str]: + env = dict(os.environ) + env.pop("HYDRA_GATE_BASE_REF", None) + if base_ref: + env["HYDRA_GATE_BASE_REF"] = base_ref + out = subprocess.run( + [sys.executable, str(HERE / "check_visual_coverage.py"), str(root)], + capture_output=True, + text=True, + env=env, + ) + return out.returncode, out.stdout + + +def _reported_count(stdout: str) -> int | None: + for line in stdout.splitlines(): + if "FAIL — " in line and "new page component" in line: + return int(line.split("FAIL — ")[1].split()[0]) + return None + + +# --------------------------------------------------------------------------- +print("== gate-26 helper: an exit status is a STATUS, never a count ==") + +with _repo(3) as t: + rc, out = _run(Path(t), "HEAD~1") + check( + "3 uncovered pages -> exit status 1 (FAIL), not 3", + rc == EXIT_FAIL, + f"rc={rc}", + ) + check("the count travels on stdout", _reported_count(out) == 3, out.strip()[-120:]) + +with _repo(256) as t: + rc, out = _run(Path(t), "HEAD~1") + # THE MUTANT-KILLING CASE. Pre-fix this returned 256, whose low byte is 0, + # so the process exited SUCCESS and the runner printed PASS. + check( + "256 uncovered pages -> exit status 1, NOT 0 (the byte-wrap false green)", + rc == EXIT_FAIL, + f"rc={rc} — pre-fix this was 0 and gate-26 reported PASS", + ) + check( + "the helper still reports all 256 on stdout", + _reported_count(out) == 256, + out.strip()[-120:], + ) + +with _repo(260) as t: + rc, _ = _run(Path(t), "HEAD~1") + check( + "260 uncovered pages -> exit status 1, not 4 (260 mod 256)", + rc == EXIT_FAIL, + f"rc={rc}", + ) + +# --------------------------------------------------------------------------- +print("== gate-26 helper: an empty scope is not a pass (#268) ==") + +with _repo(0) as t: + rc, out = _run(Path(t), "HEAD~1") + check( + "a diff that ADDS no page component -> EXIT_EMPTY_SCOPE, not PASS", + rc == EXIT_EMPTY_SCOPE, + f"rc={rc}", + ) + check("...and says so", "EMPTY SCOPE" in out or "NOT APPLICABLE" in out, out.strip()) + +# --------------------------------------------------------------------------- +print("== gate-26 helper: covered pages pass (no widening) ==") + +with _repo(3, covered=True) as t: + rc, out = _run(Path(t), "HEAD~1") + check("3 pages each with a visual baseline -> PASS", rc == EXIT_PASS, out.strip()) + +# --------------------------------------------------------------------------- +print("== gate-26 helper: no base ref means FULL TREE, not a silent diff (#242) ==") + +with _repo(3) as t: + # The pages are in the FIRST-PARENT history, so a diff against HEAD finds + # nothing added. An unscoped caller must still see all three. + rc, out = _run(Path(t), None) + check( + "no HYDRA_GATE_BASE_REF -> every page in the tree is audited", + rc == EXIT_FAIL and _reported_count(out) == 3, + f"rc={rc} out={out.strip()[-140:]}", + ) + +with _repo(3, covered=True) as t: + rc, out = _run(Path(t), None) + check( + "full-tree mode still passes when every page is baselined", + rc == EXIT_PASS, + out.strip()[-140:], + ) + +print() +print(f"{_passed}/{_passed + len(_failed)} passed") +if _failed: + print("FAILED: " + ", ".join(_failed)) + sys.exit(1) +sys.exit(0) diff --git a/hydra-gates/scripts/lib/test_filter_preexisting_methods.py b/hydra-gates/scripts/lib/test_filter_preexisting_methods.py index 002226616..9f11af9d9 100644 --- a/hydra-gates/scripts/lib/test_filter_preexisting_methods.py +++ b/hydra-gates/scripts/lib/test_filter_preexisting_methods.py @@ -238,6 +238,101 @@ def test_filter_safe_on_empty_log(): assert rc == 0 +def test_filter_keeps_a_method_whose_ATTRIBUTE_was_removed(): + """Deleting `#[PublicPage]` must keep the finding, not bury it. + + THE DEFECT THIS PINS + -------------------- + `_extract_method_body` began at the `function NAME(` line, so a method's + ATTRIBUTES and DOCBLOCK were outside the provenance comparison. Remove + `#[PublicPage]` from a monitoring controller and the body is byte-identical + to base, so the entry was classified pre-existing and MOVED OUT of the gate + log — and gate-30 reported PASS. + + Measured 2026-08-08 on openregister with `#[PublicPage]` deleted from its + own `AppHost/Controller/GenericHealthController::index` inside the diff + under test: the findings log was empty and the `.preexisting` sibling held + + lib/AppHost/Controller/GenericHealthController.php:78 method=index + rule=monitoring-endpoint-missing-public-page + + Gates 5, 9 and 30 judge the annotation region and nothing else, so for them + a method whose annotations changed IS a changed method. + """ + with tempfile.TemporaryDirectory() as td: + tmp = Path(td) + base = { + "lib/Controller/H.php": ( + " exit 4 -> "FAIL — 4"; 256 -> exit 0 -> PASS, with +# the helper's own stdout reading "FAIL — 256" on the same run. +# Identical to .github#209 in gate-19. +# +# gate-27 `2>/dev/null || true` around a helper that returns 0 on every +# successful path: the ONLY nonzero exit is a crash, and a crash +# produced an empty log and a PASS. Measured: 404 files in scope, +# none judged, verdict PASS. +# +# gate-29 a bare `[ fail -eq 0 ] && PASS` reached by BOTH guards, so an +# unscoped run and a repo with no .gitignore printed the same PASS +# as a run that really inspected a .gitignore change. +# +# gate-30 `AppHost\Controller\GenericHealth#index` maps by PSR-4 to +# lib/Controller/AppHost/Controller/…, but openregister DI-binds it +# to lib/AppHost/Controller/GenericHealthController.php. The gate +# called the file "not present in this repository" — inside the +# repository that contains it — so /api/health and /api/metrics were +# judged by this gate nowhere in the fleet. +# +# gate-33 a report of `{}` parsed as "no violations" and reported PASS, +# turning the loud missing-report skip into a silent false green. +# +# Each fixture arm below differs by exactly the thing being detected, so the +# suite fails in BOTH directions: `planted/` must FAIL and NAME the defect, and +# `clean/` must not — otherwise a repair that simply widened the checker until +# it caught everything would pass this file. +# +# Run: bash scripts/lib/test_gates_23_33_never_green_over_nothing.sh +set -uo pipefail + +PKG_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/../.." && pwd)" +RUNNER="${PKG_ROOT}/scripts/run-hydra-gates.sh" +FIXTURES="${PKG_ROOT}/scripts/test-fixtures/gates-23-33" + +_fail_n=0 +_pass_n=0 +_ok() { _pass_n=$((_pass_n + 1)); printf 'PASS — %s\n' "$1"; } +_bad() { _fail_n=$((_fail_n + 1)); printf 'FAIL — %s\n' "$1"; } + +_OUT="" +_LOGDIR="" +_run() { # [runner args...] + local _dir="$1"; shift + _LOGDIR="$(mktemp -d "${TMPDIR:-/tmp}/hydra-gate-2333.XXXXXXXX")" + # The OR-abstraction linter is WARN-only until its bake-in epoch. Force + # BLOCK so the gate's ability to FAIL is what this suite measures, not the + # calendar. A second arm below checks the WARN path separately. + _OUT="$(HYDRA_GATE_LOG_DIR="${_LOGDIR}" \ + HYDRA_OR_GATE_BLOCK_AFTER_EPOCH="${_OR_EPOCH:-0}" \ + bash "${RUNNER}" "$@" "${_dir}" 2>&1 || true)" + # An abort before the summary leaves per-gate PASS lines on stdout and + # reads exactly like a clean run. + if ! printf '%s' "${_OUT}" | grep -q '^\[hydra-gates\] COVERAGE:'; then + _bad "run in ${_dir} ABORTED before the summary — the verdicts above it are not a result" + printf '%s\n' "${_OUT}" | tail -25 | sed 's/^/ /' + return 1 + fi + return 0 +} + +_verdict() { # -> the verdict line + printf '%s' "${_OUT}" | grep -E "^\[gate-$1\] " | head -1 +} + +_expect() { # + local _line + _line="$(_verdict "$1")" + if [ -z "${_line}" ]; then + _bad "$3 — gate-$1 emitted NO verdict line at all" + return + fi + case "${_line}" in + *"$2"*) _ok "$3 — ${_line:0:120}" ;; + *) _bad "$3 — wanted '$2', got: ${_line}" ;; + esac +} + +_expect_log() { # + local _f="${_LOGDIR}/$1" + if [ ! -f "${_f}" ]; then + _bad "$3 — $1 was never written" + return + fi + if grep -qF -- "$2" "${_f}"; then + _ok "$3" + else + _bad "$3 — '$2' not in $1; log was: $(head -3 "${_f}" | tr '\n' ' ')" + fi +} + +_expect_stdout() { # + if printf '%s' "${_OUT}" | grep -qF -- "$1"; then + _ok "$2" + else + _bad "$2 — '$1' not on stdout" + fi +} + +if [ ! -d "${FIXTURES}/planted" ] || [ ! -d "${FIXTURES}/clean" ]; then + echo "FAIL — fixtures missing at ${FIXTURES}. An absent fixture makes every" + echo " assertion below vacuous, which is the defect this suite exists" + echo " to catch. Refusing to report a pass." + exit 1 +fi + +# =========================================================================== +echo "== planted/ — every gate must FAIL and NAME its defect ==" +# =========================================================================== +if _run "${FIXTURES}/planted"; then + _expect 23 "FAIL" "gate-23 names the app-local tenant boundary" + _expect_log hydra-gate-or-abstraction-anti-patterns.log \ + "TenantIsolationService.php" "gate-23 log names lib/Service/TenantIsolationService.php" + + # gate-24: the wrapper exits 0 saying "skipping" while the repo DOES + # register leaves. That is not a pass — it is an unverified correlation. + _expect 24 "SKIPPED (structural)" "gate-24 refuses to read a wrapper's exit-0 skip as a PASS" + _expect 24 "DOES register integration leaves" "gate-24 says WHY it is structural" + + _expect 26 "FAIL" "gate-26 names the page component with no visual baseline" + _expect_log hydra-gate-visual-coverage.log \ + "src/views/UnbaselinedPage.vue" "gate-26 log names src/views/UnbaselinedPage.vue" + + _expect 27 "FAIL" "gate-27 names the phantom getLeaf() RPC" + _expect_log hydra-gate-no-phantom-cross-app-rpc.log \ + "DelegationService.php" "gate-27 log names lib/Service/DelegationService.php" + + _expect 30 "FAIL" "gate-30 names the monitoring endpoint with no declared posture" + _expect_log hydra-gate-public-monitoring.log \ + "lib/Controller/HealthController.php" "gate-30 log names lib/Controller/HealthController.php" + # THE DI-BOUND CONTROLLER. Its route name maps by PSR-4 to + # lib/Controller/AppHost/Controller/…, which does not exist; the class is + # at lib/AppHost/Controller/. Before the resolver fallback this endpoint + # was reported as "not present in this repository" and never judged. + _expect_log hydra-gate-public-monitoring.log \ + "lib/AppHost/Controller/GenericHealthController.php" \ + "gate-30 resolves and JUDGES the DI-bound AppHost controller in this repo" + # ...and the two carve-outs must still be carved out, or the fix widened + # the gate into demanding #[PublicPage] on a per-placement badge. + _expect_log hydra-gate-public-monitoring-notes.log \ + "healthPing#show" "gate-30 still refuses to judge the per-object health-ping badge" + _expect_log hydra-gate-public-monitoring-notes.log \ + "healthPing#validate" "gate-30 still refuses to judge the POST health-ping endpoint" + if grep -q 'healthPing' "${_LOGDIR}/hydra-gate-public-monitoring.log" 2>/dev/null; then + _bad "gate-30 WIDENED: healthPing appears as a FINDING — its only remedy is publishing an outbound-ping oracle" + else + _ok "gate-30 did not flag healthPing (its remedy would be a security regression)" + fi + + _expect 31 "FAIL" "gate-31 names the with no alt" + _expect_log hydra-gate-img-alt.log "PlantImg.vue" "gate-31 log names src/components/PlantImg.vue" + if grep -q '@param' "${_LOGDIR}/hydra-gate-img-alt.log" 2>/dev/null; then + _bad "gate-31 scored a JSDoc line as markup (#220/#235)" + else + _ok "gate-31 did not score the JSDoc \`\` in the diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/clean/src/components/PlantImg.vue b/hydra-gates/scripts/test-fixtures/gates-23-33/clean/src/components/PlantImg.vue new file mode 100644 index 000000000..f081b47f2 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/clean/src/components/PlantImg.vue @@ -0,0 +1,17 @@ + + + diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/clean/src/views/BaselinedPage.vue b/hydra-gates/scripts/test-fixtures/gates-23-33/clean/src/views/BaselinedPage.vue new file mode 100644 index 000000000..2be22231c --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/clean/src/views/BaselinedPage.vue @@ -0,0 +1,9 @@ + + + diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/clean/tests/axe/report.json b/hydra-gates/scripts/test-fixtures/gates-23-33/clean/tests/axe/report.json new file mode 100644 index 000000000..25eaf032b --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/clean/tests/axe/report.json @@ -0,0 +1 @@ +{"violations": [], "passes": [], "url": "http://localhost/apps/gateplant/"} diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/clean/tests/e2e/visual/baselined-page.spec.js b/hydra-gates/scripts/test-fixtures/gates-23-33/clean/tests/e2e/visual/baselined-page.spec.js new file mode 100644 index 000000000..6dd9a6977 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/clean/tests/e2e/visual/baselined-page.spec.js @@ -0,0 +1,4 @@ +// Visual-regression proof for BaselinedPage. +test('BaselinedPage renders', async ({ page }) => { + await expect(page).toHaveScreenshot('BaselinedPage.png') +}) diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/appinfo/info.xml b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/appinfo/info.xml new file mode 100644 index 000000000..32545f8da --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/appinfo/info.xml @@ -0,0 +1,6 @@ + + + gateplant + Gate Plant + agpl + diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/appinfo/routes.php b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/appinfo/routes.php new file mode 100644 index 000000000..307f35a2b --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/appinfo/routes.php @@ -0,0 +1,9 @@ + [ + ['name' => 'health#index', 'url' => '/api/health', 'verb' => 'GET'], + ['name' => 'AppHost\Controller\GenericHealth#index', 'url' => '/api/engine-health', 'verb' => 'GET'], + ['name' => 'healthPing#show', 'url' => '/api/health-ping/{placementId}', 'verb' => 'GET'], + ['name' => 'healthPing#validate', 'url' => '/api/health-ping/validate', 'verb' => 'POST'], + ], +]; diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/composer.json b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/composer.json new file mode 100644 index 000000000..cca196275 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/composer.json @@ -0,0 +1 @@ +{ "name": "conduction/gateplant", "license": "EUPL-1.2" } diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/AppHost/Controller/GenericHealthController.php b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/AppHost/Controller/GenericHealthController.php new file mode 100644 index 000000000..6c0212a3c --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/AppHost/Controller/GenericHealthController.php @@ -0,0 +1,31 @@ + 'ok']); + } + +} diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Controller/HealthController.php b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Controller/HealthController.php new file mode 100644 index 000000000..35a196259 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Controller/HealthController.php @@ -0,0 +1,30 @@ + 'ok']); + } + +} diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Controller/HealthPingController.php b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Controller/HealthPingController.php new file mode 100644 index 000000000..166744781 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Controller/HealthPingController.php @@ -0,0 +1,48 @@ +canViewPlacement($placementId) === false) { + return new JSONResponse([], 403); + } + return new JSONResponse(['status' => 'ok']); + } + + /** + * @return JSONResponse + */ + #[NoAdminRequired] + public function validate(): JSONResponse + { + return new JSONResponse([]); + } + + private function canViewPlacement(string $id): bool + { + return $id !== ''; + } + +} diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Listener/RegisterLeafListener.php b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Listener/RegisterLeafListener.php new file mode 100644 index 000000000..be517d8cc --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Listener/RegisterLeafListener.php @@ -0,0 +1,22 @@ +registry->getLeaf('docudesk.reportGenerator'); + } + +} diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Service/TenantIsolationService.php b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Service/TenantIsolationService.php new file mode 100644 index 000000000..9654f4a25 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/lib/Service/TenantIsolationService.php @@ -0,0 +1,22 @@ + + + + +
+ Toggle me +
+
+ + + diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/components/PlantImg.vue b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/components/PlantImg.vue new file mode 100644 index 000000000..80dd5ec67 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/components/PlantImg.vue @@ -0,0 +1,18 @@ + + + diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/integration-leaf.js b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/integration-leaf.js new file mode 100644 index 000000000..2c8bcf0b2 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/integration-leaf.js @@ -0,0 +1,6 @@ +import { registerIntegration } from '@conduction/nextcloud-vue' + +registerIntegration({ + id: 'gateplant-agent', + renderMode: 'mount', +}) diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/views/UnbaselinedPage.vue b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/views/UnbaselinedPage.vue new file mode 100644 index 000000000..6a8619e39 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/src/views/UnbaselinedPage.vue @@ -0,0 +1,9 @@ + + + diff --git a/hydra-gates/scripts/test-fixtures/gates-23-33/planted/tests/axe/report.json b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/tests/axe/report.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/gates-23-33/planted/tests/axe/report.json @@ -0,0 +1 @@ +{} diff --git a/hydra-gates/tests/test-hydra-gates-bin.sh b/hydra-gates/tests/test-hydra-gates-bin.sh index 4645e6376..886db2f27 100755 --- a/hydra-gates/tests/test-hydra-gates-bin.sh +++ b/hydra-gates/tests/test-hydra-gates-bin.sh @@ -354,12 +354,49 @@ echo "[test] --require-full-coverage still FAILS on a structural gap" # the two halves of it. That is category (b) — structurally impossible — and it # must fail. Same fixture, same flag, opposite verdict: this is what proves the # pass above is a verdict and not an inability to fail. -mkdir -p "${FIX}/src" +mkdir -p "${FIX}/src" "${FIX}/src/components" "${FIX}/src/views" "${FIX}/tests/e2e/visual" cat > "${FIX}/src/leaf.js" <<'JS' // SPDX-License-Identifier: EUPL-1.2 import { registerIntegration } from '@conduction/nextcloud-vue' registerIntegration({ id: 'fixture-leaf', renderMode: 'component' }) JS +# `src/` EXISTING IS NOT THE SAME AS MARKUP EXISTING. Gates 26/31/32 have a +# narrower subject than `[ -d src ]`: a page component and a markup file. A +# src/ holding one .js gives them nothing to open, and reporting PASS for that +# is precisely the nldesign shape — src/ present, zero .vue, eleven a11y gates +# green over nothing. They correctly report NOT APPLICABLE for it now, so the +# positive control below has to supply their actual subject matter, not just a +# directory. Both files are deliberately CLEAN: this control asks whether the +# gates RUN, not whether they can fail (their own suites ask that). +cat > "${FIX}/src/components/FixtureCard.vue" <<'VUE' + + + +VUE +cat > "${FIX}/src/views/FixtureView.vue" <<'VUE' + + + +VUE +cat > "${FIX}/tests/e2e/visual/fixture-view.spec.js" <<'JS' +// Visual-regression proof for FixtureView, so gate-26 RUNS and passes. +test('FixtureView', async ({ page }) => { + await expect(page).toHaveScreenshot('FixtureView.png') +}) +JS git -C "${FIX}" add -A >/dev/null 2>&1 git -C "${FIX}" commit -qm "fixture: register an integration leaf" >/dev/null 2>&1 OUT_STRUCT="$("${BIN}" --app-dir "${FIX}" --base "${BASE_SHA}" --require-full-coverage 2>&1)"; RC_STRUCT=$?