Docs/Concepts
Source guide3 min read

Authentication, policy and scoped approval

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

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

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.

Read the supporting context

These mechanisms answer different questions. An authenticated user is not automatically permitted to perform every action, and a visible review button is not an approval receipt.

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

1 / 4

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.

These mechanisms answer different questions. An authenticated user is not automatically permitted to perform every action, and a visible review button is not an approval receipt.

QuestionMechanismHost responsibility
Who is calling?Authentication contextResolve identity through a trusted source
May this caller do this?Policy decisionSupply and test the decision implementation
Has this request been approved?Scoped approvalVerify the receipt against operation, subject, input and effects
Is fresh verification required?CeremonyClaim and complete the required host-bound ceremony

Declare the approval boundary explicitly

For an operation with execution.approval, the shared preparation path checks for approval evidence before handler entry. Missing evidence yields APPROVAL_REQUIRED with reason missing_receipt. If evidence exists but the host has no approval port, the reason is approval_runtime_unavailable.

Tags, presentation labels and MCP tool annotations describe an operation; they do not opt it into this enforcement. Configure the actual requirement and the trusted verifier.

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.

Bind evidence to the request

The approval port receives the operation key and version, subject context, parsed input, required effects and requested cost. Use those values to decide whether the supplied evidence authorizes this invocation, rather than treating the presence of a token as permission.

Connect has its own request, scope, digest, expiry and durable signature checks. Use the appropriate host integration for the boundary you are implementing; do not assume two differently typed receipt systems are interchangeable.

Prove denial before success

Use a disposable handler with an invocation counter. Send valid input as an authenticated fixture subject without approval through REST and MCP. Assert the actual denial from each adapter and a counter that remains zero.

Then exercise the verifier you intend to ship: wrong subject, wrong scope or expiry should remain denied where those conditions apply. Only add an allowed path when its receipt is actually verified. A stub that always returns allow is useful for UI development, but it does not demonstrate authorization.

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.

Agents / Intermediate

Draft freely. Send with approval.

Control side effects

Follow one contract boundary through a workflow and an in-memory MCP transport.

  1. Separate the two operations
  2. Inspect the workflow
  3. Inspect the MCP boundary

Source demonstratesThe source smoke fixture drives a real MCP server/client over linked in-memory transports.

Does not demonstrateDelivery of a Slack message, email, invitation, or other network request.

Inspect the walkthroughBehavior · proof and limits · source checks

Follow the source behavior

A reference agent drafts a message, waits for approval, and invokes sendMessage. The MCP smoke test uses a real MCP server and client over an in-memory transport. The actual handlers remain deterministic fixture logic.

  1. Separate the two operations

    The source defines draftAndSend.draftMessage and draftAndSend.sendMessage. Drafting is automation-safe; sending declares its approval requirement.

  2. Inspect the workflow

    The example connects draft, approval wait, send, and receipt stages through the WorkflowDevkit adapter. This is a composed reference flow, not an invitation feature in the minimal starter.

  3. Inspect the MCP boundary

    The smoke test registers the operation registry as MCP tools, then calls sendMessage with valid, absent, and tampered receipt evidence. It expects success only for the valid case.

  4. Read what send actually does

    The bound handler derives a message ID and returns status sent in memory. To send through a real provider, supply your own port and preserve the same execution boundary.

What this example establishes
Source demonstrates
  • The source smoke fixture drives a real MCP server/client over linked in-memory transports.
  • The fixture asserts APPROVAL_REQUIRED for missing and tampered receipts.
  • The same registry gate is used by the MCP adapter rather than a second hand-written approval path.
Does not demonstrate
  • Delivery of a Slack message, email, invitation, or other network request.
  • A fresh successful run or production human approval system.
  • That the minimal example includes MCP; this is a separate source package.
Reproduce the source checks

The source fixtures inspect workflow sequencing and successful versus denied MCP calls with deterministic handlers.

Working directory examples/draft-and-send-agent

bun test src/mcp-smoke.test.ts src/draft-and-send.workflow.test.ts

Test and handler source inspected; not executed here.

Continue from here.

Guides

Expose one operation through API and MCP

3 min read

Share the registered behavior while keeping authentication, transport formats and evidence explicit.

Look inside the guideOpening context · complete reading path

Start from one registry

Register the operation and bind its handler once. The REST createFetchHandler and MCP registerMcpTools implementations both call OperationSpecRegistry.executeResult. That shared invocation path is the useful connection between an API request and an agent tool call.

Work through the guide
Concepts

What the runtime checks

3 min read

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

Look inside the guideOpening context · complete reading path

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.

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
Next: Model inputs, outcomes and failures →
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.