Skip to content

Simulation

Sandbox mode with predefined scenarios

Extension URN: urn:forrst:ext:simulation


The simulation extension enables sandbox/demo mode where functions return predefined responses without executing real logic or causing side effects. Unlike dry-run (which validates real requests against real state), simulation operates entirely on predefined input/output scenarios defined by the function author.


Simulation SHOULD be used for:

  • Interactive API documentation and explorers
  • Client SDK testing without backend dependencies
  • Demo environments with predictable behavior
  • Integration testing with deterministic responses
  • Onboarding flows showing example behavior

Simulation SHOULD NOT be used for:

  • Validating real user input (use dry-run instead)
  • Testing actual business logic
  • Production environments

FieldTypeRequiredDescription
enabledbooleanYesEnable simulation mode
scenariostringNoScenario name to execute (uses default if omitted)
list_scenariosbooleanNoList available scenarios instead of executing

FieldTypeDescription
simulatedbooleanWhether response was simulated
scenariostringName of the executed scenario
available_scenariosarrayList of scenarios (when list_scenarios=true)
errorstringError type when simulation fails
requested_scenariostringRequested scenario name (when not found)

When the simulation extension is enabled:

  1. Server MUST check if function implements SimulatableInterface
  2. Server MUST NOT execute real function logic
  3. Server MUST NOT modify any state
  4. Server MUST NOT trigger side effects
  5. Server MUST return the predefined scenario output
  6. Server SHOULD match requested scenario by name

When list_scenarios is true:

  1. Server MUST return available scenarios without executing
  2. Server SHOULD include scenario descriptions and error indicators

Functions expose scenarios with:

FieldTypeRequiredDescription
namestringYesUnique scenario identifier
inputobjectYesArguments that trigger this scenario
outputanyNoSuccessful result value
descriptionstringNoHuman-readable explanation
errorobjectNoError response (code, message, data)
metadataobjectNoAdditional response metadata

{
"protocol": { "name": "forrst", "version": "0.1.0" },
"id": "req_list",
"call": {
"function": "users.get",
"version": "1.0.0",
"arguments": {}
},
"extensions": [
{
"urn": "urn:forrst:ext:simulation",
"options": {
"enabled": true,
"list_scenarios": true
}
}
]
}
{
"protocol": { "name": "forrst", "version": "0.1.0" },
"id": "req_list",
"result": null,
"extensions": [
{
"urn": "urn:forrst:ext:simulation",
"data": {
"simulated": false,
"available_scenarios": [
{
"name": "default",
"description": "Returns a typical user object",
"is_error": false,
"is_default": true
},
{
"name": "not_found",
"description": "User ID does not exist",
"is_error": true,
"is_default": false
},
{
"name": "suspended",
"description": "User account is suspended",
"is_error": false,
"is_default": false
}
]
}
}
]
}
{
"protocol": { "name": "forrst", "version": "0.1.0" },
"id": "req_sim",
"call": {
"function": "users.get",
"version": "1.0.0",
"arguments": { "id": "user_123" }
},
"extensions": [
{
"urn": "urn:forrst:ext:simulation",
"options": {
"enabled": true
}
}
]
}
{
"protocol": { "name": "forrst", "version": "0.1.0" },
"id": "req_sim",
"result": {
"id": "user_123",
"name": "Jane Doe",
"email": "jane@example.com",
"status": "active"
},
"extensions": [
{
"urn": "urn:forrst:ext:simulation",
"data": {
"simulated": true,
"scenario": "default"
}
}
]
}
{
"protocol": { "name": "forrst", "version": "0.1.0" },
"id": "req_error",
"call": {
"function": "users.get",
"version": "1.0.0",
"arguments": { "id": "user_999" }
},
"extensions": [
{
"urn": "urn:forrst:ext:simulation",
"options": {
"enabled": true,
"scenario": "not_found"
}
}
]
}
{
"protocol": { "name": "forrst", "version": "0.1.0" },
"id": "req_error",
"errors": [
{
"code": "NOT_FOUND",
"message": "User not found",
}
],
"extensions": [
{
"urn": "urn:forrst:ext:simulation",
"data": {
"simulated": true,
"scenario": "not_found"
}
}
]
}
{
"protocol": { "name": "forrst", "version": "0.1.0" },
"id": "req_unsupported",
"errors": [
{
"code": "SIMULATION_NOT_SUPPORTED",
"message": "Function 'legacy.process' does not support simulation",
}
],
"extensions": [
{
"urn": "urn:forrst:ext:simulation",
"data": {
"simulated": false,
"error": "unsupported"
}
}
]
}
{
"protocol": { "name": "forrst", "version": "0.1.0" },
"id": "req_missing",
"errors": [
{
"code": "SIMULATION_SCENARIO_NOT_FOUND",
"message": "Simulation scenario 'invalid_scenario' not found",
}
],
"extensions": [
{
"urn": "urn:forrst:ext:simulation",
"data": {
"simulated": false,
"error": "scenario_not_found",
"requested_scenario": "invalid_scenario"
}
}
]
}

AspectSimulationDry-Run
PurposeDemo/sandbox modeValidate before executing
InputIgnored (uses predefined)Validated against real state
OutputPredefined by functionComputed from real data
Backend requiredNoYes
DeterministicAlwaysUsually
Use caseTesting, demos, docsConfirmation flows

  • Functions MUST implement SimulatableInterface to support simulation
  • Scenarios SHOULD cover success, error, and edge cases
  • Scenario names MUST be unique within a function
  • The default scenario SHOULD represent the most common success case
  • Input arguments in simulation mode are ignored; output is predetermined