test: support a hermetic local API reference - #3542
Conversation
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Thermo-nuclear code-quality review: no high-confidence maintainability findings. The 9-line change is cohesive within the existing spec-resolution flow; scripts/mock remains 61 lines and no file approaches the 1,000-line threshold. Approved.
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Reviewed the exact head against the hermetic generation-input contract, explicit-path precedence, legacy network fallback, artifact/hash failure modes, and packaging. One actionable correctness issue prevents the real sealed local API reference from being used and can instead force a network request or abort mock startup; see the inline comment.
| if [[ -n "$1" && "$1" != '--'* ]]; then | ||
| URL="$1" | ||
| shift | ||
| elif [[ -f .castiron.stats.yml && -f api_reference/openapi.transformed.yml ]]; then |
There was a problem hiding this comment.
[P1] Consume the actual sealed local API-reference contract
The producer seals the local reference at .castiron/api-definition.yaml in .castiron/generation-inputs.json with a SHA-256 digest; .castiron.stats.yml contains the nested generation-lineage marker, not openapi_transformed_spec_hash. With the actual artifact set, this condition is false, so scripts/mock and scripts/test select the network-backed .stats.yml URL and fail in a hermetic environment. If api_reference/openapi.transformed.yml also exists, awk finds no expected hash and mock startup fails before invoking Steady. Resolve the API-reference path from the canonical generation-input descriptor, verify its SHA-256 and a repo-local regular file, and use the network fallback only when the descriptor/reference pair is absent.
Allow the mock server to validate and use a local API reference when generation metadata is available, while preserving the existing network-backed fallback.