Temporal.io Primer
Temporal is a durable execution platform for long-running, fault-tolerant workflows. This primer walks through the core mental model used inside Meridian for orchestrating multi-step agent pipelines that must survive crashes, restarts, and partial failures without losing state.
1.Workflows vs Activities
A Workflow is deterministic code whose execution history is persisted on every state transition. An Activity is the non-deterministic side-effect: HTTP calls, DB writes, LLM completions. Workflows orchestrate; activities do. If a worker crashes mid-workflow, Temporal replays history on a fresh worker and resumes exactly where it left off.
2.Signals, Queries, and Timers
Workflows accept Signals (async input from outside), respond to Queries (sync reads of internal state), and use Timers for durable sleeps that survive process death. A 30-day timer is just as cheap as a 30-second one. This makes Temporal ideal for human-in-the-loop approval flows and SLA tracking.
3.Minimal Worker Skeleton
The example below registers a workflow and one activity against a task queue. Run multiple workers on the same queue for horizontal scale.
import { Worker } from '@temporalio/worker';
import * as activities from './activities';
async function run() {
const worker = await Worker.create({
workflowsPath: require.resolve('./workflows'),
activities,
taskQueue: 'meridian-agents',
});
await worker.run();
}
run().catch((err) => {
console.error(err);
process.exit(1);
});