specification → working service

Describe the service.
Get the service.

Arcod is a language and a compiler for agent-built services. You write one .arc file — types, operations, errors, rules, effects, bindings — and get routes, adapters, an OpenAPI contract, a UI, tests, deploy manifests and prompts a small local model can actually follow. No library shopping, no drift between the model and the code.

Node ≥ 22.18 · Docker · Apache-2.0 · no cloud model required

examples/quiz/main.arc
// one deck, one code, every phone in the room
ui Stage {
  kind:    spa
  route:   "/"
  layout:  presentation
  start:   Live.start
  join:    Live.join
  state:   Live.state
  advance: Live.advance

  slide "Who are you?" {
    body: "Developers, QA, product."
  }
  slide "Join" {
    body: "Scan the code, follow along."
  }
}
CHECKED, NOT GUESSED

Rights are declared, not hand-written

auth op, roles: and owner: id become a guard in the runtime: 401 for anonymous, 403 for the wrong role or somebody else's record, 404 when the record is gone. A046–A049 catch a guard with no actor source or a role outside the service vocabulary.

LIVE, NOT POLLED

One page, a websocket, zero idle traffic

A stream in a service with identity checks the handshake: the token rides ?token=, and an anonymous client gets 401 before the upgrade — a private room is not protected by its name (B210).

The service publishes an event after every mutation and the page reads state. A slide reaches the phones in 13–17 ms, and an idle room sends nothing at all; polling every 3 s would keep every phone talking all session.

0
runtime deps
154
diagnostics
12
capabilities
2000+
tests
what shipped this week

Three things shipped on 2026-12-03.

Each is covered by tests in the repository.

2026-12-03 · TRANSACTION

One operation, one transaction, declared

public transactional op create puts one transaction around the whole body: every store write and every publish commits together or rolls back together. It is a clause in the model, not a habit in a body, so check names the versions that would be a silent no-op: A125 (error) without a sql store, A127 (error) for a go or python kit that opens no transaction, A126 (warning) for a body that writes nothing. examples/orders declares it on create; a test throws Conflict mid-body and finds no row afterwards.

2026-12-03 · BLOB

List, stat and presign — in three kits

io.blobList answers one page of { key, size, type } with a continuation cursor, io.blobStat reads size and type with a HEAD and no bytes, and io.blobSign returns a presigned URL a browser can upload to. Node, Go and Python speak all three over the same S3 SigV4 wire, and the tests verify the presigned query, not just the shape. One key means one object: BLOB_PREFIX is the only namespace, so a file Node writes is listed by Go and stat-ed by Python. A provider that cannot sign is A124 at check time, not a failure once a browser is already uploading.

2026-12-03 · HASH

A deterministic digest, without a crypto dependency

io.digest and io.hmac are effects on the hash capability: sha256 or sha512, lowercase hex, computed by the runtime rather than a library the body imports. A checksum, an audit chain or a dedup key finally has a stable value next to the salted io.hash. All three kits answer the published FIPS 180-4 and RFC 4231 vectors, and A123 refuses any other literal algorithm when the spec is checked.

why another tool

The model and the code are two descriptions of one thing.
They drift.

Arcod removes the second description. What cannot be checked — is not allowed to be guessed.

No library shopping

The model names a capability (kv, sql, llm, stream), the environment names a provider. The compiler knows the adapter and refuses a provider that does not implement the capability.

Prompts a 7B model can follow

One prompt per operation, derived from the contract: 66–109 tokens instead of a service description. Constant rules live in the system prompt, so the model never re-invents the framework.

Unresolved is a failure

If a step cannot be derived from effects and type shapes, generation stops with unresolved instead of quietly inventing code. Unhandled errors, unused bindings and unknown clauses are diagnostics, not surprises.

the pipeline

One file in. A running system out.

arcod make runs the same steps the standalone commands do, so the pipeline cannot drift from the CLI.

Check

Types, bindings, effects, rules, access, routes, examples. 154 codes, errors stop the build.

Plan

A deterministic task DAG: files, dependencies, acceptance criteria, --json.

Prompts

One prompt per operation with a token budget and a hash for caching.

Build & test

Service, UI, compose, manifests — then the model's own examples run against it.

examples/onetimemessage/main.arc
service OneTimeMessage : http {
  uses store: kv(ttl: 999s)
  uses uuid: ids

  contract {
    public op create(body: Body) -> MessageId {
      route: "POST /api/messages"
      effects: store.set, uuid.new
      errors: Invalid
      on error Invalid: body != null
    }

    public op read(id: MessageId) -> Body {
      route: "GET /api/messages/:id"
      errors: NotFound, Gone
    }
  }

  rules {
    invariant read.at_most_once: once(read, by: id)
    atomic read { get; del }
  }
}
what you get

Everything the service needs, derived from one source.

Not snippets to paste — artifacts that run, and that the compiler keeps honest.

Records, not blobs

A record type is a store. rules { unique Task.title } is a claim the adapter keeps: the second task with that title is the declared Conflict, not a 500. io.find takes where, order, limit and a keyset cursor, so a page does not shift under inserts.

A transaction the model declares

public transactional op create wraps the whole body in one SQL transaction: rows and the outbox event commit or roll back together, and a declared or thrown error rolls back. Because the guarantee lives in the model, check can refuse a version that would be a silent no-op — no sql store (A125) or a go/python build (A127) — and warns when the body writes nothing (A126). The in-memory SQL driver restores its snapshot on rollback, so the generated service is tested without a database.

Defaults that hold everywhere

done: bool = false is written once and honoured by the migration (DEFAULT 0), by io.insert (only missing fields are filled, an explicit null wins) and by the OpenAPI schema (default, field no longer required). A default declared after rows already exist fills on read as well: fetch, find, a where filter, order and an aggregate all see the declared value on a row that never stored it.

Input checked at the boundary

email, url and declared enums carry format into OpenAPI and a validator into the generated service: a value that breaks the declaration never reaches the operation body.

Migrations from the model

arcod migrate turns record types into typed tables — uuid as CHAR(36), unique rules as UNIQUE KEY — with a checksummed changelog the service applies on boot. Re-runs are no-ops; an edited migration refuses to start.

Totals and sums in one call

io.count returns a number and ignores limit/cursor; io.aggregate(entity, { field, op }) returns sum, avg, min or max over one numeric field with the same where operators as find. On SQL each is one statement, on kv one fold of the filtered namespace; the effect is declared as store.count or store.aggregate.

Rows appended, aggregates typed

uses events: olap(orderBy: "day", ttl: 30d) adds an analytical store: io.olapAppend writes one row as JSONEachRow, and io.olapSelect answers groupBy and metrics with the values sent as parameters, never interpolated. The ClickHouse DDL is derived from the record types the bodies name, arcod migrate --olap-url creates the tables, compose runs a /ping healthcheck and /healthz reports olap: up|down. The raw io.olapSql escape hatch is read-only, bounded by time and rows, and flagged by W054.

One row, one shape on every driver

The generated store checks a write against the record it declares before either driver sees it: a boolean field refuses "false", an int refuses 1.5, a text or bytes field refuses a number, a datetime refuses a word, a patch cannot change the id, and a field the entity does not declare names the ones it does. Declared bounds travel with the same check, so string(min: 3, max: 5) is a 400 on insert and on update.

One model, two SQL dialects

arcod build --dialect postgres emits a PgStore and Postgres migrations from the same model; MySQL remains the default output. build --env <name> takes the dialect from that environment's sql binds instead, so a prod build speaks Postgres while dev keeps MySQL. A build speaks one dialect: a DATABASE_URL of the other scheme stops startup with a named error instead of failing later.

A second language, one contract

language: go builds main.go and language: python builds main.py; both read routes, path captures, input kinds and success statuses from the same contract IR the Node service uses, so one spec cannot describe two different services. In Python, uses store: sql emits arcodsql.py with migrations and a record facade, and kv, a queue, blob and an external service compose into one io, and the kv facade answers the same entity family: fetch, insert, update, updateWhere, incr, remove, find, count, aggregate. A test binds KV_DRIVER=memory, so a Python kv service is tested without Redis. In Go, a Postgres binding emits arcodio/pg.go over the hand-written wire protocol and the same arcod_kv rows as the other runtimes, files: blob an S3 client and a queue both publish and consume — with no dependency in go.mod, so the build stays offline. A parity test builds one spec as Go and as Python and compares every operation. A capability the kit does not carry is refused by name at build time, not answered at runtime.

Several services, one module

An internal service carries its own contract, its own bodies under impl/<service>/, its own container in compose, its own Deployment and ingress path in k8s, its own image in terraform and its own prompt set at prompts/<service>/<op>.md. openapi sums every service into one document, graphql and grpc write one file per service, migrate --service picks whose plan, and a multi-service test report prefixes each result with the service it ran. Two services claiming one route is an error, not a race; two services may both own an operation named list, because a body is keyed by its service folder and one does not shadow the other.

Observable without a stack

Every service logs one JSON access line per request, echoes and propagates x-request-id, and serves /metrics in Prometheus format — RPS, latency histogram, errors, in-flight and capability calls. Timeouts come from ARCod_TIMEOUT_MS, and a HEAD probe is answered by the GET route with the same headers and no body in every runtime. A required parameter missing from the path, the query and the body is 400 Invalid naming it.

Contracts that become behaviour

atomic read { get; del } becomes a Lua script; once(read, by: id) becomes a tombstone key returning Gone. budget { concurrency: 8 } becomes a 503 limiter. A saga step with compensate: runs its undo in reverse when a later step finally fails.

Embeddings as an effect

io.embed(texts) returns one vector per input from the bound llm provider — no SDK in the service, no vendor in the model. The binding may declare dim, and a vector of another width fails the operation with a named error. examples/vector stores each note with its vector and ranks search hits by cosine in the body.

UIs without a frontend decision

Forms from public operations, layout: chat for dialogue, layout: presentation for decks: a join code, a QR encoder vendored into the page, and slide changes pushed to every phone. A field follows its declaration: an enum is a select of the accepted values, email/url are native inputs, numeric bounds become min/max.

Pages the service can serve itself

render: ssr embeds the page in the service and fills its first screen in-process, so the HTML arrives with data. Compose drops the nginx sidecar and the k8s ingress points at the service; the static files are still written for a separate front door.

Someone else's service, still typed

external service Ledger { ... } gives a remote client typed by a partial contract; the address comes from the environment, never from the body.

A contract others can read

arcod openapi prints OpenAPI 3.1 on stdout: canonical paths from route, schemas from types, status codes from the same error mapping the runtime uses, and the model's examples as named examples. A service with auth: identity publishes a bearerAuth scheme and lists the token only on operations that need it; access clauses travel as descriptions. No server, no host, no provider in the document.

Deploy as a declaration

deploy docker | aws | yandex | kubernetes produces compose or a deploy.<env>.json manifest with "executed": false — no credentials, no API calls behind your back. arcod terraform renders the same environment as Yandex Cloud HCL — network, managed Postgres/Redis, bucket — with every credential a sensitive variable.

A build you can automate

arcod build --json reports the result as one object: mode, directory, dialect, port, reference, files, images and body sources. The tree is published atomically — a late failure leaves the previous .arcod/build untouched — and migrations, prompts and SQL the contract no longer owns are pruned.

JSON on failure, not only on success

--json is not a promise only the happy path keeps: build, test, migrate, prompts, impl, deploy and run --detach answer one object on stdout. A refusal names error and the reason; a spec that does not check answers its diagnostics in the same payload, and the exit code still says what happened. Without the flag the human text is unchanged, so the machine never gets prose.

A filter refuses what cannot mean anything

contains on a bytes, datetime or decimal field is an Invalid naming the operator, not a text search that happens to match; a range comparison must name a scalar field; a list or record field cannot be an order key; and a record field compares by value, so the key order in the filter does not decide the match.

A formatter that keeps your comments

arcod fmt prints the canonical form — one style, one AST, one output — and a comment stays attached to the declaration, field, clause or block it was written in, including the last one in a body. A second pass over its own output changes nothing, so fmt --check is safe in CI.

Bodies held to the same contract

An operation body is impl/<op>.mjs, or impl/<service>/<op>.mjs when the module declares several services, and check reads it as strictly as the spec: it has to export async function <op>(input, io). A body with nothing to rename is A096 — an error, so build refuses with the file and line — while a file that matches no operation is W049 and an operation left without a body is W050: warnings that name the file and the operation. Bodies share one module, so a helper goes in impl/lib.mjs — bundled once before the bodies, called as a top-level name by every body, and refused as A093 when a body redeclares it.

Names your model chooses, not names JavaScript owns

An operation, a field, a type or a provider is a string key in the compiler's tables and in the code it emits. A key that is absent is answered by Object.prototype, so toString or __proto__ used to reach generated metadata as an inherited member. Reads check ownership, maps keyed by model names are built without a prototype, and declared keys are written with defineProperty; nine test files name the member (toString, constructor, hasOwnProperty, valueOf, __proto__) and assert the fallback or the published key, not just that nothing crashed.

kv redis sql postgres · mysql · mariadb blob s3 identity keycloak llm ollama · openai stream websocket · redis queue redis ids local hash local infrastructure-only: olap · metrics · tracing …
examples that run

Twenty-two services, all in the repository.

Each one is a single .arc file with its bodies in impl/; arcod check 'examples/**' reads all twenty-two.

examples/onetimemessage

One-time message

Create, read once, 410 on the second read.

kvrules
examples/chat

Chat with a model

History, replies, a local model as a capability.

llmsqllayout: chat
examples/vector

Notes searched by meaning

A note keeps its embedding; search ranks notes by cosine, with a declared dim: 768.

llmembeddingskv
examples/files

Files and rights

Keycloak sign-in, S3 objects, three visibilities.

identityblob
examples/kanban

Cards with owners and images

Keycloak sign-in, S3 attachments and an owner: guard on every move.

identityblobsql
examples/payments

Calling a foreign service

A ledger that exists already: contract and address only.

externalendpoint
examples/relay

Relay to another service

One outbound call per request: the body names the path, the binding owns the host.

endpointeffects
examples/mail

Mail that survives a dead relay

Enqueue stores the letter and publishes it; the job retries twice, then dead-letters with the attempts.

mailqueuejob
examples/quiz

Live quiz

Slides, a join code and QR, live over websocket.

presentationstream
examples/notes-ssr

Page served by the service

The notes are already in the HTML; the browser hydrates them.

ssrkv
examples/nightly

A nightly workflow

Three steps with typed ports and explicit needs edges on a cron; the graph is declarative in v0.1 (W022), and the operations it calls run over HTTP.

workflowcron
examples/project1

Messages with an author

One-time read over Redis, with a typed payload.

kvtypes
examples/project1-mysql

Same model, MySQL

Two lines differ from the Redis version; the bodies do not.

sqlproviders
examples/onetimemessage-pwd

Password, optional

Same service plus scrypt; the difference is the model only.

hasherrors
examples/tasks

A store with rules

Unique title, filter, multi-field sort and keyset pages over Redis.

recordsuniquepagination
examples/tasks-sql

The same bodies on MySQL

insert, find and a 409 unique claim, without touching a line of the bodies.

sqlprovidersindex
examples/tasks-sql-py

The same board, bodies in Python

The tasks-sql contract and examples with impl/*.py, run against live MySQL 8 and Postgres 16 in CI.

pythonsqlci
examples/orders

An order and its event, atomically

A fact and a queue message commit in one transaction through the outbox.

sqlqueueoutbox
examples/saga

A checkout that unwinds

A failing step compensates the ones already done, in reverse order.

sagacompensation
examples/signup

Sign-up, typed end to end

An email, a plan enum and an optional url; a bad value is 400, not 500.

emailenumsql
examples/shelf

A shelf, bodies in Python

restock is one updateWhere with an { inc } step; page and total are find and count. Tests run it on the in-process store, no Redis.

pythonkvrecords
examples/counter-go

A counter in Go

language: go with a kv store: set, read and bump a counter, built and tested by arcod test.

gokv
honesty

v0.1 is a vertical slice.

A compiler you cannot trust is worse than no compiler, so the gaps are documented and diagnosed, not hidden.

What does not work yet

  • Scaffold without bodies answers 501 NotImplemented for every operation; a build is contracts, routes and adapters until bodies come from --impl or your own code.
  • No demo in examples/ declares more than one internal service yet. The split is covered by the CLI test suite; the twenty-two demos are single-service, so a multi-service module has tests but no example to copy.
  • In a node service a body is impl/<op>.mjs, or impl/<service>/<op>.mjs in a module with several services. A body written in a .js or .ts file next to the .mjs ones is not read: W051 names that file, so it is not mistaken for a silent W050.
  • The Postgres runtime is proven against a fake wire backend, an end-to-end example and a live postgres:16 in CI running the same five examples as MySQL; a managed cloud instance is still not part of CI. MySQL remains the default build.
  • transactional is carried by the Node service. A go or python build refuses the clause (A127) instead of running the body without a transaction; the rollback is proven on the in-memory SQL driver, and the live Postgres case is not in the suite yet.
  • The ClickHouse store is append-and-read. io.olapAppend is at-least-once — a retried job writes the row twice, so a metric that must not inflate asks for distinct — and there is no update or delete: a correction is another row. No demo binds olap yet; the store is covered by tests, not by an example to copy.
  • Metrics and secrets are provisioned in compose but have no effect signatures; Kafka and RabbitMQ provision a queue the adapter cannot speak — bind queue to Redis.
  • find on kv is a scan with a filter, not a query planner: one entity namespace matched in memory. On sql the same find is pushed into WHERE/ORDER BY/LIMIT. Indexes are single-field (index Task.dueAt); composite and partial indexes are not generated.
  • A Python kv find compares equality only. Operator filters (gt, in, …) and an opaque cursor are Invalid in the Python kit rather than ignored, so a body that needs them stays in node until the kit grows the query.
  • Vector search is a scan. examples/vector reads the notes it can find and ranks them in the body: there is no ANN index and no distance order by in the store. Cosine scores stay between -1 and 1, so a caller can pick a threshold; a large corpus needs an index this example does not have.
  • SSR embeds one first screen. A page whose operations all need input cannot fill it and gets W030; later changes still come from the generated form, not from streamed updates.
  • datetime keeps milliseconds on SQL. A datetime column is DATETIME(3), so a timestamp written with six fractional digits reads back trimmed on MySQL while kv keeps the string as sent; sub-millisecond precision is not preserved across drivers.
  • A unique claim on kv outlives the record: the claim key has no TTL, so an expired record holds its value until removed or updated. On sql, uniqueness is the table constraint, so nothing to clean up.
  • Workflows are parsed, described and validated — no runner is generated (W022); a job runs only when it declares an on: queue consumer (W017).
  • Streams and queues are in-process until you bind them to Redis; only then do replicas share events. OpenAPI publishes a bearerAuth scheme for a service that uses auth: identity, and the token requirement is listed only on operations that need it; a public operation opts out with security: [].
  • arcod fmt re-lays out a record type on one line — it is a canonical printer, not a style-preserving one; the comment survives, your line breaks do not.
  • __proto__ is refused as a name, toString is not. A102 stops only the name the generated metadata maps cannot carry; constructor, valueOf and friends stay legal and are safe because every lookup is an own-key read. That rule lives in each emitter, so a new one is held to it by a test, not by check.
  • go and python are port kits, not the whole product. Both emit a service from the same contract IR, but Go refuses a mysql sql store (postgres is carried), stream, olap, mail, graphql, a ui page, roles and a saga (its files: blob client speaks the Node runtime's S3 wire), while Python carries kv, sql, queue, ids, blob and an external service, and refuses stream, olap, mail, graphql, a ui page, roles, a saga, a job and auth; store: sql beside a separate kv alias in one service is refused too, because store: already answers get/set — by name at build time, not with a 501 at runtime. arcod impl still writes Node bodies only, so a Go body (impl/<op>.go) or a Python one (impl/<op>.py) is written by hand.
  • arcod terraform targets Yandex Cloud and renders no state backend yet; an AWS target is in progress. terraform validate runs in CI for the emitted plan.

What that buys you

  • Every claim above has a diagnostic code, a test, or a note in the README.
  • No silent fallbacks: an underivable step fails with unresolved.
  • No cloud calls: the default model endpoint is local and a remote one is refused without --allow-remote.
  • No hidden dependencies: the emitted service and page are single files, including the RESP client and the QR encoder.
try it

Write the model. Run the make.

The demo reproduces without a model: bodies are already in impl/.

terminal
$ git clone git@github.com:chubakur/arcod.git
$ cd arcod && npm link
$ cd examples/quiz && arcod make . --impl
$ arcod run --impl
# http://localhost:8080