Docs/Concepts
Source guide3 min read

What the runtime checks

Follow a call from transport context to handler execution, then understand the limits of each guard.

Download Markdown ↓
Source and verification context ⌄

Source-guided

Examinar el código ↗

Repository links may require access. Source inspection is separate from a clean public-package installation.

AN INTERACTIVE READING MAP

Get the shape of this guide.

Move through the ideas, inspect their relationships, or make a focused reading path. The complete guide stays below.

SECUENCIA DE LECTURAEntender cómo se conectan las ideas
Choose a point to look closer
01 / Sección de la guía

Follow the execution boundary

A registered call resolves an operation and its bound handler, prepares the input and execution context, invokes the handler, and validates the returned value. The exact checks depend on the contract and the ports supplied by the host.

Leer el contexto de apoyo

At the inspected snapshot, preparation parses input first. Policy decisions run when ctx.decide is provided. Explicit approval and ceremony requirements are checked before control reaches the handler.

Explore a section, then continue with the complete article below.

1 / 4

Follow the execution boundary

A registered call resolves an operation and its bound handler, prepares the input and execution context, invokes the handler, and validates the returned value. The exact checks depend on the contract and the ports supplied by the host.

At the inspected snapshot, preparation parses input first. Policy decisions run when ctx.decide is provided. Explicit approval and ceremony requirements are checked before control reaches the handler.

LímiteWhat is checkedDEPENDENCIA
Adapter authenticationA non-anonymous operation has an authenticated subjectTrusted host context
Input validationThe request matches the declared schemaOperation input model
Policy decisionThe configured decision allows the operationHost decision port
Scoped approvalRequired evidence and approval runtime are present and authorize the requestDeclared approval plus host verifier
Output validationThe returned value matches the declared outputHandler result and output model

Supply trusted context

Do not construct trusted identity from an arbitrary role, tenant or user field in the request body. The host should resolve the caller using its own authentication mechanism and then provide the corresponding context.

The runtime's conditional policy hook is significant: writing requirements in a contract does not install a policy engine into the host. Test your actual context factory and decision port, not only the declaration.

Know where protection stops

The runtime can prevent a handler from starting when an applicable precondition fails. Once a handler starts, its database calls and provider effects still need application-level transaction and retry behavior.

Output validation happens after the handler returns. Rejecting an invalid result does not automatically undo a database change or external request the handler already made. For consequential effects, design persistence and recovery explicitly.

Find the point where the handler can begin.Trace the mechanism · 3 ways to look closer

Take an operation that explicitly requires approval. Change one condition and inspect the expected path from the captured runtime guide.

Which request are you inspecting?
UNA SITUACIÓN CONCRETA

Input preparation stops the path early.

The request omits an input required by the operation schema.

01 / INPUT

Parse and validate the request against the declared schema.

Qué cambia

The request cannot become a valid prepared input.

Qué sigue siendo explícito

No visible button or descriptive tag makes the missing value valid.

SEGUIR LA CONSECUENCIA

A denial test for approval should use otherwise valid input, so it actually reaches the approval boundary.

Where this explanation comes from

An authored situation, grounded in the linked source guides. Choosing a case explores its expected responsibilities; it does not execute an operation.

Distinguish execution from evidence

The invocation path provides a guarded event publisher for declared events and validates emitted payloads. The host still supplies the publisher. A direct network call made elsewhere is not made safe merely by declaring an event.

Likewise, operational telemetry is useful evidence about execution, but it is not a substitute for an authorization decision or a durable audit record. Keep those responsibilities visible in the architecture and in tests.

See it in an example.

Execution / Intermediate

Stop a write before it runs

Control side effects

Trace a REST request through an approval gate and inspect the zero-handler-call denial assertion.

  1. Declare the boundary
  2. Inspect the denied request
  3. Inspect the approved request

Qué demuestra la fuenteThe inspected denial test asserts that the handler is not invoked when a required receipt is missing.

No demuestraA fresh successful execution in this review.

Inspect the walkthroughBehavior · proof and limits · source checks

Follow the source behavior

A synthetic rest.approval.protected command has write and external-side-effect declarations. The fixture sends a request first without approval evidence, then with a receipt bound to the operation and input.

  1. Declare the boundary

    The fixture defines a command with execution.effects set to write and external-side-effect, and execution.approval.required set to true.

  2. Inspect the denied request

    The first test binds a handler with a call counter. Without a receipt, it expects HTTP 403, APPROVAL_REQUIRED with reason missing_receipt, and calls equal to zero.

  3. Inspect the approved request

    The second test provides a receipt through createFetchHandler's approvalReceipt option and an approval port with a controlled clock. The response is expected to be 200 with value ran.

  4. Apply the pattern to your side effect

    Replace the synthetic handler with your operation and trusted receipt source. Add tests for the exact subject, operation, input, expiry, and effect requirements your application uses.

What this example establishes
Qué demuestra la fuente
  • The inspected denial test asserts that the handler is not invoked when a required receipt is missing.
  • The approved case adapts receipt evidence outside the operation input.
  • The fixture has an inspectable positive and negative request path.
No demuestra
  • A fresh successful execution in this review.
  • An end-to-end human approval UI or trusted production receipt issuer.
  • A real external write: the approved handler only returns a fixture value.
Reproduce the source checks

The source assertions require a 403 denial before invocation and a 200 response for the controlled valid-receipt case.

Directorio de trabajo packages/platform/delivery/contracts-runtime-server-rest

bun test src/rest-approval-enforcement.test.ts

Test source inspected; not executed here.

Continue from here.

Concepts

Authentication, policy and scoped approval

3 min read

Give each decision a clear owner and prove that denied requests never reach the protected handler.

Look inside the guideOpening context · complete reading path

Separate the decisions

Authentication establishes who is calling. Policy decides whether that subject may perform a particular operation in context. Scoped approval supplies evidence that a specific request or class of effects has been reviewed. A ceremony requirement can require additional, fresh verification at execution time.

Work through the guide
Operations

Test the promise at the boundary

3 min read

Choose checks that establish meaningful behavior, including denied effects and real consumer imports.

Look inside the guideOpening context · complete reading path

Give each test one question

An operation has several boundaries, and one green check cannot answer every question about them. Separate declaration validity, business behavior, adapter behavior and external consumption so failures tell you where to look.

Work through the guide
Operations

Observe a call without confusing it with approval

3 min read

Use traces and outcomes to diagnose execution, and keep durable evidence requirements explicit.

Look inside the guideOpening context · complete reading path

Carry context through the call

A useful operation trace lets you connect a request, its selected contract version, the handler outcome and the interface that invoked it. The registry's canonical result can carry trace and source context supplied by the host.

Work through the guide
Next: Authentication, policy and scoped approval →
Tu vista

Make room for your context.

Shape the presentation around this moment. You can change it whenever you need.

Tu contexto

The different parts of you

Choose a starting point

Una mezcla útil de contexto, imágenes y orientación discreta.

Tune each dimension
Each dimension can change independently. Product permissions and available actions stay unchanged.

Support the way you begin and return

Tune your support

Comodidad de lectura

Elige tu idioma

El idioma de la interfaz solo cambia el texto. Los mercados, precios y flujos de trabajo conservan sus propios ajustes.

Cobertura de traducción

Parte del contenido se muestra en inglés.

Navegación151
Grafo616
Categorías188
Portafolio332
Ejemplos2035
Vista previa de la fuente41

Se añadirán más traducciones a medida que se revise el contenido.

Esta preferencia se guarda en este navegador.

Buscar en el sitio web

Puntos de partida útiles

Sin resultados. Prueba una frase más corta, un nombre de operación u otro ámbito de búsqueda.

UN POCO DE ESPACIO PARA EXPLORAR

Encuentra algo que explorar.

Abre una vista detallada en esta página, prueba otra perspectiva o sigue el detalle a su propia página.

Cómo funcionan las vistas previas y los controles
01

Mirar antes de salir

Pasa el cursor por un enlace o enfócalo con Tab para ver una vista previa. Hacer clic en el enlace original o pulsar Intro siempre abre su destino.

02

Mantener el contexto

Entra en la vista previa para explorar sus secciones. Usa Alt + ↓ desde un enlace enfocado para entrar con el teclado. Escape la cierra.

03

Abrir las posibilidades

Las filas desplegables, las perspectivas y los controles destacados revelan más. Tu vista cambia la comodidad de lectura y el contexto que exploras.

Un botón separado para mirar más de cerca

Muestra pequeños botones de vista previa junto a los enlaces donde haya espacio. Toca el ojo para inspeccionar o el enlace para ir directamente. Esta elección permanece en esta pestaña.

No se recoge historial de navegación. El movimiento reducido sigue tu dispositivo y Tu vista.