From 8b3ad75ac6f2c0bb22670d318b6559783db791bc Mon Sep 17 00:00:00 2001 From: WilcoLouwerse Date: Fri, 6 Nov 2026 14:41:14 +0100 Subject: [PATCH] fix(gate-14): the engine's own AppHost generics are a library, not unrouted endpoints gate-14 enumerates every lib/**/Controller/*.php and expects a route per public Response-returning method. In the AppHost engine (the repo that ships lib/AppHost/Bootstrap.php) the generics under lib/AppHost/Controller/Generic* are shipped for leaf apps, where Bootstrap::register() binds them and Routes::standard() names their routes; the engine routes only what it uses itself. Judged like any controller they were a permanent finding in exactly one repo: twelve missing-route lines over GenericDashboard, GenericPreferences, GenericSettings and GenericStore on every openregister pull request, beta and development alike, measured 2026-11-06. The exemption is one directory in one kind of repo: lib/AppHost/Controller/Generic*Controller.php, and only when this repo defines class Bootstrap with a register() in lib/AppHost/Bootstrap.php. Control pair apphost-engine-generics/ (engine: GenericDashboard exempt, gadget#run still reported, routed GenericHealth still resolved) and apphost-engine-generics-leaf/ (the same tree minus Bootstrap.php: both GenericDashboard methods reported). test_gate_route_registration.sh: 71 passed, 0 failed. Co-Authored-By: Claude Fable 5.1 --- .../lib/test_gate_route_registration.sh | 48 ++++++++++++++++++- hydra-gates/scripts/run-hydra-gates.sh | 38 +++++++++++++++ .../appinfo/routes.php | 13 +++++ .../Controller/GenericDashboardController.php | 24 ++++++++++ .../Controller/GenericHealthController.php | 16 +++++++ .../lib/AppInfo/Application.php | 19 ++++++++ .../lib/Controller/GadgetController.php | 14 ++++++ .../lib/Controller/PingController.php | 16 +++++++ .../appinfo/routes.php | 13 +++++ .../lib/AppHost/Bootstrap.php | 19 ++++++++ .../Controller/GenericDashboardController.php | 24 ++++++++++ .../Controller/GenericHealthController.php | 16 +++++++ .../lib/AppInfo/Application.php | 19 ++++++++ .../lib/Controller/GadgetController.php | 14 ++++++ .../lib/Controller/PingController.php | 16 +++++++ 15 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/appinfo/routes.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppHost/Controller/GenericDashboardController.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppHost/Controller/GenericHealthController.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppInfo/Application.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/Controller/GadgetController.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/Controller/PingController.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/appinfo/routes.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppHost/Bootstrap.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppHost/Controller/GenericDashboardController.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppHost/Controller/GenericHealthController.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppInfo/Application.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/Controller/GadgetController.php create mode 100644 hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/Controller/PingController.php diff --git a/hydra-gates/scripts/lib/test_gate_route_registration.sh b/hydra-gates/scripts/lib/test_gate_route_registration.sh index d0a89f698..410e19034 100644 --- a/hydra-gates/scripts/lib/test_gate_route_registration.sh +++ b/hydra-gates/scripts/lib/test_gate_route_registration.sh @@ -137,7 +137,8 @@ for _f in routes-standard routes-standard-missing-update \ delegated-registrar delegated-registrar-absent \ store-plane store-plane-absent store-plane-coincidental \ monitoring-capitalised monitoring-per-object monitoring-per-object-only \ - monitoring-none knr-braces; do + monitoring-none knr-braces \ + apphost-engine-generics apphost-engine-generics-leaf; do [ -d "${FIXTURES}/${_f}" ] || _bad "fixture ${FIXTURES}/${_f} does not exist — this suite would be green on nothing" done @@ -395,6 +396,51 @@ if _run "${FIXTURES}/knr-braces"; then "knr-braces: exactly ONE finding — brace style changed nothing but the phantom" fi +# --------------------------------------------------------------------------- +# THE ENGINE'S OWN GENERICS ARE A LIBRARY, NOT ITS ENDPOINTS (2026-11-06) +# +# ADR-040: `lib/AppHost/Controller/Generic*` is shipped by the engine (the +# repo with lib/AppHost/Bootstrap.php) and SERVED in a leaf app, where +# `Bootstrap::register()` binds the classes and `Routes::standard()` names +# their routes. In the engine repo the generics it does not use itself have +# no route, by design. Enumerated like any controller they were a permanent +# finding in exactly one repo — measured on openregister, `beta` and +# `development` alike: twelve `missing-route` lines over GenericDashboard, +# GenericPreferences, GenericSettings and GenericStore on every pull request. +# +# Control pair. `apphost-engine-generics/` carries Bootstrap.php and an +# unrouted GenericDashboard (page, catchAll): NOT reported. Its `gadget#run` +# — a conventional controller, routed nowhere — MUST still be reported, so +# the exemption is one directory in one kind of repo, not a blanket. The +# routed GenericHealth stays judged on the route side. The anti-widening +# half, `apphost-engine-generics-leaf/`, is the SAME tree minus +# Bootstrap.php — a leaf that copied a generic in — and there both +# GenericDashboard methods MUST be reported. +# --------------------------------------------------------------------------- +if _run "${FIXTURES}/apphost-engine-generics"; then + _expect_gate 14 "FAIL" "apphost-engine-generics: the engine's genuinely unrouted conventional method is still a finding" + _expect_log "${_RRLOG}" "GadgetController\.php method=run .*rule=missing-route" \ + "apphost-engine-generics: gadget#run — routed nowhere — IS reported" + _expect_not_log "${_RRLOG}" "GenericDashboardController" \ + "apphost-engine-generics: the engine's unrouted GenericDashboard is a library class and is NOT reported" + _expect_not_log "${_RRLOG}" "GenericHealthController" \ + "apphost-engine-generics: the routed GenericHealth resolves through its binding and is NOT reported" + _expect_lines "${_RRLOG}" 1 \ + "apphost-engine-generics: exactly ONE finding — the exemption is lib/AppHost/Controller/Generic* in the engine, nothing else" +fi + +if _run "${FIXTURES}/apphost-engine-generics-leaf"; then + _expect_gate 14 "FAIL" "apphost-engine-generics-leaf: without Bootstrap.php this is a leaf, and its copied generic IS judged" + _expect_log "${_RRLOG}" "GenericDashboardController\.php method=page .*rule=missing-route" \ + "apphost-engine-generics-leaf: genericDashboard#page IS reported" + _expect_log "${_RRLOG}" "GenericDashboardController\.php method=catchAll .*rule=missing-route" \ + "apphost-engine-generics-leaf: genericDashboard#catchAll IS reported" + _expect_log "${_RRLOG}" "GadgetController\.php method=run .*rule=missing-route" \ + "apphost-engine-generics-leaf: gadget#run IS reported" + _expect_lines "${_RRLOG}" 3 \ + "apphost-engine-generics-leaf: exactly THREE findings — the same tree minus the engine marker loses the exemption and nothing else changes" +fi + echo echo "== summary ==" printf ' passed: %d\n failed: %d\n' "${_pass_n}" "${_fail_n}" diff --git a/hydra-gates/scripts/run-hydra-gates.sh b/hydra-gates/scripts/run-hydra-gates.sh index 442e5b09d..7912d2048 100755 --- a/hydra-gates/scripts/run-hydra-gates.sh +++ b/hydra-gates/scripts/run-hydra-gates.sh @@ -3993,6 +3993,44 @@ if [ -f appinfo/routes.php ] && [ -n "$(_enum_controllers tracked | head -1)" ]; # arms are recorded here rather than at one convenient place. echo "${_ctrl_path}" >> "${_rr_seen}" + # THE ENGINE'S OWN GENERICS ARE A LIBRARY, NOT THIS APP'S ENDPOINTS. + # + # ADR-040: the AppHost generics (`lib/AppHost/Controller/Generic*`) + # are shipped by the engine — the repo that carries + # `lib/AppHost/Bootstrap.php` — and served in a LEAF app, where + # `Bootstrap::register()` binds them and `Routes::standard()` names + # their routes. In the engine repo itself they are source files with + # no route of their own, by design: the engine routes what it uses + # (`AppHost\Controller\GenericHealth#index`, `…GenericMetrics#index`) + # and leaves the rest to the adopters. + # + # Judged like any controller they are a permanent finding in exactly + # one repo. MEASURED 2026-11-06 on openregister, `beta` and + # `development` alike: twelve `missing-route` lines over + # GenericDashboard, GenericPreferences, GenericSettings and + # GenericStore, on every pull request, with no route anyone would + # add — adding one would turn a library class into a live endpoint. + # + # Narrow on purpose: the file must sit under lib/AppHost/Controller/ + # AND this repo must define the engine's Bootstrap (a leaf imports + # `OCA\OpenRegister\AppHost\Bootstrap`; it never ships the file). A + # leaf that copies a generic into its own lib/AppHost/Controller/ is + # still judged — `apphost-engine-generics-leaf/` asserts that — and + # so is every conventional controller in the engine + # (`apphost-engine-generics/` keeps a `gadget#run` that MUST fail). + # A generic the engine DOES route is unaffected: the route-side + # check (`method-not-found-on-target-controller`) runs on route + # names, not on this enumeration. + case "${_ctrl_path}" in + lib/AppHost/Controller/Generic*Controller.php) + if [ -f lib/AppHost/Bootstrap.php ] \ + && _php_code_only lib/AppHost/Bootstrap.php | grep -qE '^[[:space:]]*(abstract[[:space:]]+|final[[:space:]]+)?class[[:space:]]+Bootstrap\b' \ + && _php_code_only lib/AppHost/Bootstrap.php | grep -qE 'function[[:space:]]+register[[:space:]]*\('; then + continue + fi + ;; + esac + # Derive the controller route slug — strip lib/Controller/ prefix + # Controller.php suffix, lowercase the first character. Settings/ # subnamespace becomes `Settings\Foo`. diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/appinfo/routes.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/appinfo/routes.php new file mode 100644 index 000000000..a9c16acfa --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/appinfo/routes.php @@ -0,0 +1,13 @@ + [ + ['name' => 'AppHost\Controller\GenericHealth#index', 'url' => '/api/health', 'verb' => 'GET'], + ['name' => 'ping#index', 'url' => '/api/ping', 'verb' => 'GET'], + ], +]; diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppHost/Controller/GenericDashboardController.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppHost/Controller/GenericDashboardController.php new file mode 100644 index 000000000..5c49c9917 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppHost/Controller/GenericDashboardController.php @@ -0,0 +1,24 @@ + 'ok']); + } +} diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppInfo/Application.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppInfo/Application.php new file mode 100644 index 000000000..09350b1b3 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/AppInfo/Application.php @@ -0,0 +1,19 @@ +registerService( + 'AppHost\\Controller\\GenericHealthController', + static fn ($c) => new \OCA\Fixture\AppHost\Controller\GenericHealthController() + ); + } +} diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/Controller/GadgetController.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/Controller/GadgetController.php new file mode 100644 index 000000000..53f571372 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/Controller/GadgetController.php @@ -0,0 +1,14 @@ + true]); + } +} diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/Controller/PingController.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/Controller/PingController.php new file mode 100644 index 000000000..fcbdf7150 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics-leaf/lib/Controller/PingController.php @@ -0,0 +1,16 @@ + true]); + } +} diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/appinfo/routes.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/appinfo/routes.php new file mode 100644 index 000000000..a9c16acfa --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/appinfo/routes.php @@ -0,0 +1,13 @@ + [ + ['name' => 'AppHost\Controller\GenericHealth#index', 'url' => '/api/health', 'verb' => 'GET'], + ['name' => 'ping#index', 'url' => '/api/ping', 'verb' => 'GET'], + ], +]; diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppHost/Bootstrap.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppHost/Bootstrap.php new file mode 100644 index 000000000..41fa12358 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppHost/Bootstrap.php @@ -0,0 +1,19 @@ + 'ok']); + } +} diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppInfo/Application.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppInfo/Application.php new file mode 100644 index 000000000..09350b1b3 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/AppInfo/Application.php @@ -0,0 +1,19 @@ +registerService( + 'AppHost\\Controller\\GenericHealthController', + static fn ($c) => new \OCA\Fixture\AppHost\Controller\GenericHealthController() + ); + } +} diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/Controller/GadgetController.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/Controller/GadgetController.php new file mode 100644 index 000000000..53f571372 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/Controller/GadgetController.php @@ -0,0 +1,14 @@ + true]); + } +} diff --git a/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/Controller/PingController.php b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/Controller/PingController.php new file mode 100644 index 000000000..fcbdf7150 --- /dev/null +++ b/hydra-gates/scripts/test-fixtures/route-registration/apphost-engine-generics/lib/Controller/PingController.php @@ -0,0 +1,16 @@ + true]); + } +}