Skip to content

Extract the route/body/envelope derivation into an er-api-spec crate #859

Closed

Description

@athvin

API product implementation work · roadmap #1008 · use parent dependency order; not a separate product rank.

Part of #857. Stack rank 2 of 13. Depends on: T1 (sequencing only — the extraction itself is independent, but landing after T1 avoids rebasing the three test files twice).

Color

The paths derivation this epic needs already exists, gated, in three test files — er-server/tests/mcp_manifest.rs (role, path params, request-body JSON Schema, summary, for all ~92 routes), tests/response_envelopes.rs (success-envelope classification per GET), and tests/mock_contract.rs — including three copies of the same brace-matching router walk. This ticket lifts the machinery into a crate so the OpenAPI emitter (next ticket) can consume it. Pure refactor with a byte-level fidelity proof, which is what makes it a safe PR despite touching three gates.

Scope

  • New crate rust/crates/er-api-spec, pure functions over &str source (unit-testable without er-server):
    • routes(src) — the single copy of the router walk.
    • role_of, path_params, tool_name, method_and_path, summary extraction — lifted from mcp_manifest.rs verbatim.
    • struct_fields, type_schema, body_schema — lifted from mcp_manifest.rs.
    • classify_envelope + success_only/object_keys — lifted from response_envelopes.rs.
  • Comments move with the code — they record real bugs (the qualified-role prefix, by_param vs nothing, the GET-with-a-body case, the shared-line error arm) and must survive.
  • The three test files become thin consumers asserting against the committed artifacts. Every assert!(… > N, "parser is broken") floor survives — a derivation that matches nothing reports all-clear.

Out of scope

Any change to what is derived. No new fields, no OpenAPI output.

Testing

The fidelity proof is the whole test: rust/crates/er-mcp/tools.json and frontend/src/lib/api/envelopes.json must be byte-identical after the lift. Any diff means the walk changed behaviour and the PR is wrong. Unit tests move with their functions. make check.

Definition of done

Epic DoD, plus: one copy of the router walk in the workspace; the three tests import er-api-spec; both committed artifacts byte-identical to before.

Activity

  1. added
    rust
    mvp
    on Nov 8, 2026
  2. self-assigned this
    on Nov 9, 2026
  3. athvin commented on Nov 9, 2026

    @athvin
    OwnerAuthor

    Claimed — working in #1059 (draft). Closing that PR releases the claim. User authorized taking this ready Todo prerequisite next; promoted to In progress before implementation.

  4. added 2 commits that reference this issue on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

mvprust

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions