{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/immix/json-schema/immix-operation-record-schema.json",
  "title": "OperationRecord",
  "description": "One of your operations, by its key: its phase — `PENDING` until this member sees its own command on the stream, `COMMITTED` from then, `CONCLUDED` once the owner's answer lands — and the stored outcome.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/immix-operations-api-openapi.yml#/components/schemas/OperationRecord",
  "type": "object",
  "properties": {
    "key": {
      "type": "string",
      "description": "The `Idempotency-Key` as you sent it."
    },
    "phase": {
      "$ref": "#/$defs/OperationRecordPhase"
    },
    "commandGlobalSequence": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "The command's position once committed; absent while pending."
    },
    "origin": {
      "$ref": "#/$defs/OperationRecordOrigin",
      "description": "The gateway member and instance that carried the request — the journal is member-local."
    },
    "createdTimestampNs": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "When the operation was journaled, epoch nanoseconds."
    },
    "concludedTimestampNs": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "When the answer landed, epoch nanoseconds; absent until concluded."
    },
    "outcome": {
      "$ref": "#/$defs/OperationRecordOutcome",
      "description": "The stored outcome — what a retry of the key replays; absent until concluded."
    }
  },
  "required": [
    "key",
    "phase",
    "origin",
    "createdTimestampNs"
  ],
  "$defs": {
    "OperationRecordOrigin": {
      "type": "object",
      "properties": {
        "memberId": {
          "type": "integer"
        },
        "instanceId": {
          "type": "string",
          "pattern": "^-?[0-9]+$"
        }
      },
      "required": [
        "memberId",
        "instanceId"
      ],
      "description": "The gateway member and instance that carried the request — the journal is member-local.",
      "title": "OperationRecordOrigin"
    },
    "OperationRecordOutcome": {
      "type": "object",
      "properties": {
        "httpStatus": {
          "type": "integer"
        },
        "code": {
          "type": "string",
          "description": "`OK` on an accepted write; otherwise the `Error.code` the refusal carried."
        },
        "message": {
          "type": "string",
          "description": "The detail the refusal itself stated (an order refusal's observed value against its limit, and the governing policy); absent when it stated none, where a synchronous caller read the code's standing sentence as `error.message`. For humans; never parse it."
        },
        "family": {
          "$ref": "#/$defs/OperationRecordOutcomeFamily",
          "description": "The resource the operation targeted — where its `entityId` (for orders, `orderId`; for algos, `instanceId` and `configSeq`) reads; a refused address declaration names the account it referred to, under `accounts`."
        },
        "entityId": {
          "type": "integer",
          "description": "The record the outcome names: the id minted on an accepted create, the path's id otherwise, the referred account on a refused address declaration; absent when none. An orders operation names its order in `orderId` instead, an algos one its instance in `instanceId`."
        },
        "instanceId": {
          "type": "integer",
          "description": "On an algos operation, the instance the outcome names — minted on an accepted create, the path's otherwise; absent on a halt and when none."
        },
        "configSeq": {
          "type": "integer",
          "description": "On an algos operation that staged a document — a create, or a config write — the document's sequence number; absent otherwise."
        },
        "globalSequence": {
          "type": "string",
          "pattern": "^-?[0-9]+$",
          "description": "The answer's position; `0` when the outcome came from no change (a refusal at the door or in transit)."
        },
        "orderId": {
          "type": "string",
          "pattern": "^-?[0-9]+$",
          "description": "On an orders operation, the order the outcome names — minted on an accepted submit, the path's on a cancel; absent when none. A 64-bit integer, so a decimal string."
        }
      },
      "required": [
        "httpStatus",
        "code",
        "globalSequence"
      ],
      "description": "The stored outcome — what a retry of the key replays; absent until concluded.",
      "title": "OperationRecordOutcome"
    },
    "OperationRecordOutcomeFamily": {
      "type": "string",
      "enum": [
        "orgs",
        "users",
        "credentials",
        "accounts",
        "account-addresses",
        "portfolios",
        "asset-policies",
        "chain-policies",
        "trading-policies",
        "orders",
        "algos"
      ],
      "description": "The resource the operation targeted — where its `entityId` (for orders, `orderId`; for algos, `instanceId` and `configSeq`) reads; a refused address declaration names the account it referred to, under `accounts`.",
      "title": "OperationRecordOutcomeFamily"
    },
    "OperationRecordPhase": {
      "type": "string",
      "enum": [
        "PENDING",
        "COMMITTED",
        "CONCLUDED"
      ],
      "title": "OperationRecordPhase"
    }
  }
}