# Docket concepts

Docket keeps a typed process, the case moving through it, and the audit trail
of that movement. A host agent decides what work to do; Docket records and
checks the decision boundary.

## Current limitations

> **Durability notice:** When Docket runs with the Postgres case store
> (`DOCKET_CASE_STORE=postgres`), cases, facts, stage state, journals and
> explicit step events, recorded outcomes, idempotency replay records and
> queued jobs are stored in Postgres, so they survive deploys and restarts.
> Published process definitions are reinstalled from code at boot, and the
> per-process mirror-deduplication markers are not durable; losing the markers
> can cause a telemetry mirror retry, not case loss. With the in-memory fallback
> store (`DOCKET_CASE_STORE=memory`), cases and records are process-local and
> are lost on every deploy or restart, and idempotent replay holds only within
> one server process lifetime. Keep your own durable record of Docket case ids
> and pending intents outside Docket, and do not treat Docket alone as the
> system of record.

## Process

A process is a versioned set of stages, named edges, typed outputs and optional
human gates or timers. A published process is read-only from the tenant's point
of view.

## Case

A case is one running instance of a process. It is pinned to the process
version that was current when the case started. Every read and write is scoped
to the authenticated tenant represented by the bearer token.

## Decision

A decision stage asks Docket to interpret that stage's own policy. The response
names an allowed edge and the typed outputs for that edge. The host carries out
the work associated with that edge; Docket does not execute business actions.

## Human gate

A gate pauses the case for a named human verdict. While a gate is open, the
agent must not treat the proposed action as approved. Docket reports that the
case still needs approval instead of advancing it.

A reply flow may use `awaiting-send-approval` after `draft-reply`. The gate is
bound to the draft text: the owner approves the exact `hash` returned by
`allowed_next_step`, and Docket records who approved, when, and which draft hash.
Approving a different draft hash is refused. A case cannot be closed at
`draft-reply` or `awaiting-send-approval`; either the approved reply is reported
sent, or a human records a reply-withdrawn decline with a reason.

## Host effect

Sending a message, issuing a refund, paying someone, or mutating another
external system is a host effect. Docket never sends, refunds or pays. After an
approved host effect really happens, the host records that fact through the
outcome tool so the case journal reflects reality. For the send gate, this is
`record_outcome` with `kind: effect`, `edge: sent`, the approve token and
`executed: true`; only then does the case reach `end`.

## Audit trail

Every state change is journaled. A state-changing call may carry an
`idempotency_key`: reusing it with the same request returns the stored result
and marks the response as replayed, while a different request under the same
key is refused as a conflict. Read-only tools ignore `idempotency_key` and
always return live state. See the notice at the top of this page for what is
stored in Postgres and what is process-local.

Absolute service root: https://docket.cstmr.bot
