Skip to content

refactor(api): make compute routes body-only and add /plot - #201

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/api-compute-routes-189
Jun 26, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/api-compute-routes-189

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Closes #189.

First step of the local-API architecture track (Epic #195): rework the FastAPI compute surface so requests carry data, not filesystem paths. This is the stable contract the OpenAPI-generated TS client (#191) will consume, and makes the service safe to run as a stateless local sidecar.

Changes

  • POST /plan and POST /validate take a wind-definition body (the same JSON as a .wind file). /plan returns the generated program directly in gcode instead of writing a .gcode file and returning its path.
  • POST /simulate takes a G-code program body ({"gcode": "..."}).
  • New POST /plot renders an unwrapped 2D preview and returns image/png bytes.
  • Removed the path-allow-list policy (path_policy.py + FIBERPATH_API_ALLOWED_ROOTS) and the /stream route. PlotError now maps to 400.
  • Docs (API reference, axis-mapping, architecture) + CHANGELOG updated.

Driving a Marlin controller is intentionally not part of this surface — it's being reworked into a dedicated REST surface (#190 / #199).

Verification

  • API tests rewritten TDD-style (red → green): tests/api/test_plan_route.py, test_simulate_route.py, new test_plot_route.py.
  • ruff check clean · mypy clean · full suite 105 passed.

Net −580 lines.

Rework the FastAPI compute surface so requests carry data, not
filesystem paths:

- POST /plan and POST /validate take a wind definition body; /plan
  returns the generated program in `gcode` instead of writing a file.
- POST /simulate takes a G-code program body.
- Add POST /plot returning image/png bytes.
- Remove the path-allow-list policy (path_policy.py) and the streaming
  route; map PlotError to 400.

This makes the service stateless and safe to run as a local sidecar,
and is the stable contract the generated OpenAPI client will consume.

Closes #189.
@CameronBrooks11
CameronBrooks11 merged commit 2278841 into main Jun 26, 2026
12 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/api-compute-routes-189 branch June 26, 2026 03:55
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.

feat(api): in-memory compute routes (plan/simulate/validate) + plot/preview route

1 participant