Repository navigation
Description
Decision (from a full architecture review)
Today the GUI shells out to the CLI spawn-per-call, structured data crosses Rust↔Python through temp files, results are parsed as untyped JSON with heuristics (version-scraping, stderr-scraping), the FastAPI is orphaned and wrong-shaped (/from-file only, no plot, one-shot stream), Marlin is a bespoke stdio event protocol + Tauri events, and the frontend re-describes all of it in hand-written zod + a mislabeled "auto-generated" types file.
Refactor to: a local FastAPI that owns all backend logic — compute and serial — exposed as plain request/response REST (Marlin is a polled job resource; no WebSockets — the protocol is send-line→ok, progress is polled). The frontend becomes a generated OpenAPI client (the treat-as-separate-repo strictness), and Tauri shrinks to a thin native shell (window + file pickers). The CLI stays as a parallel human/automation adapter over the same core.
Why
- Kills the filesystem-IPC dance, per-call cold-start, and untyped stdout-scraping.
- One source-of-truth contract (OpenAPI) → generated client → CI drift gate; retires hand-written zod, the fake "auto-generated" types, and the bespoke stdio protocol.
- The core is already model-based, so the compute routes are thin; the only real new infra is the serial job runner, which is a REST-exposed version of what
interactive.pyalready does.
Scope (phased)
Backend (FastAPI owns everything, all REST)
- feat(api): in-memory compute routes (plan/simulate/validate) + plot/preview route #189 — in-memory compute routes + plot/preview route
- feat(api): Marlin REST surface — ports, connection, synchronous commands (part A) #190 — Marlin REST job resource + serial ownership (connect / commands / polled jobs)
Contract
- build: OpenAPI-generated TS client + CI drift gate #191 — OpenAPI → generated TS client + CI drift gate
Delivery
- build(gui): bundle + supervise the FastAPI as a hardened local sidecar (transport; part A) #192 — bundle + supervise the FastAPI as a hardened local sidecar
Frontend & shell
- refactor(gui): consume the API client; replace event streaming with polling #193 — frontend → API client + polling (delete invoke/zod/Tauri-events)
- refactor: reduce Tauri to a native shell; retire the GUI's CLI-subprocess and stdio Marlin protocol #194 — thin Tauri shell + retire CLI-subprocess / stdio Marlin protocol
Reconciliation with existing issues
- refactor: unify GUI<->subprocess IPC contract (single source of truth) #184 folded/closed — "unify GUI↔subprocess IPC contract" is superseded: the contract becomes OpenAPI and the stdio subprocess protocol is retired entirely.
- Epic: reliable, conformance-tested Marlin machine-I/O #187 (Marlin host-protocol layer) stays and is consumed by feat(api): Marlin REST surface — ports, connection, synchronous commands (part A) #190 — the parser/reliability/lifecycle/corpus/console work (feat(cli): human interactive machine console with serial TX/RX tracing #178–feat(execution): buffered streaming with a send/ack window [DEFERRED — evidence-gated] #183) is transport-independent; this epic only changes how that layer is exposed to the GUI. Marlin transport decision now resolved: REST + polling.
- Extract machine-I/O into a standalone, published Marlin host-protocol library #188 (published protocol lib) unaffected — consumed by both the API job runner and the CLI console.
- Stopgaps fix(execution): bound response waits, add send timeout, and release the serial port on stop/error #185/fix(execution): serialize machine access so streaming and manual commands can't interleave #186 remain independent acute fixes to the current code; fix(execution): serialize machine access so streaming and manual commands can't interleave #186's serialize-access becomes a server-side lock in the target design.
Notes
- Marlin REST:
GET /ports,POST/DELETE /connection,POST /commands,POST /jobs+GET /jobs/{id}(poll) + pause/resume/stop. Firmware-initiated//action:/errors surface in the polled status. - Tauri's only irreducible native role: window + native file/folder picker.
- The contract is Pydantic-model-based, hence transport-agnostic — this also yields a real remote/headless API as a byproduct if ever wanted.
Plan-review refinements (2026-06-25)
Holistic 4-lens + adversarial review. Direction confirmed; refinements:
- feat(api): Marlin REST surface — ports, connection, synchronous commands (part A) #190 split → part A (ports/connection/commands, feat(api): Marlin REST surface — ports, connection, synchronous commands (part A) #190) + feat(api): Marlin /jobs polled resource + background job runner #199 (
/jobspolled resource + runner, gated on test(execution): replay serial transport + recorded-trace conformance corpus #179 + feat(execution): formal Marlin response taxonomy + state-machine parser #180). - build(gui): bundle + supervise the FastAPI as a hardened local sidecar (transport; part A) #192 split → part A (hardened transport, build(gui): bundle + supervise the FastAPI as a hardened local sidecar (transport; part A) #192) + build(gui): sidecar serial-crash / orphaned-job recovery #200 (serial-crash / orphan recovery).
- feat(api): in-memory compute routes (plan/simulate/validate) + plot/preview route #189 simplified: body-only; delete
/from-file(×3),/stream,path_policy.py; output via shared versioned schema feat: one shared versioned output/wire schema for compute results (plan/simulate/plot) #198;/planreturns an artifact/job reference, not 243k commands inline. - build: OpenAPI-generated TS client + CI drift gate #191: continuous (gate infra Phase A; TS-DTO retirement trails feat(api): Marlin REST surface — ports, connection, synchronous commands (part A) #190/feat(api): Marlin /jobs polled resource + background job runner #199); client takes runtime baseUrl + token.
- New cross-cutting: safety: emergency-stop/abort must preempt serialization and reach the board out-of-band #196 emergency-stop carve-out (hard criterion on feat(api): Marlin /jobs polled resource + background job runner #199 and fix(execution): serialize machine access so streaming and manual commands can't interleave #186); feat: one shared versioned output/wire schema for compute results (plan/simulate/plot) #198 versioned output schema.
- Epic: open winding-program format — normative SPEC, resolvable $id, conformance corpus #141 must land its canonical
$id+ a single schema generator before build: OpenAPI-generated TS client + CI drift gate #191 (two generator scripts currently disagree). - Sequencing — test(execution): replay serial transport + recorded-trace conformance corpus #179 is the universal unblocker; do it before any feat(api): Marlin REST surface — ports, connection, synchronous commands (part A) #190/feat(api): Marlin /jobs polled resource + background job runner #199 work. Run the epics convergent, meeting at feat(api): Marlin REST surface — ports, connection, synchronous commands (part A) #190: Phase A = compute/contract/transport (zero serial) + testability spine (feat(cli): human interactive machine console with serial TX/RX tracing #178 capture → test(execution): replay serial transport + recorded-trace conformance corpus #179); Phase B = protocol (feat(execution): formal Marlin response taxonomy + state-machine parser #180 → feat(execution): reliable transfer — line numbering, checksum, and resend handling #181, fix(execution): robust connection lifecycle — DTR/reset and readiness handshake #182) + feat(api): Marlin /jobs polled resource + background job runner #199/build(gui): sidecar serial-crash / orphaned-job recovery #200; Phase C = refactor(gui): consume the API client; replace event streaming with polling #193 → refactor: reduce Tauri to a native shell; retire the GUI's CLI-subprocess and stdio Marlin protocol #194 (last).
Activity
docs(gui): refresh architecture docs for the sidecar compute path (#213)
CameronBrooks11 commentedon Jun 28, 2026
Status (2026-06-28): backend is the engine now —
marlin-hostis publishedThe host-protocol layer (#187: #178/#179/#180/#181/#182) is realized and published as
marlin-host==0.1.0on PyPI (MVP, hardware-validated on RAMPS 1.4 / Marlin bugfix-2.1.x; mock/hardware-separated suite). #188 closed (extraction done). This unblocks the machine half of this epic — the/jobsrunner becomes a thin adapter overmarlin_host.MarlinHostinstead ofinteractive.py.Where the phases stand
/ports,/connection,/commands,/jobs+ polledGET /jobs/{id}?since=, pause/resume/stop); runner owns the port viaMarlinHost; lock serializes/commandsvs the job; safety: emergency-stop/abort must preempt serialization and reach the board out-of-band #196 M112 bypasses the lock; build(gui): sidecar serial-crash / orphaned-job recovery #200 crash→orphanednot 404.marlin-api.tsTauri invokes + thestream-*events +machine-sessionevent wiring).src-tauri/src/marlin.rs(the long-livedfiberpath interactivesubprocess + 10 Tauri cmds) and deletefiberpath_cli/interactive.py+ theinteractiveCLI command.POST /connection).This machine cutover is the 0.9.0 target.
Gap analysis —
marlin-hostalready covers connect/streaming/pause/e-stop/queries (more rigorously than the oldMarlinStreamer). app-neutral upgrades needed before consumption (tracked in fiberpath/marlin-host)://action:*delivery (on_actioncallback) — board-initiated pause/resume/cancel/prompt is parsed then dropped today. feat(host): deliver //action:* messages via an on_action callback marlin-host#25list_ports()helper (fiberpath drops its direct pyserial) +position()convenience. feat(host): list_ports() and position() convenience helpers marlin-host#26Decisions carried in
marlin-host's host-side pause (send-one-await-okpacing makes board-level M0 unnecessary and was the fragile part of the old code). Keep M0/M108 only as an explicit operator-hold app feature.;-comment logging stay app-side; halt recovery viaSerialTransport.reset(flush=True)+connect().streamstays (parallel interface), rewired tomarlin-host.chore(release): bump to 0.2.0 (#29)
feat(host): thread-safe send/query (io lock) + ship py.typed (0.2.1) (#…
feat(api): Marlin machine-control surface on the sidecar (#190, #199) (…
feat(cli): stream via marlin-host; drop the fragile M0/M108 pause (#261)
feat(gui): drive Marlin through the API sidecar; delete the stdio bri…
refactor: remove the legacy in-repo Marlin code (#195) (#263)
CameronBrooks11 commentedon Jun 28, 2026
Delivered. All phases shipped: #189/#191/#192 (0.8.0), #190 (#260), #193/#194 (#262/#263). Machine control now runs on the local API sidecar (it owns the serial port) + marlin-host, the GUI uses the generated typed client with polling, and the Rust stdio subprocess is gone. Released in fiberpath 0.9.0. The split-off #200 (orphaned-job crash recovery) remains open as the one piece of follow-up hardening.