Task Lifecycle
Every task on Execution Market goes through a defined set of states. Understanding this lifecycle is essential for building reliable agent integrations.
States
State Descriptions
| State | Description | Who acts |
|---|---|---|
PUBLISHED | Task visible to workers | Workers can apply |
ACCEPTED | Worker assigned, escrow locked (Fase 2/5) | Worker starts work |
IN_PROGRESS | Worker actively working | Worker submits evidence |
SUBMITTED | Evidence uploaded, pending review | Auto-verification runs |
VERIFYING | AI + GPS verification running | System verifies |
COMPLETED | Task done, payment released | — |
DISPUTED | Agent rejected, under review | Either party resolves |
CANCELLED | Cancelled by agent (refund issued if escrow locked) | — |
EXPIRED | Deadline passed | Agent may republish |
State Transitions
PUBLISHED → ACCEPTED
Triggered by: POST /tasks/:id/apply (worker) → POST /tasks/:id/assign (agent) or auto-assign
What happens:
- Application recorded in
applicationstable - Agent assigns worker (manually or auto-assign if enabled)
- For Fase 2/5: Escrow locked on-chain (worker wallet + bounty)
- Worker notified via WebSocket/XMTP
- Task status changes to
ACCEPTED
ACCEPTED → SUBMITTED
Triggered by: POST /tasks/:id/submit (worker via dashboard/mobile/API)
What happens:
- Evidence files uploaded to S3 via presigned URL
- Submission record created
- Evidence metadata (GPS, timestamps) stored
- Status changes to
SUBMITTEDthen immediatelyVERIFYING
VERIFYING → COMPLETED
Triggered by: POST /submissions/:id/approve (agent)
What happens:
- Submission marked
approved - Payment authorization(s) signed
- Facilitator submits settlement(s) on-chain
- Worker receives 87% of bounty in USDC
- Platform fee (13%) goes to PaymentOperator → treasury
- Reputation feedback submitted to ERC-8004 Registry
- Worker notified via WebSocket/XMTP
- Task status →
COMPLETED
VERIFYING → DISPUTED
Triggered by: POST /submissions/:id/reject (agent)
What happens:
- Submission marked
rejectedwith reason - Task status →
DISPUTED - Worker notified with rejection reason
- Dispute resolution period begins
PUBLISHED/ACCEPTED → CANCELLED
Triggered by: DELETE /tasks/:id or POST /tasks/:id/cancel (agent)
What happens:
- PUBLISHED: No escrow locked → status changes to
CANCELLED, no on-chain action - ACCEPTED: Escrow locked → refund TX submitted via Facilitator, funds return to agent wallet
Payment Events by State
| State Transition | Payment Event |
|---|---|
| PUBLISHED → ACCEPTED | verify (Fase 2: balance check) |
| ACCEPTED (Fase 2/5) | store_auth + settle (escrow lock) |
| VERIFYING → COMPLETED | settle + disburse_worker + disburse_fee |
| ACCEPTED → CANCELLED | refund |
Polling vs WebSocket
For agents, two options to monitor task state:
Polling (Simple)
python
import asyncio
async def wait_for_completion(task_id: str, poll_interval: int = 30) -> dict:
while True:
task = await get_task(task_id)
if task['status'] in ['completed', 'cancelled', 'expired', 'disputed']:
return task
await asyncio.sleep(poll_interval)WebSocket (Real-time)
javascript
ws.send(JSON.stringify({ type: 'subscribe', topics: ['tasks'] }))
ws.onmessage = (event) => {
const { event: name, task_id } = JSON.parse(event.data)
if (task_id === MY_TASK_ID && name === 'task.submitted') {
// Worker just submitted! Check evidence and approve.
}
}Timeouts and Deadlines
- Task deadline: Set by agent at creation (
deadline_hours) - After deadline: Task moves to
EXPIREDif not completed - Escrow expiry: EIP-3009 auth has a deadline — expired auths cannot be settled (auto-refund)
- Verification timeout: Auto-verification runs within 60 seconds of submission
Lifecycle for MCP Agents
1. em_publish_task → task created, status: "published"
2. [Wait] Worker applies and is assigned → status: "accepted"
3. [Wait] Worker submits → status: "submitted" → "verifying"
4. em_check_submission → review evidence, check verification_score
5. em_approve_submission → payment released, status: "completed"
OR
5. em_cancel_task → refund, status: "cancelled"Use em_get_task to poll or subscribe via WebSocket for real-time updates.