1. Normalize the public contract
simile-openapi accepts OpenAPI 3.0, 3.1, and 3.2 JSON or YAML. simile-smithy accepts Smithy 2.0
IDL. simile-typescript accepts a declarations-only semantic contract package without running
JavaScript or invoking tsc. Each frontend preserves the source semantics needed for diagnostics
and reproducibility.
The adapter produces a canonical contract containing service metadata, stable METHOD /path
operation keys, optional operationId values, request bodies, responses, tags, examples, and
schema fragments. Source-format details do not escape into the canonical model.
2. Parse and resolve HCL
simile-hcl first parses syntax without consulting the contract. A semantic pass then resolves every
behavior against the canonical contract. Collection before resolution makes module order
irrelevant.
The semantic compiler rejects:
- duplicate declarations;
- behavior that names an unknown
operationId; - a response status absent from that operation;
- unknown backends used by async declarations;
- provider-specific backend kinds; and
- scenarios that select unknown outcomes.
3. Merge one compiled service
simile-compiler is the only layer allowed to combine source languages. Each HTTP operation gets
an origin:
open_apiwhen the contract supplies its complete current behavior (the stable artifact label is retained for compatibility across all three source frontends);hclwhen an optional overlay refines it.
4. Compile executable schemas
simile-schema lowers the supported JSON Schema subset into one indexed graph catalog. Local
component references become graph edges, recursive schemas remain recursive, and request and
response direction are distinct: readOnly fields leave the request graph; writeOnly fields
leave the response graph.
At this stage Simile also compiles:
x-simile-constraintsinto typed proof and construction records; and- provider-neutral generation heuristics into evidence-bearing repair plans.
5. Lower and encode
simile-artifact replaces names with indexes into sorted tables, orders all map-backed records,
and encodes the payload as deterministic CBOR. A fixed envelope records the format version,
payload length, and SHA-256 integrity digest.
The decoder validates the envelope and every internal index before returning an Artifact. This
means the runtime receives linked, checked records rather than fallible source syntax.
Why compilation is a hard boundary
Moving work out of the request path has three benefits:- Failure is early. A bad definition cannot start a service and fail only when an operation is reached.
- Runtime is smaller. It does not need YAML, HCL, JSON Schema source traversal, or unresolved strings.
- Execution is reproducible. A registered service runs the validated artifact revision even if its original URL or local source later changes.