Files
shopdb-flask/docs/COLLECTOR-INTEGRATION.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

86 lines
3.8 KiB
Markdown

<!-- docmeta
purpose: explanation
audience: operator, adopter, integrator, developer
status: current
summary: What the collector is, what it guarantees, and which of the three collector pages to open next.
loadwith:
-->
# The collector
The collector is how the shop-floor fleet pushes what it knows about itself into
ShopDB. It replaced the classic-ASP `api.asp?action=updateCompleteAsset` path.
This page is the shape and the guarantees. It is short on purpose: the detail
lives in three pages below, and you almost never need more than one of them.
## Which page you want
| You are | Open |
|---|---|
| Rolling reporting out to a fleet, or a bay is returning an error | [COLLECTOR-CLIENT-SETUP](COLLECTOR-CLIENT-SETUP.md) |
| Writing or changing a client, or answering "what does this field do" | [COLLECTOR-PAYLOADS](COLLECTOR-PAYLOADS.md) |
| Deciding how a PC proves who it is, minting or revoking a credential | [COLLECTOR-AUTH](COLLECTOR-AUTH.md) |
| Asking why the contract is shaped this way | [ADR-006](adr/ADR-006-collector-contract.md) |
Where all of this sits relative to EventSaver, the backup collectors and the
kiosks is [FLEET-ARCHITECTURE](FLEET-ARCHITECTURE.md).
## The shape
One dynamic route, `POST /api/collector/<plugin>`, serves every enabled plugin
that returns a collector schema. A plugin declares its identity field and its
accepted fields; the dispatcher handles auth, parsing, the audit row and the
error envelope, and the plugin handles the upsert. Adding a collector is adding a
schema, not adding a route.
Two plugins use it on a normal fleet:
- `computers` - what this PC is. This is the record everything else hangs off.
- `printers` - what print queues this PC actually has.
The `endpoints` plugin adds a third, much larger payload for sites running the
endpoint agent.
## What it guarantees
**Idempotent.** The same report twice changes nothing. A PC is matched by its
identity field, so re-imaging a bay updates its record instead of duplicating it,
and existing asset relationships survive.
**Patch-style, where it says so.** On the computers payload an omitted field
leaves the stored value alone, so a report from a bay that could not read its
BIOS never blanks a serial number. The printers payload is deliberately the
opposite: the reported set REPLACES the host's queues, because "what does this
bay have right now" is not a question about history.
**Warnings, not failures, for soft problems.** An unmapped pc-type, an unknown OS
string or an unknown application name is reported back in `warnings` and the row
is still written. The alternative - refusing the report - loses the whole PC over
one unrecognised string.
**Observed is never assigned.** Nothing a PC reports becomes a statement of what
it SHOULD have. A bay that installed the wrong printer cannot make itself right
by reporting it; turning observed state into assigned state is always a person's
decision.
**The report says what the PC is, not where it is on the network.** The bay
reports every NIC and takes no view of which matters. Only the server knows the
site's addressing, so only the server picks.
**Fail-closed on authentication.** A server with no credential configured refuses
every request rather than silently accepting unauthenticated data. Credentials go
in a header, never a querystring, so they stay out of access logs and proxy
history.
## The one thing that changed recently
A PC used to authenticate with a key the whole fleet shared. It now
authenticates as ITSELF, with a per-PC credential issued by enrollment and
revocable one PC at a time. The shared key still works for PCs that have not
enrolled, and is refused for any PC that has.
If you are adopting this product today, plan on per-PC credentials and treat the
shared key as the bootstrap. [COLLECTOR-AUTH](COLLECTOR-AUTH.md) is the whole
story.