Skip to content

feat(wire): shared versioned output schema for compute results - #202

Closed
CameronBrooks11 wants to merge 1 commit into
feat/api-compute-routes-189from
feat/api-output-schema-198
Closed

CameronBrooks11 wants to merge 1 commit into
feat/api-compute-routes-189from
feat/api-output-schema-198

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Closes #198. Part of the local-API architecture track (Epic #195).

Stacked on #201 (#189). Base is feat/api-compute-routes-189; review/merge #201 first, then this re-targets main.

What

Introduce fiberpath/wire.py as the single source of truth for the shape of plan/simulate results crossing a process boundary (HTTP responses, the future OpenAPI client, persisted output). It is intentionally decoupled from the engine dataclasses — engine results are mapped in via from_result, the one place renames happen — so the wire format is not hostage to internal engine refactors.

  • Every compute response carries schemaVersion (a required const: "1.0" in the OpenAPI schema) and all fields are camelCase (commandCount, cumulativeTimeSeconds, estimatedTimeSeconds, …).
  • /plan and /simulate return the wire models directly; the per-route hand-rename DTOs (PlanResponse/PlanLayer/SimulationResponse) are gone. fiberpath_api/schemas.py now holds only GcodeRequest + ValidateResponse.
  • /validate ({valid: bool}) and /plot (binary PNG) are intentionally outside the JSON wire schema.

Review gate

Self-reviewed via an independent adversarial review subagent (verdict: SHIP-WITH-NITS, no blocking). All three nits addressed:

  1. Layer-mapping test strengthened to assert every field, using the 2-layer multi_layer example so a per-vs-cumulative swap is actually observable (+ a guard that the fixture exercises distinct cumulative values).
  2. schemaVersion hardened from free str to a required Literal["1.0"] const (verified in the live OpenAPI).
  3. CLI output unification deferred (see below).

Deferred (tracked on #193)

The CLI still emits inconsistent JSON (fiberpath_cli/plan.py, simulate.py). It is not unified onto wire.py here because the current GUI parses the CLI's existing shape (fiberpath_gui/src/lib/schemas.ts expects snake_case estimated_time_s); changing it now would break the GUI. This resolves naturally on the GUI track when the GUI moves to the API client (#193/#194).

Verification

  • ruff clean · mypy clean (32 files) · full suite 108 passed (+3 wire-mapping tests).
  • Live OpenAPI confirmed: /plan→PlanResultOut, /simulate→SimulationResultOut, schemaVersion required const on both.

Introduce fiberpath/wire.py as the single source of truth for the shape
of plan/simulate results crossing a process boundary. Every response
carries schemaVersion and all fields are camelCase; the wire format is
decoupled from the engine dataclasses (mapped in via from_result), so it
is no longer hostage to engine refactors.

- API /plan and /simulate now return wire models directly; the per-route
  hand-rename DTOs (PlanResponse/PlanLayer/SimulationResponse) are gone.
- Docs + CHANGELOG updated to the camelCase, versioned shapes.

Closes #198.
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.

1 participant