Skip to main content

Module automation

Module automation 

Source
Expand description

Automations (#220): scheduled and webhook-triggered spawns.

Two layers. The rules — cron evaluation, webhook signatures, task-template interpolation — are pure functions over borrowed data, with now supplied by the caller, so every one of them is testable without waiting for wall-clock time to pass. AutomationEngine is the thin stateful shell that reads the store, decides what is due, and spawns.

Structs§

Automation
A configured automation.
AutomationEngine
The automation runtime: stored triggers, the tick that fires them, and the run history they leave behind (#220).
AutomationRun
One recorded firing of an automation, successful or not.
CreateAutomationBody
Body for POST /api/automations.
CreatedAutomationResponse
Response to POST /api/automations.
FiredResponse
Response to a fire request (run now, or an accepted webhook).
SetEnabledBody
Body for PUT /api/automations/{id}/enabled.
SpawnTemplate
The spawn an automation performs each time it fires.
StoredAutomation
An automation as persisted, including the secret the wire type omits.

Enums§

RunSource
What caused a run.
Trigger
What starts an automation.

Constants§

MAX_SUBSTITUTION
Longest substituted value, in bytes. A webhook payload is caller-controlled, and an unbounded field would let one request push a multi-megabyte prompt into an agent. Longer values are truncated with an explicit marker rather than silently cut, so the agent can see that it is reading a fragment.
RUN_HISTORY_LIMIT
Runs retained per automation. Run history is a debugging aid, not an audit log (the event store holds those), so it is bounded rather than growing without limit in the config DB.

Functions§

due_fire
The scheduled tick this automation owes, or None if it owes nothing yet.
interpolate
Substitute {{ dotted.path }} placeholders in a task template from payload.
normalize_schedule
Adapt an operator-written cron expression to the 6-field form the cron crate parses.
parse_schedule
Parse an operator-written schedule, normalizing the 5-field form first.
stamp
Render a timestamp the one way the store compares them.
verify_webhook_signature
Verify a webhook’s sha256=<hex> HMAC signature over the raw request body.