Files
shopdb-flask/docs/adr/ADR-003-plugin-distribution.md
cproudlock 534f179ee6 Make main the lean product a site receives
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.
2026-09-19 11:24:40 -04:00

4.0 KiB

ADR-003: Plugin distribution model

  • Status: ACCEPTED
  • Date: 2026-05-08
  • Deciders: ShopDB maintainers

Context

Sister sites adopting shopdb-flask need a way to:

  1. Install the framework
  2. Pick which plugins they want
  3. Build their own plugins for site-specific equipment
  4. Receive updates to both framework and plugins

Today, every plugin lives in the plugins/ directory of the framework repo. There is no separation between framework code and plugin code, no install / uninstall, and no way for a site to develop a plugin without forking the whole repo.

Three viable distribution models:

Model How a site installs a plugin
In-tree only Fork the framework repo, add plugin under plugins/, run their own deploy. No separation.
Pip-installable plugins Each plugin published as a Python package. Site does pip install shopdb-printers shopdb-network etc. Discovery via Python entry points. Framework loads any installed plugin that registers itself.
Git-based plugins Each plugin lives in its own git repo. Site clones / submodules into plugins/<name>/. Loader picks them up from the directory.

Decision

Use a hybrid model with two clearly-labeled paths.

  1. Bundled plugins: a small set of plugins ships with the framework, in-tree at plugins/. These are the reference implementations and the default install (printers, computers, network, equipment, usb, notifications). A site that wants only what's bundled needs no extra work.
  2. External plugins: sister sites or third parties build plugins in their own git repos. The site running the framework drops the plugin into plugins/<name>/ (clone, submodule, or symlink) and runs flask plugin install <name>. No pip packaging required for v1.

Pip-installable plugins (Python entry-point discovery) are deferred to v2. The complexity is not justified until at least two sites are running their own plugins.

Consequences

Positive

  • v1 is simple: filesystem-based discovery (already implemented in shopdb/plugins/loader.py), works for both bundled and external plugins.
  • Sites can develop plugins without changing the framework repo.
  • The plugins/ directory is already the canonical location, so no architectural change is needed.

Negative / cost

  • No automatic update path for external plugins. Sites must git pull in each plugin directory manually. Acceptable for v1; revisit when plugin count grows.
  • Multiple plugin authors writing in parallel can collide on namespace (e.g., two plugins both registering an AssetType named "Equipment"). Need a naming policy: plugin names and asset-type names should be prefixed with the site or org if not in the bundled set.

Neutral

  • The existing in-tree pattern keeps working. This decision just formalizes it and clarifies the path for outside-the-tree plugins.

Alternatives considered

  1. Pip-installable from day one. Cleaner for the long term but adds packaging, entry-point registration, and CI steps. Premature for current scale (one site running, no sister-site plugins yet).
  2. In-tree only forever. Forces every site to fork. Doesn't scale beyond two or three sites.
  3. Submodules only. Forces git-submodule discipline on every adopting site. Submodules are notoriously fiddly. Rejected.

Open questions

  • For external plugins, should there be a manifest field (source_url) declaring where the plugin can be cloned from, so flask plugin install could pull it for the site? Defer; manual clone is fine for v1.
  • Naming convention for non-bundled plugin directory names: prefix with site? (gea-wjsf-shipping)? Adopt if and when we hit a name collision.

References

  • shopdb/plugins/loader.py (filesystem discovery)
  • shopdb/plugins/cli.py (plugin install / uninstall command)
  • ADR-001 (defines what plugins target)
  • ADR-002 (defines plugin version compatibility)