```mermaid
sequenceDiagram
  %% Project State Layer — Coordination & Concurrency (v0.1)
  participant Agent as Agent
  participant MCP as MCP Server
  participant State as State Artifact/Store

  Note over Agent,MCP: Goal: prevent duplicate work + avoid overwrites

  Agent->>MCP: work.list(project_id, status=todo/in_progress)
  MCP->>State: read snapshot / replay events
  State-->>MCP: work items
  MCP-->>Agent: work items

  Agent->>MCP: work.claim(work_item_id, expected_version, lease_seconds)
  MCP->>State: verify version + set claim (lease)
  State-->>MCP: updated work item (version++)
  MCP-->>Agent: claim granted (lease_until)

  Agent->>MCP: work.update(work_item_id, expected_version, patch)
  alt claimant + version matches
    MCP->>State: apply patch, increment version
    State-->>MCP: updated work item
    MCP-->>Agent: ok
  else version mismatch
    MCP-->>Agent: CONFLICT + latest snapshot
  else not claimant / lease expired
    MCP-->>Agent: FORBIDDEN or LEASE_EXPIRED
  end

  Note over Agent,MCP: Append-only logs are merge-safe and idempotent

  Agent->>MCP: attempt.append(attempt_id, ...)
  MCP->>State: append attempt if ID new
  State-->>MCP: stored attempt
  MCP-->>Agent: ok (idempotent by ID)

  Agent->>MCP: timeline.append(event_id, ...)
  MCP->>State: append timeline event (idempotent)
  MCP-->>Agent: ok
```