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.

Recommended default

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.

Local durable executiontypescript
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())
SQLite state

Sessions, messages, runs, run events, workflow checkpoints, leases, and context checkpoints are persisted through the built-in Node or Bun SQLite module.

Host workspace

Each durable run gets an active directory under the configured root. Checkpoints copy that active tree so resumed work sees the committed files.

Local sandbox

The sandbox maps the run workspace to the virtual root. File operations stay jailed to the run directory; command execution is opt-in.

OTel traces

Runtime, workspace, state, and context checkpoint operations emit spans and metrics so retry and resume behavior is visible.

1
Adapter boundaries

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.

StateStore.state(...)

Session metadata, message history, run records, and run events.

DurableRuntime.runtime(...)

Workflow step checkpoints, durable leases, cancellation state, and resume position.

DurableWorkspaceStore.workspaceStore(...)

Run workspace lifecycle, checkpoint snapshots, retention, abort, and cleanup.

SandboxFactory.sandbox(...)

The filesystem or execution boundary used by agents, tools, MCP, and mounted skills.

ContextCheckpointStore.checkpoints(...)

Named JSON snapshots written by workflow code through ctx.checkpoints.

2
Execution model

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.

3
Security posture

Local persistence still needs policy

Default stance

Command execution is disabled. Content capture remains disabled unless explicitly enabled. Workspaces are confined to the configured root.

Production stance

Put the root on durable storage, set retention by workload, restrict filesystem permissions, and export OTel to your normal platform.

Stronger isolation

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.