test: support hermetic local API reference#39
Conversation
There was a problem hiding this comment.
Pull request overview
Enables the mock server script to run hermetically by preferring a locally generated OpenAPI reference (when present) and verifying it against generation metadata, while keeping the existing network URL fallback.
Changes:
- Add a local-spec detection path using
api_reference/openapi.transformed.ymlwhen accompanied by.castiron.stats.yml. - Validate the local spec by comparing its computed hash to the expected metadata hash before starting the server.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ACTUAL_HASH="$(node -e 'process.stdout.write(require("node:crypto").createHash("md5").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' "$URL")" | ||
|
|
||
| if [[ -z "$EXPECTED_HASH" || "$ACTUAL_HASH" != "$EXPECTED_HASH" ]]; then | ||
| echo "Error: Local OpenAPI specification does not match generation metadata" >&2 |
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Reviewed the exact mock-server change against the transformed OpenAPI-reference and generation-metadata contract. Verified matching reference bytes and hash, fail-closed handling of missing or mismatched hashes, explicit URL precedence, legacy network fallback, and exclusion of the nested reference module from CLI packaging. No substantive issues found.
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Thermo-nuclear code-quality review: no high-confidence maintainability findings. The change adds one cohesive precedence branch to scripts/mock (61 lines), without scattering feature checks or adding indirection. Approved.
Allow the SDK mock server to use a locally available API reference when present, while preserving the existing network-based fallback.