Execution · Intermediate · runnable fixture source
Stop a write before it runs
Trace a REST request through an approval gate and inspect the zero-handler-call denial assertion.
@lssm-tech/lib.contracts-runtime-server-rest · Test source inspected · evidence as of 2026-10-27
Source context
Test source inspected · b67c376f
Pinned source links require repository access; publication and anonymous package availability were not checked for this example.
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.
What you will learn
- Declare effect and approval requirements on an operation.
- Pass receipt evidence through the transport adapter rather than changing operation input.
- Check that a denial happens before the handler runs.
AN INTERACTIVE READING MAP
Walk through this example.
Step through the maintained source review, inspect its evidence boundaries, or assemble an adaptation packet.
SOURCE WALKTHROUGH
Read the operation in its authored order
01 / IN FOCUS
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.
1 / 4
0 points in your packet
Walk through the source
- 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.
- 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.
- 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.
- 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 review establishes
- 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.
Not established
- 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.
Before adapting
- Access to the inspected source repository and a checkout at the cited revision.
- The repository's Bun workspace dependencies and required generated package exports. These instructions were inspected; the examples were not executed in this review.
Adapt the pattern
- Use a trusted application boundary to resolve approval evidence.
- Keep authorization and approval validation at execution time.
- Preserve a negative test that measures whether the handler ran.
- declaredStability
- experimental fixture metadata
- registry
- Library test; not an example catalog entry
- inlinePreview
- None
- execution
- Not rerun
- production
- Not assessed