Repository navigation
Description
Epic — Stage 1 of the engine roadmap (docs/development/roadmap.md). The keystone refactor: introduce one typed, machine-agnostic toolpath IR so motion math lives in a single place and G-code becomes a build artifact.
Problem (confirmed in code)
Motion math is triplicated against stringly-typed G-code:
- the authoritative emitter
machine._move_segment, - the simulator (
simulate_programdoesline.split()), - the plotter (
_collect_segmentsparses'G0'text andast.literal_evals the; Parametersheader).
Worse, the planner and simulator compute time from different formulas on the same moves — planner: mandrel in raw degrees, delivery-head included; simulator: arc-mm, delivery excluded — so PlanResultOut.timeSeconds and SimulationResultOut.estimatedTimeSeconds disagree by construction. There is no intermediate representation: strategies write strings straight into machine._gcode.
🔴 The committed
examples/rocketry/*.gcodegoldens are stale — none reproduces from its.windtoday (A-axis sign flip;AvBay…triple.windedited after its gcode was cut;AvBay…singlehas no gcode). There is currently zero trustworthy byte baseline, so the epic must freeze one first (#270).
Target
plan_wind emits a typed Program{meta: ProgramMeta, moves: list[Move]}; serialize(program, dialect) -> list[str] is the only place that knows axis letters / number formatting / header JSON / opcode strings (dialect = post-processor, G-code = build artifact). Simulator, plotter, and metrics consume the IR (no per-consumer G-code parsing). A single nominal_metrics(moves, diameter) (O1 surface-arc: Euclid(carriage_mm, mandrel_arc_mm)/feed, delivery excluded) is the one motion-math implementation, ending the divergence. The validated cylinder output is byte-equal to committed goldens at every step. The IR is a clean lowering target for Stage 2 (#137) and Stage 3a (#138).
IR shape (minimal, byte-grounded)
Move{kind, targets: dict[Axis,float], feed, text}; MoveKind ∈ {RAPID, SET_FEED, SET_POSITION, COMMENT}; Program{meta, moves}. Deviations from the original proposal (verified against an 818k-line opcode histogram — only G0/G92/comments are emitted; zero G1, zero G21/G94):
- drop
lay(not emitted; would change the plot signature — defer to Stage 2), - add
Program/ProgramMeta(the header data must travel structurally so consumers stop re-parsing it), SET_FEED→G0 F…, notG1(no rapid-vs-feed distinction today),G92, notM92; never emit the deadG21/G94prologue.
Definition of done
- All frozen
.windreproduce their committed.gcodebyte-equal throughplan_wind → serialize(program, dialect)(empty diff on every IR PR). -
plan_windreturnsProgram;serialize()is the sole owner of axis letters / formatting / header / opcodes. - Exactly one motion-math/metrics implementation (
nominal_metrics, O1) consumed by both planner and simulator; their reported time agrees by construction. - No duplicate motion-math; G-code text parsing, if any, is confined to a single boundary adapter (the CLI/API path that accepts an external
.gcodefile) — simulator and plotter are IR-native (verifiable by grep). (Reinterprets the original "no text parsing" line; see S-bnd.) - Simulator/plotter goldens regenerated + reviewed where the IR corrects the silently-dropped
G92reference frame and adopts O1 (these are not byte-gated — they're deliberate metric changes).
Slices
Prework (freeze the baseline before refactoring):
- build(planning): freeze byte-exact G-code goldens before the Motion IR refactor #270 — freeze byte-exact G-code goldens (regenerate from current planner; confirm the A540 sign)
- test(planning): byte-equal .wind→.gcode golden harness + regenerator #271 — byte-equal
.wind→.gcodegolden harness +FIBERPATH_UPDATE_GOLDENS=1regenerator - test: snapshot simulator/plotter goldens + retire legacy XYZ reference runs #272 — snapshot sim/plot goldens for delta visibility; retire legacy XYZ reference runs
Build:
- feat(planning): define the typed Motion IR (Move/MoveKind/Program/ProgramMeta) #273 — S1 define the Motion IR types (pure addition)
- refactor(planning): plan_wind lowers to Motion IR + serialize() reproduces byte-equal G-code #274 — S2a
plan_windlowers to IR +serialize()reproduces byte-equal G-code (planner time unchanged — joint regression signal) - refactor(planning): adopt the single O1 nominal time model in the planner #275 — S2b adopt the single O1
nominal_metricsin the planner; re-baseline planner time
Later slices (coarse — promoted to issues when next):
- S-bnd — (S-bnd — one boundary G-code→Program reader; simulator & plotter go IR-native #282) one boundary
G-code → Programreader: consolidate the two re-parsers into a single adapter at the CLI/API edge; simulator & plotter go IR-native; the CLI's external-.gcodeuse case is preserved and the GUI's{gcode}→/plotpath is unaffected. - S3 — (S3 — simulator shares the single O1 nominal_metrics; close the planner/sim divergence #284) simulator consumes the IR and shares
nominal_metrics(divergence fixed); sim goldens re-reviewed (incl.average_feed_rate_mmpm, which becomes degenerate after unification). - S4 — (S4 — plotter honors the G92 reference frame (remove the boundary artifact) #286) plotter consumes the IR geometry; drop
_detect_dialect/ast.literal_eval; plot signature re-reviewed (G92 reference-frame correction). - S5 — (S5 — delete dead scaffolding + CI guard for the Motion IR single source of truth #288) delete dead parsers/scaffolding; CI guard enforcing a single
nominal_metricsand no duplicate consumer parsing.
Sequencing
Prework (#270 → #271 → #272) lands first — the frozen goldens + green harness are the gate. Then #273 → #274 (keystone; must show an empty G-code diff) → #275. Then S-bnd resolves the consumer-contract boundary, after which S3/S4 are internal consumer rewrites and S5 is cleanup. The validated cylinder G-code is golden-gated at every slice.
Constraints (roadmap)
Don't break the validated cylinder output (golden-gated); keep planning machine-agnostic (machine specifics stay in the dialect/post-processor); minimal-first (smallest IR that captures today's emission); additive/backward-compatible .wind.
Related
Next stages build on this IR: #137 (Stage 2 — one pattern primitive), #138 (Stage 3a — cones), #139 (Stage 3b — domes). Time-model calibration against real hardware is tracked separately (#130).
Plan produced by a multi-agent investigation of the planning/gcode/sim/viz code (6 probes → synthesis → adversarial critique); the critique tightened the slice split, added the boundary-reader slice, and pulled fiberpath_gui into scope.
Activity
[-]Stage 1 — introduce a typed Motion IR (machine-agnostic toolpath)[/-][+]Epic: Stage 1 — typed, machine-agnostic Motion IR[/+]build(planning): freeze byte-exact G-code goldens from the current pl…
test(planning): byte-equal .wind→.gcode golden harness + regenerator (#…
test: snapshot simulator/plotter output + retire legacy XYZ reference…
feat(planning): define the typed Motion IR (Move/MoveKind/Program/Pro…
refactor(planning): lower plan_wind to the Motion IR + serialize() to…
refactor(planning): adopt the single O1 nominal time model in the pla…
refactor(gcode): read G-code into the Motion IR at the CLI/API bounda…
refactor(simulation): adopt the single O1 nominal_metrics; close the …
refactor(visualization): honor the G92 reference frame in the plotter (…
CameronBrooks11 commentedon Jun 28, 2026
✅ Epic complete — Stage 1 Motion IR shipped
Every slice merged and every Definition-of-Done bullet satisfied. A typed, machine-agnostic
Program{meta, moves}is now the spine:plan_windemits it,serialize(program, dialect)is the sole G-code producer, andread_programis the sole G-code→IR reader at the CLI/API boundary. Motion math lives in exactly one place (nominal_metrics, O1 surface-arc), consumed by both the planner and the simulator — the historical planner/simulator time divergence is closed by construction.Slices
read_program); simulator + plotter go IR-nativenominal_metrics(G92-aware; divergence closed)dump_header+ CI guard for the single source of truthVerified by three independent adversarial reviews before close
test_example_goldens, all 7 goldens).multi_layersim time 1733.98s → 905.47s = the planner total, to 1e-11).tests/test_motion_ir_invariants.py(scansfiberpath/,fiberpath_cli/,fiberpath_api/): onemath.sqrt(motion-math impl, one_detect_dialect/header parser, zeroast.literal_eval.The IR is now a clean lowering target for Stage 2 (#137) and Stage 3a/3b (#138/#139). Time-model calibration against real hardware remains tracked in #130.
Closing as done.
chore(release): prepare 0.10.0 (#325)