Skip to main content

COG-8: Jobs

Status: Draft (Work in Progress)
Version: 0.4
Created: 2025-01-28
Updated: 2026-10-29
Authors: Mike Anderson

This standard specifies Jobs - the execution tracking mechanism for operations on the Covia Grid. A Job represents a running process on the Grid, represented by its current execution state.

Purpose​

Jobs are the runtime counterpart to Operations. While an operation defines what can be executed, a job represents a specific execution of that operation. Jobs provide:

  • Asynchronous Execution: Clients submit work and track progress without blocking
  • Observable Lifecycle: Every job transitions through well-defined states
  • Error Handling: Structured error reporting for failed, rejected, or cancelled work
  • Interactive Workflows: Support for human-in-the-loop patterns where jobs pause for input or authorisation
  • Lattice Data: Job records use native immutable values, replaced atomically as execution advances

Terminology​

See COG-1: Architecture for definitions of Grid terminology including Job, Operation, Venue, and Client.

Key Concepts​

Job as Current State​

A Job is a current-state record under a stable Job ID. Each accepted update atomically replaces that record. The record MUST NOT embed or reference earlier versions of itself. In particular, a venue MUST NOT write a top-level prev field, and job reads MUST NOT expose one.

Every read of a job returns its current state only: polling (GET /api/v1/jobs/{id}), each SSE event, a lattice read of the stored record (in Covia, covia:read of j/<id>), and protocol bridges such as MCP and A2A (COG-9).

The number of updates alone MUST NOT increase record size. Inputs, outputs, message history and operation-specific state are ordinary fields with their own sizes and retention requirements; none of them is an earlier version of the job. Job history and audit are out of scope for this specification.

State Record Structure​

Each current-state record contains its own fields; readers never reconstruct state from earlier versions.

FieldPresenceDescription
idREQUIREDStable Job ID
statusREQUIREDCurrent lifecycle status
opRECOMMENDEDOperation identifier
inputOPTIONALInput provided at job creation
callerRECOMMENDEDVerified submitting identity, used for access control
createdRECOMMENDEDCreation timestamp in milliseconds since Unix epoch
outputCOMPLETE; MAY also be present on interactive statesResult produced by the operation
errorTerminal (FAILED, REJECTED, CANCELLED)Error description
messageOPTIONALContext about current state
updatedRECOMMENDEDLast update timestamp in milliseconds since Unix epoch

For example, after an echo completes:

{
"id": "0x00000000000000000000000000000001",
"status": "COMPLETE",
"op": "v/test/ops/echo",
"input": {"text": "hello"},
"output": {"text": "hello"},
"caller": "did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK",
"created": 1769683717706,
"updated": 1769683717710
}

Records Carrying prev​

A stored job record that carries its predecessor under a top-level prev field MUST be read as its current state, ignoring the top-level prev link, and its current fields MUST be preserved, including nested payload fields named prev.

Relationship to Assets​

Job records, Artifacts and Operations all use immutable lattice values. An asset has a content-derived identity; a Job ID identifies an execution whose current value changes. Hashing a job snapshot identifies that value, but does not prove how the execution reached it.

One-Shot Jobs and Multi-Turn Jobs​

All jobs share the same lifecycle and data model, but differ in their interaction pattern:

One-shot jobs are created with an initial input, execute a single operation, and reach a terminal state. A typical lifecycle is: PENDING → STARTED → COMPLETE (or FAILED). This is the model used by simple tool calls and operation invocations.

Multi-turn jobs cycle through interactive states, accepting additional input between processing steps. The lifecycle may repeat interactive states: PENDING → STARTED → INPUT_REQUIRED → STARTED → INPUT_REQUIRED → ... → COMPLETE. This is the model used by conversational agents, orchestrated workflows, and any process requiring human-in-the-loop interaction.

Both types use the same job lifecycle, the same current-state record structure, and the same observation mechanisms (polling, SSE). The difference is purely behavioural — a one-shot job's transition function produces a terminal state on the first invocation, while a multi-turn job's transition function produces an interactive state and waits for the next message.

Clients that require a synchronous result (e.g. a single tool call) simply wait for the terminal state — regardless of how many intermediate transitions occur. The job's internal interaction loop is opaque to a synchronous caller. See COG-9: Agent Messaging for the asynchronous message delivery mechanism that drives multi-turn interactions.

Agents as Persistent Jobs​

A Job whose transition function never reaches a terminal state is behaviourally an Agent — a persistent process accepting repeated interactions, waiting in INPUT_REQUIRED between turns. The data model is identical; nothing in this COG is agent-specific. The agent model — state, run loop, transition functions, sessions — is specified in COG-11: Agent Lifecycle.

Specification​

Job Lifecycle​

Every job follows a lifecycle defined by its status. Status transitions are unidirectional — a job moves forward through the lifecycle and never returns to a previous state (with the exception of interactive states resuming to STARTED).

Status Values​

StatusCategoryDescription
PENDINGActiveJob created, queued for execution
STARTEDActiveJob is currently executing
COMPLETETerminalJob finished successfully with output
FAILEDTerminalJob finished with an error
CANCELLEDTerminalJob was cancelled by client or venue
REJECTEDTerminalJob was rejected before execution (e.g. policy violation, invalid input)
PAUSEDInteractiveJob execution suspended, awaiting a resume signal
INPUT_REQUIREDInteractiveJob requires additional input from the client to continue
AUTH_REQUIREDInteractiveJob requires authorisation or credentials to continue

Status Categories​

Statuses fall into three categories:

  • Active (PENDING, STARTED): The job is progressing. Clients should poll or subscribe for updates.
  • Terminal (COMPLETE, FAILED, CANCELLED, REJECTED): The job has finished. No further status changes will occur. The job's output or error is available.
  • Interactive (PAUSED, INPUT_REQUIRED, AUTH_REQUIRED): The job is waiting for external action. The client must respond before the job can continue.

State Transitions​

┌─────────────────┐
│ REJECTED │
└─────────────────┘
▲
│ (invalid input,
│ policy violation)
│
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ PENDING │ ────────▶ │ STARTED │ ────────▶ │ COMPLETE │
└──────────┘ └──────────┘ └──────────────┘
│ ▲ │
│ │ │
┌────┘ │ └────┐
│ │ │
▼ │ ▼
┌───────────┐ │ ┌──────────┐
│ PAUSED / │───┘ │ FAILED │
│ INPUT_ │ └──────────┘
│ REQUIRED /│
│ AUTH_ │ ┌──────────┐
│ REQUIRED │ │ CANCELLED │
└───────────┘ └──────────┘
▲
│
(from any non-terminal state)

The permitted transitions are:

FromToTrigger
PENDINGSTARTEDVenue begins execution
PENDINGREJECTEDVenue rejects the job (policy, quota, invalid input)
PENDINGCANCELLEDClient cancels before execution begins
STARTEDCOMPLETEOperation finishes successfully
STARTEDFAILEDOperation encounters an error
STARTEDCANCELLEDClient cancels during execution
STARTEDPAUSEDOperation suspends execution
STARTEDINPUT_REQUIREDOperation needs additional client input
STARTEDAUTH_REQUIREDOperation needs client authorisation
PAUSED / INPUT_REQUIRED / AUTH_REQUIREDSTARTEDClient provides required input or authorisation
PAUSED / INPUT_REQUIRED / AUTH_REQUIREDCANCELLEDClient cancels while paused

Each transition atomically replaces the current job state.

Terminal states are sticky: once a job reaches a terminal state, later transition attempts have no effect. When concurrent resolutions race (e.g. a completion against a cancellation), exactly one wins.

Timeouts​

Jobs have no framework-level timeout, and there is deliberately no timeout status. A job may legitimately remain active or interactive for days, weeks, or months — long workflows, human-in-the-loop requests, persistent agents.

  • Client-side waits are a client concern. A client that stops waiting (poll timeout, disconnect) MUST NOT thereby alter the job's state; it re-attaches later by Job ID and reads the current state.
  • Time bounds are feature-level policy. An operation or feature MAY impose its own expiry (e.g. a Human-in-the-Loop request's expiry, COG-16); when such a bound passes, the job resolves through the ordinary terminal states — typically FAILED with a descriptive error.
  • Operator resource policy (admission control, concurrent-job caps) acts before job creation or through cancellation, never through a special timeout state.

Job Identification​

A job is identified by a unique Job ID within the venue. The Job ID is assigned at creation time and remains stable throughout the job's lifecycle — it identifies the execution, not the hash of any particular snapshot.

Job IDs are represented as hex strings. The format is implementation-defined, but MUST be unique within the venue.

The current record is stored under that stable ID.

Job Data​

The current state of a job is represented as a JSON object when accessed via the API. This object is the complete current state, with no previous versions or inherited fields to resolve.

id (REQUIRED)​

The Job ID — the stable identifier for this job within the venue.

{
"id": "0x12345678901234567890123456789012"
}

status (REQUIRED)​

The current lifecycle status of the job. MUST be one of the status values defined above.

{
"status": "STARTED"
}

The identifier of the operation being executed (Asset ID, operation name, or adapter reference).

{
"op": "0x7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b"
}

The verified identity (DID) of the client that submitted the job. Job access control is based on this field: by default only the caller — or parties holding a delegation from them (COG-13) — can observe the job, and only the caller can mutate it.

{
"caller": "did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK"
}

output (present when COMPLETE)​

The result produced by the operation. The structure of the output is defined by the operation's output schema (see COG-7: Operations).

{
"status": "COMPLETE",
"output": {
"result": "Success",
"data": { "count": 42 }
}
}

error (present when FAILED, REJECTED, or CANCELLED)​

A human-readable error message describing why the job did not complete.

{
"status": "FAILED",
"error": "Connection to upstream service timed out"
}

message (OPTIONAL)​

A general-purpose message providing context about the current state. Particularly useful for interactive states to describe what input or authorisation is needed.

{
"status": "INPUT_REQUIRED",
"message": "Please provide the API key for the target service"
}

input (OPTIONAL)​

The input that was provided when the job was created.

Timestamp in milliseconds since Unix epoch when the job was created.

Timestamp in milliseconds since Unix epoch of the last status change.

Job Creation​

Jobs are created when a client invokes an operation on a venue via POST /api/v1/invoke. See COG-7: Operations for the invocation model.

The invoke request body carries:

FieldRequiredDescription
operationREQUIREDOperation reference — catalog path, Asset ID, or DID URL (COG-7)
inputOPTIONALInput value for the operation
waitOPTIONALWait for completion before responding: true (venue's maximum window) or a bound in milliseconds; also accepted as a query parameter
ucansOPTIONALProof channel — an array of UCAN JWT strings (COG-3 §6 for the channel; COG-13 for proof semantics)

Note the request field is operation; the job record keeps the operation as it was called.

A venue MUST create a job record for every call to /invoke; /run may skip the record for read-only calls. Admission control (rate limits, concurrency caps, resource constraints — COG-1) MAY deny a request before acceptance with a transport-level error, in which case no job is created. Once a job is created, how the operation ends is recorded in the job, not reported as a transport-level error; COG-21: REST API specifies the HTTP routes and statuses.

A venue MUST create the job record with status PENDING (or REJECTED if the job is immediately rejected).

A venue MAY immediately update the status to STARTED if execution begins synchronously.

Job Observation​

Clients can observe job progress through two mechanisms:

Polling​

Clients poll the job status via GET /api/v1/jobs/{id}. This returns the current job record, including current status, output (if complete), or error (if failed).

Clients SHOULD use exponential backoff when polling to avoid overloading the venue. Recommended parameters:

ParameterValue
Initial delay300ms
Backoff factor1.5x
Maximum delay10s

Abandoning a poll or a blocking wait is purely a client-side event: it MUST NOT alter the job's state. A client re-attaches at any time by Job ID and reads the current state (see Timeouts).

Server-Sent Events (SSE)​

Clients can subscribe to real-time updates via GET /api/v1/jobs/{id}/sse. Each job-update event carries the current job record, without earlier versions.

SSE is preferred over polling for long-running jobs because it:

  • Reduces network overhead
  • Provides immediate notification of state changes
  • Avoids the latency inherent in polling intervals

Job Pause​

Clients can pause a running job via PUT /api/v1/jobs/{id}/pause.

Pause genuinely suspends execution — a status change alone is not a pause while work continues underneath. Support is therefore operation-dependent: only operations whose executor can suspend in-flight work are pausable.

A venue MUST atomically update the record to status PAUSED if the job is in STARTED state (matching the STARTED → PAUSED transition) and the executing operation supports suspension.

A venue MUST return 409 Conflict if the job is not in STARTED state, or if the executing operation does not support suspension.

Job Resume​

Clients can resume a paused job via PUT /api/v1/jobs/{id}/resume.

A venue MUST atomically update the record to status STARTED if the job is in PAUSED state and the executing operation supports resumption from its suspended state.

A venue MUST return 409 Conflict if the job is not in PAUSED state, or if the operation does not support resumption.

Resumption continues from the operation's own suspended state. A venue MUST NOT re-execute the operation from its stored input — re-invocation can duplicate non-idempotent side effects and does not carry the original request's authority.

Note: INPUT_REQUIRED and AUTH_REQUIRED jobs are resumed by delivering a message (see COG-9: Agent Messaging), not by calling the resume endpoint. The resume endpoint is specifically for PAUSED jobs.

Job Cancellation​

Clients can cancel a job via PUT /api/v1/jobs/{id}/cancel.

A venue MUST atomically update the record to status CANCELLED if the job is in a non-terminal state.

A cancel request for a job that is already in a terminal state MUST leave the job unchanged; the venue responds 200 OK with the current (terminal) job state.

Cancellation is best-effort — the underlying operation may have already produced side effects before the cancellation takes effect.

Job Deletion​

Clients can remove a job record via PUT /api/v1/jobs/{id}/delete.

Deletion removes the current record from the venue's job index.

Deletion does not affect any resources or outputs produced by the job.

Job Finality​

Once a job reaches a terminal state:

  • Its lifecycle status MUST NOT change
  • Its terminal output or error MUST NOT be replaced by a later lifecycle transition
  • The record MUST remain available until explicitly deleted

Messages, scratch data and backend cancellation diagnostics may still be updated independently, without reopening the job or replaying terminal hooks.

Lattice Storage​

The venue stores each job's current record under its Job ID in the owning user's job index in the Grid Lattice. Each update replaces the stored record atomically; concurrent terminal transitions admit one winner. Replication follows the venue-level merge policy; there are no retained job versions to merge.

Interactive Jobs​

Interactive statuses (PAUSED, INPUT_REQUIRED, AUTH_REQUIRED) enable human-in-the-loop, multi-step workflows, and agent interaction patterns where execution cannot proceed without external action.

Use Cases​

StatusUse Case
PAUSEDDebugging breakpoint; operator-initiated suspension (operation-dependent — see Job Pause)
INPUT_REQUIREDOperation needs additional parameters not provided at invocation; multi-turn conversation flows; agent interaction
AUTH_REQUIREDOperation needs credentials for a downstream service; consent or approval step

Client Responsibilities​

When a job enters an interactive state, the client SHOULD:

  1. Read the message field to understand what is required
  2. Deliver the requested input via POST /api/v1/jobs/{id} (see COG-9: Agent Messaging)
  3. Monitor for resumption to STARTED via polling or SSE

If a client cannot fulfil an interactive request, it SHOULD cancel the job rather than leaving it indefinitely paused.

Abandoned interactive jobs are managed by feature-level expiry (e.g. a Human-in-the-Loop request's expiry, COG-16) or operator policy — there is no framework timeout (see Timeouts).

Agent Interaction Pattern​

For persistent agents (jobs that cycle through interactive states), the client interaction loop is:

1. Invoke operation → Job created (PENDING → STARTED → INPUT_REQUIRED)
2. Client sends message → Job processes the turn (INPUT_REQUIRED → STARTED → INPUT_REQUIRED)
3. Repeat step 2 for each interaction turn
4. Agent terminates → Job reaches terminal state (COMPLETE or FAILED)

Each turn updates the current job state. Conversation history belongs to the receiving operation, such as an agent session; it is not retained by embedding earlier job versions.

Messages are delivered via COG-9: Agent Messaging. Whether a message is processed immediately or queued for a later turn is a property of the receiving operation — agents, for example, queue inbound messages in their session (COG-11) — so clients MAY send a message at any time, including while the job is actively processing (STARTED). Message delivery to a job in a terminal state MUST be rejected.

Synchronous vs. Asynchronous Observation​

The same job supports both synchronous and asynchronous interaction:

  • Synchronous callers (e.g. an MCP tools/call bridge) wait for the terminal state. The entire multi-turn interaction — including any intermediate message exchanges — is opaque to them. They submit the initial input and receive the final result.
  • Asynchronous callers (e.g. a conversational UI, an A2A agent) observe each state transition in real time via SSE, and submit messages via POST /api/v1/jobs/{id} as the interaction progresses.

Both patterns operate on the same job, the same current-state record, and the same message delivery surface. The choice is the client's, not the job's.

Examples​

Simple Invocation​

Client Venue
│ │
│ POST /api/v1/invoke │
│ {"operation": │
│ "v/test/ops/echo", │
│ "input": {"text": "hello"}} │
│ ─────────────────────────────────▶ │
│ │ Create job: PENDING
│ 201 Created │ Status → STARTED
│ {"id": "0xabc...", │
│ "status": "PENDING"} │
│ ◀───────────────────────────────── │
│ │ Execute; status → COMPLETE
│ GET /api/v1/jobs/0xabc... │
│ ─────────────────────────────────▶ │
│ │
│ 200 OK │
│ {"id": "0xabc...", │
│ "status": "COMPLETE", │
│ "output": {"text": "hello"}} │
│ ◀───────────────────────────────── │

Cancellation​

Client Venue
│ │
│ POST /api/v1/invoke │
│ {"operation": "long-running"} │
│ ─────────────────────────────────▶ │
│ │
│ 201 Created │ Create job: PENDING
│ {"id": "0xdef...", │ Status → STARTED
│ "status": "PENDING"} │
│ ◀───────────────────────────────── │
│ │
│ PUT /api/v1/jobs/0xdef.../cancel │
│ ─────────────────────────────────▶ │
│ │ Status → CANCELLED
│ 200 OK │
│ {"id": "0xdef...", │
│ "status": "CANCELLED", │
│ "error": "Job cancelled"} │
│ ◀───────────────────────────────── │

Interactive Job (Input Required)​

Client Venue
│ │
│ POST /api/v1/invoke │
│ {"operation": "data-import"} │
│ ─────────────────────────────────▶ │
│ │ Create job: PENDING
│ 201 Created │ Status → STARTED
│ {"id": "0x123...", │
│ "status": "PENDING"} │
│ ◀───────────────────────────────── │
│ │ Status → INPUT_REQUIRED
│ GET /api/v1/jobs/0x123... │
│ ─────────────────────────────────▶ │
│ │
│ 200 OK │
│ {"id": "0x123...", │
│ "status": "INPUT_REQUIRED", │
│ "message": "Provide API key"} │
│ ◀───────────────────────────────── │
│ │
│ (Client provides input) │
│ ─────────────────────────────────▶ │ Status → STARTED
│ │ Status → COMPLETE
│ GET /api/v1/jobs/0x123... │
│ ─────────────────────────────────▶ │
│ │
│ 200 OK │
│ {"id": "0x123...", │
│ "status": "COMPLETE", │
│ "output": {"imported": 1500}} │
│ ◀───────────────────────────────── │

Agent Interaction (Multi-Turn)​

Client Venue
│ │
│ POST /api/v1/invoke │
│ {"operation": "llm-agent", │
│ "input": {"prompt": "Hello"}} │
│ ─────────────────────────────────▶ │
│ │ Create job: PENDING
│ 201 Created │ Status → STARTED (LLM call)
│ {"id": "0x456...", │ Status → INPUT_REQUIRED
│ "status": "PENDING"} │ (response + awaiting next turn)
│ ◀───────────────────────────────── │
│ │
│ GET /api/v1/jobs/0x456... │
│ ─────────────────────────────────▶ │
│ │
│ 200 OK │
│ {"id": "0x456...", │
│ "status": "INPUT_REQUIRED", │
│ "output": {"response": "Hi!"}, │
│ "message": "Awaiting input"} │
│ ◀───────────────────────────────── │
│ │
│ (Client sends next message) │
│ ─────────────────────────────────▶ │ Status → STARTED (LLM call)
│ │ Status → INPUT_REQUIRED
│ GET /api/v1/jobs/0x456... │ (response + awaiting next turn)
│ ─────────────────────────────────▶ │
│ │
│ 200 OK │
│ {"id": "0x456...", │
│ "status": "INPUT_REQUIRED", │
│ "output": {"response": "..."}, │
│ "message": "Awaiting input"} │
│ ◀───────────────────────────────── │
│ │
│ ... (conversation continues) │

Security Considerations​

Resource Exhaustion​

Jobs consume venue resources (memory, connections, compute). Venues SHOULD:

  • Impose limits on the number of concurrent jobs per client (admission control, before job creation)
  • Clean up resources promptly when jobs reach terminal states
  • Bound long-running work through feature-level expiry or operator-initiated cancellation — never a framework timeout (see Timeouts)

Long-lived agent jobs (persistent interactive processes) require particular attention to resource management. Venues SHOULD apply explicit retention policies to conversation data. Job records do not accumulate earlier versions, so update frequency alone does not grow them.

Job Data Sensitivity​

Job records may contain sensitive information in their inputs and outputs. Venues SHOULD:

  • Apply access control so that only the submitting client (or authorised parties) can query a job
  • Redact or encrypt sensitive fields in stored job records
  • Support job deletion to allow clients to remove current records containing sensitive data

Cancellation Safety​

Cancellation does not guarantee rollback. Operations may have produced side effects (network calls, data writes) before cancellation takes effect. Clients SHOULD NOT rely on cancellation as a mechanism for undoing work.

Execution Evidence​

A job record is the venue's report of the job's current state, not cryptographic proof of how the job reached it.