Skip to content

refactor(planning): lower plan_wind to the Motion IR + serialize() to G-code - #280

Merged
CameronBrooks11 merged 1 commit into
mainfrom
refactor/plan-wind-motion-ir-serialize
Jun 28, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
refactor/plan-wind-motion-ir-serialize

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Part of #136 (Motion IR epic). Closes #274. S2a — the keystone. Motion math gets a single home and G-code becomes a build artifact, with the validated cylinder output byte-identical (gated by test_example_goldens.py).

The cutover

  • WinderMachine records a list[Move] (one per emitted line) instead of G-code strings. The strategies drive it exactly as before — carriage segmentation, all-axis completion, the zero_axes macro, and the time/tow accumulation stay here, so the IR is post-segmentation (one motion Move == one G0 line) and motion math is not re-derived anywhere.
  • New fiberpath/gcode/serializer.py is the dialect post-processor and the only place that knows axis letters, number formatting, and the ; Parameters header (reproducing dump_header's key order + int-normalization + compact separators). It never emits the dead G21/G94 prologue.
  • plan_wind builds Program{meta, moves=[init_rapid, *recorded]} and returns serialize(program, dialect); the init line and header are now structural (a RAPID Move and ProgramMeta) rather than hand-built strings.

Time deliberately unchanged

Planner time stays on the degrees+delivery formula in this slice, so the existing time assertions stay green and — together with the empty G-code diff — jointly prove the refactor changed nothing. Adopting the single O1 model is S2b (#275).

Back-compat / cleanup

get_gcode() is kept as a derived convenience (render each Move, no header), so the strategy-level layer fixtures pass untouched. Removed the unused add_raw_gcode escape hatch (no IR representation; only one unit test used it — retargeted to the mandrel accessor). Fully relocating dump_header out of schemas.py is deferred to S5.

Verification (4 independent signals)

  • Byte-equal goldens: 7 passed — empty G-code diff across all example parts incl. the rocketry mandrels.
  • Existing planner-time assertions: unchanged/green (the "changed nothing" proof).
  • Layer fixtures (test_layer_strategies, test_helpers_machine): 10 passed via the derived get_gcode().
  • sim/plot snapshot (test: snapshot simulator/plotter goldens + retire legacy XYZ reference runs #272): unchanged.
  • Full suite 138 passed; ruff/format/mypy clean (44 source files); no OpenAPI drift.

… G-code

S2a, the keystone of the Motion IR epic (#136): motion math now has a single
home and G-code becomes a build artifact, with the validated cylinder output
byte-identical (gated by tests/planning/test_example_goldens.py).

- WinderMachine records a list[Move] (one per emitted line) instead of G-code
  strings. The strategies drive it exactly as before — carriage segmentation,
  all-axis completion, the zero_axes macro, and the time/tow accumulation stay
  here, so the IR is post-segmentation (one motion Move == one G0 line) and the
  motion math is not re-derived anywhere.
- New fiberpath/gcode/serializer.py is the dialect post-processor and the ONLY
  place that knows axis letters, number formatting, and the `; Parameters`
  header (reproducing dump_header's key order, int-normalization, and compact
  separators). It never emits the dead G21/G94 prologue.
- plan_wind builds a Program{meta, moves=[init_rapid, *recorded]} and returns
  serialize(program, dialect); the init line and header are now structural (a
  RAPID Move and ProgramMeta) rather than hand-built strings.

Planner time is deliberately UNCHANGED in this slice (still the degrees+delivery
formula), so the existing time assertions stay green and jointly prove — with
the empty G-code diff — that the refactor changed nothing. Adopting the single
O1 model is S2b (#275).

get_gcode() is kept as a derived convenience (render each Move, no header) so the
strategy-level layer fixtures pass untouched. Removed the unused add_raw_gcode
escape hatch (no IR representation; only a unit test used it — retargeted to the
mandrel accessor).

Verified: byte-equal goldens (7), layer fixtures (10), sim/plot snapshot
unchanged, full suite 138 passed; ruff/mypy clean; no OpenAPI drift.

Part of #136. Closes #274.
@CameronBrooks11
CameronBrooks11 merged commit f87ac5e into main Jun 28, 2026
21 checks passed
@CameronBrooks11
CameronBrooks11 deleted the refactor/plan-wind-motion-ir-serialize branch June 28, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(planning): plan_wind lowers to Motion IR + serialize() reproduces byte-equal G-code

1 participant