You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
S-bnd — one boundary G-code→Program reader; simulator & plotter go IR-native #282
Slice S-bnd of #136 — consolidate the two G-code re-parsers into ONE boundary adapter so the simulator and plotter become IR-native.
Problem
The simulator (simulate_program, line.split()) and plotter (_collect_segments, 'G0' text + ast.literal_eval of the ; Parameters header) each independently parse G-code text and re-derive motion — the duplication the epic targets. Each also carries its own _detect_dialect/_extract_metadata.
Approach — output-preserving
Introduce fiberpath/gcode/reader.py::read_program(lines, *, dialect=None) -> Program: the single inverse of serialize. It parses the ; Parameters header → ProgramMeta, detects the dialect once, and lowers each line to a Move (G0 F…→SET_FEED, G0 …→RAPID, G92 …→SET_POSITION, comments→COMMENT).
The CLI/API boundary parses text→Program once; the simulator and plotter consume the IR. This slice deliberately changes no numbers: both consumers reproduce today's output exactly (the simulator stays G92-blind, marked minimal: for S3; the plotter unchanged). So the gate is a 100%-green sim_plot_snapshot.json with no regen, proving the reader faithful in isolation — the #274 analog. G92-awareness / O1 unification land as the isolated, reviewable regens in S3 (sim) and S4 (plot).
Acceptance
read_program is the sole G-code text parser; simulator & plotter take a Program (verifiable by grep — no .split() G-code parsing outside the reader).
NEW tests/gcode/test_reader_roundtrip.py: serialize(read_program(g), dialect) reproduces each of the 7 frozen goldens byte-for-byte, + unit tests (header, comment, G92, feed, mixed feed+motion).
tests/test_sim_plot_snapshot.py green withoutFIBERPATH_UPDATE_GOLDENS (output-preserving proof).
CLI simulate/plot <file.gcode> and the /simulate+/plot routes parse via the boundary reader; external-.gcode use case preserved; GUI {gcode}→/plot unaffected; no OpenAPI drift.
ruff + mypy clean.
Part of #136. Followed by S3 (simulator shares nominal_metrics), S4 (plotter IR geometry), S5 (delete dead parsers + CI guard).
Activity
refactor(gcode): read G-code into the Motion IR at the CLI/API bounda…