Durable workflowswithout a hostedorchestrator.
Long-running agents need more than memory. The harness can persist workflow checkpoints, session state, leases, context snapshots, and workspace files inside your application boundary, then resume safely after restart.
One local bundle for state, runtime, and files
Use localDurableExecution({ root }) when you want production-shaped durability without adding Redis, Postgres, Docker, or a hosted workflow engine on day one.
import { defineHarness, localDurableExecution } from '@purista/harness'
const local = localDurableExecution({
root: './.harness',
exec: false,
policy: {
retention: { cleanupMode: 'manual_only' },
},
})
const harness = defineHarness({ name: 'research' })
.state(local.state)
.runtime(local.runtime)
.sandbox(local.sandbox)
.workspaceStore(local.workspaceStore)
.checkpoints(local.checkpoints)
.workflows(({ workflow }) => ({
report: workflow({
input,
output,
durable: { enabled: true },
handler: async ctx => {
const facts = await collectFacts(ctx)
await ctx.checkpoints.write('facts', facts)
return writeReport(facts)
},
}),
}))
.build()
process.on('SIGTERM', () => local.close())Sessions, messages, runs, run events, workflow checkpoints, leases, and context checkpoints are persisted through the built-in Node or Bun SQLite module.
Each durable run gets an active directory under the configured root. Checkpoints copy that active tree so resumed work sees the committed files.
The sandbox maps the run workspace to the virtual root. File operations stay jailed to the run directory; command execution is opt-in.
Runtime, workspace, state, and context checkpoint operations emit spans and metrics so retry and resume behavior is visible.
Durability is a set of replaceable ports
The local bundle is only the default. Each part can be replaced independently when a deployment needs Postgres, S3, encrypted volumes, containers, remote sandboxes, or stricter retention.
.state(...)Session metadata, message history, run records, and run events.
.runtime(...)Workflow step checkpoints, durable leases, cancellation state, and resume position.
.workspaceStore(...)Run workspace lifecycle, checkpoint snapshots, retention, abort, and cleanup.
.sandbox(...)The filesystem or execution boundary used by agents, tools, MCP, and mounted skills.
.checkpoints(...)Named JSON snapshots written by workflow code through ctx.checkpoints.
Checkpoint only deterministic boundaries
A durable workflow resumes from the last committed harness checkpoint. Keep external writes behind idempotent tools or PURISTA commands, then checkpoint after the result is safely recorded.
Acquire first
The harness acquires the durable lease and workspace before it creates the run record, preventing duplicate active workers from mutating the same durable run.
Write explicit context
Use ctx.checkpoints for application-level snapshots such as extracted facts, cursor positions, and reviewed decisions.
Keep streams observational
Stream events help users and operators watch progress. They are not used as recovery cursors. Recovery is driven by durable checkpoints.
Prefer local files, swap later
A host directory is enough for the full API. Container and remote adapters can be plugged in later without changing workflow code.
Local persistence still needs policy
Command execution is disabled. Content capture remains disabled unless explicitly enabled. Workspaces are confined to the configured root.
Put the root on durable storage, set retention by workload, restrict filesystem permissions, and export OTel to your normal platform.
Keep the same harness API and replace the sandbox/workspace adapters with Docker, Firecracker, Kubernetes, or a remote worker implementation.
Durability should be boring infrastructure.
Start with the local bundle, then replace adapters only where your deployment requirements justify it.