ConversationRunCoordinator
@forge/monorepo / backend/src / ConversationRunCoordinator
Interface: ConversationRunCoordinator
Defined in: backend/src/persistence/index.ts:126
Per-conversation run serialization (docs/13 → Run ordering). At most one Running run per
conversation; further runs queue FIFO by enqueue time so session-state and message order are
deterministic. Backed by DistributedLockStore semantics in production; in-memory for tests.
Methods
active()
active(
input):Promise<RunId|null>
Defined in: backend/src/persistence/index.ts:143
Parameters
input
TenantScope & object
Returns
Promise<RunId | null>
claimOrEnqueue()
claimOrEnqueue(
input):Promise<{position:number;status:"queued"|"started"; }>
Defined in: backend/src/persistence/index.ts:132
Atomically claim the conversation for runId, or enqueue it FIFO if one is already active. This
MUST be atomic (no claim→enqueue gap) so a run can never slip past into an idle-but-unclaimed
slot and strand itself. The primary entry point for starting a run.
Parameters
input
TenantScope & object
Returns
Promise<{ position: number; status: "queued" | "started"; }>
depth()
depth(
input):Promise<number>
Defined in: backend/src/persistence/index.ts:144
Parameters
input
TenantScope & object
Returns
Promise<number>
releaseAndPromote()
releaseAndPromote(
input):Promise<RunId|null>
Defined in: backend/src/persistence/index.ts:140
Atomically release runId (if it holds the slot) and promote the next queued run. MUST be atomic
(no release→dequeue→claim gap) so two runs can never both become active. Returns the promoted run
to dispatch, or null when the backlog is empty. The primary entry point on run terminal.
Parameters
input
TenantScope & object
Returns
Promise<RunId | null>