Skip to content

test: support hermetic local API reference#39

Draft
apcha-oai wants to merge 1 commit into
mainfrom
apcha/hermetic-api-reference
Draft

test: support hermetic local API reference#39
apcha-oai wants to merge 1 commit into
mainfrom
apcha/hermetic-api-reference

Conversation

@apcha-oai

Copy link
Copy Markdown
Contributor

Allow the SDK mock server to use a locally available API reference when present, while preserving the existing network-based fallback.

Copilot AI review requested due to automatic review settings July 26, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml when 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.

Comment thread scripts/mock
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 HAYDEN-OAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

4 participants