Add a pipeline
Goal
Create a public.pipelines row: an ordered stages array the runner executes when something (a trigger, a timer, or a manual run) invokes it.
Steps
- Choose the
trigger_type.manual(run by button/API),event(fired by a trigger),scheduled(fired by a timer), orwebhook. This is metadata for callers — what actually runs a pipeline is whatever invokesrunPipeline, so the type should match how you plan to wire it (Automation). Draft the
stagesarray. Each stage needs astage_typematching an active slug inpublic.actionsplus aconfig. Built-in stage types (seeded by.framework/migrations/053_builtin_action_seeds.sql):update_item,create_record,http_request,send_notification,send_email,run_pipeline,search_knowledge,query_items,agent_inference,generate_embeddings,revoke_embeddings,kb_ingest,kb_revoke,create_interaction(.framework/functions/_shared/pipeline-runner.ts).[ { "stage_type": "query_items", "config": { "entity": "items", "type_slug": "ticket", "filters": { "status": "open" } } }, { "stage_type": "http_request", "config": { "url": "https://example.com/hook", "method": "POST", "body": { "title": "{{record.data.title}}" } } } ]- Stage config merges
action.config(defaults on the actions row) understage.config, plus injected_pipelineId/_executionId/_stageIndex/_triggerData(.framework/functions/_shared/pipeline-runner.ts). {{trigger.*}}resolves into the trigger-data envelope;{{record.*}}resolves intotriggerData.entity.data— the record that fired the run (.framework/functions/_shared/pipeline-runner.ts).continue_on_error: trueon a stage lets the run continue after a failure; otherwise a failed stage aborts the whole run (.framework/functions/_shared/pipeline-runner.ts).
- Stage config merges
- Create the pipeline. Admin UI → Configs → Pipelines → New (
configs/pipelines/new), orPOST /api/pipelineswith{ name, trigger_type, stages }— all three required (.framework/functions/pipelines.ts). Setis_active: true;runPipelinerefuses inactive pipelines. - Wire the entry point. A pipeline with
trigger_type: "event"needs a trigger (Add a trigger);scheduledneeds a timer (Add a timer);manualruns on demand. Changingtrigger_typelater does not rewire existing triggers or timers — relink them separately.
Verify
- Run it directly:
npx spine-framework pipelines run <id> --data '{"x":1}'— see CLI reference. - Check Observability → Executions (
observability/executions) orpipelines executions <id>for acompletedrow with per-stage results. - A missing
stage_typefails fast withAction not found for stage type: <type>— the runner looks the slug up inpublic.actionswithis_active = truebefore executing (.framework/functions/_shared/pipeline-runner.ts).
Common mistakes
- Nonexistent stage_type. Seed validation and the runner both reject unknown slugs; stick to the built-ins or seed your own
actionsrow (see Package and install an app). - Expecting stage outputs to chain into the next stage. Each stage gets the merged
action.config+stage.config+_triggerData; previous stage outputs are collected into the execution result, not injected into later configs. Templates only see{{trigger.*}}and{{record.*}}. scheduledwith no timer, oreventwith no trigger. The pipeline is then unreachable —get_due_timersonly returns timers withpipeline_idset, and triggers dispatch bypipeline_id.- Editing
stageswhile runs are queued. The runner reads the pipeline row at execution time; a queued execution picks up whateverstagesexist when it starts, not when it was queued.