Repository navigation
refactor(api): share route and schema derivation (#859) - #1059
Merged
Merged
Conversation
athvin
marked this pull request as ready for review
November 9, 2026 20:31
athvin
force-pushed
the
issue/859-api-spec
branch
from
November 9, 2026 20:31
bc15916 to
25f98c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #859
What
Extract the existing route, request-body and response-envelope derivation into the pure
er-api-speclibrary. The three contract gates consume that shared machinery.Why
#859 removes three copies of the router scan and makes the already-gated derivation reusable by the next OpenAPI ticket, without changing the derived contract.
Proof
Six pure-library fixtures, strict crate Clippy and all nine real-source contract assertions pass. Both artifact-fidelity assertions were observed failing under deliberate byte drift, then passing after restoration. Both regeneration tests ran and their outputs match the baseline SHA-256 hashes byte-for-byte. Full
make checkpassed locally. The original implementation commit passed every CI workflow; after rebasing onto the independent production IAM change at3e95a13d, the Rust tree and reviewed patch are byte-identical to the tested version. Six independent house reviews (library/adapters, each covering instrumentation, execution placement and reuse) found no candidates. All 15 live required contexts and all four detect jobs passed on25f98c4f; the final preflight verified its base still matched main before squash merge.Risk & rollback
The risk is changing parser behavior while moving it. Preserve existing comments, thresholds and fixture coverage; compare the artifacts byte-for-byte. Revert the refactor to restore the old test-local helpers.
Post-merge ledger
Closed by: Codex · session
Codex:01a1be1b-0c92-7703-a4c2-25cb2c999baaonMac-46· 2026-11-09T21:08:13Zmainis green with this change on it — merge8453c27debfd5b1b1a44ff86503662673d6de23ais present on main. Rust 42694759494, frontend 42694758926, infra 42694758501 and devcontainer 42694758919 succeeded. The 30-minute watch ran from 20:37:31Z through 21:07:33Z on 2026-11-09 with no new main failures.images— run 42694758446 succeeded for merge8453c27d.deployconverged — runtime gap resolved at 2026-11-09T22:22:21Z using the independently recorded evidence in PR #1062’s post-merge ledger. Its deploy 42706442649 names0a208d9c8c6cd8e9275ec4e6da7bc1fd4e0145ae, verified locally to descend from this PR’s merge8453c27debfd5b1b1a44ff86503662673d6de23a. The peer verified the production API’ser-server listeningline at 21:52:51.130164Z and dev startup at 21:55:09.394202Z, with both live pods at zero restarts; its ledger records live selectors/replicas and explains dev’s replacement as node eviction of the same ReplicaSet. This is attributed peer runtime evidence, not an inference from workflow success or a fresh AWS read by this session.Specific to this change
Context — plan, discoveries, measurements, files
Plan
er-api-specwith pure source-string inputs for route/docs/body/envelope derivation. Move the parser rationale and classifier fixtures with the functions; add focused route and injected-source cases for the shared seam.cargo add, update the API-contract reference and regenerate the crate inventory. Prove the two committed JSON artifacts are unchanged; observe a deliberate bad derivation fail the fidelity gate before restoring the implementation.make check, six independent house reviews, refreshed exact-head CI, squash merge and the 30-minute main watch are complete. The ledger records the remaining guarded-access process-log verification gap explicitly.Discoveries
The existing consumers intentionally differ after locating each registration: MCP detects method substrings, the mock gate enforces identifier boundaries and erases parameter names, and the envelope gate selects GET handlers. The extracted
routesreturns the original path/handler slices, so those consumer rules remain unchanged.er-api-specis a dev-dependency ofer-serverin this PR; no request handler, endpoint, SQL statement or deployed task changes.The pure library accepts source strings for documentation/body parsing and ledger generation. It preserves the existing fallback/unsupported-type behavior; broadening the supported source language belongs in a subsequent ticket with its own contract changes.
Commit audit
38f68dbf75159b6bf2b548c8041b48b68c9357de.25f98c4f9c6e1627d046610a42eca42806ed1261.8453c27debfd5b1b1a44ff86503662673d6de23a.Measurements
Focused proof: 6 library tests and 9 existing real-server contract assertions pass. Both existing fidelity assertions failed on a deliberately appended newline, then passed after restoring the exact bytes. The two ignored regeneration tests were explicitly run and produced unchanged artifacts:
rust/crates/er-mcp/tools.json: SHA-25652760cad4f7916ebce04f70fd8c494b607972dd3721a8556df6abdefd41cba63.frontend/src/lib/api/envelopes.json: SHA-256ba939b61cb4e737a0fb4e5f776450484aa99f9e94398f6c2cb14efdd434012c8.Files