35 Process-backed scenarios🔗ℹ

mcp/scenario-process, mcp/scenario and mcp export call-with-scenario-process. Its first argument is a nonempty command list (executable followed by path/string arguments); its second is a procedure receiving an opaque process-scenario value. No shell is inserted. The child fixture owns its interface, adapters, principal, clock and storage configuration. Those Racket values are not serialized from the parent. An explicit SQLite path in the command lets a restarted fixture resume the same application state.

The equivalent language form is:

(scenario (restart child)

  #:command (list (find-executable-path "racket") application "--state" state-file)

  #:capabilities (hasheq 'elicitation (hasheq))

  ...)

Configuration expressions run in the test submodule, once in declaration order. The optional clauses, in order, are #:transport, #:capabilities, #:timeout, #:shutdown-timeout, #:stderr-limit, #:directory, and #:environment. The function accepts the same keywords. Defaults are stdio, empty capabilities, a five-second request/startup timeout, two seconds per cleanup phase, a 65,536-byte stderr tail, the current directory and a copied environment. The executable, arguments, directory and environment are retained across restarts.

scenario-process-request returns the SDK’s event-compatible request handle; scenario-process-call waits and raises exception outcomes. Both accept method, optional params, #:capabilities and #:timeout. Subscription deadlines default to #f; other requests use the configured timeout. A buffered native reply is drained before classifying process loss. If the client cannot supply a terminal outcome after process exit, exn:fail:scenario-process-loss carries the observed PID and exit status. Cancellation uses the native request handle.

scenario-process-kill! hard-kills and reaps the child. Repeating it is harmless. scenario-process-restart! kills a running generation and starts a fresh child; it does not replay requests. Old handles retain their terminal outcomes. scenario-process-running?, scenario-process-pid, and scenario-process-status expose observed process state. scenario-process-stderr returns the bounded raw-byte tail for the current or most recently stopped generation. Capture it before restarting if it must be kept. Scope exit first closes stdin, then uses a bounded wait and forced termination if necessary. Pending handles settle before client workers are destroyed. Requests share one drain deadline; stderr has its own bounded drain phase.

For #:transport ’http, the child must print a loopback HTTP URL with an explicit port as its first stdout line (under 8,192 bytes), then serve that endpoint. The harness bounds startup, drains subsequent stdout, and captures stderr separately. The transport does not automatically send discovery or replay an uncertain call. The command runs as a normal child process, with the supplied directory/environment.

examples/process-restart-scenario.rkt demonstrates an actual hard restart at an MRTR input boundary. The process controls complement in-process session controls; they do not automatically serialize deterministic adapters or inject process-local clock changes. Authored child fixtures supply those facilities explicitly.