Files
shopdb-flask/docs/adr/ADR-018-metrology-instruments-are-machines.md
cproudlock f9d6b57f0f Move the documentation to the line that ships, and correct it against the code
The docs lived on one lineage and the fleet code on another. That is why six
pages described a shared fleet key as how an agent authenticates, why
COLLECTOR-AUTH had to warn that the per-PC credential code was not in the
repository it sat in, and why ADR-019 recorded a decision whose implementation
was somewhere else. Documentation that cannot see the code it documents goes
stale by construction, and no amount of editing fixes that.

So the corpus moves here: 84 files, 56 pages, 20 ADRs, the proposals, INDEX.md,
llms.txt and both gates. Filenames are unchanged, because a wiki page name is
derived from the filename and a rename breaks every link anybody saved.

THE POINT OF THE MOVE IS THE CORRECTION IT ENABLES. Every caveat that said "not
in this tree" was false the moment the files landed beside the code, so each was
rewritten from what is actually here:

- COLLECTOR-AUTH gained the real enroll request body, the two bounds on the
  unauthenticated route (per-IP rate limit, pending cap with stale rows dropped
  before a real PC is refused), and the rejected pending reason that binds to
  the endpoint identity rather than the nonce.
- ADR-019 now describes an implementation that is present, including its tests,
  and says plainly that what remains is the FLEET migration, not the code.
- proposals/device-identity claimed phase 1 was unbuilt. plugins/computers
  declares deviceid on the collector schema and prefers it over the older
  fallbacks. Corrected in the page, its summary and the index.

WINDOWS/IIS IS NOW DOCUMENTED AS THE LEGACY PATH, per the product decision, and
carefully: it is what production runs today. Every Windows page opens by saying
it is supported, not for a new site, and where a new site should go instead. No
procedure was cut - an operator on an IIS box at 2am needs these pages to work
exactly as well tomorrow. MIGRATE-TOPOLOGY stops being a footnote and becomes
the off-ramp, which is why it nearly doubled: what was there did not match how
the Docker stack really works here.

The Docker material that already lived on this line was kept and given
ownership rather than buried under the ported Windows-centric prose: DEPLOY now
describes the four services, the migrate service that runs the upgrade chain
before api starts, TLS terminated by nginx, and the plugin count corrected from
thirteen to seventeen - a number both lineages had wrong.

ROADMAP is rewritten from evidence rather than memory: what has shipped, read
out of the changelog, the ADRs and the manifests, and ahead of it exactly two
items - finalize a distributed release and polish the setup wizard.

PROJECT-MAP is generated and was stale; the GENERATOR was what was wrong.
--check passes now.

API-REFERENCE is retired to a pointer. /api/docs serves 573 operations with
derived auth, query parameters and harvested examples, and a hand-written page
competing with that is a liability. The file stays so its wiki page and its
inbound links survive.

AND THE MOVE TURNED ON A SCRUB THAT HAD NEVER RUN HERE. test_docs_publishable
keys on docs/*.md, which this line did not have, so it skipped - its own comment
predicted what would surface. Porting the corpus activated it and it found 48
lines that must not reach a published wiki: branch names abbreviating the site,
assistant-tooling paths, the site name in two deployment pages, and an employee
ID in a Windows path that the scrub does not even look for.
2026-09-19 09:10:15 -04:00

6.1 KiB

ADR-018: Metrology instruments are machines

  • Status: ACCEPTED
  • Date: 2026-09-04
  • Deciders: ShopDB maintainers
  • Relates to: ADR-001 (asset as the platform contract), ADR-006 (collector contract), ADR-008 (a plugin owns its tables and its migration chain)
  • Supersedes: ADR-005 (equipment plugin scope vs measuringtools plugin)

Context

ADR-005 split manufacturing machinery from metrology instruments into two plugins on the grounds that they are two asset classes: machines make parts, measuring tools measure them. It named the metrology population as "CMMs, Keyence vision systems, wax-and-trace surface profilometers, GenSpec instruments", and the measuringtools plugin was built against a docstring naming a different population again: "calipers, micrometers, thread gages, bore gages, height gages".

Those two lists are not the same thing, and the difference is the whole decision. One is bay-mounted capital equipment with a controlling PC. The other is hand tools in a drawer. The plugin was built for the second and populated with neither.

Sixteen months on, the evidence is in:

  • measuringtools holds zero rows, against 204 machines, 305 computers, 73 network devices and 53 printers.
  • The metrology inventory actually waiting to be entered is 134 instruments: 35 CMM, 32 form tracer, 23 vision, 18 wax trace, 14 measuring, 8 Genspect, 2 eddy current, 1 spline. Every one is bay-mounted with a controlling PC.
  • Not one caliper, micrometer, thread gage, bore gage or height gage. The population the plugin's own docstring justifies it with does not exist at the reference site and is not planned.
  • CMM already exists as a machinetype, and Part Marker is already classed as a machine while Form Tracer is classed as a measuring tool. Two bay instruments with a controlling PC, split across two plugins, with the line drawn somewhere no operator can predict.

The split has therefore been paying an ongoing cost - a duplicate type page, a settings group, a nav section, a migration chain, a searcher, dashboard cards, map colours, label printing and four collector pctypemap entries - to model a distinction that the inventory does not make.

Decision

Metrology and inspection instruments are machines. The measuringtools plugin is retired and the measuring_tool asset type is removed.

Calibration moves to machines, and is not lost

machines gains the calibration lifecycle as nullable columns:

machines
- calibrationintervaldays   integer, null
- lastcalibrationdate       date, null
- nextcalibrationdate       date, null
- calibrationprovider       varchar(150), null

Calibration status stays derived at read time from nextcalibrationdate (overdue / duesoon / current / unknown, 30-day window), exactly as measuringtools derived it and for the same reason: a stored status is stale the day after it is written. The helper moves across unchanged.

This is a net gain rather than a port. A machine could not record calibration at all before, and a part marker with a certified fixture, or a machine with a calibrated probe, had nowhere to put it.

machinetypes.ismetrology answers ADR-005's objection

ADR-005 made one concrete technical argument, and it deserves a concrete answer rather than silence:

"show me all measuring tools" requires an enumeration of measuring-instrument equipmenttype values, which scales badly.

That is correct about enumeration and it is why machinetypes gains a boolean ismetrology. The metrology view stays a first-class single-column filter - WHERE mt.ismetrology = 1 - not a hardcoded list of type names that drifts the first time someone adds an instrument type. The calibration report, the gage lab view and any compliance export all hang off that flag.

What does not change

  • assets.gaugelabreference stays on the core asset. The gage tag was never a measuringtools column, so it survives untouched and stays searchable for every asset type.
  • The collector's device identity file and the measuringtoolid payload alias stay accepted. Bays staged with measuringtool-id.txt keep reporting; only the asset type they resolve to changes.
  • Instrument types keep their names. A Form Tracer is still a Form Tracer, now as a machinetype with ismetrology = 1.

Consequences

The migration is free today and expensive later. measuringtools has zero rows, so retirement is a DROP TABLE, not a data migration. Once the 134 staged instruments are entered they carry relationships, audit history, map positions and collector links, and every one of those would have to be rewritten. This ADR is being taken now specifically because the window is open.

A site that did populate it needs a real migration. The reference site did not and the sister site shows no sign of having done so - its branch contains no deliberate work on the plugin in its entire history - but that is inference, not a query against their database. Confirm before the removal ships to another site. If rows exist, the retirement migration must copy them into machines with ismetrology types rather than drop them.

Four collector pctypemap entries change asset type. gea-shopfloor-cmm, -keyence, -genspect and -waxtrace resolve to machine instead of measuring_tool. The collector:measuringtool relationship label is kept as a recognised origin marker so links a collector already created are still archived correctly rather than orphaned.

One fewer of everything. A duplicate type page, a settings group, a plugin migration chain, a gated searcher, a set of dashboard cards, a map colour entry and a label-printing branch all go. That is the point.

ADR-005 is superseded, not reversed in principle. Its reasoning was sound for the population it described. The population never arrived. If a site ever does track hand gages in quantity, the answer is a handgages plugin against that real inventory - not the reinstatement of this one.