Skip to content

Mental model

Typra starts from a root TypeSpec model, resolves the contract graph, lowers it to an internal contract AST, then emits configured targets.

When root-namespace is set, Typra can include additional models from that namespace, so review metadata before accepting a generated baseline.

Think of Typra as a compiler extension with a review trail:

  1. TypeSpec declares the contract.
  2. Typra lowers the selected model graph.
  3. Targets emit runtime surfaces and tests.
  4. Metadata records what changed.
  5. typra-verify decides whether the generated drift is safe to accept.

Typra owns reusable generation behavior. Product-specific TypeSpec contracts, service behavior, and hand-authored adapters stay in the consuming product.

  • Type graph discovery and lowering.
  • Scalar coercion and factory expansion.
  • Polymorphic dispatch.
  • Provider-specific wire names.
  • Generated-file markers and manifest metadata.
  • Generated tests, protocol scaffolds, reference docs, and JSON AST output.

Each generation can include target source, target tests, JSON AST metadata, generated-file manifests, and verifier reports. See Generated output for the file-level shape.

Generated files include Typra markers, and the emitter records generated ownership metadata. typra-verify compares a committed baseline with current generated output and reports drift. It does not replace product tests or review.

Generated output is not a substitute for product tests. Typra gives teams repeatable surfaces, target tests, and metadata evidence; consuming products still own integration tests, adapter behavior, release review, and runtime observability.