Repository navigation
feat(planning): versioned machine-profile contract; planner consumes a profile (#197) - #323
Merged
Merged
Conversation
…dialect (#197) Introduce `MachineProfile` (`fiberpath.config`): a versioned, validated description of a target controller — axis mapping, units/feed semantics, and the G-code opcodes a compatible winder must support. It is the seed of the compatibility spec (sibling to the `.wind` open format), kept deliberately lightweight: the Pydantic model is the schema, validated on load; no separate published-$id/conformance machinery. The canonical Marlin X/A/B target now ships as data (`fiberpath/profiles/marlin_xab.json`, loaded via importlib.resources) instead of a hardcoded constant. `PlanOptions.dialect` becomes `PlanOptions.profile`; the planner derives the runtime `MarlinDialect` via `dialect_from_profile`, and `MARLIN_XAB_STANDARD` is now derived from the default profile. The derivation reproduces the historical dialect exactly, so all G-code goldens stay byte-identical. Profiles are frozen value objects (immutable `requiredGcodes` tuple, each entry a G/M opcode); `units` is constrained to mm and `feedMode` to G94 — the only modes FiberPath can currently honor, since it never emits G20/G21/G94 (see #322). The docs guide states that as an explicit controller requirement. Adds docs/guides/machine-profile.md and a profile test suite; updates the axis-mapping guide and the CLI/test call sites for the profile-based API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #197.
Introduces a versioned machine-profile contract — the controller-side counterpart to the
.windformat — and switches the planner from a hardcoded dialect constant to a profile. Kept deliberately simple: the Pydantic model is the schema (validated on load); no published-$id/conformance machinery (proportionate to a backend config contract, not the full.windgovernance).What
MachineProfile(fiberpath.config, frozen Pydantic):profileVersion(1.x additive policy, mirrorsschemaVersion),id/name/controller,units,feedMode,axisMapping,requiredGcodes. It's the compatibility contract — "what hardware must meet to be compatible."fiberpath/profiles/marlin_xab.json— the canonical Marlin X/A/B target expressed as data, loaded viaimportlib.resources(ships in the wheel; verified).PlanOptions.dialect→PlanOptions.profile(default = bundledmarlin-xab). The runtimeMarlinDialectis derived viadialect_from_profile, andMARLIN_XAB_STANDARDis now derived from the default profile rather than hand-written.Byte-identical output
The derived default reproduces the historical X/A/B dialect exactly — the example-golden test passes unchanged. Strong regression guard.
Grounded, honest contract
requiredGcodes=["G0", "G92"](what the serializer actually emits). FiberPath does not emitG21/G94, sounitsis constrained tommandfeedModetoG94(the only modes it can honor) and the guide states "controller MUST already be in mm + units-per-minute mode." The deadprologue()that would emit those codes is filed separately as #322.Tests / checks
pytest240 pass (12 new profile tests: load/validate, default == legacy dialect, frozen immutability, custom-axis profile, and reject cases — bad version/non-distinct axes/multi-letter/empty+non-G-code opcodes/non-mm units) ·ruff check+ruff format --checkclean · scopedmypyclean · no wind-schema/openapi drift.unitsto mm-only (it had acceptedinch, which the planner can't honor), per-opcode validation onrequiredGcodes, andrequiredGcodesas an immutable tuple (the frozen+lru_cache'd default had a mutable-list bypass).extra="ignore"kept deliberately to match the additive-forward-compat policy.Found while scoping (filed, not fixed here)
#322 —
MarlinDialect.prologue()is dead code; G21/G94 (units & feed mode) are never emitted. This PR documents the mm + units-per-minute assumption as an explicit requirement; #322 tracks whether FiberPath should emit those setup codes.