Language model
A Simile service has one contract source and an optional behavior source:- OpenAPI, Smithy, or semantic TypeScript is the authority for HTTP routes, request schemas, response statuses, media types, and response schemas. Exactly one is selected.
- Simile HCL composes the runnable service and adds public behavior the contract cannot express, such as named outcomes, scenarios, abstract effects, and environmental faults.
Documents
Simile accepts two document forms.Service configuration
A service configuration contains exactly oneservice block and may contain behavior declarations
in the same file. Simfile is the conventional filename for a local service configuration:
modules paths name additional HCL modules. Inline and imported declarations enter the
same compiler and namespace. simile register, simile describe, and simile start load
./Simfile when invoked without a service name or explicit configuration.
For compatibility, behaviors is accepted as a deprecated alias for modules. A service cannot
define both attributes.
HCL module
An HCL module contains service-model declarations but noservice or principal_setup block:
simile run --module and by the modules attribute of a local service
configuration. A module may declare principals, profiles, operation behavior, state effects,
scenarios, faults, asynchronous work, or webhooks.
Top-level forms
Concrete syntax
Simile follows HCL’s native block syntax:- block labels are quoted strings;
- attribute names and block types are case-sensitive;
- a top-level attribute is never valid;
- unknown blocks, nested blocks, and attributes are errors;
- comments use
#,//, or/* ... */HCL syntax; - strings, numbers, booleans, arrays, and objects use HCL literal syntax; and
- references to variables, Terraform resources, providers, functions, and dynamic blocks are not part of Simile HCL.
body and equals attributes accept any
expression that evaluates without external variables or functions and converts to a JSON value.
Public descriptions
Named semantic blocks accept an optionaldescription attribute: service, principal_setup,
principal-setup collect and issue, backend, principal, profile, async,
effect, behavior, outcome, error_set, protocol_error, scenario, custom fault,
fault_profile, and provider-authored webhook. Its value must be a non-empty string. Descriptions are presentation metadata
retained in the compiled artifact and displayed by simile describe service; they never influence
matching, selection, synthesis, or execution.
Structural blocks do not accept description: listen, openapi, response, when,
apply_error_set, faults, webhooks, use, select, inject, delay, and disconnect. Their meaning
belongs to the named object that contains or references them. Descriptions are public integration
documentation and must not contain secrets, internal thresholds, private rules, or production
system names.
Notation used below
In syntax summaries:NAME,OPERATION_ID, and similar uppercase words stand for quoted string labels;[...]in prose means optional syntax, not an HCL array;...means a form may repeat; and- an attribute marked “required” must occur exactly once.
service
Exactly one
service block, one listen block, and one contract block are required. The deprecated
behaviors attribute is accepted instead of modules, but the two cannot be combined.
listen
The CLI
simile start ... --port PORT overrides listen.port for that invocation without changing
the configuration.
reporting
The endpoint declares provider capability. It grants no permission to submit.
simile setup and
simile reporting store user-owned automatic-reporting consent and contact information outside the
service artifact. One-off reports require an explicit send action and contact address.
Simile appends /preflight to this URL for version and service-definition checks. It sends the
technical report, reproduction attachments, and reporter contact as separate multipart fields to
the declared endpoint. See Report an issue.
openapi, smithy, and typescript
Exactly one source attribute is required:
path and url are mutually exclusive. The three contract blocks are mutually exclusive. A
service configuration loaded from a URL has no local base directory, so it must use a contract URL
and inline behavior declarations. Split TypeScript packages require a local path; a TypeScript URL
must identify a self-contained declaration document.
principal_setup
principal it provisions. Each principal may have at most one
principal_setup block. At
least one issue block is required.
The referenced operation must exist in the selected contract. Setup synthesizes its smallest valid
request, applies collected values, and selects a declared successful response when one is
available. The operation’s synchronous effects and profile creation commit in one service-state
checkpoint.
collect
Supported collect bindings are
webhook.target and webhook.signing_secret. A URL value must
begin with http:// or https://. Traversal segments are compiled to JSON Pointer; quoted index
syntax may address property names that are not HCL identifiers.
issue
from and generate are mutually exclusive. A credential must name a slot declared by the
referenced principal, whose label in turn names a supported contract security scheme. API key,
HTTP bearer, OAuth 2.0, and OpenID Connect credentials use one issued string;
HTTP Basic credentials require a username/password pair and therefore cannot currently be issued
by setup. Credential values must be strings.
Supported issue bindings are webhook.target and webhook.signing_secret. Sensitive values are
stored for runtime use and written to the profile’s private environment file; describe, profile,
and setup reports omit their contents.
webhook
OpenAPI callbacks and OpenAPI 3.1/3.2 top-level webhooks are imported as webhook contracts. Use a
singular webhook block only when that public contract is absent from the selected API source:
The block defines a wire-message identity, not a trigger. An effect decides which
committed operation emits it and supplies the payload. A provider-authored webhook cannot redefine
a webhook imported from the API contract. Its payload is not schema-constrained; publish the
webhook in OpenAPI when consumers need Simile to validate its body against a reusable schema.
webhooks
webhooks block may appear across the
inline configuration and every imported HCL module.
signing
The signing key becomes part of the local compiled artifact so that restarts reproduce the same
delivery behavior. Use a dedicated test value. Production credentials do not belong in a Simile
configuration.
best_effort is deliberately the default. Concurrent webhook infrastructure rarely guarantees
global ordering, and retries can naturally arrive after newer occurrences. Simile samples only
independent deliveries inside the configured window. The decision is derived from the compiled
service fingerprint, correlation identifier, and delivery identifiers, so restarting the same
service reproduces the same decision.
An explicit causal dependency is stronger than this policy. When one occurrence declares that it
must follow another, the runtime never reorders that pair. A strict service must omit
reorder_window and set out_of_order_probability to zero or omit it. A non-zero probability also
requires concurrency of at least two.
See Webhook delivery for the policy layers and rationale.
Behavior declarations
The remaining top-level blocks are legal both inline in a service configuration and in a behavior module.backend
description is the only optional attribute.
The supported kinds are:
The canonical backend reference is
KIND.NAME, for example queue.orders. Backend kinds are
provider-neutral. Names such as postgres, redis, or s3 are rejected.
principal
grants belongs to the credential slot because an OpenAPI operation
requests scopes through a particular scheme.
Each principal
credential accepts an optional grants array. Credential values live on profiles.
The compiler verifies that each credential label resolves to a contract security scheme. During
authentication, Simile compares an operation’s required scopes with the grants on that slot.
profile
simile setup creates durable profiles through a principal_setup
workflow.
A profile
credential accepts either value, or the pair username and password. API-key,
bearer, OAuth2, and OpenID schemes use value; HTTP Basic uses the username/password pair. The
compiler checks the credential form against the referenced security scheme. Use synthetic values
created solely for emulation.
OpenAPI security requirements preserve their native composition. Schemes inside one requirement
are all required; separate requirements are alternatives. An operation with an empty security
requirement remains public. Simile authenticates an active profile, then evaluates grants through
its principal contract. Missing, invalid, revoked, expired, or insufficient credentials select the
operation’s declared authentication or permission response.
async
Every reference must resolve to a declared backend. Action backends are added to
uses
automatically. An async declaration is inert until an effect.async attribute names it; once
attached, the service writes the planned work into its durable outbox in the same commit as the
operation. A background worker leases and dispatches the actions after the response-critical work
has committed. Restarting a persistent service preserves pending work, lease expiry makes an
interrupted item eligible again, and exhausted attempts move the item to the dead-letter queue.
effect
An effect must contain at least one synchronous action, one async reference, or one webhook
emission. Operation IDs, async names, webhook names, backends, commands, required arguments, and
accepted optional arguments are all validated at compile time.
An action value may be a JSON-compatible literal,
request, response, a dotted projection such
as request.customer_id or response.order.id, or an array/object recursively containing those
values. Projections are compiled into JSON Pointers; arbitrary functions and private backend reads
are not part of the expression language.
emit is deliberately a map rather than a repeated block: one effect can declare several related
occurrences compactly. Every key must name a webhook imported from OpenAPI or declared with
webhook. An OpenAPI webhook body is checked against its request schema after the payload
projection is rendered. after, delay, and to are optional maps whose keys must also occur in
emit; they refine only the named occurrence.
after forms a hard causal graph. Dependencies must name distinct webhook occurrences emitted by
the same effect, and cycles are rejected. The service-wide best-effort delivery policy may reorder
independent occurrences but never crosses one of these edges. delay accepts the same duration
syntax as other HCL timing controls. to accepts a string or request/response projection and
overrides an OpenAPI callback runtime expression for that occurrence.
An OpenAPI callback target is otherwise resolved from its runtime expression. The current runtime
supports JSON-body pointers such as {$request.body#/callback_url} and
{$response.body#/links/webhook}. Header, query, path, and expression-composition targets are
retained in the contract but require an explicit to override until those parameter contexts are
available to effect planning.
Supported mutation commands are:
The command determines required and optional arguments. For example,
db.put and db.merge
require collection, key, and value; queue.publish requires body and optionally accepts
attributes and delay_ms. db.put replaces the stored document. db.merge recursively merges
object fields, replaces supplied scalars and arrays, and preserves omitted fields. Unsupported reads
such as db.get are rejected because an effect describes consequences, not an alternate query API.
behavior
All referenced error sets must exist. All selected statuses must already be declared by the
contract operation.
resolve
resolve reads one document for each scalar selected by key, takes the stored value at select,
and adds it at into in the request view used by response relations. It does not modify the
validated request retained by the operation, outcome predicates, replay, or effects. This makes it
safe to enrich a reference branch with a field that is mutually exclusive on the public wire.
Every
where block requires stored and exactly one predicate:
equals = VALUEcompares a stored field with a JSON-compatible literal;request = "/path"compares it with the request value at the corresponding wildcard position; orstate = "present|absent|null|non-null|null-or-absent"checks presence and nullability.
otherwise may name a provider-authored outcome on any where block. The named outcome must
belong to the same behavior or one of its applied error sets. Predicates are evaluated in source
order, so authors can preserve a documented precedence between overlapping public lifecycle states.
State projections must use public resource names and public fields. They are not a way to publish
private tables, thresholds, routing rules, or production decision trees. A missing document,
missing selected value, or failed predicate cannot be used to construct a successful response.
Without an explicit failure outcome, those conditions remain provider-configuration errors.
response
status is required and must be an HTTP status integer from 100 through 599. The operation’s
contract responses must declare it.
outcome
A supplied body must validate against the selected contract response schema. A provider-authored
outcome may replace a contract-derived outcome with the same name. Two different provider-authored
outcomes with the same name for one operation are a compilation error.
when
path is a JSON Pointer into the validated request body. equals is a JSON-compatible value.
Every when block on an outcome must match for the outcome to be selected. Predicates operate only
on public request data; they cannot read headers, production state, backends, or private rules.
error_set
outcome blocks. Its optional description is a non-empty
public string. A service may declare each error-set name once. An error set is inert until a
behavior.error_sets attribute or apply_error_set block attaches it to operations.
apply_error_set
tags is a required, non-empty array of contract tag strings. The named error set is attached to
every operation that has at least one listed tag. Every named tag and the error set must exist.
Each attached outcome is checked against every affected operation’s declared responses.
protocol_error
Simile defines these provider-neutral causes:
malformed_request, invalid_body,
unsupported_media_type, authentication_required, permission_denied,
idempotency_conflict, and rate_limited. Declaring the same cause replaces Simile’s built-in
mapping for the service. At runtime, Simile chooses only a compatible response declared by the
matched operation; otherwise it uses its diagnostic fallback.
scenario
description is retained for
simile describe. Its label is selected with --scenario.
One scenario may contain selections and injections for several operations. It may select and inject
for the same operation, but it may not contain two selections or two injections for one operation.
All operation IDs, outcomes, and faults must resolve during compilation.
Environmental faults
Domain failures belong in outcomes. Faults model how a completed result reaches the caller and may be activated deterministically by a scenario or stochastically by a fault profile.faults and use
An unmatched selector is an error. Repeated imports of the same unchanged definition are
idempotent. Exclusions are applied across all modules before positive imports.
An exact selector may be aliased or receive a supported override:
Aliases and overrides are legal only when the selector resolves to one fault. Exclusions accept no
attributes. An override is legal only when that catalog action supports it. The current catalog is
listed in the fault glossary.
fault
description, a required phase, and exactly
one action block. Imported catalog faults inherit the catalog’s built-in description, including
when aliased.
delay.milliseconds is a required integer from 1 through 86,400,000. Other phase/action
combinations are rejected.
fault_profile
Profiles may contain environmental faults only. Domain outcomes are deterministic and cannot be
randomly selected by a fault profile.
Name resolution and compilation
Parsing proves that each file uses legal HCL structure and value types. Compilation then combines all modules with the selected contract and resolves the service as a whole. Resolution is independent of declaration order. A reference may target a declaration in a later file. Compilation rejects:- duplicate backends, behaviors, error sets, async operations, scenarios, custom faults, or fault profiles;
- unknown contract operation IDs or tags;
- response statuses absent from the targeted contract operation;
- provider-authored response bodies that fail the selected response schema;
- unknown backends, error sets, outcomes, or faults;
- duplicate provider-authored outcome names for one operation; and
- incompatible fault phases, actions, selectors, or stochastic-profile members.
.similec artifact. Imported
catalog faults are expanded into the artifact; the runtime does not need the original HCL or fault
catalog to execute it.