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

Inspect the source ↗

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.

READING SEQUENCEUnderstand how the ideas connect
Choose a point to look closer
01 / Guide section

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.

Read the supporting context

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.

BoundaryWhat is checkedDEPENDENCY
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?
A CONCRETE SITUATION

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.

What changes

The request cannot become a valid prepared input.

What stays explicit

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

FOLLOW THE CONSEQUENCE

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

Source demonstratesThe inspected denial test asserts that the handler is not invoked when a required receipt is missing.

Does not demonstrateA 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
Source demonstrates
  • 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.
Does not demonstrate
  • 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.

Working directory 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 →
Your view

Make room for your context.

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

Your context

The different parts of you

Choose a starting point

A useful mix of context, visuals and gentle guidance.

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

Reading comfort

Choose your language

Interface language changes text only. Markets, prices and workflows keep their own settings.

Translation coverage

Original source

Navigation151
Graph616
Categories378
Portfolio833
Examples2,035
Source preview1,542

More translations will be added as content is reviewed.

This preference is saved on this browser.

Search the website

Useful starting points

No results. Try a shorter phrase, an operation name or another search area.

A LITTLE ROOM TO EXPLORE

Find something to explore.

Open a closer look on this page, try a different perspective, or follow the detail into its own page.

How previews and controls work
01

Look before you leave

Hover a link or focus it with Tab to see a preview. Clicking the original link or pressing Enter always opens its destination.

02

Stay with the context

Move into the preview to explore its sections. Use Alt + ↓ from a focused link to enter it with the keyboard. Escape closes it.

03

Open the possibilities

Disclosure rows, perspective choices and highlighted controls reveal more. Your view changes reading comfort and the context you explore.

A separate button for a closer look

Show small preview buttons beside links where there is room. Tap the eye to inspect, or tap the link to go straight there. This choice stays in this tab.

No browsing history is collected. Reduced motion follows your device and Your view.