Skip to content

Spec to runtime

Carbon’s core value is turning a description of an API into a runtime that behaves like the real service. That happens in three stages, all deterministic and all reversible.

The @carbon/parser package normalizes every supported input format into one shared shape:

Input formatNotes
OpenAPI 3.xJSON or YAML, $ref resolved
AsyncAPI 2.x / 3.xChannels and messages become endpoints + resources
GraphQL SDLQuery/Mutation fields become endpoints; types become resources
protobuf / gRPCRPCs become endpoints; messages become resources
HARCaptured request/response pairs become endpoint templates
Postman collectionItems become endpoints; folders become tags
Recorded trafficcarbon record output; same shape as HAR

The IR is a small, well-typed structure — api, endpoints[], resources[], relationships[]. You can inspect it directly:

Terminal window
carbon ingest ./petstore.openapi.json

@carbon/graph walks the IR and builds a behavior graph: a state machine that describes how each endpoint reads and mutates resources. Where the raw spec is silent, the AI inference pipeline can enrich it — resources are grouped, path parameters are tied to resource ids, and cross-resource relationships (owner, membership) are proposed. A quality judge then scores the enrichment so bad inferences can be caught in CI.

@carbon/runtime boots a Fastify server that serves the behavior graph. Requests hit the graph, resources are read/written through @carbon/state, and everything is deterministic — same request sequence, same responses, byte for byte.

Runtime endpoints exposed under /__carbon/*:

  • GET /__carbon/health — is the runtime up?
  • GET /__carbon/inspect — endpoints, resources, relationships summary
  • POST /__carbon/state/snapshot — dump current state as JSON
  • POST /__carbon/state/restore — restore a snapshot

Because API descriptions disagree about almost everything except that endpoints exist and take shapes. The IR lets one runtime, one behavior graph, one state engine, one snapshot format, and one CI story cover every input. Add a parser, get a runtime.