Skip to content

gate-14: AppHost detection greps only Application.php, so a decomposed registrar re-opens the FP #199 closed #237

Closed

Description

@rubenvdlinde

.github#199 ("an AppHost generic the leaf registers itself is not an unreachable route") is merged, and gate-14 still reports 4 false controller-class-not-found findings on procest at hydra-gates@main (756fe89, i.e. after #199).

Measured

$ hydra-gates --app-dir <procest@084fbf03> --full
[gate-14] route-reachability: FAIL — 4 unrouted method(s) or wrong-target route(s)

lib/Controller/HealthController.php      route='health#index'                rule=controller-class-not-found
lib/Controller/MetricsController.php     route='metrics#index'               rule=controller-class-not-found
lib/Controller/PreferencesController.php route='preferences#getPreference'   rule=controller-class-not-found
lib/Controller/PreferencesController.php route='preferences#setPreference'   rule=controller-class-not-found

All four are served. OCA\\OpenRegister\\AppHost\\Bootstrap::registerControllers() binds OCA\\Procest\\Controller\\HealthController etc. to its generics via aliasControllerUnlessLeafDefinesIt(). The absence of the files is deliberate and required — creating them would make the alias skip and break the routes.

Cause

run-hydra-gates.sh L483-488:

_HYDRA_APPHOST=0
if [ -f lib/AppInfo/Application.php ] \
    && grep -qE 'AppHost\\+Bootstrap' lib/AppInfo/Application.php \
    && grep -qE 'Bootstrap::register[[:space:]]*\(' lib/AppInfo/Application.php; then
    _HYDRA_APPHOST=1
fi

Both probes are pinned to lib/AppInfo/Application.php. procest does not call Bootstrap::register() there; it delegates Application.php → Registrar/ServiceRegistrar.php → Registrar/AppHostRegistrar.php:121. So _HYDRA_APPHOST=0, _apphost_serves() returns 1 for every slug, and the legitimate-absence branch is unreachable. _di_binds_controller() cannot rescue it either — it is also scoped to Application.php (L534).

Measured, with a positive control so a zero is not mistaken for a broken grep:

$ grep -cE 'AppHost\\+Bootstrap'                lib/AppInfo/Application.php   -> 0
$ grep -cE 'Bootstrap::register[[:space:]]*\('   lib/AppInfo/Application.php   -> 0
# same two greps against a file that DOES contain the patterns:
$ grep -cE 'AppHost\\+Bootstrap'                /tmp/probe.php                -> 1
$ grep -cE 'Bootstrap::register[[:space:]]*\('   /tmp/probe.php                -> 1
$ grep -rn 'Bootstrap::register' lib/AppInfo/
  lib/AppInfo/Registrar/AppHostRegistrar.php:121:        Bootstrap::register(

Why this matters beyond one repo

The trigger was a quality change. procest#717 ("decompose Application bootstrap", a phpmd remediation) moved the call out of Application.php into a registrar. Decomposing a god-object composition root is exactly what the other gates push apps toward — and doing it silently turns gate-14 red on correct code. Any app that has done, or will do, the same refactor is affected.

Suggested fix

Widen both probes from lib/AppInfo/Application.php to lib/AppInfo/ (recursive), keeping the evidence requirement unchanged — still the literal Bootstrap::register( / the exact fully-qualified class name, never a wildcard, so a genuinely missing controller still fails.

Worth a fixture for the decomposed-registrar shape: the current test suite presumably only covers the inline-in-Application.php shape, which is why #199 read as complete.

Not a duplicate of

Activity

  1. rubenvdlinde commented on Aug 8, 2026

    @rubenvdlinde
    ContributorAuthor

    A third way the AppHost exemption misses, measured on doriath. This one is not about where registration lives — doriath's detection works fine — it is that the exemption is gated on the wrong condition.

    Detection succeeds here. Both greps match lib/AppInfo/Application.php:

    $ grep -cE 'AppHost\\+Bootstrap' lib/AppInfo/Application.php        -> 2
    $ grep -cE 'Bootstrap::register[[:space:]]*\(' lib/AppInfo/Application.php -> 2
    

    So _HYDRA_APPHOST=1. gate-14 still reports 5 phantom findings:

    lib/Controller/DashboardController.php method=catchAll expected_route='dashboard#catchAll' rule=missing-route
    lib/Controller/DashboardController.php method=page     expected_route='dashboard#page'     rule=missing-route
    lib/Controller/SettingsController.php  method=create   expected_route='settings#create'    rule=missing-route
    lib/Controller/SettingsController.php  method=index    expected_route='settings#index'     rule=missing-route
    lib/Controller/SettingsController.php  method=load     expected_route='settings#load'      rule=missing-route
    

    Why. _apphost_serves() is documented as firing only when the controller file is absent:

    NB: Bootstrap uses aliasControllerUnlessLeafDefinesIt — a leaf that ships its own e.g. SettingsController.php keeps it, and the file therefore exists and is judged normally. This helper only ever fires when the file is ABSENT.

    doriath ships both files on purpose. Application.php::registerDomainOverrides() re-registers SettingsController (admin/user split + #[AuthorizedAdminSetting]) and SettingsService so the concrete leaf classes win over the generic aliases. So the exemption is switched off — while the routes for page, catchAll, index, create and load are still supplied by the engine, via \OCA\OpenRegister\AppHost\Routes::standard() at appinfo/routes.php:22:

    return \OCA\OpenRegister\AppHost\Routes::standard([ …app routes… ]);

    gate-14 parses appinfo/routes.php statically and cannot see inside Routes::standard(), so it concludes the routes are missing.

    The two facts are independent. "Does the leaf define the controller class?" and "does the leaf define the route?" are different questions, and AppHost's design deliberately splits them: a leaf can override the controller while the route still comes from the shared builder. Gating the route exemption on file absence conflates them.

    Suggested fix: key the exemption on the route table, not the controller file — if appinfo/routes.php returns Routes::standard(...), treat the five _HYDRA_APPHOST_SLUGS route names as provided regardless of whether the leaf ships its own controller class. That keeps the deliberate anti-wildcard property (still an explicit five-slug list) while matching what Routes::standard() actually injects.

    For calibration: this is 5 of doriath's 19 full-tree gate failures, i.e. all of gate-14, and every one is phantom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions