Eleven commits from the sister site: a reversible Maximo/WINC machine-adoption import, a versioned agent binary store with upload and rollback, remote-BuildKit CI, tray version reporting, and UI fixes. Applied as a patch again - the published mirror rewrites hashes, so the branches have unrelated histories and git refuses to merge them. Reviewed by three agents before merging. Four things fixed here. THE PUBLISH WORKFLOW WAS DEAD. The new remote-BuildKit step in publish-images.yml sits at column 0 instead of indented under steps:, so the whole file is invalid YAML and GitHub would refuse it. Their entire GHCR distribution channel - which Start-ShopDBDev.ps1 and the compose files consume - was broken at the source and clearly never run. Indented; all five workflows now parse. THE IMPORT'S APPROVAL CHECK COULD NOT FAIL. commit() built the plan and the approval packet from the same upload and then asked the writer whether they matched, so packet_matches_plan compared a hash against itself. The documented contract - "a human approves a specific, frozen plan, and the writer can prove nothing drifted" - did not exist in the web path: an admin could preview file A and commit file B, gated only by the needs-create group NAMES they ticked. The preview's planhash is now required at commit and checked against a freshly rebuilt plan. Their tests committed without previewing, which is what let this through; they go through the real flow now, and three new tests pin it - all confirmed to fail with the check stubbed out. endpoints.agentpackage QUIETLY GREW. It used to mean "wrap the staged exe in a ZIP"; with the upload routes it also means "choose the executable every future package installs and runs as SYSTEM". Before this, staging needed filesystem access to the server. The permission description still said only "generate and download a package", so an admin granting it could not see what they were granting. Reworded. NOTHING RECORDED WHAT WAS STAGED, OR BY WHOM. The manifest held version, size and timestamp; re-uploading a version replaces the bytes in place under the same label. A sha256 of the stored file is now recorded, and the upload is audit-logged with it - after an incident there was previously no answer to who put that binary on the fleet. Also documented the nine new routes in docs/api-inventory.json (that gate cannot run on the mirror, so it falls to us at promotion time again), regenerated the spec and the project map, and kept our own docs where they conflicted: docs/ is scrubbed from the mirror, so their DEV-BUILD-TEST.md still had the dev-be channel mapping we corrected, and their PLUGIN-HOOKS.md was a new 45-line file rather than our 737-line canonical one. Their journal section is appended to ours. Contract version comes across as 0.30.0 for a genuinely additive surface. Suite 2369, frontend 324, gate green. Scope: product
4.6 KiB
Copilot instructions for shopdb-flask
Follow these when suggesting code. They are enforced by a naming/style hook and
by CI (.github/workflows/ci.yml) - suggestions that break them fail the build.
CONTRIBUTING.md is the full authority; this is the short version.
Naming (LOCKED - the hook rejects violations)
- DB tables: lowercase, concatenated, plural. No underscores, no dashes.
machines,networkdevices,businessunits- NOTmachine_types,BusinessUnits. - DB columns: lowercase, concatenated, singular. No underscores.
machineid,lastzabbixsync,isactive- NOTmachine_id,last_zabbix_sync. - Foreign keys: referenced table (singular) +
id:locationid,vendorid. - Booleans:
is/hasprefix:isactive,isshopfloor. - Index names:
idx_<table>_<column>(underscores allowed here only).
Python
- A variable, attribute, function, or dict key that holds a DB value MUST match
the column name exactly - do NOT convert to snake_case.
Column
machineid->Machine.machineid,{"machineid": 1}, localmachineid. - Pure code that does NOT mirror a DB field uses normal snake_case (PEP 8):
loop_count,current_user,validate_input(). - Classes: PascalCase, spelled out (
NetworkDevice,AssetType).
JavaScript / Vue
- A JS variable holding an API field value matches the API key exactly - do NOT
camelCase it. API
{"machineid": 1}->response.machineid, nevermachineId. - Components: PascalCase (
AssetDetail.vue). CSS classes: lowercase-with-dashes.
API
- Endpoints: lowercase plural nouns, no underscores/dashes:
/api/networkdevices. - Query params + response keys match column names:
?locationid=5,{"machineid": 1, "lastzabbixsync": "..."}.
Allowed acronyms only
Universal: id url api http https json jwt sql os ip dns csv pdf cors ttl uuid html css orm. Domain: cmm cnc pc usb vnc winrm ssh ssl tls tcp udp smtp ldap vlan sso dnc focas clm mtconnect. Anything else: spell it out.
Banned shorthand
Never use cfg ctx mgr req res env util helper or db as a standalone variable
name. Spell out: config context manager request response environment utilities.
_bp is fine only as a suffix with a meaningful prefix (printers_bp).
Style (ASCII only)
- NO emojis anywhere - code, comments, strings, UI.
- NO em-dashes, en-dashes, Unicode arrows, or smart quotes. Plain ASCII only.
- Comments default to NONE. Add one only when the WHY is non-obvious; keep inline
#///comments terse. Docstrings stay normal English. - Dark theme is the default; keep UI functional and professional.
Architecture (do not violate)
- Plugins are the product. Plugin code lives in
plugins/<name>/{models,api,services,schemas}/with amanifest.json(single source of truth: name, version, dependencies, api_prefix) and aBasePluginsubclass inplugin.py. - Plugins never import core internals. Use the contract surface
shopdb.api(e.g.from shopdb.api import db, Asset, success_response). Adding to that surface is a contract-version bump + adocs/PLUGIN-HOOKSupdate in the same PR. - Migrations, never
db.create_all(). The core Alembic chain is inmigrations/versions/; each plugin owns its own chain underplugins/<name>/migrations/. New schema = a new migration with an idempotent guard and a real downgrade. Migrations must run clean on strict MySQL 8. Any model column/table change ships WITH its migration in the SAME change, and bringing up a new image MUST runflask db upgradethenflask plugin upgrade-allbefore serving traffic. A model that references a column its migration has not applied yet 500s every query on that table (1054 Unknown column), so code and schema must never be deployed out of step. - Asset model is the platform contract. Physical things are an
Assetplus a plugin subtype row linked byassetid(FK,ON DELETE CASCADE). Consumables with quantities are standalone tables, not assets. - Ledger pattern: a cached
quantityonhandmoves in the SAME commit as the signed transaction row it reflects. - Configuration for endpoint agent: The endpoint agent's live collector key and base URL are provisioned in the Windows registry
HKLM\SOFTWARE\GE\ShopDB(valuesCollectorKey,BaseUrl), not committed inappsettings.json;appsettings.jsonholds only non-secret runtime settings.
Before you finish a change
Run the three gates (CI runs the same):
python -m pytest tests/ -q
cd frontend && npx vitest run && npm run build && cd ..
bash scripts/check-naming-and-style.sh
Commits: short present-tense subject, body says WHY. No AI/tool attribution in commit messages, code comments, or docs.