api: wire engine and render endpoints to core #21

Merged
yuuhikaze merged 2 commits from api/engine into master 2026-10-23 23:29:25 -05:00
Owner

Closes #15.

What changed

  • api — every engine endpoint now calls rgxr-core; /render calls rgxr-render::render_svg (both merged). The interim 501 helper and its tests are gone.
    • Engine work runs on tokio's blocking pool (spawn_blocking): subset construction and products are CPU-bound and exponential in the worst case, and must not stall async workers.
    • Error mapping: FaError::Regex → 400 invalid_regex; every other FaError → 400 invalid_fa; RenderError::Dot → 400 invalid_fa; Unavailable → 503 render_unavailable; Failed → 500 internal, with the detail logged, not returned.
    • The cardinality checks (≥2 for boolean ops, exactly 2 for difference, ≥1 for concatenation → 400 invalid_request) and the latex gate are unchanged.
    • RenderResponse.engine serializes rgxr_render::Engine: same lowercase wire values as before.
  • core — to_dfa and the product constructions stop at 10,000 states and return 400 invalid_fa ("would build more than 10000 states"). Same denial-of-service class as the fa_to_regex fix in !14, now that these run on request paths.

Gates

cargo fmt --check                     → clean
cargo clippy --workspace --all-targets → 0 warnings
cargo test --workspace                → 95 passed, 0 failed, 1 ignored
                                        (api 44, core 11 + 28, render 12)

The ignored test is render's to_dot_renders_epsilon_glyph; it passes with -- --ignored. Un-ignoring it is opencode's (see #20).

New api tests cover real results for run (trace with symbol: null), union naming, L \ L empty, concatenation #k naming, the to_dfa → minimize → complement pipeline, regex round trip, invalid_regex mapping, the empty-language → invalid_fa path, the latex gate, and invalid_fa before rendering. The router-level /api/v1/run test now asserts 200 + trace.

Semantic decisions

  • The 10,000-state cap is a core constant, not configuration. Larger automata are beyond what the canvas UI can usefully show.
  • Render failures return a generic 500 message: toolchain stderr can contain paths, so it goes to the tracing log only.
Closes #15. ## What changed - **api** — every engine endpoint now calls `rgxr-core`; `/render` calls `rgxr-render::render_svg` (both merged). The interim 501 helper and its tests are gone. - Engine work runs on tokio's blocking pool (`spawn_blocking`): subset construction and products are CPU-bound and exponential in the worst case, and must not stall async workers. - Error mapping: `FaError::Regex` → 400 `invalid_regex`; every other `FaError` → 400 `invalid_fa`; `RenderError::Dot` → 400 `invalid_fa`; `Unavailable` → 503 `render_unavailable`; `Failed` → 500 `internal`, with the detail logged, not returned. - The cardinality checks (≥2 for boolean ops, exactly 2 for difference, ≥1 for concatenation → 400 `invalid_request`) and the latex gate are unchanged. - `RenderResponse.engine` serializes `rgxr_render::Engine`: same lowercase wire values as before. - **core** — `to_dfa` and the product constructions stop at 10,000 states and return 400 `invalid_fa` ("would build more than 10000 states"). Same denial-of-service class as the `fa_to_regex` fix in !14, now that these run on request paths. ## Gates ``` cargo fmt --check → clean cargo clippy --workspace --all-targets → 0 warnings cargo test --workspace → 95 passed, 0 failed, 1 ignored (api 44, core 11 + 28, render 12) ``` The ignored test is render's `to_dot_renders_epsilon_glyph`; it passes with `-- --ignored`. Un-ignoring it is opencode's (see #20). New api tests cover real results for run (trace with `symbol: null`), union naming, `L \ L` empty, concatenation `#k` naming, the to_dfa → minimize → complement pipeline, regex round trip, `invalid_regex` mapping, the empty-language → `invalid_fa` path, the latex gate, and `invalid_fa` before rendering. The router-level `/api/v1/run` test now asserts 200 + trace. ## Semantic decisions - The 10,000-state cap is a core constant, not configuration. Larger automata are beyond what the canvas UI can usefully show. - Render failures return a generic 500 message: toolchain stderr can contain paths, so it goes to the tracing log only.
Both are exponential in worst case and now run on request paths;
exceeding cap returns invalid_fa instead of exhausting memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tt5Kc71LcLjqfyZWoZosqh
feat(api): wire engine and render endpoints to core
Some checks failed
ci / rust (pull_request) Failing after 4s
ci / web (push) Successful in 15s
ci / rust (push) Failing after 32s
ci / web (pull_request) Failing after 1m12s
f1cef9c8ea
Replace 501 placeholders with rgxr-core and rgxr-render calls. Engine
work runs on blocking pool; RenderError maps to 400/503/500.

Closes #15

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tt5Kc71LcLjqfyZWoZosqh
yuuhikaze merged commit f1cef9c8ea into master 2026-10-23 23:29:25 -05:00
yuuhikaze deleted branch api/engine 2026-10-23 23:29:25 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
k8s-services/rgxr!21
No description provided.