{
  "spec": "agent-settlement/1.0",
  "domain": "agentsettlement.org",
  "layer": "L4.5",
  "description": "Schema for agent settlement declarations. Settlement is the act of finality: the moment an agent transaction is confirmed complete, its record sealed, its dispute window declared, and its liability assigned. This schema closes the accountability chain that authority declares and provenance records.",
  "note": "Authority before action. Proof after action. Settlement after proof. The chain: authority (agent-authority.org) declares what an agent may do. Provenance (agent-provenance.org) records what it did. Settlement declares that the record is final, the obligations discharged, and the dispute window open or closed.",
  "chain_position": {
    "upstream": "agent-provenance.org — action_record is the input to settlement",
    "closes": "The accountability chain. A settled action record is a finality claim.",
    "open_dependency": "Cryptographic signing mechanism — see agent-provenance.org/.well-known/signing.json. Settlement finality is an assertion until signing is defined; it becomes a verifiable proof once it is."
  },
  "schema": {
    "settlement_record": {
      "description": "Declaration that an agent action is settled — finalized, obligations discharged, dispute window declared.",
      "required": [
        "settlement_id",
        "action_record_ref",
        "settled_at",
        "settled_by",
        "finality_status",
        "dispute_window_closes"
      ],
      "optional": [
        "clearing_ref",
        "counterparty_acknowledgment",
        "liability_assignment",
        "jurisdiction_ref",
        "signed_by",
        "parent_settlement"
      ],
      "finality_status_values": [
        "final",
        "conditional",
        "disputed",
        "reversed",
        "pending_acknowledgment"
      ],
      "field_descriptions": {
        "settlement_id": "Stable URI for this settlement record. Immutable after issuance.",
        "action_record_ref": "The action record being settled. References provenance.json action_record record_id.",
        "settled_at": "ISO 8601 UTC. When settlement was declared.",
        "settled_by": "The agent or principal declaring settlement. Should be the issuer or an authorized settlement agent.",
        "finality_status": "The settlement state. See finality_status_values. 'final' means no further dispute is possible under the declared dispute window.",
        "dispute_window_closes": "ISO 8601 UTC. The deadline after which this settlement record cannot be disputed. Consuming systems should not accept disputes filed after this timestamp.",
        "clearing_ref": "Reference to an external clearing record if settlement was processed through a clearing layer.",
        "counterparty_acknowledgment": "Whether the counterparty has acknowledged settlement. Options: acknowledged, pending, waived.",
        "liability_assignment": "Who bears liability for the settled action. Options: agent_operator, human_principal, counterparty, shared, unassigned.",
        "jurisdiction_ref": "Applicable jurisdiction for this settlement record. See agent-authority.org jurisdiction.json.",
        "signed_by": "Signing key identifier if this settlement record is cryptographically signed. See signing.json for the open mechanism.",
        "parent_settlement": "If this settlement supersedes a prior settlement record: that settlement_id."
      }
    },
    "clearing_record": {
      "description": "Confirmation that value transfer was processed by a clearing layer. Optional — used when settlement passes through an intermediary clearing system.",
      "required": ["clearing_id", "action_record_ref", "cleared_at", "clearing_agent"],
      "optional": ["net_value", "currency", "clearing_system", "settlement_ref"],
      "field_descriptions": {
        "clearing_id": "Stable identifier for this clearing record.",
        "action_record_ref": "The action record that was cleared.",
        "cleared_at": "ISO 8601 UTC. When clearing completed.",
        "clearing_agent": "The system or agent that performed clearing.",
        "net_value": "The net value transferred, after any netting or offsets.",
        "currency": "ISO 4217 currency code or token identifier.",
        "clearing_system": "The clearing system used. Examples: x402, GENIUS-compliant, bilateral.",
        "settlement_ref": "The settlement record this clearing supports."
      }
    },
    "dispute_record": {
      "description": "Schema for initiating a dispute against a settled action record. A dispute must be filed before dispute_window_closes on the settlement record.",
      "required": ["dispute_id", "settlement_ref", "disputed_by", "filed_at", "grounds"],
      "optional": ["evidence_ref", "claimed_remedy", "jurisdiction_ref", "resolution_ref"],
      "grounds_values": [
        "UNAUTHORIZED_ACTION",
        "SCOPE_EXCEEDED",
        "VALUE_MISMATCH",
        "COUNTERPARTY_BREACH",
        "SETTLEMENT_ERROR",
        "FRAUD"
      ],
      "field_descriptions": {
        "dispute_id": "Stable identifier for this dispute record.",
        "settlement_ref": "The settlement_id being disputed.",
        "disputed_by": "Who is filing the dispute. DID or domain-anchored identifier.",
        "filed_at": "ISO 8601 UTC. When the dispute was filed. Must be before dispute_window_closes on the settlement record.",
        "grounds": "The basis for the dispute. See grounds_values.",
        "evidence_ref": "Reference to supporting evidence. May be a URL, IPFS CID, or signed document reference.",
        "claimed_remedy": "What the disputing party is requesting. Options: reversal, partial_reversal, acknowledgment, compensation.",
        "jurisdiction_ref": "Jurisdiction under which this dispute should be resolved.",
        "resolution_ref": "If resolved: reference to the resolution record."
      }
    }
  },
  "settlement_model": {
    "principle": "Settlement declares finality. A settled action is a claim that the accountability chain is complete — authority granted, action taken, proof recorded, obligations discharged.",
    "dispute_window": "Every settlement record must declare a dispute window. Actions are not finally settled until the window closes without a filed dispute.",
    "chain": "human_principal → authority_grant → agent_declaration → action_record → settlement_record",
    "reversal": "A settlement may be reversed by a new settlement record with finality_status 'reversed' and a parent_settlement reference. Reversal is itself a settlement act — it does not delete history.",
    "signing_dependency": "Settlement finality claims are assertions until the signing mechanism (signing.json) is defined. Once defined, signed settlement records become cryptographically verifiable proofs of finality."
  },
  "example_settlement": {
    "settlement_id": "https://example.com/settlements/settle-001",
    "action_record_ref": "action:example.com:purchase-agent:2026-05-15T16:00:00Z:001",
    "settled_at": "2026-05-15T16:05:00Z",
    "settled_by": "did:web:example.com",
    "finality_status": "final",
    "dispute_window_closes": "2026-06-15T16:05:00Z",
    "counterparty_acknowledgment": "acknowledged",
    "liability_assignment": "agent_operator",
    "jurisdiction_ref": "https://agent-authority.org/.well-known/jurisdiction.json#EU-GDPR"
  },
  "example_dispute": {
    "dispute_id": "https://example.com/disputes/dispute-001",
    "settlement_ref": "https://example.com/settlements/settle-001",
    "disputed_by": "dns:trusted-supplier.com",
    "filed_at": "2026-05-20T09:00:00Z",
    "grounds": "VALUE_MISMATCH",
    "claimed_remedy": "partial_reversal",
    "jurisdiction_ref": "https://agent-authority.org/.well-known/jurisdiction.json#EU-GDPR"
  },
  "companion": {
    "authority_layer": "https://agent-authority.org/.well-known/authority.json",
    "agent_declaration": "https://agent-authority.org/.well-known/agent.json",
    "provenance_schema": "https://agent-provenance.org/.well-known/provenance.json",
    "audit_schema": "https://agent-provenance.org/.well-known/audit.json",
    "signing_stub": "https://agent-provenance.org/.well-known/signing.json"
  }
}
