Skip to content

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

Closed

Description

@CameronBrooks11

Stage 1 Motion IR — slice S2a (the keystone). Part of #136. Depends on S1 + the golden freeze/harness (P0/P1).

plan_wind lowers to the Program IR and serialize(program, dialect) reproduces the validated cylinder G-code byte-for-byte. This makes motion math have one home (the lowering) and the dialect a true post-processor. Planner time is left on today's formula in this slice so the existing time tests remain an independent regression signal alongside the byte-equal diff (adopting O1 is S2b).

Scope

  • Lowering builds list[Move] + ProgramMeta instead of appending strings — move INTO the lowering: carriage segmentation (int(round(abs(carriage_delta)))+1, all-axis linear interpolation), the carry-forward all-axis completion move, the zero_axes macro (→ G92 + a real rotate-to-360 RAPID + G92), the init RAPID (all-zero targets), the single SET_FEED, and all comments (incl. the literal tab in helical pattern comments).
  • serialize(program, dialect) -> list[str] owns: AxisMapping X/A/B letters, strip_precision (with defensive -0.0 normalization), RAPID emits all 3 axes in fixed CARRIAGE,MANDREL,DELIVERY order while SET_POSITION emits only its subset in caller order, G0/G92/; prefixes, the ; Parameters {json} header (relocate dump_header's key-order/separators/int-normalization out of config/schemas.py), sanitize_program, trailing newline.
  • plan_wind returns Program; PlanResult.commands = serialize(program, dialect); LayerMetrics derived from the IR but using today's degrees+delivery time formula.
  • Do not emit dialect.prologue (G21/G94).

Acceptance

  • P1 byte-equal golden test green (empty G-code diff) for all frozen .wind→.gcode pairs and the 4 layer fixtures.
  • PlanResult.commands byte-identical to the P0 baseline (compare via the write_gcode trailing-newline path, exact text).
  • Existing planner-time assertions UNCHANGED (joint proof that the refactor changed nothing).
  • machine no longer the authoritative string emitter for motion.

Byte-equality watch-list (from the investigation)

banker's-rounding segment count · fixed XAB order vs ordered G92 subset · header key-order/separators/int-normalization · trailing newline · embedded literal tab · -0.0/sub-epsilon negatives → preserve interpolate_coordinates and per-axis delta arithmetic in identical order (the primary guarantee; value+0.0 only catches exact -0.0).

Activity

  1. added
    enhancement
    python
    on Jun 28, 2026
  2. added 2 commits that reference this issue on Jun 28, 2026
    f87ac5e
    8964637
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpython

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions