Skip to content

Latest commit

 

History

History
413 lines (350 loc) · 30.9 KB

DESIGN-KIT.md

File metadata and controls

413 lines (350 loc) · 30.9 KB

The design kit, and what is left of it

The kit is twenty-one screens of static HTML in design/. Those files are the source of truth for what a screen shows — this document is not a transcription of them, and deliberately no longer tries to be.

What it carries instead is the part the HTML cannot: which screens exist in the app, what the two that do not would need from the backend, and the conventions that hold across all of them.

Replaces DESIGN-KIT-PLAN.md, DESIGN-KIT-INTEGRATION.md and DESIGN-KIT-BACKEND-GAPS.md, which answered the same question from three angles and disagreed with each other and with the code. The per-screen inventories they carried for built screens are gone: the code is the truth for those now, and a second description of a finished screen is a second thing to keep in step.

Statuses below were read off the code — routes in each app's App.tsx, models in backend/printorian/contexts/ — not off a plan. Re-verify before trusting; that is how all three predecessors went wrong.

Last verified 2026-09-05. The settings counts in §1 and §2.1 come from len(SECTIONS) and len(FIELDS) in contexts/settings/sections.py and from the kind counts over FIELDS, evaluated rather than transcribed; the screen's state comes from App.tsx rendering SettingsPage and from SettingsPage.test.tsx. Deliberately not from HANDOFF.md — a status copied from another document has only moved the drift.


1. Where the screens stand

Twenty-one of twenty-one are built. Every screen ships, public and control; what each still owes is in its §2 entry. settings was the nearest of them and is now built — 105 parameters across fourteen sections, served and audited. What is left of it is three of the table-valued settings, not the screen (§2.1).

Screen Realm State
promo catalog configurator checkout cabinet account auth blog blog-post public built — all nine
dashboard orders fleet materials users postproduction packaging control built
settings control built — scalars and Диагностика; the tables remain, §2.1
service control built — the ticket board, the work order and the reliability table; §2.2 for the rest
purchasing control built — the desk, the six stages and receiving into stock (filament, packaging, consumables, spare parts); the deferred panels are in §2.3
store control built — cells, ledger and movements; §2.4 for the rest
logistics control built — shipments, carriers and delivery accuracy; §2.5 for the rest

index.html is the kit's own contents page, not a screen.

2. Settings, purchasing, the store, and the two that are not built

For §2.2 and §2.5 the kit inventories are preserved verbatim, because for those the kit is the spec, and each ends with what the backend already has. §2.1, §2.3 and §2.4 are no longer among them — settings, purchasing and the store are built, so the code is the truth for them and this document records only what is still owed. The numbering is kept as it was so that the references to it from the tracker and from §2.5 keep pointing at the same place.

2.1 settings.html — built, minus the tables

The screen exists. SettingsPage.tsx renders it and contexts/settings serves it: 105 parameters across fourteen sections, over GET /settings, GET /settings/sections, GET /settings/history and PUT/DELETE /settings/{key}, gated on MANAGE_SETTINGS.

The catalogue is derived, not hand-listed — the pricing rates are read off dataclasses.fields(RateSnapshot) and the scheduler weights off SchedulingPolicy. That is the same argument ADR-0020 makes for rates_to_dict: a hand-listed set of keys silently omits the next rate somebody adds, and a settings screen missing a rate is worse than one that never had it, because it looks complete.

One control per kind, all built — integer 31 · decimal 30 · boolean 15 · enum 15 · string 8 · table 5 · secret 1. The single secret, finance.yookassa_secret_key, is write-only: stored encrypted and never read back. Editing a row marks it dirty, reveals the previous value, offers a per-row revert and counts into a save bar; each save writes an audited «было · стало» that GET /settings/history serves back under Обслуживание системы. All three of the kit's irreversible operations are built and guarded by typing the farm name first — reset rates, drop telemetry and clear the wait list. The third one's hint is the one place the screen deliberately does not say what the kit says: the kit promises waiting orders return to «Подготовка», and production.policies has no such transition — READY goes only to ASSIGNED or CANCELLED. The operation removes the recorded reasons for waiting and leaves the jobs ready, the button says so, and which of the two is wrong is a question for a person rather than something the code should guess (contexts/production/wait_list.py).

The store is read at the edge, not only stored. Six resolutions run per request or per worker pass rather than once at process start: resolve_rates and resolve_tiers (pricing and orders), resolve_promise (SLA), resolve_int for telemetry retention, resolve_scheduling in the scheduler pass, and resolve_finishes at the four edges that price a postprocessing operation — the two quoting endpoints, the order/reprice pair, and the intake sweep. A key with no row resolves to the code default, so an empty table prices exactly as the farm always did, and an order keeps the rate snapshot it was agreed at (ADR-0020) — changing a margin moves the next quote and nothing already sold.

Диагностика is built, and it is the one section that is not a form. DiagnosticsPanel.tsx draws the kit's section 14 from /health/ready and /health/workers — each dependency, each worker loop and each printer the worker says it is driving, with the backend's own ok / degraded / failed distinction kept intact and a fourth state, «не измерено», for anything that did not answer. The tab is inserted by the console rather than served: SECTION_ORDER has fourteen entries because a read-only page has nothing for a settings catalogue to carry, and that is still the right call.

What is still owed. Three of #29's six table-valued sections, two columns of «Каталог операций», and one behaviour the screen displays without wiring:

  • #29 — the remaining table-valued sections. Five are built and are the pattern to copy rather than reinvent: the volume ladder, the customer tiers, postprocess.operations — the operations catalogue, whose norm-hours and flat fees the pricing engine reads at both the quote and the order — and logistics.zones, the shipping tariff, which resolve_rates maps onto RateSnapshot.zones and which therefore reaches a customer's estimate and is pinned per order — and service.maintenance_defaults, the maintenance intervals, which POST /printers seeds a new machine's service card from and which an operation added without a periodicity takes its interval from; its «Простой» and «Расход» columns are not stored, because nothing reads them. API keys are built (identity.api_keys, /api-keys, settings/ApiKeysPanel.tsx): a key is shown once, stored as a hash, holds read permissions only and never more than its owner holds now, is refused by every route that acts as a person, and is accepted by the live stream so the kit's floor screen can use one. Still owed: notification event×channel and webhooks. Webhooks are a new subsystem with delivery, signing and retry, and the event matrix is switches over channels that do not exist — neither is a catalogue row away from working.
  • Two columns of «Каталог операций» are deliberately not ported, and neither is an oversight. «На см² поверхности» needs a surface area inside PriceSpec, and surface area does not reach the checkout: the quote context emits volume_cm3 and bounding_box_mm and no surface_area_mm2, and CheckoutPage.tsx sends no mesh at all — so the term would price at the configurator and not on the order. Pricing an unmeasured mesh at 0 cm² is ADR-0007's forbidden move, and it is also a change to the calculation's shape, which moves ENGINE_VERSION and makes CachedPlates._rates_for refuse the cached-plate path for every order already paid. «Доступна» is only honest once the configurator stops offering what the farm switched off, and FinishStep.tsx renders a hardcoded list before any quote — so it needs a public read of the catalogue: a new endpoint, a regenerated client and an entry against test_docs_endpoint_consumers.py. The same closure is why «Добавить операцию» is absent: the code set is closed to the four the storefront offers, and the server refuses a fifth.
  • #32 — worker loop intervals still take effect only on restart.

design/settings.html stays the reference for anything not yet built. For what is built, the code is the truth — and per this document's own opening rule, a second description of a finished screen is a second thing to keep in step.

2.2 service.html

Five ticket kinds: установка · ремонт · ТО · загрузка материала · перемещение.

  • Ticket board with priority and elapsed time; «СООБЩИЛ ДРАЙВЕР» origin
  • Последствия — what this ticket already costs
  • Порядок работ — steps with norms
  • Fleet reliability table: Машина · Состояние · Наработка · Ближайшее ТО · Отказов/год · Надёжность
  • Причины отказов — 90 суток · 18 случаев, funnel
  • Запчасти на посту — Позиция · Остаток · Расход/мес · Статус
  • Crew badges and marks; MTTR, fleet readiness

What backend exists: ServiceOperation with kind/interval/hours, наработка, ближайшее ТО. Since #33's first slice, also the failure record — printer_failures, opened automatically from a machine the driver reported in ERROR, closed by the observation that saw it working again, and read back through GET /service/reliability as отказов/1000 ч, MTTR over repaired failures only, and the «Причины отказов» funnel with an uncategorised count beside it. The second slice (#33 again) is the ticket board: service_tickets and their steps, raised by a person or — for a driver-reported failure — by the sweep, worked through «Порядок работ» and closed; ServicePage.tsx draws the five lanes, the work order and the reliability table, which is why §1 now calls service built.

Still owed, and why each waits: «Последствия» is money and needs a route behind VIEW_FINANCIALS; «Запчасти на посту» needs a spare-parts stock that inventory does not hold; crew badges need a crew record; maintenance tickets raised from running hours need the service card to open tickets, with its own idempotence question.

Two judgements in that slice are worth knowing before arguing with the numbers. OFFLINE is deliberately not a failure: mark_unreachable writes it for a poll that did not answer, so counting it would mint one failure per machine on every network blip and drive MTTR from repairs nobody made. The cost is real and unfixed — a machine that is unreachable half the month still contributes its offline_seconds to its own denominator and so reads as reliable. And a driver's bambu.print_error.{code} is recorded verbatim but is not a cause; the farm has no table mapping one to «слом филамента», so the funnel counts only causes a person named.

What the backend still owes: #33 — tickets as an entity with steps, assignee, elapsed, consequence; spare parts stock; наработка on the same table as надёжность, which today would be two rulers (Printer.printed_hours accumulates from the live row, while надёжность divides by metric_rollups). «Последствия» is not merely unbuilt but partly unmeasurable: nothing decrements a spool, so «потеряно материала 148 г» has no source, and «Итого потеря 2 140 ₽» is money and belongs behind VIEW_FINANCIALS rather than on a production response.

2.3 purchasing.html — built, minus the panels that need receipts first

The screen exists. purchasing/PurchasingPage.tsx renders it and contexts/procurement serves it: suppliers, purchase orders over the kit's six stages plus cancellation, five purchasable classes on the lines, and receiving a material line into a material_lots row carrying its lot number and the price paid — and, since #35, a packaging, consumable or spare-part line into the shared stock (inventory.stock_articles), with the order's number as the movement's «Основание». A printer is still ordered but never stocked. MANAGE_INVENTORY gates the desk; prices arrive from GET /purchasing/orders/{id}/costs behind VIEW_FINANCIALS, as a separate route rather than as blanked fields — a null already means "not measured" (ADR-0007) and reusing it for "not permitted" makes the two indistinguishable.

It also gave inventory.low_stock_grams, inventory.auto_reorder and their two siblings their first reader, and it replaced material_specs.has_open_order — a hand-set boolean whose own comment called it a placeholder — with a question asked of the order lines.

What is deliberately not built, and why. Each of these is a follow-up rather than an omission; three of them would have to invent a number to exist at all.

  • «Структура закупок» and the four KPI tiles — «Экономия за квартал» has no baseline and «БЮДЖЕТ МЕСЯЦА 68%» has no source: there is no budget setting anywhere in the catalogue. Dropped the way #30 dropped the uptime tile.
  • Supplier scorecards — «Поставок · В срок · Брак · Оборот · Оценка» needs a defect record captured at receiving and a promised-versus-delivered measure. On a farm with no receipts every column would be a fabricated denominator, so the supplier panel carries counts and nothing else.
  • «Цены по ключевым позициям» — derivable from purchase_receipts once they accumulate. Empty and honest on day one.
  • «Зачем этот заказ»'s consumption rows, and the months-of-cover arm of «Последствие» — nothing in this system measures material consumption: material_lots.remaining_grams is written once, at lot creation, and never decremented. The reorder row's consequence is a discriminated value with no coverage arm and the console draws «—». test_procurement_reorder.py is the tripwire.
  • Receiving into packaging_tara and postproduction_consumables and spare parts stock — built by #35 as one shared stock model (inventory.stock_articles, its own ledger article_movements). Each receipt adds through an increment and a ledger row, which is what the old per-context counts lacked.

2.4 store.html — built

The screen exists. StorePage.tsx draws the cell map by zone and the movements feed; CellDetail.tsx is the cell popup, with its batches FIFO oldest-first. Behind them are storage_zones, storage_cells and the append-only material_movements, served by /store/cells, /store/cells/{address} and /store/movements.

One of the kit's four KPI tiles is deliberately not drawn. «Стоимость остатков» would sum MaterialLot.purchase_price over every lot, and receiving (#34) is the only writer of that column, so on a farm that has not received through it the tile would read 0 ₽ on several hundred thousand roubles of filament. «Ячеек» and «Заполнение» — counted from cells that exist — ship, and so does «Расхождения»: the lines of the last closed stocktake whose count differed from the book, or a dash when the farm has never counted. Of the right-hand column, «Движения», «Оборачиваемость» and «Залежалое» are built (StoreMeasures.tsx, over /store/turnover and /store/dead-stock): turnover is the mean days on shelf over lots that left, with the ones still there counted beside it; dead stock is costed only where receiving recorded a price, the unpriced lots counted rather than costed at nought, and the whole panel sits behind VIEW_FINANCIALS and is never requested without it. «Инвентаризация» is built (Stocktake.tsx, over /store/stocktakes): a count opens by snapshotting the book for every spool in a cell (a spool in a machine or the dryer is not on a shelf to count), lines are filled in one spool at a time, and closing corrects remaining_grams to the count with one stock.counted ledger row per spool that differed — the second and last path in the system that changes that column. An uncounted line stays at its book value and is reported as not checked; nothing is defaulted to zero. «Недостача» and «Излишек» in money are /store/stocktakes/{id}/value, behind VIEW_FINANCIALS, costed only where a price was recorded. «Следующая» is not drawn: no setting says how often the farm counts, and a date from an interval nobody chose is a promise nobody made.

Drying is a state computed at read time, from one stored instant. MaterialLot.dried_at is written by POST /store/lots/{id}/dried and by nothing else; the cell panel's «Сушка» column is inventory.drying_state folded from that instant, the clock and the two settings inventory.require_drying and inventory.drying_valid_hours — which nothing read before this slice. A spool never marked is unknown («не сушилась»), not expired («просрочена»): nothing was measured, so nothing lapsed. PLA and the rule switched off read as a dash. The trip to the dryer is two ledger rows (stock.to_dryer, stock.dried) and the spool keeps its cell meanwhile, so the map does not offer its slot to anybody.

Packaging, consumables and spare parts are stock now (#35, the owner's decision: one shared stock model). An article — inventory.stock_articles — is an item, its unit and how many there are, in at most one cell; every change is a row in article_movements, the shape of the spool ledger in the article's own unit. Packing a parcel consumes its box through it (and a changed choice gives the first box back — the old code took two), purchasing receives into it, and the packing and post-processing catalogues read their counts from it. The map counts articles beside spools, the cell panel lists them with move, issue and write-off, and «Движения» interleaves both ledgers with each quantity in its own unit.

And they are counted and measured like spools. A stocktake lines up the articles in the counted cells beside the spools (stocktake_article_lines, in each item's own unit) and its close corrects them through the article ledger, against the book at close. «Оборачиваемость» for articles is days of cover — how long what is on hand would last at the window's rate — because a box of film has no history of its own to measure days-per-lot on (article_measures); the unused ones are counted beside the mean. «Залежалое» adds the articles nothing has touched, valued at their recorded unit cost, to the one total behind VIEW_FINANCIALS. With this, §2.4 owes nothing.

When dead stock arrives it takes the api/routers/jobs.py shape — a separate route with VIEW_FINANCIALS on top of the production gate — never a value field appended to the cell map an operator already reads.

2.5 logistics.html

  • Отгрузка сегодня to the same cut-off as packaging
  • Carriers — Перевозчик · Отправлений · В срок · Повреждений · Средняя цена
  • Зоны и тарифы — built once, in settings (§2.1), and read from there: the rows are logistics.zones, they price the shipping lines of a real order, and the whole table is archived into that order's rate snapshot. What this screen still owes is the Отправлений column, which counts parcels — nothing counts parcels until there is a Shipment, and a column of noughts would claim the farm shipped nothing (ADR-0007), so the console's editor omits it.
  • Сроки доставки — Зона · Обещано · Факт · Точность
  • Shipment detail: 6-stage path, address from the cabinet, tracking history

What exists (#36): a Shipment opens when packaging ships a parcel, pinning the zone and its transit days from the order's own rate snapshot; every later change is a shipment_events row; delivered_at is set by the delivered event alone. GET /logistics/board, /scorecards and /shipments/{id} serve the lanes, «Перевозчики» (Отправлений · В срок over promised deliveries · Повреждений as recorded) and «Сроки доставки» per zone and per pinned promise. LogisticsPage.tsx draws them.

Still owed, and why each waits: «Отгрузка сегодня» is the packaging board's and is not copied; «Средняя цена» and «Что и почём» are money for a VIEW_FINANCIALS route; «Оценка» is a composite with no chosen weights; «Куда» needs the address off the order on a logistics read; «Возвраты» and «География» are a rate the scorecard already implies and a map.

3. Conventions every screen honours

Re-checked against the code; five of these were recorded as missing and are not, and a sixth — the tabs row — was recorded as missing while half of it was already in the tree. Every row here is a claim about a file, so check the file.

Convention State
data-realm public/control split, hazard rail, realm badge ✅ applyRealm
data-theme Void/Paper ✅ ThemeSwitch
data-state machine states ✅
data-tone (live/good/warn/bad) — colour means machine state, never decoration ✅
data-pri task priority ✅
data-tier operator badges ✅
data-sentiment (spend up = bad, revenue up = good) ✅
Shared modal ✅ shell/Modal.tsx
Sortable headers ✅ DataTable — via props, not the kit's data-sort-value
Filter counter chips ✅ FilterChips, and the three screens that hand-rolled it converted to it
data-bind live numeric readouts — deliberately not ported, and not an omission
data-tabs / data-tab-target / data-tab-panel ✅ Tabs · TabRail · TabView, over harvester/tabs.css
data-auth-open popup on any element ✅ AuthDialog, opened from the masthead
Tabular figures, right-aligned, basis underneath ✅

Tabs are two shapes and one convention. TabRail is the vertical rail the account's seven sections and settings' fourteen use; Tabs is the horizontal strip the kit draws for the faces of a single thing — the printer popup's «Сейчас · Параметры · Обслуживание · Слоты AMS», and the purchase order and the shipment when those are built. Both switch a TabView, which is the panel and its entry animation, and both take their arrow keys from shell/tablist.ts so a rail and a strip cannot become two controls. Nothing imports Tabs yet: it is built ahead of the screens that need it precisely so the four of them do not each invent one, which is the failure ROADMAP names under "Management tables are not a phase".

The row above used to read "CSS section 22 not ported", and section 22 had been ported — packages/ui/src/harvester/tabs.css is it, near enough verbatim, and has been since the account screen landed. The status had been carried forward from a plan instead of read off the file, which is the mistake this document's own opening warns about. What was actually missing was the horizontal strip and the keyboard behaviour — the rail and the panel were built, exported and in use on two screens while this table called the whole convention absent.

The kit's three attributes do not all survive the port, and that is correct. data-tab-panel stays, because the ported CSS selects on it to animate the panel that just became current. data-tabs and data-tab-target do not: they were how the static kit's JavaScript found the panel a button switched to, and in React the component holds that relationship. Emitting them anyway would be markup that does nothing — a hook with no handler, which the next reader has to prove is dead before they may touch it.

data-bind is deliberately not ported. Do not build it. In the kit it wires a range input to a live readout, because the kit is static HTML and has no other way to make a number follow a slider; in React the readout is a render of the same state the input sets, which is the configurator's % and шт already working without an attribute. Porting it would add a second path to the same pixel, and the second path is the one that goes stale. This entry is — rather than ❌ for that reason: it is not owed, and an issue that asks for it should be closed as answered here rather than opened again out of completeness.

4. Backend capability nothing consumes

This list was empty and is not any more. All fourteen endpoints it originally carried gained consumers; the last of them was GET /materials/{code}, and #38 put two ways of closing it — build the materials detail popup the route was written for, or delete the route. The popup was built. frontend/apps/console/src/MaterialDetail.tsx reads the spec by code when a row is opened, which is where the density, the tensile figure, the heat-deflection temperature and the two suitability flags come from.

The four that remain are three writes to the failure record and one ticket action. The failure record's reads are consumed now — ServicePage.tsx draws «Надёжность» from GET /service/reliability and the ticket board from GET /service/tickets — but the screen records nothing by hand: a failure is opened by the sweep from a driver-reported state, and the three routes below are the person's half (recording one, closing one, naming its cause), which the board does not yet expose. Assigning a ticket to a named person needs a staff picker the board does not have; «Взять в работу» assigns it to whoever presses it.

  • #33 — POST /service/failures, a person recording that a machine stopped working; the sweep in workers/service.py writes the «СООБЩИЛ ДРАЙВЕР» half and no client can claim that badge
  • #33 — POST /service/failures/{failure_id}/restore, the observation in which the machine was working again, which is the only measurement of how long it was down
  • #33 — POST /service/failures/{failure_id}/cause, naming the cause of a failure the driver opened with none — the farm holds no table turning bambu.print_error.{code} into «слом филамента» (ADR-0007), so this route is the only way a bar of the funnel is ever written
  • #33 — POST /service/tickets/{ticket_id}/assign, handing a ticket to a named person; the board assigns to whoever starts the work and has no staff picker yet

TelemetrySample was the headline entry here and no longer is: metric_rollups summarises it and /fleet/metrics serves it. EstimateVariance left the same way — GET /jobs/variances serves it and the order desk's «Пересмотр цены» panel reads it. So did RateSnapshotRecord: GET /orders/{order_id}/rate-snapshot serves it and «Тарифы заказа» reads it.

This section is measured from both ends. backend/tests/unit/test_docs_endpoint_consumers.py fails if an entry listed here has quietly gained a consumer — the drift that took thirteen of them at once while the section sat still. It also fails in the other direction: an endpoint the API serves, with no path literal anywhere under frontend/apps/*/src or frontend/packages/*/src, has to be named here or exempted in NOT_A_SCREEN_CONSUMER with the reason. That list holds twenty-two routes — three no screen can ever have, and nineteen that are real gaps, each naming the screen or the action that is missing. (Twenty-three until GET /health/workers gained the settings screen's «Диагностика» section and left; the arithmetic here is ungated prose and had gone stale by one, which is the drift this section is otherwise about.) It is longer than this section has ever been, so reading a short list here as "the backend owes the console nothing" would be precisely the flattering mistake §4 exists to catch.

5. Order to build the rest in

settings ──┬──► logistics   (zones and tariffs are one table, defined in settings)
  (built)  └──► purchasing  (reorder thresholds and lead days are settings)
                            — both now wait on the #29 tables, not on the screen

purchasing ──► store        (receiving a PO is what puts a batch in a cell)

service      independent of all three — ServiceOperation already exists

settings was first, and it is done. That was not only because it was largest: the other screens read parameters it owns, and building them against constants would have meant building them twice. The edge that survives it is narrower — what logistics waits on is the zones table specifically (#29), not the screen. service any time — it needs nothing the others produce.

store after purchasing is a preference rather than a hard edge: a cell map can be built over lots that already exist, but receiving is where batches come from, and a warehouse screen with no inbound is a screen with nothing to show.