Skip to content

refactor: structure rewrite R1 — firmware values, per-topic contracts, main topic folders #98

Closed

Description

@mottihoresh

Part of the structure rewrite (parent issue linked in the sidebar). All PRs target refactor/structure.

R1 moves the firmware values and splits the shared contracts and models.

PR Title Done when
R1.1 refactor(firmware): generated reference to shared/firmware, imports replace hand-typed copies sync-a4ec.ts OUT_DIR → src/shared/firmware/ + hand-written barrel; CI freshness path updated. The 35 hand-typed copies replaced by imports (CAL_TYPE/CAL_NACK/magic/envelope/slots, NODE_MSG/END/REQ_ADDR, HFLAG_*, NODE_KIND, TELEM pages, rail/PDU flags, HID layout counts/offsets/hat centre, AXIS_LABELS → HID_CONTROLS, fault codes 0x05/0x09 by name, callink NACK_NAME, device-link NACK lookup). reference.test becomes a version/shape guard. L-firmware-leaf → error
R1.2 build(sync): sync USB identity, node bus and calibration timing New sync sources: PanelBridge.cpp MAX_NODE_ID, SimGateway.cpp VID/PID/product/manufacturer/baud + CAL_SESSION_TIMEOUT_MS, TelemSchedule.h TELEM_PERIOD_MS, AxisCal.h max frame, hat directions, flag names (keys only). reference.test asserts each equals today's literal
R1.3 refactor(ipc): per-topic contracts, shared/format, break the model↔contract cycles shared/ipc.ts → shared/{app,gateway,dcs,nodes,hid,hid/calibration,events,config}/ipc.ts + index.ts. Pushed shapes + DCS-BIOS endpoint constants into contracts. SettingsStore read-only store type in shared/config. shared/format merges the duplicated formatters (identical output). Preload built from shared/app/ipc. Compile-time Equal<OldSkyhawkApi, SkyhawkApi>. P3, C1, C2 = 0 → error
R1.4 refactor(main): topic folders; main-only models move from shared to main main/<topic>/ + index.ts. Models move (dcsbios → dcs/bios-protocol + gateway/link-framing; nodes/node-telem/node-kind/node-mapping/node-rules/psu/events/gateway health/config-file/cal-cache rules/hid decode/capture). Paths, Log, write injected (no electron outside app). Delete biosconfig.ts + test. STATUS_FLAGS/faultLabel → events/status-flags. Functions the renderer still calls stay in shared/<topic>/legacy-rules.ts (@deprecated, removed by R3.4). P1, P2, P6 → error
R1.5 build(sync): sync the newly named firmware protocol values Waits on OpenSkyHawk/OpenSkyhawk#346. Sync reads the 9 values (Gateway node 0, status row layout, HB flag bits, ESR split, die-temp sentinel, TELEM framing, page layouts, NTC sentinel, calibration payload offsets); the client's hand copies go. Can land any time before the branch merges

Until R1.5, those 9 stay hand-typed in one file inside shared/firmware/, guarded by a shape test.

Checklist

Result (2026-10-17)

  • Every firmware value comes from npm run sync (src/shared/firmware/, pin a78dd902): 35 copies replaced (R1.1), 9 newly synced (R1.2), 9 named in firmware then synced (R1.5). Typed name tables restore key typo-safety.
  • src/shared = per-topic contracts + firmware + format + 3 legacy-rules.ts (renderer still calls them; removed in R3).
  • src/main/<topic>/ with index.ts; electron only in main/app; paths/log injected; biosconfig.ts deleted.
  • Proofs per PR: value-equality runs, built-bundle boot comparison (byte-identical), render comparison (byte-identical HTML).
  • Boundary lint: errors for P1/P2/P3/P4/P6, contracts, cycles, firmware/format leaves. Remaining warnings 19: legacy-rules 10, DeviceLink cross-topic 3 (R2.2), main deep imports 5 (R2.2/R2.3), renderer deep import 1 (R3.4).
  • Tests 881. R1.3 and R1.4 were each split into two PRs for reviewability (no scope change).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions