/lookup or /page, which are common in RPC-shaped HTTP APIs.
Enable state
Declare one provider-neutral database:Product declares an id, a successful create can persist the synthesized or authored product.
The later item GET reads that identity, the collection GET queries all products, and DELETE removes
the selected identity. State lives in the service’s redb checkpoint under $SIMILE_HOME, so a
registered service can continue after restart.
For a POST /lookup, Simile reads an id or resource-shaped *_id scalar from the validated JSON
object. For POST /page, it projects stored entities into a contract-valid collection response and
repairs declared size, count, total, and has_more page metadata. It does not interpret
arbitrary POST operations as reads. An ambiguous identity or incompatible response projection
leaves the operation’s ordinary authored or contract-derived outcome in control.
Understand the inference threshold
Simile adds the default write only when all of these facts are clear:- exactly one
dbbackend exists; - the operation is
POST,PUT, orPATCHand has a stableoperationId; - exactly one successful response entity has an
idproperty; - the route yields one stable collection name; and
- no provider-authored effect already owns the operation.
/v1/products/create becomes products;
version and mutation scaffolding such as create, update, and delete is ignored. Simile also
requires the resulting resource name to match the successful response entity. This structural
check prevents a POST action from becoming a write merely because of its method or vocabulary.
Reads accept only response shapes that the contract proves, including a direct entity, a singular
or collection wrapper, an array, { "data": [...] }, and page wrappers whose collection and
metadata remain schema-valid after stored values are inserted. A possible state read whose stored
value cannot satisfy the declared response falls through to the operation’s ordinary outcome.
Take control with an effect
Custom keys, projections, multi-entity responses, or transitions across several stores deserve an explicit effect:Resolve stored references during synthesis
Some valid requests identify a stored public resource instead of repeating its value. An order may carryprice_id, for example, while its response snapshots the resolved amount. Declare that read
inside the operation behavior:
missing_outcome selects a declared public result when the referenced document is absent.
otherwise on a where predicate selects a declared result when that public condition fails.
Leave either unset when failure indicates a broken Simfile or corrupt test state rather than a
documented service outcome.
For mutations, a stored snapshot is a baseline rather than an exact response fixture. Simile keeps
compatible stored values, constructs any newly required response fields from the schema, and then
applies the operation’s declared request-to-response relation. This lets lifecycle operations add
public timestamps without erasing the resource fields already stored by an earlier request.
Server-owned creation, update, processing, and lifecycle timestamps use the Stack’s shared
logical time, so a stored resource records the same operation instant observed by
the causal journal and effects.
Inspect authority
simile audit ARTIFACT identifies convention-inferred effects, missing state effects, and ambiguous
operations. simile describe service NAME --verbose labels operation refinements as
contract_derived or provider_authored. simile state NAME --values shows the stored engine
state when payload inspection is appropriate.
Inference represents a public convention. It carries less authority than an authored effect and
never claims knowledge of a provider’s private tables or implementation.
Continue with Dependencies and effects,
State inspection, or Stack database.