escenari_disparador
Envia un esdeveniment de desencadenament (programador/external) i avalua l’execució.
Notes clau
- El temps d’activació és subministrat pel qui crida; no es fan lectures del rellotge de paret.
- Registra l’esdeveniment de desencadenament i la decisió resultant.
- La càrrega útil es manté en els registres de l’estat d’execució/runpack; no envieu secrets en brut.
- Utilitzeu per a desencadenants basats en el temps o sistemes externs.
Inputs
- scenario_id (required): Identificador de l’escenari.
- trigger (requerit): Payload de l’esdeveniment de desencadenament.
Input Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"scenario_id": {
"description": "Scenario identifier.",
"type": "string"
},
"trigger": {
"additionalProperties": false,
"description": "Trigger event payload.",
"properties": {
"correlation_id": {
"oneOf": [
{
"type": "null"
},
{
"description": "Correlation identifier.",
"type": "string"
}
]
},
"kind": {
"enum": [
"agent_request_next",
"tick",
"external_event",
"backend_event"
],
"type": "string"
},
"namespace_id": {
"description": "Namespace identifier.",
"minimum": 1,
"type": "integer"
},
"payload": {
"oneOf": [
{
"type": "null"
},
{
"oneOf": [
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "json"
},
"value": {
"description": "Inline JSON payload.",
"type": [
"null",
"boolean",
"number",
"string",
"array",
"object"
]
}
},
"required": [
"kind",
"value"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"bytes": {
"items": {
"maximum": 255,
"minimum": 0,
"type": "integer"
},
"type": "array"
},
"kind": {
"const": "bytes"
}
},
"required": [
"kind",
"bytes"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"content_ref": {
"additionalProperties": false,
"properties": {
"content_hash": {
"additionalProperties": false,
"properties": {
"algorithm": {
"enum": [
"sha256"
],
"type": "string"
},
"value": {
"description": "Lowercase hex digest.",
"type": "string"
}
},
"required": [
"algorithm",
"value"
],
"type": "object"
},
"encryption": {
"oneOf": [
{
"type": "null"
},
{
"description": "Encryption metadata.",
"type": "string"
}
]
},
"uri": {
"description": "Content URI.",
"type": "string"
}
},
"required": [
"uri",
"content_hash",
"encryption"
],
"type": "object"
},
"kind": {
"const": "external"
}
},
"required": [
"kind",
"content_ref"
],
"type": "object"
}
]
}
]
},
"run_id": {
"description": "Run identifier.",
"type": "string"
},
"source_id": {
"description": "Trigger source identifier.",
"type": "string"
},
"tenant_id": {
"description": "Tenant identifier.",
"minimum": 1,
"type": "integer"
},
"time": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "unix_millis"
},
"value": {
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "logical"
},
"value": {
"minimum": 0,
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
}
]
},
"trigger_id": {
"description": "Trigger identifier.",
"type": "string"
}
},
"required": [
"trigger_id",
"tenant_id",
"namespace_id",
"run_id",
"kind",
"time",
"source_id"
],
"type": "object"
}
},
"required": [
"scenario_id",
"trigger"
],
"type": "object"
}
Sortides
- decisió (requerit): Tipus: objecte.
- paquets (requerit): Tipus: array.
- status (requerit): Tipus: string.
Esquema de sortida
{
"additionalProperties": false,
"properties": {
"decision": {
"additionalProperties": false,
"properties": {
"correlation_id": {
"oneOf": [
{
"type": "null"
},
{
"description": "Correlation identifier.",
"type": "string"
}
]
},
"decided_at": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "unix_millis"
},
"value": {
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "logical"
},
"value": {
"minimum": 0,
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
}
]
},
"decision_id": {
"description": "Decision identifier.",
"type": "string"
},
"outcome": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "start"
},
"stage_id": {
"description": "Initial stage identifier.",
"type": "string"
}
},
"required": [
"kind",
"stage_id"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "complete"
},
"stage_id": {
"description": "Terminal stage identifier.",
"type": "string"
}
},
"required": [
"kind",
"stage_id"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"from_stage": {
"description": "Previous stage identifier.",
"type": "string"
},
"kind": {
"const": "advance"
},
"timeout": {
"type": "boolean"
},
"to_stage": {
"description": "Next stage identifier.",
"type": "string"
}
},
"required": [
"kind",
"from_stage",
"to_stage",
"timeout"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "hold"
},
"summary": {
"additionalProperties": false,
"properties": {
"policy_tags": {
"description": "Policy tags applied to the summary.",
"items": {
"type": "string"
},
"type": "array"
},
"retry_hint": {
"oneOf": [
{
"type": "null"
},
{
"description": "Optional retry hint.",
"type": "string"
}
]
},
"status": {
"description": "Summary status.",
"type": "string"
},
"unmet_gates": {
"items": {
"description": "Gate identifier.",
"type": "string"
},
"type": "array"
}
},
"required": [
"status",
"unmet_gates",
"retry_hint",
"policy_tags"
],
"type": "object"
}
},
"required": [
"kind",
"summary"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "fail"
},
"reason": {
"description": "Failure reason.",
"type": "string"
}
},
"required": [
"kind",
"reason"
],
"type": "object"
}
]
},
"seq": {
"minimum": 0,
"type": "integer"
},
"stage_id": {
"description": "Stage identifier.",
"type": "string"
},
"trigger_id": {
"description": "Trigger identifier.",
"type": "string"
}
},
"required": [
"decision_id",
"seq",
"trigger_id",
"stage_id",
"decided_at",
"outcome",
"correlation_id"
],
"type": "object"
},
"packets": {
"items": {
"additionalProperties": false,
"properties": {
"decision_id": {
"description": "Decision identifier.",
"type": "string"
},
"envelope": {
"additionalProperties": false,
"properties": {
"content_hash": {
"additionalProperties": false,
"properties": {
"algorithm": {
"enum": [
"sha256"
],
"type": "string"
},
"value": {
"description": "Lowercase hex digest.",
"type": "string"
}
},
"required": [
"algorithm",
"value"
],
"type": "object"
},
"content_type": {
"description": "Packet content type.",
"type": "string"
},
"correlation_id": {
"oneOf": [
{
"type": "null"
},
{
"description": "Correlation identifier.",
"type": "string"
}
]
},
"expiry": {
"oneOf": [
{
"type": "null"
},
{
"oneOf": [
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "unix_millis"
},
"value": {
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "logical"
},
"value": {
"minimum": 0,
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
}
]
}
]
},
"issued_at": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "unix_millis"
},
"value": {
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "logical"
},
"value": {
"minimum": 0,
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
}
]
},
"packet_id": {
"description": "Packet identifier.",
"type": "string"
},
"run_id": {
"description": "Run identifier.",
"type": "string"
},
"scenario_id": {
"description": "Scenario identifier.",
"type": "string"
},
"schema_id": {
"description": "Schema identifier.",
"type": "string"
},
"stage_id": {
"description": "Stage identifier.",
"type": "string"
},
"visibility": {
"additionalProperties": false,
"properties": {
"labels": {
"description": "Visibility labels.",
"items": {
"type": "string"
},
"type": "array"
},
"policy_tags": {
"description": "Policy tags.",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"labels",
"policy_tags"
],
"type": "object"
}
},
"required": [
"scenario_id",
"run_id",
"stage_id",
"packet_id",
"schema_id",
"content_type",
"content_hash",
"visibility",
"expiry",
"correlation_id",
"issued_at"
],
"type": "object"
},
"payload": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "json"
},
"value": {
"description": "Inline JSON payload.",
"type": [
"null",
"boolean",
"number",
"string",
"array",
"object"
]
}
},
"required": [
"kind",
"value"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"bytes": {
"items": {
"maximum": 255,
"minimum": 0,
"type": "integer"
},
"type": "array"
},
"kind": {
"const": "bytes"
}
},
"required": [
"kind",
"bytes"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"content_ref": {
"additionalProperties": false,
"properties": {
"content_hash": {
"additionalProperties": false,
"properties": {
"algorithm": {
"enum": [
"sha256"
],
"type": "string"
},
"value": {
"description": "Lowercase hex digest.",
"type": "string"
}
},
"required": [
"algorithm",
"value"
],
"type": "object"
},
"encryption": {
"oneOf": [
{
"type": "null"
},
{
"description": "Encryption metadata.",
"type": "string"
}
]
},
"uri": {
"description": "Content URI.",
"type": "string"
}
},
"required": [
"uri",
"content_hash",
"encryption"
],
"type": "object"
},
"kind": {
"const": "external"
}
},
"required": [
"kind",
"content_ref"
],
"type": "object"
}
]
},
"receipts": {
"items": {
"additionalProperties": false,
"properties": {
"dispatch_id": {
"description": "Dispatch identifier.",
"type": "string"
},
"dispatched_at": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "unix_millis"
},
"value": {
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "logical"
},
"value": {
"minimum": 0,
"type": "integer"
}
},
"required": [
"kind",
"value"
],
"type": "object"
}
]
},
"dispatcher": {
"description": "Dispatcher identifier.",
"type": "string"
},
"receipt_hash": {
"additionalProperties": false,
"properties": {
"algorithm": {
"enum": [
"sha256"
],
"type": "string"
},
"value": {
"description": "Lowercase hex digest.",
"type": "string"
}
},
"required": [
"algorithm",
"value"
],
"type": "object"
},
"target": {
"oneOf": [
{
"additionalProperties": false,
"properties": {
"agent_id": {
"description": "Agent identifier.",
"type": "string"
},
"kind": {
"const": "agent"
}
},
"required": [
"kind",
"agent_id"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "session"
},
"session_id": {
"description": "Session identifier.",
"type": "string"
}
},
"required": [
"kind",
"session_id"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"kind": {
"const": "external"
},
"system": {
"description": "External system name.",
"type": "string"
},
"target": {
"description": "External system target.",
"type": "string"
}
},
"required": [
"kind",
"system",
"target"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"channel": {
"description": "Broadcast channel identifier.",
"type": "string"
},
"kind": {
"const": "channel"
}
},
"required": [
"kind",
"channel"
],
"type": "object"
}
]
}
},
"required": [
"dispatch_id",
"target",
"receipt_hash",
"dispatched_at",
"dispatcher"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"envelope",
"payload",
"receipts",
"decision_id"
],
"type": "object"
},
"type": "array"
},
"status": {
"enum": [
"active",
"completed",
"failed"
],
"type": "string"
}
},
"required": [
"decision",
"packets",
"status"
],
"type": "object"
}
Exemples
Avança una execució des d’un programador o un desencadenant extern.
Input:
{
"scenario_id": "example-scenario",
"trigger": {
"correlation_id": null,
"kind": "tick",
"namespace_id": 1,
"payload": null,
"run_id": "run-0001",
"source_id": "scheduler-01",
"tenant_id": 1,
"time": {
"kind": "unix_millis",
"value": 1710000000000
},
"trigger_id": "trigger-0001"
}
}
Output:
{
"decision": {
"correlation_id": null,
"decided_at": {
"kind": "unix_millis",
"value": 1710000000000
},
"decision_id": "decision-0001",
"outcome": {
"kind": "complete",
"stage_id": "main"
},
"seq": 0,
"stage_id": "main",
"trigger_id": "trigger-0001"
},
"packets": [],
"status": "completed"
}