Receiving External Events
There Is No Webhook Receiver To Build
Remediation Orchestrator has no webhook receiver. The script-launch API is already an authenticated HTTP endpoint that starts a workflow from a JSON body. An external system points at it, and a Starlark script turns the incoming event into a specialized action.
The HTTP API, workflow runtime, argument parsing, idempotency, and circuit breaker stay generic; the script is the only place that knows what the source is, what its payload means, and what to do about it.
A node health monitor is the running example.
The Pattern At A Glance
The external system makes one authenticated POST. Remediation Orchestrator starts or reuses a
workflow and returns 202 immediately; everything after the response runs
asynchronously on Temporal.
The Request Contract
The endpoint is the generic script entrypoint, the same route the Run Workflow dialog uses.
A success returns 202 Accepted:
202 means the workflow started, not that the work finished. Treat the body as a
handle for status and correlation, not a result.
Errors worth handling on the caller side:
Write The Receiving Script
A receiving script defines one entrypoint function and registers it. Two rules carry the contract:
- The docstring declares each argument and type in Google style
(
name: type, description). Remediation Orchestrator uses it to coerce the JSON body and reject mismatched types. - The function returns a dict describing what it did. That dict is recorded with
the workflow and shown to operators inspecting the run. Declare the return type
in the docstring as
dict: descriptionso workflow queries can validate the result.
A minimal receiver:
That accepts POST /api/v1/script/<script_name>/handle_event. register_workflow
takes optional callbacks the next sections use:
Worked Example: A Node Health Monitor
The monitor detects node health signals (link-down, NVLink bandwidth loss, symbol errors) and, while a node stays unhealthy, posts a fresh alert every minute. The script drains the node so the existing breakfix flow picks it up.
The monitor calls:
with this body:
The entrypoint validates the required fields, builds a drain reason, looks up the node, and drains it. Only the required fields drive behavior; the rest is metadata for humans.
The drain reason carries the [MONITOR] source tag plus the originating event_id.
State the source plainly in whatever the action leaves behind (a drain reason here, a cordon note or ticket body elsewhere). Name the source it came from; do not borrow another subsystem’s vocabulary, since a health-check-looking reason that never came from a health check would mislead whoever reads it next. Let the downstream flow decide what the tag means.
Idempotency For Real-Time Sources
A real-time source does not retry deliveries; it keeps sending new events while a
condition persists. The monitor posts a new event_id every minute for the same node.
Without idempotency, each post starts another workflow.
Remediation Orchestrator deduplicates by workflow ID: while a workflow with a given ID is running, a
new start for that ID reuses it instead of starting a second, and does not count
against the circuit breaker. The workflow_id callback chooses the key. Scope it to
the entity being worked on, not the event:
Two consequences:
- Repeated posts for the same entity return the same
workflow_idand do no extra work while it is handled (the monitor’s minute-by-minute posts for one node collapse onto a single workflow). - Once the entity is resolved and the workflow ends, a later post is a genuine new occurrence and starts a fresh workflow (a node that returns to service and later fires again gets a new run).
The event_id stays in the drain reason for traceability, but it is not the key.
Putting a per-occurrence identifier (such as the monitor’s per-minute event_id) in the
workflow ID defeats dedupe and causes a workflow storm.
A Working POST Is Not Enough
A 202 only means the workflow started. The integration is safe only when the
downstream workflow’s terminal behavior is valid for the signal. A 202 says nothing
about whether the entity was repaired, quarantined, or sent back to service
unchanged.
The Boomerang
A transient signal often will not reproduce when the downstream flow re-checks the entity at pickup, because that check only sees the entity’s state at validation time, not the state when the signal fired. The drain is real and the flow picks up the entity, but the check finds nothing wrong, so the entity passes, returns to service unfixed, and the source fires again.
Node health monitors show this directly. Most of their signals are transient (a port flaps, bandwidth drops for a window), and breakfix validates with point-in-time health checks, so the condition is usually gone by the time the node is re-checked.
The plumbing works; the outcome is wrong. A signal the downstream flow does not handle specially gets default treatment, which can run standard validation and return the entity to service.
What To Decide Before Enabling
Decide the terminal state for the source’s signals before enabling in production:
- Auto-repair, but only for signals backed by a reproducing check or a concrete remediation action?
- Hold or quarantine the entity for a human owner instead of letting standard validation pass it?
- Teach the downstream flow the source tag so it applies a signal-specific policy instead of the default path?
Decide the terminal behavior before you enable. The receiving script’s job is only to deliver a truthful event. Until the terminal behavior is settled, keep the integration disabled, and do not call it automatic repair.
Surface Asynchronous Failures
Because the response returns at 202 and the workflow runs afterward, a post-start
failure is invisible to the caller. Without a hook, the only trace is in Temporal
history, which no external operator watches.
Register an on_failure handler that notifies wherever the integration’s owners
actually watch (Slack here, a pager or ticket queue elsewhere). It receives the
original arguments plus the error history, so it can report which event failed and
why:
The handler needs its own docstring. Remediation Orchestrator drops positional
arguments the docstring does not declare. Every keyword argument the original
workflow receives must also be declared in the handler’s docstring and signature;
an undeclared keyword argument makes the handler fail before it runs, so no
failure alert is sent. error and errors are passed only when declared as
string and list[string].
The handler succeeds even though the workflow failed: that is what converts a silent Temporal failure into a message the right people see.
Authentication And Provisioning
The caller sends an access token from the deployment’s identity provider on every request. The header depends on the deployment’s authentication setup, described in Appendix B of the deployment checklist:
The deployment owner tells the caller which identity provider issues its tokens and authorizes the caller to access the Remediation Orchestrator API for the target environment. This is a deployment configuration change, separate from the script. Tokens are short-lived, so mint a fresh one and cache it until it expires rather than requesting one per event.
For quick manual testing, you can also copy a ready-to-use token from the
Profile page in the Remediation Orchestrator UI (user menu, then Profile),
if a token is shown, instead of minting one. The page also shows when the token
expires and a sample curl command. The token is tied to your own session, so
use it for one-off curl checks, not for a standing integration.
Where To Go Next
- Using the Remediation Orchestrator Agent: add bounded agentic decisions inside a receiving script.
- Architecture: how the API, workflow IDs, dedupe, and the circuit breaker fit together.
- Reference: look up module functions such as
register_workflowand the Slurm and Slack builtins used above.