Skip to content

feat(planning): versioned machine-profile contract; planner consumes a profile (#197) - #323

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/machine-profile-spec
Jun 30, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/machine-profile-spec

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Closes #197.

Introduces a versioned machine-profile contract — the controller-side counterpart to the .wind format — 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 .wind governance).

What

  • MachineProfile (fiberpath.config, frozen Pydantic): profileVersion (1.x additive policy, mirrors schemaVersion), 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 via importlib.resources (ships in the wheel; verified).
  • Planner consumes a profile: PlanOptions.dialect → PlanOptions.profile (default = bundled marlin-xab). The runtime MarlinDialect is derived via dialect_from_profile, and MARLIN_XAB_STANDARD is now derived from the default profile rather than hand-written.
  • New Machine Profile guide; updated axis-mapping guide + CLI/test call sites.

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 emit G21/G94, so units is constrained to mm and feedMode to G94 (the only modes it can honor) and the guide states "controller MUST already be in mm + units-per-minute mode." The dead prologue() that would emit those codes is filed separately as #322.

Tests / checks

  • pytest 240 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 --check clean · scoped mypy clean · no wind-schema/openapi drift.
  • Adversarial review: no correctness blockers. Fixes applied from it — tightened units to mm-only (it had accepted inch, which the planner can't honor), per-opcode validation on requiredGcodes, and requiredGcodes as 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.

…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.
@CameronBrooks11
CameronBrooks11 merged commit c3c2cc9 into main Jun 30, 2026
21 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/machine-profile-spec branch June 30, 2026 01:50
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.

spec: machine-profile / firmware-compatibility spec ('what hardware must meet to be compatible')

1 participant