main was 16 days and 259 commits behind the line the product is actually built on, at contract 0.30.0 against 0.35.0, with no per-PC credential code at all. It was neither current nor curated - just stale. This brings it forward and, at the same time, makes it mean something: main is what a receiving site installs, and nothing else. WHAT IT CARRIES. Twelve plugins - backups, computers, endpoints, guides, knowledgebase, machines, network, notifications, printers, slides, tools, warranty - plus applications, which is manifest-less core and always ships. The only manifest dependency inside that set is endpoints on computers, and both are in it, so the closure is self-contained. WHAT IT DOES NOT. employees, geenforce, measuringtools, printedparts and usb stay on the site line. So do the Windows installer tree, the VM rehearsal helpers, the agent tooling config, one site's data loader, the internal audit and findings records, and the planner spreadsheet. 1,135 tracked files against 1,438. A REMOVAL THAT BREAKS THE APP IS NOT A REMOVAL, and two nearly shipped: deploy/site-profile-universal.json still named all seventeen plugins. It is the file docs/DEPLOY.md tells a site to provision from, so a fresh install would have failed at `flask plugin apply-profile` with PluginError - the first thing a receiving site does, broken by the branch meant to serve them. It now names the twelve that exist, and its comment says the two must agree. agent/ was never refreshed. Whoever populated this branch copied shopdb/, plugins/, frontend/ and tests/ from the site line and left the agent tree at its September state: 22 C# and PowerShell sources missing, including AgentCredentials, EnrollmentService, AgentHttpFactory and the fleet-alert client, plus one file the site line had deleted still present. The old tree is internally consistent, so it compiles, and nothing in CI builds it - every gate was green over a server that speaks enrollment and per-PC credentials to a bundled agent source that cannot. Resynced whole. DECISIONS THIS ENCODES, rather than defers: - The plugin-authoring lab builds printedparts, whose manifest depends on employees, so it could not stay. The lab remains on the site line and main ships no build-along tutorial. That is a real loss for an adopting developer and is recorded here rather than discovered later. - Recognition, Training and Recertification notifications are no longer seeded. Each splits one notification into a card per employee and renders a photo, which needs a plugin this branch does not bundle. Seeding them would offer an author a type that cannot resolve anybody. A site that installs employees gets them from that plugin's own seed. - Windows/IIS is documented as the legacy path throughout, and the README leads with Docker, because that is what a receiving site gets. The API description is regenerated for THIS branch - 347 paths and 483 operations, down from 415 and 573 - so the published contract describes what is here rather than what the site line serves. docs/CONFIG.md lost the two measuring-tool label keys the code no longer declares, which two lanes had decided opposite ways. Suite: 3124 passed, 6 skipped. Naming and style gates pass. The docs gates run rather than skip, and every index line count is derived from the file it names.
7.4 KiB
ADR-009: Frontend plugin gating
- Status: ACCEPTED
- Date: 2026-07-10
- Deciders: ShopDB maintainers
- Supersedes: none
Context
The backend plugin system (ADR-002, ADR-003) lets an operator disable a
plugin. Disabling it unregisters the plugin's API blueprint, drops its
rows from global search (see test_search_disabled), and removes its
entry from get_navigation_items(), so the disabled feature's sidebar
link disappears.
The frontend told a different story. Every plugin's Vue routes and views
ship inside the core bundle. frontend/src/router/index.js auto-discovers
them with import.meta.glob('./routes/*.js'), so a route like /usb or
/printers/3 is registered regardless of whether the owning backend
plugin is enabled. A user who typed the URL, followed a stale bookmark,
or clicked a cross-link reached a page whose API calls all 404, landing
on a broken shell instead of a clean redirect. The navigation was already
data-driven; direct-URL reachability was the gap.
There is no frontend plugin system yet. The product is packaged as one core Flask app plus backend-only plugins; the Vue app is monolithic and build-time static. Any gating has to live in core frontend code because that is the only place the plugin routes exist.
Decision
Step 1 (this ADR, implemented): route-level gating
Plugin-owned frontend routes are gated against the backend's enabled-plugin list. This is the whole of what ships now.
-
Enabled-list endpoint. A new
GET /api/plugins/enabled(jwt_required(optional=True)) returns a flat JSON array of enabled plugin name strings and nothing else. It is a cheap registry read (registry.get_enabled_plugins()), no database access. Exposing it to anonymous callers is safe becauseGET /api/dashboard/navigationalready leaks the same enabled/disabled signal, and unauthenticated kiosk routes (/tv) need the answer too. It carries no metadata, so it reveals strictly less than the equally-anonymous but metadata-carryingGET /api/plugins(alsojwt_required(optional=True); only thePUT /api/plugins/<name>toggle is admin-gated). -
Route tagging. Every plugin-owned route carries
meta.plugin = '<pluginname>'. This covers the per-plugin route modules (routes/computers.js,routes/equipment.js, ...) and the plugin-owned routes that physically live in core files: the PC-relationships and toner reports, the slide manager and/tvdashboard (slides), the printer-QR and USB-label print pages, and the employee-detail page. Genuinely core routes (dashboard, search, map, applications, reference-data settings) stay untagged and are never gated. -
Cached fetch, fail-open. A composable (
composables/enabledPlugins.js) fetches the list exactly once behind a cached promise. If the fetch fails or returns a non-array, the code fails open: every plugin is treated as enabled. A transient API error must never brick navigation. The cost is that a disabled plugin's page is briefly reachable during an outage, which is acceptable because its API calls would fail anyway and the next successful fetch closes the gap. -
Router guard.
router.beforeEachawaits the cached fetch when the target route hasmeta.plugin. If that plugin is not enabled it redirects to/and raises an info toast. The endpoint is jwt-optional, so the guard works for both authenticated pages and the unauthenticated/tvkiosk route.
This is intentionally a thin layer. It does not change the plugin
contract surface, so __contract_version__ does not move: adding a core
HTTP endpoint and tagging core-shipped routes are not plugin-contract
changes. Plugins still ship no frontend code of their own.
Non-goals for step 1
- No build-time or runtime loading of plugin-authored Vue code.
- No per-permission or per-role route gating (that stays with the
existing
requiresAuth/requiresAdminmeta flags). - No removal of disabled routes from the route table; they remain registered and are intercepted by the guard. Keeping them registered avoids a rebuild when a plugin is toggled and keeps the redirect path simple.
Future direction (PROPOSED, not implemented)
Step 1 gates routes that core already owns. The longer-term goal is a real frontend-plugin contract where a plugin ships its own frontend and core discovers it, mirroring the backend model. Sketch:
-
Plugin-owned frontend tree. Each plugin gains a
plugins/<name>/frontend/directory holding its route module, views, and any plugin-specific components. Core stops carryingviews/usb,views/printers, and so on. -
Build-time discovery. The Vite build discovers plugin frontends with a glob over
plugins/*/frontend/routes.js(analogous to today'simport.meta.glob('./routes/*.js')), so a plugin's presence in the tree is what puts its routes in the bundle. Combined with the step-1 enabled-list gate, a plugin that is absent from the build ships no code and a plugin that is present-but-disabled is route-gated at runtime. -
Shared component + registration contract. Plugins register into named extension points instead of editing core files: an
iconMapregistration for nav/asset icons, asset-detail panels, map-marker renderers, and search-result renderers (the "Frontend hook contract" already listed as deferred in docs/ROADMAP.md). Core exposes a stable set of shared components (form controls, detail-page shells, table primitives) as the plugin frontend's only allowed core imports, the frontend analogue of theshopdb.apinamespace. -
Versioned frontend contract. The shared-component and registration surface would be versioned the same way the backend contract is (ADR-002), so a plugin frontend can declare the core frontend range it needs.
Tradeoffs of the future direction
- Pro: true plugin self-containment; a site can drop in or remove a plugin (frontend and backend together) without patching core; smaller core; clearer ownership.
- Con: significant build-system work (per-plugin Vite entry discovery, code-splitting, dev-server HMR across the plugin tree); a new versioned frontend contract to maintain and document; a migration that moves ten plugins' worth of views out of core; risk of a leaky shared-component surface becoming an accidental contract. The payoff only matters once external (out-of-tree) plugins with their own frontends are a real requirement. Until then, step 1's route gating delivers the user-visible correctness (no reachable dead pages) at a fraction of the cost.
Consequences
- Disabling a backend plugin now makes its frontend routes redirect to the dashboard instead of loading a broken shell. Behavior matches the already-dynamic navigation.
- One extra lightweight request at app boot (
GET /api/plugins/enabled), cached for the session. - Fail-open means gating is a UX guardrail, not a security control. It is not a substitute for backend authorization: the API still enforces auth and the disabled plugin's endpoints are simply unregistered. Never rely on route gating to protect data.
- The future frontend-plugin contract remains open work; this ADR records the direction and its cost so a later decision can pick it up.