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.2 KiB
ADR-017: Buildings and levels as the map model
- Status: ACCEPTED
- Date: 2026-08-17
- Deciders: ShopDB maintainers
- Relates to: ADR-001 (asset as the platform contract), ADR-004 (per-site instances), ADR-010 (frontend plugin hooks), ADR-015 (site-specific configuration)
- Supersedes: the site-wide
map_blueprint_light/map_blueprint_dark/map_width/map_heightsettings
Context
A site's floor map is one image. Four settings describe it - two blueprints
(light and dark) and the native pixel width and height - and assets.mapx /
assets.mapy are absolute pixel coordinates in that image's space.
That model has one floor in one building, which was true when it was written and is no longer. The reference site is adding a second level, and a second building is likely within a year or two. The immediate trigger is a new blueprint at 3308x4000 where the old one was 3300x2550.
The obvious cheap answer is to stack levels on one canvas: draw the second level below the first and keep one image. It works, and it was seriously considered. It was rejected because it makes the level an inference rather than a fact:
- "Which level is this asset on" becomes
mapy > 2550. Every per-level filter, count, report and export has to know that constant, and re-exporting the drawing at a different height silently changes the answer everywhere. Not broken - wrong, which is worse. - Distance between two markers becomes computable and meaningless, so anything doing nearest-asset or clustering quietly answers nonsense across levels.
- One canvas forces one scale. A mezzanine drawn at a different scale than the floor below cannot be expressed at all.
- 3308x4000 is portrait for a building whose floor is landscape. At a zoom where a marker is clickable, roughly half a level is visible, and "fit to level" is not expressible.
- A third level makes each of these worse, and adds a second threshold.
Timing decided it. Because the level layout changed and machines moved, every marker is going to be repositioned anyway. Introducing levels now costs one pass over the positions; stacking now and splitting later costs two, and in between every position placed encodes the threshold into real data - which a later migration would then have to un-guess by comparing Y against it.
Decision
Two tables, and assets reference the level.
buildings buildingid, buildingname, sortorder, isactive
maplevels levelid, buildingid, levelname, sortorder,
blueprintlight, blueprintdark, mapwidth, mapheight,
isdefault, isactive
assets levelid (nullable; the default level for existing rows)
1. An asset references the level, never the building. The building derives from the level, so the two cannot disagree. Storing both would be a fact recorded twice with no difference in granularity to justify it.
2. Blueprints and native dimensions belong to the level. This is what the site-wide settings could not express: two levels in one building may be drawn at different sizes and scales, and two buildings certainly are.
3. Name and order are separate. levelname is text and sortorder is an
integer. Levels are not reliably numbered - basement, ground, mezzanine, roof,
tunnel - and sort order gives adjacency and up/down navigation without
pretending the names are ordinal. It also lets a mezzanine be inserted between
two existing levels without renumbering anything.
4. mapx / mapy keep their meaning, scoped to the level. They stay
absolute pixels in the native coordinate space of the level's blueprint. No
normalisation to fractions: pixels are what the drawing tools produce, what an
operator can read off an image, and what the existing data already holds.
5. A level is required to render a position, and absence is not a default. Where a payload carries a position without a level, the UI renders "level unknown" rather than falling back to the default level. Falling back draws one building's ground floor with a marker positioned for another building's mezzanine: it renders perfectly and points at the wrong place, and nothing about the result looks wrong. A visible gap is worth more than a confident wrong answer.
6. The level list is readable without authentication. The printer installer map runs optional-auth, before anyone logs in, and it needs a blueprint. This follows the precedent already set for printer install-list and the slide feed. Blueprint paths and level names are not secrets; the positions of assets on them already render on public kiosk pages.
7. Levels are not Locations. Assets carry locationid already, and reusing
it is tempting. A Location answers "which operation owns this"; a level answers
"which drawing renders it, at what native size". Overloading Location with
blueprint images and pixel dimensions makes both concepts worse. They coexist:
an asset on level 2 in operation 0613.
Migration
The existing four settings become one building and one level, marked default, and every asset with a position points at it. Nothing renders differently on the day it lands. The settings keys are then retired rather than left as a second source of truth that can disagree with the rows.
Consequences
Positive:
- A second building costs a row and a blueprint. So does a third level.
- Per-level export, per-level zoom, and per-level calibration all become expressible. Calibrating one level against its own landmarks is more correct than transforming a whole site at once.
- Level becomes queryable - counts and filters per level or per building are ordinary queries rather than coordinate arithmetic.
Negative:
- Every surface that draws a marker learns there is more than one drawing. That
is two components, seven views, four asset position pickers, the printer
installer map, the PDF export, and eight API payloads that must emit
levelidbesidemapx. A payload that forgets it produces the silent-wrong-map failure described above, which is why rule 5 exists and why a build gate checks that the two fields travel together. get_map_overlaysgains level context, so this is a plugin contract change (0.20.0) and plugins rendering overlays need to declare which level they are for.- One more admin surface: levels and buildings have to be managed somewhere, and the existing floor-map settings page becomes that.
Alternatives considered
Stack levels on one canvas. Rejected above. Zero cost today, and it makes the level an inference over a magic number.
Normalise coordinates to fractions of the image. Would make a rescaled blueprint self-correcting, which is genuinely attractive. Rejected for now because it converts every existing integer position through a lossy division, and because it does not help the actual problem: the levels changed and machines moved, so the positions need human review regardless. Worth revisiting independently.
A level string on the asset, with one blueprint per level in settings.
Rejected: settings keyed by level name is a table with extra steps, and it gives
no place for per-level dimensions or ordering.